--- np2/win9x/dialog/np2class.cpp 2003/10/30 12:45:38 1.1 +++ np2/win9x/dialog/np2class.cpp 2004/05/23 15:01:45 1.6 @@ -1,9 +1,13 @@ #include "compiler.h" +#include #include "resource.h" +#include "winloc.h" +#include "np2class.h" const char np2dlgclass[] = "np2dialog"; + void np2class_initialize(HINSTANCE hinst) { WNDCLASS wc; @@ -28,7 +32,7 @@ void np2class_deinitialize(HINSTANCE hin } -// ---- +// ---- void np2class_move(HWND hWnd, int posx, int posy, int cx, int cy) { @@ -51,3 +55,128 @@ void np2class_move(HWND hWnd, int posx, MoveWindow(hWnd, posx, posy, cx, cy, TRUE); } +// ---- + +int CALLBACK np2class_propetysheet(HWND hWndDlg, UINT uMsg, LPARAM lParam) { + + if (uMsg == PSCB_INITIALIZED) { + SetWindowLong(hWndDlg, GWL_EXSTYLE, + GetWindowLong(hWndDlg, GWL_EXSTYLE) & (~WS_EX_CONTEXTHELP)); + } + return(0); +} + + +// ---- + +void np2class_wmcreate(HWND hWnd) { + + 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; + + hmenu = (HMENU)GetWindowLong(hWnd, NP2GWL_HMENU); + draw = FALSE; + if (enable) { + if (hmenu) { + SetMenu(hWnd, hmenu); + hmenu = NULL; + draw = TRUE; + } + } + else { + if (hmenu == NULL) { + hmenu = GetMenu(hWnd); + if (hmenu) { + SetMenu(hWnd, NULL); + draw = TRUE; + } + } + } + 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_FRAMECHANGED | SWP_DRAWFRAME | + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); + winloc_setclientsize(hWnd, + rect.right - rect.left, rect.bottom - rect.top); +} + +void np2class_frametype(HWND hWnd, BYTE thick) { + + RECT rect; + DWORD style; + + GetClientRect(hWnd, &rect); + style = GetWindowLong(hWnd, GWL_STYLE); + if (thick) { + style |= WS_THICKFRAME; + } + else { + style &= ~WS_THICKFRAME; + } + SetWindowLong(hWnd, GWL_STYLE, style); + SetWindowPos(hWnd, 0, 0, 0, 0, 0, + SWP_FRAMECHANGED | SWP_DRAWFRAME | + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); + winloc_setclientsize(hWnd, + rect.right - rect.left, rect.bottom - rect.top); +} + + + +HMENU np2class_gethmenu(HWND hWnd) { + + HMENU ret; + + ret = (HMENU)GetWindowLong(hWnd, NP2GWL_HMENU); + if (ret == NULL) { + ret = GetMenu(hWnd); + } + return(ret); +} +