--- np2/win9x/dialog/np2class.cpp 2003/11/03 00:49:55 1.3 +++ np2/win9x/dialog/np2class.cpp 2003/11/04 15:44:59 1.4 @@ -32,7 +32,7 @@ void np2class_deinitialize(HINSTANCE hin } -// ---- +// ---- void np2class_move(HWND hWnd, int posx, int posy, int cx, int cy) { @@ -69,31 +69,76 @@ int CALLBACK np2class_propetysheet(HWND // ---- -void np2class_windowtype(HWND hWnd, BYTE type) { +void np2class_wmcreate(HWND hWnd) { - RECT rect; - DWORD style; - HMENU hmenu; + SetWindowLong(hWnd, NP2GWL_HMENU, 0); +} + +void np2class_wmdestroy(HWND hWnd) { + + HMENU hmenu; + + hmenu = (HMENU)GetWindowLong(hWnd, NP2GWL_HMENU); + if (hmenu != NULL) { + DestroyMenu(hmenu); + SetWindowLong(hWnd, NP2GWL_HMENU, 0); + } +} + +void np2class_enablemenu(HWND hWnd, BOOL enable) { + + HMENU hmenu; + BOOL draw; - GetClientRect(hWnd, &rect); - style = GetWindowLong(hWnd, GWL_STYLE); hmenu = (HMENU)GetWindowLong(hWnd, NP2GWL_HMENU); - if (!(type & 1)) { - style |= WS_CAPTION; + draw = FALSE; + if (enable) { if (hmenu) { SetMenu(hWnd, hmenu); hmenu = NULL; + draw = TRUE; } } else { - style &= ~WS_CAPTION; if (hmenu == NULL) { hmenu = GetMenu(hWnd); - SetMenu(hWnd, NULL); + if (hmenu) { + SetMenu(hWnd, NULL); + draw = TRUE; + } } } - SetWindowLong(hWnd, GWL_STYLE, style); SetWindowLong(hWnd, NP2GWL_HMENU, (LONG)hmenu); + if (draw) { + DrawMenuBar(hWnd); + } +} + +void np2class_windowtype(HWND hWnd, BYTE type) { + + RECT rect; + DWORD style; + + GetClientRect(hWnd, &rect); + style = GetWindowLong(hWnd, GWL_STYLE); + switch(type) { + case 0: + default: + style |= WS_CAPTION; + np2class_enablemenu(hWnd, TRUE); + break; + + case 1: + style |= WS_CAPTION; + np2class_enablemenu(hWnd, FALSE); + break; + + case 2: + style &= ~WS_CAPTION; + np2class_enablemenu(hWnd, FALSE); + break; + } + SetWindowLong(hWnd, GWL_STYLE, style); SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); winloc_setclientsize(hWnd, @@ -111,14 +156,3 @@ HMENU np2class_gethmenu(HWND hWnd) { return(ret); } -void np2class_destroymenu(HWND hWnd) { - - HMENU hmenu; - - hmenu = (HMENU)GetWindowLong(hWnd, NP2GWL_HMENU); - if (hmenu != NULL) { - DestroyMenu(hmenu); - SetWindowLong(hWnd, NP2GWL_HMENU, 0); - } -} -