Hi All,

On Wince 6.0 , I am trying to create a dialog based win32
application.
When I call CreateDialog as bellow, I get the error 0x6 i.e. Invalid
handle.

//my dlgproc
static BOOL CALLBACK MyDlgProcHWND, UINT, WPARAM, LPARAM );


//create dilaog
g_Hwnd = CreateDialog ( g_hInstace,
MAKEINTRESOURCE(IDD_MYDLG),
GetDesktopWindow(), //or NULL
MyDlgProc
);



MyDlg.rc file entry for dialog is:

IDD_MYDLG DIALOG 0, 0, 184, 157
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
CAPTION "My DLg ..."
FONT 8, "System"
BEGIN
CONTROL "Option1",IDC_OPT1,"Button",BS_AUTORADIOBUTTON |
WS_GROUP | WS_TABSTOP,15,118,61,10
CONTROL "Option2",IDC_OPT2,"Button",BS_AUTORADIOBUTTON,
98,118,66,10
GROUPBOX "Options...",IDC_STATIC,7,108,169,26
DEFPUSHBUTTON "OK",IDOK,7,138,78,13,WS_GROUP
PUSHBUTTON "Cancel",IDCANCEL,99,138,78,13
END


The dialog pops up, but app looses control. i.e.MyDlgProc does not get
any keyboard messages, WM_KEYDOWN.

Any Input would be great help.

Thanks & Regards,
Dev

Re: CreateDialog gives Error 0x6, invalid handle by Michel

Michel
Thu Oct 04 15:53:02 CDT 2007

Do you have a messageloop after the call to CreateDialog?

Try g_hWnd = DialogBox( ...

That call doesn't return until your dialog box exits. Also, is
g_hInstace really the right variable, or just a typo? g_hInstance looks
better...

Set a breakpoint in your dialog box procedure at WM_INITDIALOG and see
if it gets there.

Michel Verhagen, eMVP
EmbeddedFusion
www.EmbeddedFusion.com
mverhagen at embeddedfusion dot com

dev wrote:
> Hi All,
>
> On Wince 6.0 , I am trying to create a dialog based win32
> application.
> When I call CreateDialog as bellow, I get the error 0x6 i.e. Invalid
> handle.
>
> //my dlgproc
> static BOOL CALLBACK MyDlgProcHWND, UINT, WPARAM, LPARAM );
>
>
> //create dilaog
> g_Hwnd = CreateDialog ( g_hInstace,
> MAKEINTRESOURCE(IDD_MYDLG),
> GetDesktopWindow(), //or NULL
> MyDlgProc
> );
>
>
>
> MyDlg.rc file entry for dialog is:
>
> IDD_MYDLG DIALOG 0, 0, 184, 157
> STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE |
> WS_CAPTION | WS_SYSMENU
> CAPTION "My DLg ..."
> FONT 8, "System"
> BEGIN
> CONTROL "Option1",IDC_OPT1,"Button",BS_AUTORADIOBUTTON |
> WS_GROUP | WS_TABSTOP,15,118,61,10
> CONTROL "Option2",IDC_OPT2,"Button",BS_AUTORADIOBUTTON,
> 98,118,66,10
> GROUPBOX "Options...",IDC_STATIC,7,108,169,26
> DEFPUSHBUTTON "OK",IDOK,7,138,78,13,WS_GROUP
> PUSHBUTTON "Cancel",IDCANCEL,99,138,78,13
> END
>
>
> The dialog pops up, but app looses control. i.e.MyDlgProc does not get
> any keyboard messages, WM_KEYDOWN.
>
> Any Input would be great help.
>
> Thanks & Regards,
> Dev
>

--