// 26 april 2015 #include "uipriv_windows.h" #define containerClass L"libui_uiContainerClass" HWND initialParent; static LRESULT CALLBACK containerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { uiContainer *c; CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam; c = uiContainer(GetWindowLongPtrW(hwnd, GWLP_USERDATA)); if (c == NULL) if (uMsg == WM_NCCREATE) SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) (cs->lpCreateParams)); // DO NOT RETURN DEFWINDOWPROC() HERE // see the next block of comments as to why // instead, we simply check if c == NULL again later switch (uMsg) { // these must always be run, even on the initial parent // why? http://blogs.msdn.com/b/oldnewthing/archive/2010/03/16/9979112.aspx // TODO // these are only run if c is not NULL case WM_WINDOWPOSCHANGED: case msgUpdateChild: if (c == NULL) break; ; // TODO } return DefWindowProcW(hwnd, uMsg, wParam, lParam); } const char *initContainer(void) { WNDCLASSW wc; ZeroMemory(&wc, sizeof (WNDCLASSW)); wc.lpszClassName = containerClass; wc.lpfnWndProc = containerWndProc; wc.hInstance = hInstance; wc.hIcon = hDefaultIcon; wc.hCursor = hDefaultCursor; wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); if (RegisterClassW(&wc) == 0) return "registering uiContainer window class"; initialParent = CreateWindowExW(0, uiOSContainerClass, L"", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, NULL, NULL, hInstance, NULL); if (initialParent == NULL) return "creating initial parent window"; // just to be safe, disable the initial parent so it can't be interacted with accidentally // if this causes issues for our controls, we can remove it EnableWindow(initialParent, FALSE); return NULL; } void uiMakeContainer(uiContainer *c) { // TODO }