|
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.
|
|
|
|
|
http://msdn.microsoft.com/en-us/library/kcz8ck35.aspx[^]
Quoting the link:
"You can specify a .res file when linking a program."
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.
|
|
|
|
|
hi
i have instled vc++6.0 and executes a threading projects it asking activex controls not installed
|
|
|
|
|
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Find the ActiveX that is missing and register it using the command line - regsvr32 <activex_name>.ocx
|
|
|
|
|
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.
Cheers Vaclav
FILTER_INFO FilterInfo;
hr = pCurrFilt->QueryFilterInfo(&FilterInfo);
IUnknown *pFilterUnk;
pCurrFilt->QueryInterface(IID_IUnknown, (void **)&pFilterUnk);
CAUUID caGUID;
pProp->GetPages(&caGUID);
pProp->Release();
OleCreatePropertyFrame(
this->m_hWnd, // Parent window
0, 0, // Reserved
FilterInfo.achName, // Caption for the dialog box
1, // Number of objects (just the filter)
&pFilterUnk, // Array of object pointers.
caGUID.cElems, // Number of property pages
caGUID.pElems, // Array of property page CLSIDs
0, // Locale identifier
0, NULL // Reserved
);
PS the FilterInfo contains dialog box title / name and pointer to the graph itself only.
|
|
|
|
|
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:
void PrintInfo(HWND wnd, int level)
{
for (int i=0; i<level; ++i)
printf(" ");
char classname[0x100];
classname[GetClassNameA(wnd, classname, sizeof(classname))] = 0;
printf("HWND=%p ctrl_id=%d classname='%s'\n", (void*)wnd, GetDlgCtrlID(wnd), classname);
}
void TraverseTree(HWND parent, int level)
{
PrintInfo(parent, level);
++level;
HWND child = GetWindow(parent, GW_CHILD);
if (!child)
return;
do
{
TraverseTree(child, level);
child = GetWindow(child, GW_HWNDNEXT);
}
while (child);
}
void WindowFunc()
{
HWND wnd = FindWindowA("Afx:00400000:b:00010005:00000006:000B078D", NULL);
if (!wnd)
ExitProcess(1);
TraverseTree(wnd, 0);
ExitProcess(0);
}
modified 18-Sep-13 10:43am.
|
|
|
|
|
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
Vaclav
|
|
|
|
|
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.
Vaclav
|
|
|
|
|
hi all,
I have file size in bytes, I am converting it in MB to display,
but or two decimal places its display round off value.
I don't want to round up the value and value should be displayed in two decimal places.
QWORD nSize=524285686;
static char szSize[16];
if (nSize < 1024)
{
sprintf(szSize, "%u Byte", nSize);
}
else
{
char szScales[] = "KMGTPEZY";
int nScale = 0;
for (; nScale < sizeof(szScales); ++nScale)
{
if (nSize < 1024 * 1024)
{
sprintf(szSize, "%6.2f %cB", nSize / 1024.0f, szScales[nScale]);
break;
}
nSize = (nSize + 512) / 1024;
}
if (nScale == sizeof(szScales))
{
strcpy(szSize, "Unknown Size");
}
}
return szSize;
//its return size=500.00MB
//but in real its = 499.99779319
thanks in advance.
modified 18-Sep-13 3:18am.
|
|
|
|
|
You are using integer arithmetic within the loop. Convert the original size to a double type at the beginning and use decimal arithmetic throughout.
Veni, vidi, abiit domum
|
|
|
|
|
now its display the value upto six decimal place,
I want to display value upto 2 decimal place without rounding off.
|
|
|
|
|
Then you need to print it to a memory buffer in full and then remove all the extra digits from the string before displaying it.
Veni, vidi, abiit domum
|
|
|
|
|
|
Try this code:
int size = 511998;
int di = (int)(size/10.24);
printf("%d.%02d", di/100,di%100);
(Fixed thanks to pasztorpisti)
Veni, vidi, vici.
modified 18-Sep-13 5:31am.
|
|
|
|
|
"%d.%d" -> "%d.%02d". If the fraction part is below 10 then %d gives wrong result, for example "1" instead of "01".
|
|
|
|
|
Fixed, thank you very much.
Veni, vidi, vici.
|
|
|
|
|
|
If you want to use integer arithmetic without floating point then do it this way:
unsigned __int64 size = 524285686;
const unsigned MEG = 1024*1024;
unsigned megs = (unsigned)(size / MEG);
unsigned fraction = (unsigned)((size % MEG) * 100u / MEG);
printf("%u.%02u\n", megs, fraction);
EDIT: changed from signed integers to unsigned integers
modified 18-Sep-13 6:15am.
|
|
|
|
|
Hello all,
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.
I want all the GUI elements to be developed in HTML with some JavaScript(JS) added. Now i want to trigger the controls in the HTML/JS using the C++ code that runs the DLL. And also i should be able to launch this DLL on another web browser and display the HTML/JS controls.
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.
|
|
|
|
|
Don Guy wrote: Is this possible to do?
I suppose anything is possible, but what is your specific question?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Don Guy wrote: Please let me know of any examples that does similar things. Google is the place for such questions. Also it is not clear exactly what your problem is.
Veni, vidi, abiit domum
|
|
|
|