"Return" is ending dialog! I dont want that

This is a discussion on "Return" is ending dialog! I dont want that within the Windows Programming forums, part of the Platform Specific Boards category; Hi. I have a dialog, with a textedit-controll.. it looks like this in the resource-script: Code: CONNECTBOX DIALOG DISCARDABLE 30, ...

  1. #1
    Registered User Drogin's Avatar
    Join Date
    Oct 2005
    Location
    Norway
    Posts
    105

    "Return" is ending dialog! I dont want that

    Hi.
    I have a dialog, with a textedit-controll.. it looks like this in the resource-script:
    Code:
    CONNECTBOX DIALOG DISCARDABLE 30, 30, 250, 70
    FONT 8, "MS Sans Serif"
    BEGIN
    CTEXT "Enter the IP adress you want to contact",IDC_STATIC,57,0,140,8
    EDITTEXT ID_IPADRESS,75,20,100,80
    DEFPUSHBUTTON "Connect",ID_CONNECT_OK,85,50,40,20
    DEFPUSHBUTTON  "Cancel",ID_CANCLEIP,130,50,40,20
    END
    Now, i start it up by doing this in the main windowprocedure:
    Code:
    case IDM_CONNECT:
           DialogBox(hInstance,"CONNECTBOX",hwnd,ConnectDlgProc);
    break;
    And this is the DialogProcedure:
    Code:
    BOOL CALLBACK ConnectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
    static HWND hwndDlgIP;
    switch(message) {
    case WM_INITDIALOG:
    hwndDlgIP=GetDlgItem(hDlg,ID_IPADRESS);
    SendMessage(hwndDlgIP,EM_SETPASSWORDCHAR,'*',0);
    SetFocus(hwndDlgIP);
    return FALSE;        
            
    case WM_COMMAND:
         switch(LOWORD(wParam)) {
         case ID_CANCLEIP:
              EndDialog(hDlg,FALSE);
         return TRUE;     
    
         case ID_CONNECT_OK:
             EndDialog(hDlg,FALSE);
         return TRUE;     
         }
    }
    
    return FALSE;     
    }
    It works. Whats the problem?
    If the Text-edit-controll has the inputfocus, and "return" or '\r'
    is pressed, the whole dialogwindow just goes down.
    I even tried to override it by using windows-subclassing, but the whole dialog goes down, even then!
    If i try to press return, when the inputfocus is not on the textedit, it works fine...

  2. #2
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    it's because you are using default buttons for ok and cancel.

  3. #3
    Registered User Drogin's Avatar
    Join Date
    Oct 2005
    Location
    Norway
    Posts
    105
    um..okay,... and how do i fix that?

  4. #4
    Registered User Drogin's Avatar
    Join Date
    Oct 2005
    Location
    Norway
    Posts
    105
    Stupid me.... it worked
    This was the solution...thanks for setting me on the right track
    Code:
    DEFPUSHBUTTON "Connect",ID_CONNECT_OK,85,50,40,20
    DEFPUSHBUTTON  "Cancel",ID_CANCLEIP,130,50,40,20
    should be:
    Code:
    PUSHBUTTON "Connect",ID_CONNECT_OK,85,50,40,20
    PUSHBUTTON  "Cancel",ID_CANCLEIP,130,50,40,20

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Edit controls of a dialog from another dialog...
    By Snake in forum Windows Programming
    Replies: 9
    Last Post: 07-01-2005, 03:18 PM
  3. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 03:42 PM
  4. Getting the position of a dialog without parent on the screen
    By stormbringer in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2003, 03:59 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21