LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static HWND hChild; static RECT rect; switch(msg) { case WM_CREATE:{ printf("wm_create executed\n"); GetClientRect(hwnd, &rect); WNDCLASSEX wcc; //child windowclassex memset(&wcc, 0, sizeof(WNDCLASSEX)); wcc.cbSize = sizeof(WNDCLASSEX); wcc.style = CS_HREDRAW | CS_VREDRAW; wcc.hInstance = GetModuleHandle(NULL); wcc.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE; wcc.lpfnWndProc = ChildProc; wcc.lpszClassName = "SubClass"; if(!RegisterClassEx(&wcc)){MessageBox(hwnd, "Register Child Class Failed", "ERROR",MB_ICONEXCLAMATION | MB_OK);} hChild = CreateWindowEx( WS_EX_DLGMODALFRAME, wcc.lpszClassName, "", WS_CHILD | WS_VISIBLE | WS_TILED, 20, 90, 50, 50, //x y xW yW hwnd, NULL, GetModuleHandle(NULL), NULL); if(hChild==NULL)printf("Child Create failed!\n"); return 0;} case WM_SIZE:{ rect.right = LOWORD(lParam); rect.bottom = HIWORD(lParam); MoveWindow(hChild, 5, rect.bottom - 35, rect.right - 10, 30, TRUE); return 0;} case WM_CLOSE: DestroyWindow(hwnd);break; case WM_DESTROY: PostQuitMessage(0);break; /* case WM_LBUTTONUP: { char szFileName[MAX_PATH]; HINSTANCE hInstance = GetModuleHandle(NULL); GetModuleFileName(hInstance, szFileName, MAX_PATH); MessageBox(hwnd , szFileName, "This program is:", MB_ICONINFORMATION| MB_OK | MB_ICONINFORMATION); }break; */ default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }