san_lee
January 14th, 2003, 08:17 PM
I'd like to create an irregular window in win32 dll. The same code I use can be used in win32 application, but, it doesn't work quite well in win32 dll. It seems having message loop deadlock. Can anyone tell me a simple example that create a window in dll?
Thanks.
here is the code I call in DLL_PROCESS_ATTACH:
int InitWnd(HINSTANCE hInst) {
static TCHAR szAppName[] = TEXT("TTT");
MSG msg;
WNDCLASS wndclass;
if (hwnd != NULL) return -1;
hInstance = hInst;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
if (!RegisterClass(&wndclass)) {
MessageBox(NULL, TEXT("wrong"), "title", MB_ICONERROR);
return 0;
}
nSizeBorder = GetSystemMetrics(SM_CXSIZEFRAME) + 1;
hwnd = CreateWindowEx(0, szAppName,
"tttwindow",
WS_POPUP,
200,
200,
600,
600,
NULL,
NULL,
hInstance,
NULL);
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
return 0;
} //InitWnd()
Thanks.
here is the code I call in DLL_PROCESS_ATTACH:
int InitWnd(HINSTANCE hInst) {
static TCHAR szAppName[] = TEXT("TTT");
MSG msg;
WNDCLASS wndclass;
if (hwnd != NULL) return -1;
hInstance = hInst;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
if (!RegisterClass(&wndclass)) {
MessageBox(NULL, TEXT("wrong"), "title", MB_ICONERROR);
return 0;
}
nSizeBorder = GetSystemMetrics(SM_CXSIZEFRAME) + 1;
hwnd = CreateWindowEx(0, szAppName,
"tttwindow",
WS_POPUP,
200,
200,
600,
600,
NULL,
NULL,
hInstance,
NULL);
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
return 0;
} //InitWnd()