Microsoft KB Archive/298685

= How To Implement an Independent Floating Modeless Dialog Box in MFC for Pocket PC =

Article ID: 298685

Article Last Modified on 10/11/2004

-

APPLIES TO


 * Microsoft Windows CE Palm-size PC 2.01 software

-



This article was previously published under Q298685



SUMMARY
When you implement a modeless dialog box for Pocket PC in Microsoft Foundation Classes (MFC), MFC may resize the dialog box and hook some default processing to it. Sometimes it is desirable to have a fixed size for the dialog box and enable the user to move it around, such as a floating toolbox.



MORE INFORMATION
Follow these steps to create a floating dialog box of fixed size:  Define your CDialog class (for example, CMyDialog) as usual.  Implement WM_INITDIALOG in a static dialog procedure, which will be used in that next step, that:

 Sets the dialog box's m_bFullScreen member to FALSE. Attaches the newly created dialog box to your dialog class. Calls OnInitDialog.

This following code demonstrates this: // This proc is declared as static in the class declaration BOOL CALLBACK CMyDialog::MyDlgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) {   CDialog *pDlg;

switch (msg) {       case WM_INITDIALOG: pDlg = (CDialog*)lParam; pDlg->m_bFullScreen = FALSE; pDlg->Attach(hWnd); return pDlg->OnInitDialog;

default: return FALSE; }

}                     Override CMyDialog::Create to call ::CreateDialogParam and pass the this pointer as the dwInitParam parameter. This will be passed in the lParam of the WM_INITDIALOG message: BOOL CMyDialog::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) {   ::CreateDialogParam(AfxGetInstanceHandle,        MAKEINTRESOURCE(IDD_DIALOG1),        pParentWnd->GetSafeHwnd,        CMyDialog::MyDlgProc,        (LPARAM)this);

return TRUE; }

</li>  Implement CMyDialog::OnSettingChange to return CWnd::OnSettingChange: void CMyDialog::OnSettingChange(UINT uFlags,LPCTSTR lpszSection) {   CWnd::OnSettingChange(uFlags,lpszSection); }                   </li></ol>

Now you should have a dialog box that assumes the size of the dialog resource it was created from and that can be moved around.

Keywords: kbhowto KB298685

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.