SilverScreen Solid Modeler

A Note on Resources

A Note on Resources

Previous topic Next topic  

A Note on Resources

Previous topic Next topic JavaScript is required for the print function  

SilverPlusEllipse

 

A Note on Resources

 


An important usage of SilverPlus DLL’s is to store your own resources (dialog templates, menus, toolbars and the like) for your own UI. A requirement of using the MFC resource handling mechanisms to load resources from the DLL is that the default resource handle for the application be set to the instance of the DLL. The call to set the default resource handle is the MFC function AfxSetResourceHandle, passing it the instance handle of your resource DLL. The instance handle is used to uniquely identify an executable module (.EXE or .DLL), and is set when your DLL is loaded. If you have an MFC style DLL, then it is part of the CWinApp-derived class that is the base of your DLL. Alternatively, if you have an “old-style” DLL, the instance handle is passed as the first argument to DLLMain.

 

For purposes of loading its own resources, SilverScreen will set the default resource handle as necessary, and then restore it when finished. This is always true in the case of executed commands (via ss_command), and almost every SilverScreen API routine. However, it is possible that SilverScreen's resource handle is set while a resource is being requested from your DLL when inchar is in use. If you understand what happens when a SilverPlus application installs a toolbar and runs an inchar loop while the user moves the mouse such that a tooltip is requested, you understand that the tooltip must come from the SilverPlus DLL and that inchar cannot interfere with the current resource handle. In other words, the best behavior for inchar is to stay out of the way and expect the resource handle to be set properly.

 

This means that if you are running an inchar loop and it is possible for one of your DLLs resources to be requested you have two options. The first is to ensure your resource IDs do not conflict with SilverScreen's by making use of ID_FIRST_DEVELOPER_ID and ID_LAST_DEVELOPER_ID (see A Note on Command IDs), and the second is to make sure your resource handle is set, and the current one is restored, around such inchar loops.