delphi - VCL Style from DLL is affecting TMenuItem in Application -


I am using Delphi XE6 and VCL styles. I have the main application and DLL. My main application runtime theme is enabled and I am using vcl style files. I did a lot for my DLL, I have enabled the Runtime Theme and have used the VCL.Themes, VCL.Styles under VCL style file and used the resource file. When DLL loads, I load the VCL style from resources and set it to DLL GUI. The main app and DLL have not been created with the runtime package

Now I have the main app GUI that is styled with its style and DLL Gui is styled with its style. It works fine as long as ...

When I click on the button in my main app, this event opens TPopupMenu, then it's a style similar to the DLL GUI instead of the main app style Styles together. If I navigate through the menu then I also get AV and the program crashes. See attached image

What am I doing wrong? The only way I can see the present, which was obtained from some other control, would be to create my own customized TPopupMenu. Enter image details here


As I promised I had my application Has developed a simple demo program. It has a host application with its own style and DLL with a style that connects with the resource. Run it and click the popup button, then select something from the popup. It will crash and some studwins can prok or do something like that. Apart from this, if you go to the window system menu (left top corner), when you try to select something from that menu you will see that the system menu is styled as DLL GUI and also crash. Link to Rar file:

Enter image details here

Thanks for your help. This is a fundamental problem with VCL styles and the way they are style menus. The style process is implemented with a wide hook, especially a call to CBT hook from SetWindowsHookEx to TCustomStyleEngine.CreateSysHook in the Vcl.Themes unit Has been established by. In fact, the hook only applies to the GUI thread, but it is detailed in the process that there is absolutely one GUI thread in this process.

Since you have several examples of VCL that are in your application (in one DLL and in one application), two hooks are installed. This is a lot more recently installed in the form of the hook (DLL) This happens), and this is why the DLL menu styling infects your execution. And why do you face an access violation. Attempting to operate DLL executable on the menu. And therefore, despite your best efforts, you have terminated DLL code to access VCL objects from host executable.

There is no easy way to work around this and both modules have the basic result of the design here. The system was not designed to support many VCL examples. If you want to use VCL styles in many modules, the designer expects you to use the runtime package.

I think you can get some traction by operating DLL with a completely different thread. This involves loading the DLL with that thread so that the VCL can be started in the thread. And DLL has to make all the calls from that thread. And you will need to run a message loop in that thread. It is possible that you may be able to do that work, but I doubt it. Even with all the provisions, it has been mentioned that you still need to handle the fact that you have two GUI threads that present all kinds of issues dealing with the input queue.

Perhaps another way would be to uninstall the hook from DLL. Unless your DLL menu is showing up, you can uninstall that hook. This will disable the style for the menu shown by DLL, but it is probably acceptable.

This version of your DLL (I still uninstall it after making it somewhat simplified)

  Library VCLStyleDLL; {$ R 'Style.res' 'Style.rc'} uses VCL.Styles, VCL.Themes, VCL.SysStyles; // TSysPopupStyleHook {$ R * .res} to get access to TStyleManager.TrySetStyle ('shiny', wrong); TCustomStyleEngine.UnRegisterSysStyleHook ('# 32768', TSysPopupStyleHook); End.   

With this version of DLL, the host executable does not suffer from your description problems in your question.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -