📄 mainframe.c
字号:
static void
mainFrame_OnDestroy (HWND hwnd)
{
// Tell WinHelp we don't need it any more...
WinHelp (hwnd, getHelpFileName (), HELP_QUIT, (DWORD) 0) ;
PostQuitMessage (0) ;
}
//
// void mainFrame_OnDisplayChange (HWND hwnd, UINT cBitsPerPixel,
// UINT cxScreen, UINT cyScreen)
//
// hwnd Handle of window to which this message applies
// cBitsPerPixel Specifies the new image depth of the display
// in bits per pixel.
// cxScreen Specifies the new horizontal resolution of the screen.
// cyScreen Specifies the new vertical resolution of the screen.
//
// PURPOSE: Windows calls this handler when the display
// resolution has changed.
//
// COMMENTS: Beta versions of Windows 95 sent this message twice,
// once in anticipation of a change to the display
// resolution and once after the display resolution
// changed. The cBitsPerPixel parameter was a Boolean
// value which indicated which notification applied.
//
// Windows 95 now only sends this message after the
// display resolution has changed and the cBitsPerPixel
// parameter has the semantics described above.
//
// VERSION NOTES: The WM_DISPLAYCHANGE message is implemented on Windows 95
// but not currently on the Windows NT.
//
static void
mainFrame_OnDisplayChange (HWND hwnd, UINT cBitsPerPixel, UINT cxScreen, UINT cyScreen)
{
FORWARD_WM_DISPLAYCHANGE (hwnd, cBitsPerPixel, cxScreen, cyScreen, DefWindowProc) ;
}
//
// void mainFrame_OnNCRButtonUp (HWND hwnd, int x, int y, UINT codeHitTest)
//
// hwnd Handle of window to which this message applies
// x Specifies the horizontal client coordinate of the mouse click.
// y Specifies the vertical client coordinate of the mouse click.
// codeHitTest Specifies the hit-test value returned by the DefWindowProc
// function as a result of processing the WM_NCHITTEST message.
//
// PURPOSE: Windows calls this handler when the user releases the right
// mouse button while the cursor is in the non-client area of
// a window.
//
// COMMENTS: Windows 95 user interface guildines state that you should
// display a window popup menu in certain circumstances in
// response to this message. The window pop-up menu is
// the popup menu associated with a window, in this case,
// the main frame window. Do not mistake the window popup
// menu for the "Window" drop-down menu found in MDI
// applications. The window popup menu replaces the
// Windows 3.x Control menu, also referred to as the System
// menu.
//
// Note: DefWindowProc on Windows 95 processes this message
// by sending a WM_CONTEXTMENU message. Therefore all context
// menu processing under Windows 95 is normally performed
// in response to the WM_CONTEXTMENU message.
// The user displays a window抯 popup menu by clicking the
// right mouse button anywhere in the title bar area, excluding
// the title bar icon. Clicking on the title bar icon with
// the right button displays the pop-up menu for the object
// represented by the icon.
//
static void
mainFrame_OnNCRButtonUp (HWND hwnd, int x, int y, UINT codeHitTest)
{
switch (codeHitTest) {
case HTSYSMENU:
// Windows NT note:
// The user just clicked the right mouse button on the application's
// title bar icon. Normally you would now alter the default system menu
// however your application requires. See the Explorer for an example.
return ;
case HTCAPTION:
case HTREDUCE:
case HTZOOM:
// Windows NT note:
// The user just clicked the right mouse button on the application's
// title bar , excluding the title bar icon. Normally you would now
// display the window popup menu.
return ;
}
// Allow default message processing regardless
FORWARD_WM_NCRBUTTONUP (hwnd, x, y, codeHitTest, DefWindowProc) ;
}
//
// BOOL mainFrame_OnNotify (HWND hwnd, int idCtrl, NMHDR FAR* pnmhdr)
//
// hwnd Handle of window to which this message applies
// idCtrl Identifier of the control sending the message
// pnmhdr Pointer to structure that contains the notification
// code and additional information
//
// PURPOSE: An event has occurred in one of thie window's child
// controls or a control requires some kind of information
//
// COMMENTS:
//
static BOOL
mainFrame_OnNotify (HWND hwnd, int idFrom, LPNMHDR pnmhdr)
{
return TRUE ;
}
//
// void mainFrame_OnPaint (HWND hwnd)
//
// hwnd Handle of window to which this message applies
//
// PURPOSE: Windows calls this handler when the window needs repainting.
//
// COMMENTS:
//
static void
mainFrame_OnPaint (HWND hwnd)
{
HBRUSH hbrush ;
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
/**********************************************************/
/* The window needs to be redrawn. Draw the three posts. */
/**********************************************************/
hdc = BeginPaint (hwnd, &ps) ;
hbrush = GetStockObject (BLACK_BRUSH) ;
SetRect (&rect,
CENTERPOSTPOS - POSTWIDTH / 2, POSTHEIGHT,
CENTERPOSTPOS + POSTWIDTH / 2, 0) ;
if (mainFrame_IntersectRect (&rect, &ps.rcPaint))
FillRect (hdc, &rect, hbrush) ;
SetRect (&rect,
LEFTPOSTPOS - POSTWIDTH / 2, POSTHEIGHT,
LEFTPOSTPOS + POSTWIDTH / 2, 0) ;
if (mainFrame_IntersectRect (&rect, &ps.rcPaint))
FillRect (hdc, &rect, hbrush) ;
SetRect (&rect,
RIGHTPOSTPOS - POSTWIDTH / 2, POSTHEIGHT,
RIGHTPOSTPOS + POSTWIDTH / 2, 0) ;
if (mainFrame_IntersectRect (&rect, &ps.rcPaint))
FillRect (hdc, &rect, hbrush) ;
EndPaint (hwnd, &ps) ;
}
//
// void mainFrame_OnPrintClient (HWND hwnd, HDC hdc, UINT uFlags)
//
// hwnd Handle of window to which this message applies
// hdc Handle of device context in which to draw client area
// uFlags Drawing flags from WM_PRINT message
//
// PURPOSE: Draw the client area into the provided device context
// which is typically a printer device context. You should
// drawing the entire client area, unlike WM_PRINT processing
// where you draw only the invalid area.
//
// COMMENTS:
//
// VERSION NOTES: The WM_PRINTCLIENT message is implemented on Windows 95
// but not currently on the Windows NT.
//
static void
mainFrame_OnPrintClient (HWND hwnd, HDC hdc, UINT uFlags)
{
// Your drawing code goes here
}
//
// void mainFrame_OnRButtonDown (HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
//
// hwnd Handle of window to which this message applies
// fDoubleClick TRUE when this is a double-click notification,
// FALSE when this is a single-click notification.
// x Specifies the horizontal client coordinate of the mouse click
// y Specifies the vertical client coordinate of the mouse click
// keyFlags Flags indicating the state of some virtual keys
//
// PURPOSE: Windows calls this handler when the user presses the right
// mouse button while the cursor is in the client area of a window.
//
// COMMENTS: Windows 95 user interface guidelines recommend you display
// the context menu for the item in the client area upon which
// the user just clicked.
//
//
static void
mainFrame_OnRButtonDown (HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
{
POINT pt = { x, y } ;
mainFrame_DisplayContextMenu (hwnd, pt) ;
}
//
// void mainFrame_OnSettingChange (HWND hwnd, UINT uiFlag, LPCTSTR pszMetrics)
// void mainFrame_OnWinIniChange (HWND hwnd, UINT unused, LPCTSTR pszSection)
//
// WM_SETTINGCHANGE:
// hwnd Handle of window to which this message applies
// uiFlag Specifies the systemwide parameter that has changed.
// pszMetrics Points to the string "WindowMetrics" when certain
// systemwide parameters have changed
//
// WM_WININICHANGE:
// hwnd Handle of window to which this message applies
// unused Unused, must be zero.
// pszSection Points to a string containing the name
// of the section that has changed
//
// PURPOSE: This is the appropriate place to reload any system
// metrics that the application has cached.
//
// COMMENTS: Windows 95 sends the WM_SETTINGCHANGE message to all
// windows after an application changes a system-wide
// setting by calling the SystemParametersInfo function.
//
// Windows NT sends the WM_WININICHANGE message to all
// windows after an application changes a system-wide
// setting by calling the SystemParametersInfo function.
//
// On all operating systems, an application sends the
// WM_WININICHANGE message to all top-level windows
// after making a change to the WIN.INI file
//
// VERSION NOTES: Microsoft assigned the same message code (26) to both
// the WM_SETTINGCHANGE and the WM_WININICHANGE messages.
// The only way to distinguish the two messages is to
// test the uiFlag parameter. A zero value means this is
// a WM_WININICHANGE message and a non-zero value means
// this is a WM_SETTINGCHANGE message.
//
static void
mainFrame_OnSettingChange (HWND hwnd, UINT uiFlag, LPCTSTR pszMetrics)
{
}
//
// void mainFrame_OnSize (HWND hwnd, UINT state, int cx, int cy)
//
// hwnd Handle of window to which this message applies
// state
// cx New horizontal extent of window
// cy New vertical extent of window
//
// PURPOSE: Notify child windows that parent changed size.
//
// COMMENTS:
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -