9. How to change the icon of the window?
10. How to change the default style of the window?
11. How do I display the window?
12. How to maximize and minimize windows and MDI windows?
13. How to keep the program extremely small?
14. How to limit the size of the window?
15. How to make the window are invisible?
16. How to make the window always in the forehead?
9. How to change the icon of the window?
Send a WM_SECTION message to the window.
EXAMPLE:
HiCon Hicon = AFXGetApp () -> Loadicon (IDI_ICON);
Assert (hic);
AFXGETMAINWND () -> SendMessage (WM_SECTION, TRUE, (LPARAM) HICON;
10. How to change the default style of the window?
Replay CWnd :: PrecreateWindow and modify the CreateStruct structure to specify the window style and other
Create information.
Example: Delete "Max" Button and Set Original Window's Position and Size
Bool CMAINFRAME :: PrecreateWindow (CreateStruct & Cs)
{
CS.Style & = ~ WS_MAXINIZEMOX;
Cs.x = cs.y = 0;
Cs.cx = getSystemMetrics (SM_CXSCREEN / 2);
Cs.cy = getSystemMetrics (SM_CYSCREEN / 2);
Return CmdiframeWnd :: PrecreateWindow (CS);
}
11. How do I display the window?
Easy, Call Function CWnd :: Center Windows
Example (1): center window (); // relative to it's parent
// Relative to Screen
Example (2): center window (cWnd :: getDesktopWindow ());
// Relative to Application's Mainwindow
AFXGETMAINWND () -> center window ();
12. How to maximize and minimize windows and MDI windows?
Let's talk about the window first.
Set the value of m_ncmdshow in the initstance function.
m_ncmdshow = sw_showmaxmized; // Maximize
m_ncmdshow = sw_showminmized; // Minimize
m_ncmdshow = sw_shownormal; // Normal mode
MDI window:
If you are creating a new application, you can use the MFC AppWizard's Advanced button and
Maximization or minimize detection in the MDI sub-window style group; you can also overload MDI Window
PrecreateWindow function, set WS_MAXMIZE or WS_MINMIZE;
If you are derived from cmdichildwnd, call CWnd :: Show in the OnInitialUpdate function
Window is specified in the style of MDI Child Window.
13. How to keep the program extremely small?
Very interesting question
That do you do this: WINDOW will send WM_QUERY-OPEN messages in the recovery process form.
Set the member function on QueryOpen (), add backing code with ClassWizard
Bool cmainframe :: ONQUERYOPEN ()
{
Return False;
}
14. How to limit the size of the window?
That is, FixedDialog form. Windows sends a WM_GETMAXMINFO message to track,
In response to it, write code in ONGETMAXMINFO:
15. How to make the window are invisible?
Very simple, hidden with SW_HIDE, you can combine FindWindow, ShowWindow control.
16. How to make the window always in the forehead?
Two ways.
Bringwindowtotop (Handle);
SetWindowPos function, the top style of the specified window, the style of the WS_EX_TOPMOST extension window
EXAMPLE:
Void ToggletopMost (CWND * PWND)
{
Assert_Valid (PWND);
PWnd -> SetwindowPos (PWND-> getStyle () & WS_EX_TOPMOST?
& WndnotopMost: & Wndtopmost, 0,0,0,0, ssp_nosize | wsp_nomove;
}