Dear All, I have resource sharing issue in my MFC programming. Below, I will describe the scenario. I am using VC++ 6.o version I have a dialog(modeless) based application. Main dialog box has a Button( say "Button1" ) with OnButton1(), that will call member function DisplayChildDialog() I have a worker thread also, that will call DisplayChildDialog() using PostMessage() of main dialog. DisplayChildDialog() will dispaly a child dialog(modal). Child dialog's object is created locally in DisplayChildDialog(). So DisplayChildDialog() will always called from the GUI thread. Scenario: When I clicks on "Button1", OnButton1() will call a member function DisplayChildDialog() and a child dialog(modal) will appear. This time worker thread will also call DisplayChildDialog() using PostMessage() of Main dialog. When I click on "Button1" DisplayChildDialog() will also call from worker thread using PostMessage(). of the main dialog. So two dialogs will appear simultaniously. To avoid this situation I made the second caller of DisplayDialog() to enter in a MessageLoop, and will check a flag that will infrom whether the first caller has left the DisplayChildDialog() or not. I wrote the message loop in DisplayDialog() like this. DisplayDialog() { if( CChildDlg::m_bDisply == true ) { while( GetMessage( &stMsg, 0, 0, 0 )) { TranslateMessage( &stMsg ); DispatchMessage( &stMsg ); if( false == CChildDialog::m_bDisply ) { OutputDebugString( _T( "### Message loop false************************" )); return; } } } CChildDlg::m_bDisply = true; CChildDlg objChild; objChild.DoModal(); CChildDlg::m_bDisply = false; } But this will work 5 or 6 times correctly. But after that, when I clicks on "Button1", the first caller of DisplayDialog() will terminate before showing the dialog box it will just make CChildDlg::m_bDisply = true. So the second caller will enter in Message loop and never exit. I tried this too instead of above given message loop: while( CChildDlg::m_bDisply && WaitMessage()) { AfxGetApp()->PumpMessage(); } But both given same result.. Please help me.
georgekjolly
Posts
-
Resource Sharing issue -
How to uniquely identify or distinguish windows that have no window name, same class name and resource id is zero [modified]Dear all, I have an application that can identify a window. The method in which I worked out is given below. I will store the attributes of the window such as( class name, window caption, resource id etc..) to a file. When the second time , window is up, using the above attributes, I will identify the window. But, I encounter a problem with the above scenario. The problem comes, when the 'window does not have window caption', 'window class name is same' and 'control id is zero'.. I can't use window handle, bcz it will differ when the window is up for the second time. Is there any method to solve this problem? OR Is there any unique attribute to identify the window? Please help, Thanks in advance, George K J
modified on Monday, September 22, 2008 4:22 AM
-
How to Merge two or more CImageList objects to a single oneHi Mark, Thank you for your reply. You mean, extracting BitMap from CImageList and adding it to the Master Image List.. But will it make any overhead ? Or Can we achieve the merging of ImageLists using some other methods like Copy.. Thanks George K Jolly
-
How to Merge two or more CImageList objects to a single oneDear all, I have, CImageList ImgList1; CImageList ImgList2; CImageList MasterImgList; I have added several "CBitMap" objects to the "ImgList1" and "ImgList2" using CImageList::Add( CBitmap* pbmImage, COLORREF crMask ) method. Now I would Like to Merge "ImgList1" and "ImgList2" to the "MasterImgList". That is after merging, "MasterImgList" contains both the contents of "ImgList1" and ImgList2". Please help me.. Thanks in Advance George K Jolly
-
Implementing more than one interfaces in same coclassHi Roger, I tried it, and its working. Now I am able to Query one interface from another(They belongs to different coclass) . Thanks George
-
Implementing more than one interfaces in same coclassHai, How can I implement more than one interfaces in same coclass using ATL Thanks George
-
Query Interface from Another Interface of Same Com ServerHi Sir, Thank you very much for your help. Regards and Thanks George K J
-
Query Interface from Another Interface of Same Com ServerHai Roger, I got it. Thank you very much. I have another Doubt. Is all COM communications(between COM Server and Client) happening through RPC. Bcz, I have seen RPC header files such as "rpc.h" "rpcndr.h" in both the COM Exe and COM Dll. Thanks George
-
Data Transfer in Socket ProgrammingHi Sir, Thank you very much for ur Reply. Thanks and Best Regards George
-
Query Interface from Another Interface of Same Com ServerHai all, I have two ATL Objects in my COM Server. Their interfaces are 1) IFirstIFC 2) ISecondIFC In my client programme I have imported the type library and using code below obtained the COM Object of IFirstIFC IFirstIFCPtr fIF; fIF.CreateInstance(__uuidof(FirstIFC)); Now my task is to obtain the COM Object of ISecondIFC. My Question is , Is there any method for Obtaining the Interface Pointer of ISecondFC by not calling again CreateInstance for that Interface. That is by avoiding this Code ISecondIFCPtr sIF; sIF.CreateInstance(__uuidof(SecondIFC)); That is,since both Interfaces are residing in the same COM Server, Can I get the Interface Pointer of ISecondFC through IFirstIFC. Thanks George
-
Data Transfer in Socket ProgrammingHai All, I have a doubt regarding the transfer of Data in InterProcess communication like Socket Programming. ->Client and Server are two different Process running in two different machines ->Assume , I am passing a user defined structure from client process to Server Process. ->As usual I will fill the structure with values and pass the address of structure to the server process. ->My doubt starts here , since Server is another process running in another address space and also in another machine, how can the server fetch the values stored in the address given by client. Are they sharing any memory ??, if yes, where it resides ??, Thanks George
-
Passing a Class Object to a COM EXE Server through VARIANTHai all, Do anyone know , how to pass a C++ class from a VC++ Client to a COM EXE Server, through VARIANT. Thanks, George.
-
Passing a structure through VARIANT from VC++ Client to COM Server [modified]Hi Pallini, My code is given below /************Client Side****************************************/ typedef struct { int i; char ch[10]; }StrctMine; VARIANT vrt; StrctMine gOb; gOb.i = 10; strcpy(gOb.ch,"geo"); vrt.vt = VT_BYREF; vrt.byref = (void*)&gOb; myPtr.CreateInstance(__uuidof(MyVar)); myPtr->VarFun(&vrt); /*************************************************/ In Server side , I have written my structure in idl file, And I called a method , that is given below. STDMETHODIMP CMyVar::VarFun(VARIANT *vPtr_i) { // TODO: Add your implementation code here MessageBox(NULL,"Hai","",MB_OK); return S_OK; } But this code is not working. Thanks George
-
Beginner In COM where to start first?This link will be very helpfull to understand basics of COM , ie COM from scratch. http://www.codeproject.com/com/com\_in\_c1.asp http://www.codeproject.com/com/com\_in\_c2.asp Thanks George
-
Passing a structure through VARIANT from VC++ Client to COM Server [modified]Hai all, Do anyone know , how to pass a user define structure from a VC++ Client to a COM Server, through VARIANT. Thanks, George.
-
Preventing Broadcasting from a Singleton Com Server EXEHai all, -> I have a "COM Server Exe" , with connection point. ->And I made my COM Object class Singleton by using Macro "DECLARE_CLASSFACTORY_SINGLETON" -> My Com Cleint is a Dialog Based Programme .I started 5 clients by clicking on same exe. -> Whenever the client starts , It will set up all the connection points -> I am able to call a COM Method( for eg: my_ComFun() ) by clicking a button on my dialog box -> From inside my_ComFun() I am firing an event to my client . implementation of my_ComFun() /**************************************************************/ STDMETHODIMP CMyServer::my_ComFun(int i) { Fire_MyEvent(i); return S_OK; } /**************************************************************/ ->Whenever I am Firing events from my COM Server(Using function Fire_MyEvent() ) , All my clients are getting function calls , since my COM Server is a Singleton class. * My Requirement is to prevent this broadcasting and direct the function calls from COM to that specific client which calls the Servers my_ComFun(), by keeping the COM Server Singleton. Thanks in Advance. George
-
Getting Window Handle of an Explorer BandHai Prasad , Thank you very much for ur reply . it helped me to rectify my problem. Thanks George
-
Getting Window Handle of an Explorer BandHai all. I have created a Toolbar for Internet Explorer. I need to get the window handle of an Explorer Band(Created by me) in my tool bar. I know the class ID of the Explorer Band, and I am able to hide and unhide the Explorer Band using that Class ID , from the toolbar using ShowBrowserBar(&vtBandGUID, &vtShow, 0); function. But for my purpose, I need to get the window handle of the Explorer Band How I can Get the window handle?? . Please Help me Thanks George
-
To Retrieve Path of a DLL file.Hi all , How can I get the path of a COM DLL ?? I am using this way.. Inside DLL , I am writing this code. /******************************************************/ HINSTANCE g_hInst; TCHAR szModule[MAX_PATH]; g_hInst = _Module.GetModuleInstance(); GetModuleFileName(g_hInst, szModule, MAX_PATH); /*******************************************************/ I am getting the Path . But am getting in this form.. "D:\THINVI~1\INTEGR~1.DLL" . The tilt sign makes the folder and file names incomplete . My actual path is "D:\THINVISITS_14-2-07\INTEGRALHOTBAR.DLL" So how can I get my dll path in the complete form without Tilt(~).. Please Help Me Thanks George.
-
Problem in Passing 1d array from VC++ to VB [modified]Hi lafleon , Its working excellent . I have implemented it for a 3d array and got correct result. Thank you Very much for your help. George