none
msdn示例代码错误 RRS feed

  • 问题

  • ms-help://MS.MSDNQTR.v90.chs/winui/winui/windowsuserinterface/windowing/dialogboxes/usingdialogboxes.htm#modeless_box

    The loop checks the validity of the window handle to the dialog box and only calls the IsDialogMessage function if the handle is valid. IsDialogMessage only processes the message if it belongs to the dialog box. Otherwise, it returns FALSE and the loop dispatches the message to the appropriate window.

    The following statements define the dialog box procedure.

    Hide Example

    int iLine;             // Receives line number.
    BOOL fRelative;        // Receives check box status. 
     
    BOOL CALLBACK GoToProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) 
    { 
        BOOL fError; 
     
        switch (message) 
        { 
            case WM_INITDIALOG: 
                CheckDlgButton(hwndDlg, ID_ABSREL, fRelative); 
                return TRUE; 
     
            case WM_COMMAND: 
                switch (LOWORD(wParam)) 
                { 
                    case IDOK: 
                        fRelative = IsDlgButtonChecked(hwndDlg, ID_ABSREL); 
                        iLine = GetDlgItemInt(hwndDlg, ID_LINE, &fError, fRelative); 
                        if (fError)   //this true means success.
                        { 
                            MessageBox(hwndDlg, SZINVALIDNUMBER, SZGOTOERR, MB_OK); 
                            SendDlgItemMessage(hwndDlg, ID_LINE, EM_SETSEL, 0, -1L); 
                        } 
                        else 
    
                        // Notify the owner window to carry out the task. 
     
                        return TRUE; 
     
                    case IDCANCEL: 
                        DestroyWindow(hwndDlg); 
                        hwndGoto = NULL; 
                        return TRUE; 
                } 
        } 
        return FALSE; 
    } 

    2013年9月11日 1:31

全部回复