|
I have two applications that has a same structure and these two applications communicates values using the structure in shared memory created using CreateFileMapping, OpenFileMapping and MapViewOfFile. So Whenever a value in the structure is changed by application 1, it gets reflected in appliction 2 and viceversa. This is fine.
But the 2 applications are running in the same machine. Now I want to make the 2 applications run in separate machines connected within a LAN and I require the same functionality (i.e. Communication between the 2 applications) without any synchronization issues.
Anybody, Please suggest me the best way to implement this and also the step by step method of code to achieve this. .
|
|
|
|
|
Please do not crosspost the same message in multiple forums.
Veni, vidi, abiit domum
|
|
|
|
|
Hi Everyone,
I want to place MFC control in RunningObjectTable. Is this possible?. If yes how can we place it in RunningObjectTable?
Regards,
Rajendar.
|
|
|
|
|
|
For inter process communication
|
|
|
|
|
Rajendarmanda wrote: For inter process communication OK, and what exactly does that add by way of explanation? Please think about what problem you are trying to solve, and give some proper details of where you are stuck. If your question begins with "How do I ...", or "Is it possible ...", then you will most likely find some useful information through Google searches.
Veni, vidi, abiit domum
|
|
|
|
|
Actually we have placed COM object into RunningObjevtTable(ROT) but when we try same thing for MFC it is not working. we are suspecting whether we put MFC object into ROT or not?
|
|
|
|
|
Rajendarmanda wrote: when we try same thing for MFC it is not working. Then you will need to do some debugging to try and identify why.
Veni, vidi, abiit domum
|
|
|
|
|
I am trying to run a modal dialog in a property page.
The dialog is located in static library.
Here is the implemetation of DoModal
int C_MAINPropertyPage4::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CPropertyPage::OnCreate(lpCreateStruct) == -1)
return -1;
pCWaveInFFTDlg.DoModal();
return 0;
}
And here is where CDialog fails, in FindResource:
// load resource as necessary
LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
HGLOBAL hDialogTemplate = m_hDialogTemplate;
HINSTANCE hInst = AfxGetResourceHandle();
if (m_lpszTemplateName != NULL)
{
hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);
hInst looks OK
HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);
hResource is NULL, so it fails from here on.
hDialogTemplate = LoadResource(hInst, hResource);
}
if (hDialogTemplate != NULL)
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
// return -1 in case of failure to load the dialog template resource
if (lpDialogTemplate == NULL)
return -1;
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.
Cheers
Vaclav
|
|
|
|
|
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
|
|
|
|