locked
Help needed regarding modal dialog box RRS feed

  • Question

  • Hello,
    I'm developing wince application for windows mobile 6.
    i'm creating a edit box control part of modal dialog box for getting user input, but i've resized the dialog box for positioning the edit box at specified place. problem is when i'm clicking off the dialog box region i get a beep but no any message recieved by the dialog box.Is there any way to get this event on dialog box or parent window (not possible since parent window is disabled till dialog box destroyed by EndDialog).
    please help me..
    Monday, March 30, 2009 3:06 PM

Answers

  • Even with modeless dialog you still can block the main application by executing an event loop and waiting for say a flag to be set.
    On a more general note - I suggest you rethink your UI paradigm. What you are describing is not usually done.
    Alex Feinman. MVP .NET Compact Framework
    Wednesday, April 1, 2009 4:00 AM

All replies

  • Can you post some code on your dialog box. Are returning the dialog result?

    Ryan
    Monday, March 30, 2009 3:30 PM
  • yeah sure.
    below i've given the code snippt.
    //.rc file

    IDD_TEXTBOX DIALOG  0, 0, 240, 280
    STYLE DS_SETFONT | WS_POPUP
    EXSTYLE 0x80000000L
    FONT 10, "MS Sans Serif"
    BEGIN
     EDITTEXT        IDC_EDIT1, 0, 0, 160, 100, ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | NOT WS_BORDER
    END


    //.cpp file
    void someproc(){
    .....
    .....
    int result =  DialogBox(g_hInst, (LPCTSTR)IDD_TEXTBOX, g_hWnd, TextBoxProc);
    ....
    ....
    }

     

    BOOL CALLBACK TextBoxProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    {
     switch( message )
     {
      case WM_INITDIALOG:
      { 
      
       // Retrieve the handle to the edit control.
       hWndCtrl = GetDlgItem(hDlg, IDC_EDIT1);

       //overriding default edit control procedure
       SetWindowLong(hWndCtrl, GWL_USERDATA, GetWindowLong(hWndCtrl, GWL_WNDPROC)); 
       SetWindowLong(hWndCtrl, GWL_WNDPROC, (LONG)MaskedEditProc); 
      
      MoveWindow(hDlg, 0, 50, 240,50, FALSE);
     }
            break;
     
            case WM_CLOSE:
       EndDialog(hDlg, LOWORD(wParam));         
              return TRUE;

     default:
       return (INT_PTR)FALSE;
    }

     


    // Subclass procedure
    INT_PTR CALLBACK MaskedEditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

     WNDPROC pfnOldWndProc = (WNDPROC)GetWindowLong(hWnd, GWL_USERDATA);
     INT_PTR  retCode = CallWindowProc(pfnOldWndProc, hWnd, message, wParam, lParam); 
     return  retCode;
    }


    I'm returning the value from DialogBox but as i told you that when i'm clicking outside the dialog region ie 0-50 or 100 - 200 in this sample i'm getting a beep but no any message rcvd by TextBoxProc procedure.

    Monday, March 30, 2009 4:22 PM
  • If you want to receive messages when user clicks off the dialog box, you need to make it modeless. Use CreateDialog instead of DialogBox


    Alex Feinman. MVP .NET Compact Framework
    Tuesday, March 31, 2009 12:11 AM
  • @AlexFeinman
    Actually I bound to call the modal  dialog box b'coz i want that once the user select the edit box for entering input then my code has to wait for user to finished first.I'm trying to give various options for user to finish its input like if edit box is single line then pressing up/down etc..down the line i want that if user click off the dialog box containing inherent edit box i want to make it too ie user has finshed that why i want to capture those events.
    Is there any way to get those events ?

    Thanks in advance.
    Tuesday, March 31, 2009 3:24 AM
  • Even with modeless dialog you still can block the main application by executing an event loop and waiting for say a flag to be set.
    On a more general note - I suggest you rethink your UI paradigm. What you are describing is not usually done.
    Alex Feinman. MVP .NET Compact Framework
    Wednesday, April 1, 2009 4:00 AM