// return -1 in case of failure to load the dialog template resource
if (lpDialogTemplate == NULL)
When I run this dialog in its own project the hInst returns same value as when I run it in my application. The m_lpszTemplateName is also same , empty, when run in its own project or in my application.
I did run the DoModal in property page OnInitDialog with same result.
I did copy the source from the original to my static library and I am at lost what “resource template” is missing.
Any help would be appreciated. Of course I am still using VC 6.0 and MFC.
Every module (exe or dll or whatever) can contain a resource tree that contains different kind of resources (icon, dialog template, cursors, wav sound, popup menus, binary data, ... the list is increasing). You usually compile an .rc file into a .res file and currently you can link only one .res file into the final module (exe or dll) and the linker composes the (search) tree from the resource list. Resources declared in a static libs don't link to the modules from which you use the static libs themselves. Correct me if I'm wrong but I've burnt myself with this several times so I avoid using resources in static libs. To my best knowledge there is no solution to this problem in newer visual studio versions. http://stackoverflow.com/questions/531502/vc-resources-in-a-static-library[^]
If you compile your library as a DLL then your DLL can have its own resources and you can use the HMODULE received as the first parameter of the DllMain() as your hInst when you call FindResource().
Additional advice: Use ResHacker to check out the resource tree of an exe or dll.
Found a note that you should be able to use “additional includes directory” to link to the static module resources, but it did not work.
Basically – the static library gets build and the .res / .rc gets also build and included in the build.
But the main application will not retrieve the “dialog template” from the library.
So putting CDialog derived class in static library is worthless.
I am going to build the page “dialog” directly and forget about using the static library “external” dialog.
I was just hoping that putting the dialog in static library I can keep the supporting classes together with the dialog itself. I was just trying to offload the “module” classes from the main application.
No big deal.
I still do not get where the “template” addition to “dialog” came from. But that is irrelevant now.
Before posting my previous answer I tried on the commandline to link a DLL with two res files, both containing an icon (with VS2010). It didn't work. If it doesn't work on low level on the commandline it cant work from the devenv/IDE that also uses these commandline tools.
In VC 6.0 there is an option in Project Setting -> Resources ->Additional resources include directories.
It did not work.
Terrible though – VC 6.0 wizard for creating static library does have an option to “use “ MFC, but does not have an easy way to add MFC derived classes. ( I posted the question about it here but got nowhere – some folks just don't want to be bothered with “obsolete “ VC6.0 questions).
So there are no MFC message queues available , hence “standard “ termination of modeless dialog- using OK button- does not exist. Maybe that is the real reason why this additional resources include does not work.
But you tried it with icon, so, I may be totally off in the left field with this.
I have this method which creates a CDialog containing controls / info about DirectShow filter.
I would like to access the dialog and use the controls to adjust the filter properties.
I posted this in DiectShow forum and getting nowhere.
I have no clue how to do this.
Any help would be greatly appreciated.
If you want to modify gui elements programmatically then it is a big hack that may or may not work on other machines. Even if we know how to do this magic we don't know what you want to do and we can't read your mind to find it out. It is possible to traverse the window/child control hierarchy and if you can identify certain controls then you can manipulate them. Often identifying the controls is possible by their/their parents' Z order and/or control ID. Depending on what you want to do different kind of hacks/functions may be necessary.
EDIT: as a first step you should write a function that prints out the full window hierarchy of your dialog along with some extra info with each child control window (like hwnd value, control id, classname). Use the GetWindow() function to traverse the window (tree) hierarchy. At the same time you should check the properties of the child controls you want to manipulate with Spy++. This way you can find the location of a control in the hierarchy and write the code that somehow programmatically retrieves the necessary HWNDs from the hierarchy for you. When you are done you will have to manipulate the gui controls by calling windows functions and sending messages to the HWND of the given control.
EDIT: Here is a piece of code that prints you the tree you can view with Spy++. This small piece of code contains a few function calls that can come handy when its about getting the HWND of a specified child control in the gui hierarchy:
Thanks, it's a start.
BTW this is not "for hire" project and as long as it works for me I am happy.
I am busy learning about COM because I feel the "interface array" may be used to accomplish this. But right now it is way over my head.
Personally I am puzzled why MS published this method if it just for show, but there are other DirectShow applications pretty much same style - half-baked.
But I like your Spy approach. Thanks
You are welcome. I have no clue about directshow. If there is a nice "official" method to adjust settings (that I doubt if you couldn't get help on a specialized forum) then do it that way instead of hacking around with HWNDs. Sometimes however the hack is the only solution. If the program is not a production release (for example a temporary throw away helper tool, or an in-house tool) then its quite okay to go with hacky "working" solutions. In-house you can restrict directshow versions (like we restrict browser versions compatible with our in-house web-interfaces). If you want to release it to the wild to be used with a lot of windows/directshow versions then its more dangerous, you cant test your hack with all windows/directshow versions...
Been doing some research and found this interface IPropertyPageSite which may work. So far no luck finding a usage of it.
There my be another way to do it but I would have to replace the modal dialog with modeles.
There was KB article on that but it is gone. Thanks MS.
If you want to use integer arithmetic without floating point then do it this way:
unsigned__int64 size = 524285686;
constunsigned MEG = 1024*1024;
unsigned megs = (unsigned)(size / MEG);
// If you want 3 digits in the fraction then change 100 to 1000 and change %02u to %03u in the format string.unsigned fraction = (unsigned)((size % MEG) * 100u / MEG);
printf("%u.%02u\n", megs, fraction);
EDIT: changed from signed integers to unsigned integers
I want to develop a DLL that has a web browser embedded in it. In the past i have created MFC dialog app using CDHtmlDialog. With that experience what i want to achieve is create a DLL that has browser embedded in it, and then load this DLL into a web browser like IE, Chrome or Firefox.
Is this possible to do?
The reason why i want it this way is because the C++ code in the DLL will talk with another C++ DLL and take instructions on how and when to show the HTML/JS controls.
As i said earlier, i have worked with CDHtmlDialog in MFC Dialog app. But in this case i don't need any MFC controls. All i need is a Web Browser capability like the one CDHtmlDialog provided. And also this should be launchable from with in another web browser like IE or Chrome or Firefox.
Please let me know of any examples that does similar things.
Thanks in advance.
Last Visit: 23-Mar-19 2:19 Last Update: 23-Mar-19 2:19