Thread: unresponsive modeless dialogs

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    50

    unresponsive modeless dialogs

    hi all,

    I have a modeless dialog that isn't responding to the mouse. Presumably, i've not tied it into the messaging loop properly somewhere, but I can't work out where.

    I have created the modeless dialog with CreateDialog(...)

    The dialog has its own message handler, which handles WM_INIT and one app message defined as WM_USER+1 and otherwise returns (INT_PTR)false.

    I have modified my message loop:
    Code:
    GetMessage(&msg, NULL, 0, 0);
    if(!IsDialogMessage(hStatusDlg, &msg))
    {
    	TranslateMessage(&msg);
    	DispatchMessage(&msg);
    }
    hStatusDlg is a valid handle to the modeless dialog.


    If i send the app defined message to it, it makes some updates its members as expected.

    Does anyone have any ideas what i've missed?

    thanks,

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    From what you've posted, it seems you've omitted the looping feature of the 'message loop':
    Code:
    while (GetMessage(&msg, 0, 0, 0)>0)
    {
      if(!IsDialogMessage(hStatusDlg, &msg))
      {
    	TranslateMessage(&msg);
    	DispatchMessage(&msg);
      }
    }
    Last edited by Ken Fitlike; 05-04-2006 at 01:10 PM. Reason: typos
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    50
    oops, sorry. bad post.

    i'm actually using a idle time message loop

    Code:
    while(!done)
    	{	
    		if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
    		{
    			if ( msg.message == WM_QUIT )
                     done = TRUE;
    			else
    			{
    				GetMessage(&msg, NULL, 0, 0);
    				if(!IsDialogMessage(hStatusDlg, &msg))
    				{
    					TranslateMessage(&msg);
    					DispatchMessage(&msg);
    				}
    			}
    		}
    		else
    		{
    			//wait until the worker thread pauses itself, then upload the star positions to the graphics card
    			if(threadLink == PAUSE)
    			{
    				//note the the directX visualiser is cpu efficient - this memcpy and the buffer filling above is almost
    				//the only load put on the cpu by the vis
    
    				//give the data to the visualiser
    				visualiser.Update(visBuffer);
    				//have the visualiser render
    				visualiser.Render();
    
    				threadLink = ITERATE;	//tell the worker thread to resume
    			}
    
    			SendMessage(hStatusDlg, UM_UPDATE, 0, 0);
    
    			Sleep(0);	//surrender the rest of the timeslice after one iteration, so that the app (and rest of the system)
    						//still respond to the user
    		}
    	}
    (its an n-body spiral galaxy evolution simulation, hence the references to stars and directX visualisations)

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    50
    As expected, I was being a donut. I had set the dialog as disabled in the resource editor by mistake which of course meant it quite rightly didn't respond to user input and locked out the app.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ok..Tabbed dialogs...XP style
    By Joelito in forum Windows Programming
    Replies: 5
    Last Post: 05-14-2006, 02:36 PM
  2. I need to use dialogs as tabs?
    By BenPage in forum C++ Programming
    Replies: 1
    Last Post: 08-03-2005, 08:59 AM
  3. Accelerators in dialogs
    By confuted in forum Windows Programming
    Replies: 2
    Last Post: 06-25-2005, 04:07 AM
  4. Modeless Dialogs in Multiple threads
    By MrGrieves in forum Windows Programming
    Replies: 0
    Last Post: 06-22-2004, 01:33 PM
  5. Dialogs and stuff
    By Nova_Collision in forum Windows Programming
    Replies: 4
    Last Post: 03-18-2004, 09:38 AM