DLL中创建窗口

char szClassName[] = "MainWClass";

WNDCLASSEX wndclass;

// 用描述主窗口的参数填充WNDCLASSEX结构

wndclass.cbSize = sizeof(wndclass);

wndclass.style = CS_HREDRAW|CS_VREDRAW;

wndclass.lpfnWndProc = WindowProc;

wndclass.cbClsExtra = 0;

wndclass.cbWndExtra = 0;

wndclass.hInstance = NULL;

wndclass.hIcon = ::LoadIcon(NULL, IDI_APPLICATION);

wndclass.hCursor = ::LoadCursor(NULL, IDC_ARROW);

wndclass.hbrBackground = (HBRUSH)::GetStockObject(WHITE_BRUSH);

wndclass.lpszMenuName = NULL;

wndclass.lpszClassName = szClassName ;

wndclass.hIconSm = NULL;

::RegisterClassEx(&wndclass); 

// 创建主窗口

HWND hWnd = ::CreateWindowEx( 

0,

szClassName,

"",

WS_OVERLAPPEDWINDOW,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

CW_USEDEFAULT,

NULL,

NULL,

NULL,

NULL);

if(hWnd == NULL)

{

::MessageBox(NULL, "创建窗口出错!", "error", MB_OK);

return -1;

}

CWnd* pParentWnd = CWnd::FromHandle(hWnd);

你可能感兴趣的:(DLL)