alank2 5 Posted November 7 (edited) I need to put a VCL form in a DLL and call it from another application. I've made the DLL and can call it just fine, but it shows as maximized even though it isn't supposed to be. //create form Form1=new TForm1(NULL); //show form modally Form1->ShowModal(); //copy result strcpy(APhoneNumber, Form1->phonenumber); //delete form delete Form1; Windows state is set to normal, If I put this in the formshow of the form: Form1->WindowState=wsNormal; There is no difference - I think the WindowState is already set this way. If I could click the title bar of the form, it does go to the right size. If I close it and reopen it with the above code (which creates a new TForm1), it does NOT happen a second time. If I change the formshow to this: Form1->WindowState=wsMinimized; Form1->WindowState=wsNormal; It does show as normal size the first and subsequent times, but I can see the animation of it minimizing and restoring. Why does this happen? Could it be perceiving the way the application that is using it was loaded such as maximized and overriding the WindowState somehow? if so, can that be prevented in a better way that what I'm doing? Other thoughts? edit: Does this have to do with Application->FInitialMainFormState? Can I change it somehow? When I try it says it is protected. Edited November 7 by alank2 Share this post Link to post
Softacom | Company 2 Posted November 11 VCL Framework does not support work inside DLL. The problem is that DLL can’t share types, memory manager etc. So, you got uninited instance of Application inside your dll and many, many more problems. The easiest way to solve all these problems is to use BPL instead of DLL. It's can be loaded dynamicaly too, if you need it. Or you can try to write your form in pure WinApi. Share this post Link to post
Remy Lebeau 1392 Posted November 11 On 11/7/2024 at 8:46 AM, alank2 said: Why does this happen? Could it be perceiving the way the application that is using it was loaded such as maximized and overriding the WindowState somehow? if so, can that be prevented in a better way that what I'm doing? Other thoughts? Does the host application display any UI windows of its own before the DLL's VCL form is displayed? If not, then does GetStartupInfo() report that the 1st window shown should be maximized? Share this post Link to post