Thread: modeless dialog not interacting with main window

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    416

    modeless dialog not interacting with main window

    I am having trouble getting my toolbar dialog to interact with the main window, or the edit box. Right now I am just testing it on save, and open. The functions do work from the menu, but not from the dialog. I've tried using SendMessage(), PostMessage(), and SendNotifyMessage(). None of which seem to work correctly with the window. PostMessage freezes the entire program, the other two don't do anything. I just want to be able to click save from the toolbar, and have it save the edit box text. There are no compiler errors, or warnings. Here is my DlgProc() function.

    Code:
    BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
        switch(Message)
        {
            case WM_INITDIALOG:
    
            return TRUE;
            case WM_COMMAND:
                switch(LOWORD(wParam))
                {
                    case ID_FILE_SAVE:
    					if(MiniWnd){
    						PostMessage(hwnd,WM_COMMAND,ID_FILE_SAVE,0);
    						}
    					else
                            MessageBox(hwnd,"Please open the edit box","Error",MB_OK);
                    break;
                    
                    case ID_FILE_OPEN:
    					if(MiniWnd){
    						PostMessage(hwnd,WM_COMMAND,ID_FILE_OPEN,0);
    						}
    					else
    						MessageBox(hwnd,"Please open the edit box","Error",MB_OK);
                    break;
                    
                    case ID_DLG_CLOSE:
    					ShowWindow(dlgret,SW_HIDE);
    					break;
                }
            break;
            default:
                return FALSE;
        }
        return TRUE;
    }
    I can't get it to indent correctly on the post, but it is indented right in the .cpp file, so don't worry about that.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > I can't get it to indent correctly on the post, but it is indented right in the .cpp file, so don't worry about that.
    Wrong way round - we have to read the poorly formatted code, not you.
    FYI, turn off TABS in your IDE and make it indent only using spaces. Then everyone will see the same as you see.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Doesn't your postmessage have to go to the MAIN window (I'm no good with postmessage, so I'm not saying it is so).

    --
    Mats

  4. #4
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    Salem, thank you for the tip

    matsp, i didnt catch what you meant at first, but i realized i had the same variable name for the HWND of the DlgProc as the main window of the program, it now works the way I want it to.

    Thanks guys!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fixing Z-order on a modeless dialog?
    By Viper187 in forum Windows Programming
    Replies: 6
    Last Post: 06-20-2008, 07:10 PM
  2. Memory leaks problem in C -- Help please
    By Amely in forum C Programming
    Replies: 14
    Last Post: 05-21-2008, 11:16 AM
  3. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  4. Problem with creating new window, from another window
    By Garfield in forum Windows Programming
    Replies: 6
    Last Post: 01-11-2004, 02:10 PM
  5. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 04:10 AM