请教各位大侠:
我在dll中写了一个类,类中准备用win32方式注册一个窗口,但是在注册窗口的时候要用当前程序的实例句柄,不然,注册不成功,请问怎么才能获得当前dll的hinstance实例句柄,代码如下:怎么老是注册不成功,就不能使用窗口的消息队列????
static TCHAR szAppName[]=TEXT("隐含窗口");
MSG msg;
WNDCLASS wndclass;
HINSTANCE hInstancemain=AfxGetInstanceHandle( );
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc1;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstancemain ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = NULL ;
if (!AfxRegisterClass(&wndclass))
{
return 0 ;
} m_hwnd= CreateWindow (szAppName, // window class name
TEXT (" "), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstancemain, // program instance handle
NULL) ; // creation parameters
ShowWindow (m_hwnd,SW_HIDE) ;
UpdateWindow (m_hwnd) ;while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return 1;
}
我在dll中写了一个类,类中准备用win32方式注册一个窗口,但是在注册窗口的时候要用当前程序的实例句柄,不然,注册不成功,请问怎么才能获得当前dll的hinstance实例句柄,代码如下:怎么老是注册不成功,就不能使用窗口的消息队列????
static TCHAR szAppName[]=TEXT("隐含窗口");
MSG msg;
WNDCLASS wndclass;
HINSTANCE hInstancemain=AfxGetInstanceHandle( );
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc1;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstancemain ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = NULL ;
if (!AfxRegisterClass(&wndclass))
{
return 0 ;
} m_hwnd= CreateWindow (szAppName, // window class name
TEXT (" "), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstancemain, // program instance handle
NULL) ; // creation parameters
ShowWindow (m_hwnd,SW_HIDE) ;
UpdateWindow (m_hwnd) ;while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return 1;
}
解决方案 »
- DllMain????
- 怎样将string类型转化成const OLECHAR *? 在线等 各位大侠帮帮忙!
- 郁闷好几天了,大虾快救我啊![ActiveX控件中捕获不到TWAIN消息,而做成应用,在窗体中可捕获消息]
- 请问一个关于ado数据集指针的问题!!比较急
- VC 6.0 IDE 字体的研究
- 2.读取当前文件夹下文件列表问题?(如何判断当前读取的是文件还是文件夹)
- 请教一个问题,在线等!!
- 请问怎样用openFileDialog打开图象文件,并在pictureBox1显示出来???
- Win98下用VC如何编写使用NetBIOS编写服务器端程序
- 熟悉ODBC的高手请帮帮我
- SpinButton捣乱?
- VC.EXE可以打开可执行文件,提取EXE文件的图标另存为一个图标,那它可不可以更改一个可执行程序的图标啊?
The GetModuleHandle function retrieves a module handle for the specified module if the file has been mapped into the address space of the calling process. To avoid the race conditions described in the Res section, use the GetModuleHandleEx function.HMODULE GetModuleHandle(
LPCTSTR lpModuleName // module name
);
if (!AfxRegisterClass(&wndclass))
{
return 0 ;
}