Modal Dialogs HELP!!!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Modal Dialogs HELP!!!

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Posts
    3

    Modal Dialogs HELP!!!

    Hi everyone,

    I have a modal dialog box which is called by the main thread. This dialog has no parent (appears at center screen, overlapped, and shown in taskbar). When the user clicks "Save" in the dialog, the dialog procedure receives the command and displays a save file dialog (GetSaveFileName).
    The problem is that the second dialog (Save Dialog) doesn't work at all. It can't be activated, and seems kind of frozen (can't be closed, buttons and scroll bars are frozen). Here's my code:

    Code:
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    	DialogBox(hInstance, MAKEINTRESOURCE(101), NULL, DialogProc);
    	MSG msg;
    	while (GetMessage(&msg, NULL, 0, 0) != 0)
    	{
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    	return (int)msg.wParam;
    }
    
    INT_PTR CALLBACK DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
    HDC hdc; PAINTSTRUCT ps;
    switch (message) {
    	case WM_COMMAND:
    		switch(LOWORD(wParam)) {
    			case IDSAVE:
    				OPENFILENAME OFN;
    				OFN.hwndOwner = hWnd;
    				[...]
    				//PROBLEM IS HERE. The save file dialog is half-frozen and never returns.
    				if (GetSaveFileName(&OFN)) {[...]}
    				break;
    			default:
    				return DefWindowProc(hWnd, message, wParam, lParam);
    		}
    		return true;
    	case WM_PAINT:
    		hdc = BeginPaint(hWnd, &ps);
    		EndPaint(hWnd, &ps);
    		break;
    	case WM_INITDIALOG:
    		[...]
    		return true;
    	case WM_CLOSE:
    		[...]
    		return true;
    	case WM_DESTROY:
    		[...]
    		return true;
    	default:
    		return DefWindowProc(hWnd, message, wParam, lParam);
    	}
    	return false;
    }
    Whatever dialog type I put at this line (print dialog, modal dialog, modeless dialog), it doesn't behave properly. What am I missing?
    I tried with OFN.hwndOwner = NULL, but doesn't work.

    Thanks in advance!

  2. #2
    Join Date
    Feb 2010
    Posts
    1

    return 0

    have you tried to return 0 to WM_CLOSE (not 'true')

  3. #3
    Join Date
    May 2010
    Posts
    2
    afik you shouldn't call DefWindowProc in a dialog procedure, just return instead. maybe this helps.

  4. #4
    Join Date
    May 2010
    Posts
    2
    afik you shouldn't call DefWindowProc in a dialog procedure, just return

Similar Threads

  1. Switch between window modal/not modal
    By kicaj in forum .NET
    Replies: 1
    Last Post: 06-24-2007, 09:51 PM
  2. Replies: 0
    Last Post: 07-12-2001, 01:41 AM
  3. Modal dialogs
    By John Senford in forum Java
    Replies: 1
    Last Post: 01-17-2001, 01:38 AM
  4. SHBrowseForFolder - modal
    By LThib in forum VB Classic
    Replies: 0
    Last Post: 11-13-2000, 04:52 PM
  5. SHBrowseForFolder - modal
    By LThib in forum VB Classic
    Replies: 0
    Last Post: 11-13-2000, 04:52 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center