| version 1.2, 2003/11/01 22:23:04 | version 1.10, 2007/01/08 07:52:01 | 
| Line 1 | Line 1 | 
 | #include        "compiler.h" | #include        "compiler.h" | 
 |  | #include        <prsht.h> | 
 | #include        "resource.h" | #include        "resource.h" | 
 | #include        "winloc.h" | #include        "winloc.h" | 
 | #include        "np2class.h" | #include        "np2class.h" | 
 |  |  | 
 |  |  | 
| const char np2dlgclass[] = "np2dialog"; | const TCHAR np2dlgclass[] = _T("np2dialog"); | 
 |  |  | 
 |  |  | 
 | void np2class_initialize(HINSTANCE hinst) { | void np2class_initialize(HINSTANCE hinst) { | 
| Line 31  void np2class_deinitialize(HINSTANCE hin | Line 32  void np2class_deinitialize(HINSTANCE hin | 
 | } | } | 
 |  |  | 
 |  |  | 
| // ---- | // ---- | 
 |  |  | 
 | void np2class_move(HWND hWnd, int posx, int posy, int cx, int cy) { | void np2class_move(HWND hWnd, int posx, int posy, int cx, int cy) { | 
 |  |  | 
| Line 54  void np2class_move(HWND hWnd, int posx, | Line 55  void np2class_move(HWND hWnd, int posx, | 
 | MoveWindow(hWnd, posx, posy, cx, cy, TRUE); | 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_windowtype(HWND hWnd, BYTE type) { | void np2class_wmcreate(HWND hWnd) { | 
 |  |  | 
| RECT            rect; | SetWindowLongPtr(hWnd, NP2GWLP_HMENU, 0); | 
| DWORD           style; | } | 
| HMENU           hmenu; |  | 
 |  |  | 
| GetClientRect(hWnd, &rect); | void np2class_wmdestroy(HWND hWnd) { | 
| style = GetWindowLong(hWnd, GWL_STYLE); |  | 
| hmenu = (HMENU)GetWindowLong(hWnd, NP2GWL_HMENU); | HMENU   hmenu; | 
| if (!(type & 1)) { |  | 
| style |= WS_CAPTION; | hmenu = (HMENU)GetWindowLongPtr(hWnd, NP2GWLP_HMENU); | 
|  | if (hmenu != NULL) { | 
|  | DestroyMenu(hmenu); | 
|  | SetWindowLongPtr(hWnd, NP2GWLP_HMENU, 0); | 
|  | } | 
|  | } | 
|  |  | 
|  | void np2class_enablemenu(HWND hWnd, BOOL enable) { | 
|  |  | 
|  | HMENU   hmenu; | 
|  | BOOL    draw; | 
|  |  | 
|  | hmenu = (HMENU)GetWindowLongPtr(hWnd, NP2GWLP_HMENU); | 
|  | draw = FALSE; | 
|  | if (enable) { | 
 | if (hmenu) { | if (hmenu) { | 
 | SetMenu(hWnd, hmenu); | SetMenu(hWnd, hmenu); | 
 | hmenu = NULL; | hmenu = NULL; | 
 |  | draw = TRUE; | 
 | } | } | 
 | } | } | 
 | else { | else { | 
 | style &= ~WS_CAPTION; |  | 
 | if (hmenu == NULL) { | if (hmenu == NULL) { | 
 | hmenu = GetMenu(hWnd); | hmenu = GetMenu(hWnd); | 
| SetMenu(hWnd, NULL); | if (hmenu) { | 
|  | SetMenu(hWnd, NULL); | 
|  | draw = TRUE; | 
|  | } | 
 | } | } | 
 | } | } | 
 |  | SetWindowLongPtr(hWnd, NP2GWLP_HMENU, (LONG_PTR)hmenu); | 
 |  | if (draw) { | 
 |  | DrawMenuBar(hWnd); | 
 |  | } | 
 |  | } | 
 |  |  | 
 |  | void np2class_windowtype(HWND hWnd, UINT8 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); | SetWindowLong(hWnd, GWL_STYLE, style); | 
 | SetWindowLong(hWnd, NP2GWL_HMENU, (LONG)hmenu); |  | 
 | SetWindowPos(hWnd, 0, 0, 0, 0, 0, | SetWindowPos(hWnd, 0, 0, 0, 0, 0, | 
| SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); | SWP_FRAMECHANGED | SWP_DRAWFRAME | | 
|  | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); | 
 | winloc_setclientsize(hWnd, | winloc_setclientsize(hWnd, | 
 | rect.right - rect.left, rect.bottom - rect.top); | rect.right - rect.left, rect.bottom - rect.top); | 
 | } | } | 
 |  |  | 
| HMENU np2class_gethmenu(HWND hWnd) { | void np2class_frametype(HWND hWnd, UINT8 thick) { | 
 |  |  | 
| HMENU   ret; | RECT    rect; | 
|  | DWORD   style; | 
 |  |  | 
| ret = (HMENU)GetWindowLong(hWnd, NP2GWL_HMENU); | GetClientRect(hWnd, &rect); | 
| if (ret == NULL) { | style = GetWindowLong(hWnd, GWL_STYLE); | 
| ret = GetMenu(hWnd); | if (thick) { | 
|  | style |= WS_THICKFRAME; | 
 | } | } | 
| return(ret); | 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); | 
 | } | } | 
 |  |  | 
 | void np2class_destroymenu(HWND hWnd) { |  | 
 |  |  | 
 | HMENU   hmenu; |  | 
 |  |  | 
| hmenu = (HMENU)GetWindowLong(hWnd, NP2GWL_HMENU); | HMENU np2class_gethmenu(HWND hWnd) { | 
| if (hmenu != NULL) { |  | 
| DestroyMenu(hmenu); | HMENU   ret; | 
| SetWindowLong(hWnd, NP2GWL_HMENU, 0); |  | 
|  | ret = (HMENU)GetWindowLongPtr(hWnd, NP2GWLP_HMENU); | 
|  | if (ret == NULL) { | 
|  | ret = GetMenu(hWnd); | 
 | } | } | 
 |  | return(ret); | 
 | } | } | 
 |  |  |