www.pudn.com > SDK 工具条,分割条,TREE 等控件演示代码.rar > childframe1.cpp


#include "WinMain.h" 
#include "childframe1.h" 
 
extern HINSTANCE hInst; 
 
HWND hChild; 
 
void RegisterFrame(void) 
{ 
 
WNDCLASSEX frame; 
 
frame.cbSize = sizeof(frame); 
frame.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; 
 
 
frame.lpfnWndProc = frameWndProc; 
frame.cbClsExtra = 0; 
frame.cbWndExtra = 0; 
frame.hInstance =hInst; 
frame.hIcon = NULL; 
frame.hCursor =LoadCursor(NULL,IDC_CROSS); 
frame.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); 
 
frame.lpszMenuName = NULL; 
frame.lpszClassName = "ChildWindow"; 
frame.hIconSm =NULL; 
 
RegisterClassEx(&frame); 
 
} 
BOOL CreateChildFrame(HWND hWnd) 
{ 
 
hChild =CreateWindow("ChildWindow","A Child Window",WS_CHILD|WS_VISIBLE|WS_OVERLAPPEDWINDOW,40,40,400,100,hWnd,(HMENU)10011,hInst,NULL); 
 
//ASSERT(hChild!=NULL); 
return 0; 
} 
 
 
 
 
 
 
 
 
LRESULT CALLBACK frameWndProc(HWND hChild,UINT iMsg,WPARAM wParam,LPARAM lParam) 
{ 
	HDC childDc; 
	switch (iMsg) 
	{ 
	case WM_CREATE: 
		childDc = GetDC(hChild); 
		SelectObject(childDc,GetStockObject(SYSTEM_FIXED_FONT)); 
		return 0; 
		//case WM_ 
	case WM_DESTROY: 
		return 0; 
	} 
	return DefWindowProc(hChild,iMsg,wParam,lParam); 
}