The error code is 6 with GetLastError£¨£©£¬
First i registered a WNDCLASS£¬then I create a dialog¡£
But it failed¡£
My intent is to add an icon for the dialog in a dll.
Someone can help me?
Thanks.
Code:
wc.style = CS_HREDRAW | CS_VREDRAW ;
wc.lpfnWndProc = (WNDPROC)WndProc ;//callback procedure
wc.cbClsExtra = 0 ;
wc.cbWndExtra = DLGWINDOWEXTRA ;
wc.hInstance = tmp_hModule ;
//dllmain input handle when attach process
wc.hIcon = LoadIcon(tmp_hModule, MAKEINTRESOURCE(IDI_ICON1));
wc.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wc.hbrBackground = GetStockObject (LTGRAY_BRUSH) ;
wc.lpszMenuName = NULL ;
wc.lpszClassName = szAppName;
//defined as TCHAR szAppName[] = TEXT("OPERATIONPANEL");
if(!RegisterClass(&wc)) return FALSE ;

hwnd=CreateDialog(tmp_hModule,MAKEINTRESOURCE(IDD_TABLEDLG),0,WndProc);
if(hwnd==NULL)
{
error=GetLastError();
wsprintf(str,L"error=%d",GetLastError());
MessageBox(NULL,str,L"CreateDialog",MB_OK);
return FALSE;



-
hy
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------

Re: error on CreateDialog by Alexander

Alexander
Tue Oct 11 10:38:35 CDT 2005

To create a dialog you don't have to register a class. Your class will not
used for the dialog, anyway.

"hyf" <hyf.1wqchn@mail.codecomments.com> wrote in message
news:hyf.1wqchn@mail.codecomments.com...
>
> The error code is 6 with GetLastError£¨£©£¬
> First i registered a WNDCLASS£¬then I create a dialog¡£
> But it failed¡£
> My intent is to add an icon for the dialog in a dll.
> Someone can help me?
> Thanks.
> Code:
> wc.style = CS_HREDRAW | CS_VREDRAW ;
> wc.lpfnWndProc = (WNDPROC)WndProc ;//callback procedure
> wc.cbClsExtra = 0 ;
> wc.cbWndExtra = DLGWINDOWEXTRA ;
> wc.hInstance = tmp_hModule ;
> //dllmain input handle when attach process
> wc.hIcon = LoadIcon(tmp_hModule, MAKEINTRESOURCE(IDI_ICON1));
> wc.hCursor = LoadCursor (NULL, IDC_ARROW) ;
> wc.hbrBackground = GetStockObject (LTGRAY_BRUSH) ;
> wc.lpszMenuName = NULL ;
> wc.lpszClassName = szAppName;
> //defined as TCHAR szAppName[] = TEXT("OPERATIONPANEL");
> if(!RegisterClass(&wc)) return FALSE ;
>
> hwnd=CreateDialog(tmp_hModule,MAKEINTRESOURCE(IDD_TABLEDLG),0,WndProc);
> if(hwnd==NULL)
> {
> error=GetLastError();
> wsprintf(str,L"error=%d",GetLastError());
> MessageBox(NULL,str,L"CreateDialog",MB_OK);
> return FALSE;
> }
>
>
>
> --
> hyf
> ------------------------------------------------------------------------
> Posted via http://www.codecomments.com
> ------------------------------------------------------------------------
>



Re: error on CreateDialog by Skywing

Skywing
Tue Oct 11 11:17:12 CDT 2005

You can actually use a custom class with a dialog, BTW.

Error 6 is invalid handle. Perhaps the hinstance that the OP specified is
invalid..?

"Alexander Grigoriev" <alegr@earthlink.net> wrote in message
news:eetIennzFHA.2424@TK2MSFTNGP12.phx.gbl...
> To create a dialog you don't have to register a class. Your class will not
> used for the dialog, anyway.
>
> "hyf" <hyf.1wqchn@mail.codecomments.com> wrote in message
> news:hyf.1wqchn@mail.codecomments.com...
>>
>> The error code is 6 with GetLastError£¨£©£¬
>> First i registered a WNDCLASS£¬then I create a dialog¡£
>> But it failed¡£
>> My intent is to add an icon for the dialog in a dll.
>> Someone can help me?
>> Thanks.
>> Code:
>> wc.style = CS_HREDRAW | CS_VREDRAW ;
>> wc.lpfnWndProc = (WNDPROC)WndProc ;//callback procedure
>> wc.cbClsExtra = 0 ;
>> wc.cbWndExtra = DLGWINDOWEXTRA ;
>> wc.hInstance = tmp_hModule ;
>> //dllmain input handle when attach process
>> wc.hIcon = LoadIcon(tmp_hModule, MAKEINTRESOURCE(IDI_ICON1));
>> wc.hCursor = LoadCursor (NULL, IDC_ARROW) ;
>> wc.hbrBackground = GetStockObject (LTGRAY_BRUSH) ;
>> wc.lpszMenuName = NULL ;
>> wc.lpszClassName = szAppName;
>> //defined as TCHAR szAppName[] = TEXT("OPERATIONPANEL");
>> if(!RegisterClass(&wc)) return FALSE ;
>>
>> hwnd=CreateDialog(tmp_hModule,MAKEINTRESOURCE(IDD_TABLEDLG),0,WndProc);
>> if(hwnd==NULL)
>> {
>> error=GetLastError();
>> wsprintf(str,L"error=%d",GetLastError());
>> MessageBox(NULL,str,L"CreateDialog",MB_OK);
>> return FALSE;
>> }
>>
>>
>>
>> --
>> hyf
>> ------------------------------------------------------------------------
>> Posted via http://www.codecomments.com
>> ------------------------------------------------------------------------
>>
>
>



Re: error on CreateDialog by CheckAbdoul

CheckAbdoul
Tue Oct 11 15:47:59 CDT 2005

I believe you have to change the .rc file to add the CLASS item in the
dialog resource. See

http://support.microsoft.com/?id=251059
How to provide your own Window class name for an MFC dialog box

BTW, this is not the correct newsgroup for SDK questions. Next time
try microsoft.public.vc.mfc newsgroup.
--
Cheers
Check Abdoul
-----------------


"hyf" <hyf.1wqchn@mail.codecomments.com> wrote in message
news:hyf.1wqchn@mail.codecomments.com...
>
> The error code is 6 with GetLastError£¨£©£¬
> First i registered a WNDCLASS£¬then I create a dialog¡£
> But it failed¡£
> My intent is to add an icon for the dialog in a dll.
> Someone can help me?
> Thanks.
> Code:
> wc.style = CS_HREDRAW | CS_VREDRAW ;
> wc.lpfnWndProc = (WNDPROC)WndProc ;//callback procedure
> wc.cbClsExtra = 0 ;
> wc.cbWndExtra = DLGWINDOWEXTRA ;
> wc.hInstance = tmp_hModule ;
> //dllmain input handle when attach process
> wc.hIcon = LoadIcon(tmp_hModule, MAKEINTRESOURCE(IDI_ICON1));
> wc.hCursor = LoadCursor (NULL, IDC_ARROW) ;
> wc.hbrBackground = GetStockObject (LTGRAY_BRUSH) ;
> wc.lpszMenuName = NULL ;
> wc.lpszClassName = szAppName;
> //defined as TCHAR szAppName[] = TEXT("OPERATIONPANEL");
> if(!RegisterClass(&wc)) return FALSE ;
>
> hwnd=CreateDialog(tmp_hModule,MAKEINTRESOURCE(IDD_TABLEDLG),0,WndProc);
> if(hwnd==NULL)
> {
> error=GetLastError();
> wsprintf(str,L"error=%d",GetLastError());
> MessageBox(NULL,str,L"CreateDialog",MB_OK);
> return FALSE;
> }
>
>
>
> --
> hyf
> ------------------------------------------------------------------------
> Posted via http://www.codecomments.com
> ------------------------------------------------------------------------
>