📄 comcthlp.h
字号:
/*---------------------------------------------------
COMCTHLP.H -- Helper macros for common controls
(c) Paul Yao, 1996
Portions Copyright (c) 1992-1996, Microsoft Corp.
---------------------------------------------------*/
//-------------------------------------------------------------------
// Hot-Key Helper Macros
//-------------------------------------------------------------------
#define HotKey_SetHotKey(hwnd, bVKHotKey, bfMods) \
(void)SendMessage((hwnd), HKM_SETHOTKEY, MAKEWORD(bVKHotKey, bfMods), 0L)
#define HotKey_GetHotKey(hwnd) \
(WORD)SendMessage((hwnd), HKM_GETHOTKEY, 0, 0L)
#define HotKey_SetRules(hwnd, fwCombInv, fwModInv) \
(void)SendMessage((hwnd), HKM_SETRULES, (WPARAM) fwCombInv, MAKELPARAM(fwModInv, 0))
//-------------------------------------------------------------------
// Progress Bar Helper Macros
//-------------------------------------------------------------------
#define Progress_SetRange(hwnd, nMinRange, nMaxRange) \
(DWORD)SendMessage((hwnd), PBM_SETRANGE, 0, MAKELPARAM(nMinRange, nMaxRange))
#define Progress_SetPos(hwnd, nNewPos) \
(int)SendMessage((hwnd), PBM_SETPOS, (WPARAM) nNewPos, 0L)
#define Progress_DeltaPos(hwnd, nIncrement) \
(int)SendMessage((hwnd), PBM_DELTAPOS, (WPARAM) nIncrement, 0L)
#define Progress_SetStep(hwnd, nStepInc) \
(int)SendMessage((hwnd), PBM_SETSTEP, (WPARAM) nStepInc, 0L)
#define Progress_StepIt(hwnd) \
(int)SendMessage((hwnd), PBM_STEPIT, 0, 0L)
//-------------------------------------------------------------------
// Rich Edit Control Helper Macros
//-------------------------------------------------------------------
//---------------- Begin Macros Copied from windowsx.h---------------
#define RichEdit_Enable(hwndCtl, fEnable) \
(BOOL)EnableWindow((hwndCtl), (fEnable))
#define RichEdit_GetText(hwndCtl, lpch, cchMax) \
(int)GetWindowText((hwndCtl), (lpch), (cchMax))
#define RichEdit_GetTextLength(hwndCtl) \
(int)GetWindowTextLength(hwndCtl)
#define RichEdit_SetText(hwndCtl, lpsz) \
(BOOL)SetWindowText((hwndCtl), (lpsz))
#define RichEdit_LimitText(hwndCtl, cchMax) \
((void)SendMessage((hwndCtl), EM_LIMITTEXT, (WPARAM)(cchMax), 0L))
#define RichEdit_GetLineCount(hwndCtl) \
((int)(DWORD)SendMessage((hwndCtl), EM_GETLINECOUNT, 0L, 0L))
#define RichEdit_GetLine(hwndCtl, line, lpch, cchMax) \
((*((int *)(lpch)) = (cchMax)), ((int)(DWORD)SendMessage((hwndCtl), EM_GETLINE, (WPARAM)(int)(line), (LPARAM)(LPTSTR)(lpch))))
#define RichEdit_GetRect(hwndCtl, lprc) \
((void)SendMessage((hwndCtl), EM_GETRECT, 0L, (LPARAM)(RECT *)(lprc)))
#define RichEdit_SetRect(hwndCtl, lprc) \
((void)SendMessage((hwndCtl), EM_SETRECT, 0L, (LPARAM)(const RECT *)(lprc)))
#define RichEdit_GetSel(hwndCtl) \
((DWORD)SendMessage((hwndCtl), EM_GETSEL, 0L, 0L))
#define RichEdit_SetSel(hwndCtl, ichStart, ichEnd) \
((void)SendMessage((hwndCtl), EM_SETSEL, (ichStart), (ichEnd)))
#define RichEdit_ReplaceSel(hwndCtl, lpszReplace) \
((void)SendMessage((hwndCtl), EM_REPLACESEL, 0L, (LPARAM)(LPCTSTR)(lpszReplace)))
#define RichEdit_GetModify(hwndCtl) \
((BOOL)(DWORD)SendMessage((hwndCtl), EM_GETMODIFY, 0L, 0L))
#define RichEdit_SetModify(hwndCtl, fModified) \
((void)SendMessage((hwndCtl), EM_SETMODIFY, (WPARAM)(UINT)(fModified), 0L))
#define RichEdit_ScrollCaret(hwndCtl) \
((BOOL)(DWORD)SendMessage((hwndCtl), EM_SCROLLCARET, 0, 0L))
#define RichEdit_LineFromChar(hwndCtl, ich) \
((int)(DWORD)SendMessage((hwndCtl), EM_LINEFROMCHAR, (WPARAM)(int)(ich), 0L))
#define RichEdit_LineIndex(hwndCtl, line) \
((int)(DWORD)SendMessage((hwndCtl), EM_LINEINDEX, (WPARAM)(int)(line), 0L))
#define RichEdit_LineLength(hwndCtl, line) \
((int)(DWORD)SendMessage((hwndCtl), EM_LINELENGTH, (WPARAM)(int)(line), 0L))
#define RichEdit_Scroll(hwndCtl, dv, dh) \
((void)SendMessage((hwndCtl), EM_LINESCROLL, (WPARAM)(dh), (LPARAM)(dv)))
#define RichEdit_CanUndo(hwndCtl) \
((BOOL)(DWORD)SendMessage((hwndCtl), EM_CANUNDO, 0L, 0L))
#define RichEdit_Undo(hwndCtl) \
((BOOL)(DWORD)SendMessage((hwndCtl), EM_UNDO, 0L, 0L))
#define RichEdit_EmptyUndoBuffer(hwndCtl) \
((void)SendMessage((hwndCtl), EM_EMPTYUNDOBUFFER, 0L, 0L))
#define RichEdit_GetFirstVisibleLine(hwndCtl) \
((int)(DWORD)SendMessage((hwndCtl), EM_GETFIRSTVISIBLELINE, 0L, 0L))
#define RichEdit_SetReadOnly(hwndCtl, fReadOnly) \
((BOOL)(DWORD)SendMessage((hwndCtl), EM_SETREADONLY, (WPARAM)(BOOL)(fReadOnly), 0L))
#define RichEdit_SetWordBreakProc(hwndCtl, lpfnWordBreak) \
((void)SendMessage((hwndCtl), EM_SETWORDBREAKPROC, 0L, (LPARAM)(EDITWORDBREAKPROC)(lpfnWordBreak)))
#define RichEdit_GetWordBreakProc(hwndCtl) \
((EDITWORDBREAKPROC)SendMessage((hwndCtl), EM_GETWORDBREAKPROC, 0L, 0L))
#define RichEdit_CanPaste(hwnd, uFormat) \
(BOOL)SendMessage((hwnd), EM_CANPASTE, (WPARAM) (UINT) uFormat, 0L)
#define RichEdit_CharFromPos(hwnd, x, y) \
(DWORD)SendMessage((hwnd), EM_CHARFROMPOS, 0, MAKELPARAM(x, y))
#define RichEdit_DisplayBand(hwnd, lprc) \
(BOOL)SendMessage((hwnd), EM_DISPLAYBAND, 0, (LPARAM) (LPRECT) lprc)
#define RichEdit_ExGetSel(hwnd, lpchr) \
(void)SendMessage((hwnd), EM_EXGETSEL, 0, (LPARAM) (CHARRANGE FAR *) lpchr)
#define RichEdit_ExLimitText(hwnd, cchTextMax) \
(void)SendMessage((hwnd), EM_EXLIMITTEXT, 0, (LPARAM) (DWORD) cchTextMax)
#define RichEdit_ExLineFromChar(hwnd, ichCharPos) \
(int)SendMessage((hwnd), EM_EXLINEFROMCHAR, 0, (LPARAM) (DWORD) ichCharPos)
#define RichEdit_ExSetSel(hwnd, ichCharRange) \
(int)SendMessage((hwnd), EM_EXSETSEL, 0, (LPARAM) (CHARRANGE FAR *) ichCharRange)
#define RichEdit_FindText(hwnd, fuFlags, lpFindText) \
(int)SendMessage((hwnd), EM_FINDTEXT, (WPARAM) (UINT) fuFlags, (LPARAM) (FINDTEXT FAR *) lpFindText)
#define RichEdit_FindTextEx(hwnd, fuFlags, lpFindText) \
(int)SendMessage((hwnd), EM_FINDTEXTEX, (WPARAM) (UINT) fuFlags, (LPARAM) (FINDTEXT FAR *) lpFindText)
#define RichEdit_FindWordBreak(hwnd, code, ichStart) \
(int)SendMessage((hwnd), EM_FINDWORDBREAK, (WPARAM) (UINT) code, (LPARAM) (DWORD) ichStart)
#define RichEdit_FormatRange(hwnd, fRender, lpFmt) \
(int)SendMessage((hwnd), EM_FORMATRANGE, (WPARAM) (BOOL) fRender, (LPARAM) (FORMATRANGE FAR *) lpFmt)
#define RichEdit_GetCharFormat(hwnd, fSelection, lpFmt) \
(DWORD)SendMessage((hwnd), EM_GETCHARFORMAT, (WPARAM) (BOOL) fSelection, (LPARAM) (CHARFORMAT FAR *) lpFmt)
#define RichEdit_GetEventMask(hwnd) \
(DWORD)SendMessage((hwnd), EM_GETEVENTMASK, 0, 0L)
#define RichEdit_GetLimitText(hwnd) \
(int)SendMessage((hwnd), EM_GETLIMITTEXT, 0, 0L)
#define RichEdit_GetOleInterface(hwnd, ppObject) \
(BOOL)SendMessage((hwnd), EM_GETOLEINTERFACE, 0, (LPARAM) (LPVOID FAR *) ppObject)
#define RichEdit_GetOptions(hwnd) \
(UINT)SendMessage((hwnd), EM_GETOPTIONS, 0, 0L)
#define RichEdit_GetParaFormat(hwnd, lpFmt) \
(DWORD)SendMessage((hwnd), EM_GETPARAFORMAT, 0, (LPARAM) (PARAFORMAT FAR *) lpFmt)
#define RichEdit_GetSelText(hwnd, lpBuf) \
(int)SendMessage((hwnd), EM_GETSELTEXT, 0, (LPARAM) (LPSTR) lpBuf)
#define RichEdit_GetTextRange(hwnd, lpRange) \
(int)SendMessage((hwnd), EM_GETTEXTRANGE, 0, (LPARAM) (TEXTRANGE FAR *) lpRange)
#define RichEdit_GetWordBreakProcEx(hwnd) \
(EDITWORDBREAKPROCEX *)SendMessage((hwnd), EM_GETWORDBREAKPROCEX, 0, 0L)
//----------------- End Macros Copied from windowsx.h----------------
#define RichEdit_HideSelection(hwnd, fHide, fChangeStyle) \
(void)SendMessage((hwnd), EM_HIDESELECTION, (WPARAM) (BOOL) fHide, (LPARAM) (BOOL) fChangeStyle)
#define RichEdit_PasteSpecial(hwnd, uFormat) \
(void)SendMessage((hwnd), EM_PASTESPECIAL, (WPARAM) (UINT) uFormat, 0L)
#define RichEdit_PosFromChar(hwnd, wCharIndex) \
(DWORD)SendMessage((hwnd), EM_POSFROMCHAR, (WPARAM)wCharIndex, 0L)
#define RichEdit_RequestResize(hwnd) \
(void)SendMessage((hwnd), EM_REQUESTRESIZE, 0, 0L)
#define RichEdit_SelectionType(hwnd) \
(int)SendMessage((hwnd), EM_SELECTIONTYPE, 0, 0L)
#define RichEdit_SetBkgndColor(hwnd, fUseSysColor, clr) \
(COLORREF)SendMessage((hwnd), EM_SETBKGNDCOLOR, (WPARAM) (BOOL) fUseSysColor, (LPARAM) (COLORREF) clr)
#define RichEdit_SetCharFormat(hwnd, uFlags, lpFmt) \
(BOOL)SendMessage((hwnd), EM_SETCHARFORMAT, (WPARAM) (UINT) uFlags, (LPARAM) (CHARFORMAT FAR *) lpFmt)
#define RichEdit_SetEventMask(hwnd, dwMask) \
(DWORD)SendMessage((hwnd), EM_SETEVENTMASK, 0, (LPARAM) (DWORD) dwMask)
#define RichEdit_SetOleCallback(hwnd, lpObj) \
(BOOL)SendMessage((hwnd), EM_SETOLECALLBACK, 0, (LPARAM) (IRichEditOleCallback FAR *) lpObj)
#define RichEdit_SetOptions(hwnd, fOperation, fOptions) \
(UINT)SendMessage((hwnd), EM_SETOPTIONS, (WPARAM) (UINT) fOperation, (LPARAM) (UINT) fOptions)
#define RichEdit_SetParaFormat(hwnd, lpFmt) \
(BOOL)SendMessage((hwnd), EM_SETPARAFORMAT, 0, (LPARAM) (PARAFORMAT FAR *) lpFmt)
#define RichEdit_SetTargetDevice(hwnd, hdcTarget, cxLineWidth) \
(BOOL)SendMessage((hwnd), EM_SETTARGETDEVICE, (WPARAM) (HDC) hdcTarget, (LPARAM) (int) cxLineWidth)
#define RichEdit_SetWordBreakProcEx(hwnd, pfnWordBreakProcEx) \
(EDITWORDBREAKPROCEX *)SendMessage((hwnd), EM_SETWORDBREAKPROCEX, 0, (LPARAM) (EDITWORDBREAKPROCEX *)pfnWordBreakProcEx)
#define RichEdit_StreamIn(hwnd, uFormat, lpStream) \
(int)SendMessage((hwnd), EM_STREAMIN, (WPARAM) (UINT) uFormat, (LPARAM) (EDITSTREAM FAR *) lpStream)
#define RichEdit_StreamOut(hwnd, uFormat, lpStream) \
(int)SendMessage((hwnd), EM_STREAMOUT, (WPARAM) (UINT) uFormat, (LPARAM) (EDITSTREAM FAR *) lpStream)
//-------------------------------------------------------------------
// Status Bar Helper Macros
//-------------------------------------------------------------------
#define Status_GetBorders(hwnd, aBorders) \
(BOOL)SendMessage((hwnd), SB_GETBORDERS, 0, (LPARAM) (LPINT) aBorders)
#define Status_GetParts(hwnd, nParts, aRightCoord) \
(int)SendMessage((hwnd), SB_GETPARTS, (WPARAM) nParts, (LPARAM) (LPINT) aRightCoord)
#define Status_GetRect(hwnd, iPart, lprc) \
(BOOL)SendMessage((hwnd), SB_GETRECT, (WPARAM) iPart, (LPARAM) (LPRECT) lprc)
#define Status_GetText(hwnd, iPart, szText) \
(DWORD)SendMessage((hwnd), SB_GETTEXT, (WPARAM) iPart, (LPARAM) (LPSTR) szText)
#define Status_GetTextLength(hwnd, iPart) \
(DWORD)SendMessage((hwnd), SB_GETTEXTLENGTH, (WPARAM) iPart, 0L)
#define Status_SetMinHeight(hwnd, minHeight) \
(void)SendMessage((hwnd), SB_SETMINHEIGHT, (WPARAM) minHeight, 0L)
#define Status_SetParts(hwnd, nParts, aWidths) \
(BOOL)SendMessage((hwnd), SB_SETPARTS, (WPARAM) nParts, (LPARAM) (LPINT) aWidths)
#define Status_SetText(hwnd, iPart, uType, szText) \
(BOOL)SendMessage((hwnd), SB_SETTEXT, (WPARAM) (iPart | uType), (LPARAM) (LPSTR) szText)
#define Status_Simple(hwnd, fSimple) \
(BOOL)SendMessage((hwnd), SB_SIMPLE, (WPARAM) (BOOL) fSimple, 0L)
//-------------------------------------------------------------------
// Tool Bar Helper Macros
//-------------------------------------------------------------------
#define ToolBar_AddBitmap(hwnd, nButtons, lptbab) \
(int)SendMessage((hwnd), TB_ADDBITMAP, (WPARAM)nButtons, (LPARAM)(LPTBADDBITMAP) lptbab)
#define ToolBar_AddButtons(hwnd, uNumButtons, lpButtons) \
(BOOL)SendMessage((hwnd), TB_ADDBUTTONS, (WPARAM)(UINT)uNumButtons, (LPARAM)(LPTBBUTTON)lpButtons)
#define ToolBar_AddString(hwnd, hinst, idString) \
(int)SendMessage((hwnd), TB_ADDSTRING, (WPARAM)(HINSTANCE)hinst, (LPARAM)idString)
#define ToolBar_AutoSize(hwnd) \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -