📄 wndproc.c
字号:
(HWND) 0, GetWindowWord (hWnd, GWW_HINSTANCE), NULL); hWndEdit = CreateWindow("edit", NULL, WS_CHILD |ES_MULTILINE|ES_NOHIDESEL| ES_AUTOHSCROLL|WS_VSCROLL|WS_HSCROLL, 0, 0, 0, 0, hWndStatic, NULL, GetWindowWord (hWnd, GWW_HINSTANCE), NULL);#else hWndStatic = CreateWindow("StaticClass", "WiZ Edit/Status Window", WS_OVERLAPPEDWINDOW|WS_SIZEBOX, 0, 0, 0, 0, hWnd, NULL, /* Use class menu */ (HANDLE)GetWindowLong (hWnd, GWL_HINSTANCE), NULL); WinAssert(hWndStatic); hWndEdit = CreateWindow("RICHEDIT", NULL, WS_CHILD |ES_MULTILINE|ECO_AUTOWORDSELECTION| ECO_AUTOHSCROLL|WS_VSCROLL|WS_HSCROLL| ES_NOHIDESEL|ECO_AUTOVSCROLL, 0, 0, 0, 0, hWndStatic, NULL, (HANDLE)GetWindowLong (hWnd, GWL_HINSTANCE), NULL);#endif WinAssert(hWndEdit); /* Subclass the edit control */ lpOldEditProc = (FARPROC)GetWindowLong (hWndEdit, GWL_WNDPROC); SetWindowLong (hWndEdit, GWL_WNDPROC, (LONG)SubClassEditProc); /* Now we set the maximum size the edit control can utilize */#ifdef WIN32 SendMessage(hWndEdit, EM_EXLIMITTEXT, (WPARAM)0, (LPARAM)EDIT_BUF_SIZE);#else SendMessage(hWndEdit, EM_LIMITTEXT, (WPARAM) 0, 0L);#endif SendMessage(hWndEdit, WM_SETFONT, (WPARAM)hFixedFont, TRUE);#ifdef WIN32 /* Insure rich edit control alignment is set to left */ { PARAFORMAT pf; pf.cbSize = sizeof(pf); pf.dwMask = PFM_ALIGNMENT; pf.wAlignment = PFA_LEFT; SendMessage(hWndEdit, EM_SETPARAFORMAT, 0, (LPARAM)&pf); }#endif GetWizOptions(); /* Get options from .INI file */ UpdateListBox();#ifndef WIN32 SendMessage(hWndList, LB_SETSEL, 1, 0L);#else ListViewSetSel(0, TRUE);#endif SetCaption(hWnd); uCommDlgHelpMsg = RegisterWindowMessage((LPSTR)HELPMSGSTRING); /* register open help message */ if ( uf.fCanDragDrop ) DragAcceptFiles( hWnd, TRUE ); break; case WM_SETFOCUS: SetFocus(hWndList); break;#ifdef WIN32 /* This whole section is only for the ListView control which is only available with Windows 95/Windows NT - and not for 16 bit Windows programs. */ case WM_NOTIFY: { DWORD dwpos; NM_LISTVIEW *pNm = (NM_LISTVIEW *)lParam; /* Are we dealing with a message from the list box? */ if (pNm->hdr.hwndFrom != hWndList) break; switch (pNm->hdr.code) { case NM_RCLICK: /* Now is it a right mouse button click? */ {/* This will allow you to perform a hit test on a line in the list box, however, you then tend to lose the concept of being able to do ctrl-mouse click and undo selections. It wasn't important enough to spend any more time fooling with. MapCursorToListItem();*/ dwpos = GetMessagePos(); PostMessage(hWndMain, WM_RBUTTONUP, (WPARAM) 0L, (LPARAM) dwpos); /* Yep */ break; } case NM_DBLCLK: /* Double-click in ListView control */ {/* This will allow you to perform a hit test on a line in the list box, however, you then tend to lose the concept of being able to do ctrl-mouse click and undo selections. It wasn't important enough to spend any more time fooling with. MapCursorToListItem();*/ UpdateButtons(); if ( uf.fCanDragDrop ) DragAcceptFiles( hWnd, FALSE ); Action(hWnd, (WPARAM)(wLBSelection - IDM_LB_EXTRACT)); if ( uf.fCanDragDrop ) DragAcceptFiles( hWnd, TRUE ); break; } /* This is for "sorting" and is a kludge as it requires reading from disk each time you do a sort, but I don't know a better way other than keeping a list in memory which results in a whole bunch of memory being eaten up just for a "fancy". If the time delay bothers you - don't do it, just take this out. */ case LVN_COLUMNCLICK: /* Column clicked on - now sort */ ListViewSortOnColumns(pNm->iSubItem);#ifndef WIN32 SendMessage(hWndList, LB_SETSEL, 1, 0L);#else ListViewSetSel(0, TRUE);#endif break; case LVN_ITEMCHANGED: { UpdateButtons(); break; }/* This will allow you to perform a hit test on a line in the list box, however, you then tend to lose the concept of being able to do ctrl-mouse click and undo selections. It wasn't important enough to spend any more time fooling with. case NM_CLICK: MapCursorToListItem(); break;*/ } break; }#endif /* WIN32 ? */ case WM_ACTIVATE: /* This section is put in to fix a weird problem with the listbox not displaying the contents of an archive file if it is either dropped on WiZ, or if it is started from the command line. I have no idea why this happens. */ { extern int ofretval; if ((lpumb->szFileName[0]!='\0') && (ofretval)) { UpdateListBox(); /* We have to have something selected before we can activate the buttons! */#ifndef WIN32 SendMessage(hWndList, LB_SETSEL, 1, 0L);#else ListViewSetSel(0, TRUE);#endif UpdateButtons(); } ofretval = 0; } SetCaption(hWnd); return DefWindowProc(hWnd, wMessage, wParam, lParam); case WM_SIZE: SizeWindow(); break; case WM_SYSCOMMAND: return DefWindowProc( hWnd, wMessage, wParam, lParam ); case WM_RBUTTONUP: /* PURPOSE: Display and track popup menu on button click. PARAMETERS: hWnd - Window handle lparam - Coordinates where the mouse was pressed Always returns 0 - Message handled */ { HMENU hmenu; HMENU hmenuTrackPopup; RECT rc; BOOL fButtonState; POINT pt; DWORD dwpos; /* Draw the appropriate "floating" popup in the client area Check the listbox first */ GetWindowRect(hWndList, &rc); dwpos = GetMessagePos(); pt.x = LOWORD(dwpos); pt.y = HIWORD(dwpos); if (PtInRect(&rc, pt)) { /* Get the menu for the popup from the resource file. */ hmenu = LoadMenu(hInst, "PopupListMenu"); if (!hmenu) return 0; /* Get the first menu in it which we will use for the call to * TrackPopup(). This could also be created on the fly using * CreatePopupMenu and then using InsertMenu() or * AppendMenu. */ hmenuTrackPopup = GetSubMenu(hmenu, 0); if (lpumb->szFileName[0] &&#ifndef WIN32 SendMessage(hWndList, LB_GETSELCOUNT, 0, 0L)) /* anything selected ? */#else ListView_GetSelectedCount(hWndList))#endif fButtonState = TRUE; else fButtonState = FALSE; EnableMenuItem(hmenuTrackPopup, IDM_EXTRACT, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_DISPLAY, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_TEST, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_SHOW_COMMENT, (BOOL)(fButtonState && lpUserFunctions->cchComment ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_GET_ZIPINFO, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_UPDATE_ZIP, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_ZIP_DELETE_ENTRIES, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); if (lpumb->szFileName[0] != '\0') fButtonState = TRUE; else fButtonState = FALSE; EnableMenuItem(hmenuTrackPopup, IDM_COPY_ARCHIVE, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_MOVE_ARCHIVE, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_DELETE_ARCHIVE, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_RENAME_ARCHIVE, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_SELECT_ALL, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_DESELECT_ALL, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_SELECT_BY_PATTERN, (fButtonState ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); /* Draw and track the "floating" popup */#ifdef WIN32 TrackPopupMenuEx(hmenuTrackPopup, TPM_LEFTALIGN | TPM_TOPALIGN | /* default values */ TPM_LEFTBUTTON | TPM_HORIZONTAL | /* equivalent to 0 */ TPM_RIGHTBUTTON, /* Right selection */ pt.x, pt.y, hWnd, NULL);#else TrackPopupMenu(hmenuTrackPopup, TPM_LEFTALIGN | /* default values */ TPM_LEFTBUTTON | /* equivalent to 0 */ TPM_RIGHTBUTTON, /* Right selection */ pt.x, pt.y, 0, hWnd, NULL);#endif /* Destroy the menu since we are done with it. */ DestroyMenu(hmenu); return 0; } /* The mouse was not in the list box, now let's check the edit box */ GetWindowRect(hWndEdit, &rc); if (PtInRect(&rc, pt)) { UINT fEnable; UINT ichStart, ichEnd;#ifndef WIN32 DWORD dwResult;#endif /* Get the edit control menu which we will use for the call to * TrackPopup(). This could also be created on the fly using * CreatePopupMenu and then using InsertMenu() or * AppendMenu. */ hmenu = LoadMenu(hInst, "EditMenu"); if (!hmenu) return 0; /* Get the edit menu from the parent of the edit control */ hmenuTrackPopup = GetSubMenu(hmenu, 1); /* Is an "undo" operation possible? */ fEnable = (UINT)SendMessage(hWndEdit, EM_CANUNDO, 0, 0); EnableMenuItem(hmenuTrackPopup, IDM_EDIT_UNDO, (fEnable ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); /* Can we paste to the edit control? */ if (OpenClipboard(hWnd)) { /* Only allow text */ if (IsClipboardFormatAvailable(CF_TEXT) || IsClipboardFormatAvailable(CF_OEMTEXT)) fEnable = TRUE; else fEnable = FALSE; } CloseClipboard(); EnableMenuItem(hmenuTrackPopup, IDM_EDIT_PASTE, (fEnable ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); /* Is anything selected in the edit control */#ifdef WIN32 SendMessage(hWndEdit, EM_GETSEL, (WPARAM)&ichStart, (LPARAM)&ichEnd); fEnable = (ichStart != ichEnd);#else dwResult = SendMessage(hWndEdit, EM_GETSEL, 0, 0); ichStart = LOWORD(dwResult); ichEnd = HIWORD(dwResult); fEnable = (ichStart != ichEnd);#endif EnableMenuItem(hmenuTrackPopup, IDM_EDIT_CUT, (fEnable ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_EDIT_COPY, (fEnable ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); EnableMenuItem(hmenuTrackPopup, IDM_EDIT_DELETE, (fEnable ? MF_ENABLED : MF_DISABLED|MF_GRAYED)|MF_BYCOMMAND); /* Anything in the edit control at all? */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -