VCL-Komponenten in der DLL und die Applikation lässt sich nicht mehr minimieren
-
Hallöchen!
Ich habe in meine Hauptapplikation eine DLL mit VCL-Komponenten eingebunden. Sobald ich jetzt innerhalb der DLL z.B. einen TTimer nutze (das Anlegen mit new und das sofortige Löschen mit delete reicht aus), kann ich meine Hauptapplikation nicht mehr minimieren. Geht einfach nicht. Das Fenster verschwindet zwar im Hintergrund, bzw. wird deaktiviert, aber minimiert wird es eben nicht.
Das Ganze konnte ich auch nachvollziehen, indem ich einfach eine neue Applikation und ein Dll-Projekt erstellt habe. Innerhalb der Dll habe ich eine Funktion exportiert, die nix anderes macht als einen Timer anzulegen und wieder zu löschen.
Sobald ich diese Funktion in die Hauptapplikation einbinde und ausführe kann ich nicht mehr minimieren.
Jemand von euch ne Idee?
Ich habe von allein schon heraus gefunden, dass ich das Problem mit dem Timer lösen kann, indem ich in der DLL von der VCL auf die CLX umsteige, aber ich habe innerhalb meine ursprünglichen DLL auch noch einen TComPort und dort hilft das gar nix.
Hier mal kurz die Quellen zur DLL:
//--------------------------------------------------------------------------- #include <vcl.h> #include <windows.h> #pragma hdrstop //--------------------------------------------------------------------------- // Important note about DLL memory management when your DLL uses the // static version of the RunTime Library: // // If your DLL exports any functions that pass String objects (or structs/ // classes containing nested Strings) as parameter or function results, // you will need to add the library MEMMGR.LIB to both the DLL project and // any other projects that use the DLL. You will also need to use MEMMGR.LIB // if any other projects which use the DLL will be performing new or delete // operations on any non-TObject-derived classes which are exported from the // DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling // EXE's to use the BORLNDMM.DLL as their memory manager. In these cases, // the file BORLNDMM.DLL should be deployed along with your DLL. // // To avoid using BORLNDMM.DLL, pass string information using "char *" or // ShortString parameters. // // If your DLL uses the dynamic version of the RTL, you do not need to // explicitly add MEMMGR.LIB as this will be done implicitly for you //--------------------------------------------------------------------------- #pragma argsused int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved) { return 1; } //--------------------------------------------------------------------------- void __declspec(dllexport) __stdcall DoItDll(TObject *Owner) { TTimer *tmr = new TTimer((TComponent*)Owner); //TTimer *tmr = new TTimer(NULL); //gleiches Ergebnis :-( delete tmr; } //---------------------------------------------------------------------------Hier der Header vom Hauptformular:
//--------------------------------------------------------------------------- #ifndef MainH #define MainH //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> //--------------------------------------------------------------------------- __declspec(dllimport) void __stdcall DoItDll(TObject *Owner); //--------------------------------------------------------------------------- class TMainForm : public TForm { __published: // IDE-managed Components private: // User declarations public: // User declarations __fastcall TMainForm(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TMainForm *MainForm; //--------------------------------------------------------------------------- #endifUnd hier noch das Hauptformular selbst:
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Main.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TMainForm *MainForm; //--------------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner) { DoItDll(Owner); } //---------------------------------------------------------------------------
-
nur so ganz dumm in den Raum geworfen:
Gibt es das gleiche Problem wenn Du nicht die VCL-Timer-Komponente verwendest, sondern den Win-API-Timer?
-
Joe_M. schrieb:
nur so ganz dumm in den Raum geworfen:
Gibt es das gleiche Problem wenn Du nicht die VCL-Timer-Komponente verwendest, sondern den Win-API-Timer?
Ich war ganz kurz in Versuchung mal nen Win-API-Timer auszuprobieren, doch dann holte mich die Wirklichkeit wieder ein -> Ich hab vorhin das Gleiche mit nem TButton probiert, Effekt war der gleiche, Minimieren geht nimmer

Ich habe noch die Vermutung, dass es etwas mit dem Botschaftenaustausch zu tun haben könnte. Ich habe vorhin irgendwo gelesen, dass der bei der CLX anders abläuft als in der VCL (welche ja das Botschaftssystem der Win-API nutzt).
Als ich mir eben mal den Quelltext vom TTimer in VCL und CLX angeschaut habe und ein paar Zeilen Code davon einzeln in meine DLL gapackt habe, hab ich auch gefunden dass der Aufruf: "Application.HandleException(Self);" für das Nicht-Minimieren-Können veranwortlich ist. Es reicht, wenn die Zeile mit Compiliert wird. Sie muss nichtmal aufgerufen werden..

procedure TTimer.WndProc(var Msg: TMessage); begin with Msg do if Msg = WM_TIMER then try Timer; except Application.HandleException(Self); end else Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam); end;