Now we finally start programming with VC. A lot of questions make me dizzy. recently, I encountered several small problems in programming. With the help of many friends, I finally solved them. to sum up, we made a test demo. the knowledge points involved are as follows.
1. the OK button in the upper-right corner of the form changes to X. in mobile systems, normally, "OK" indicates "disabled", and "X" indicates "minimized. by default, all forms are OK. click to close. if you want to change "OK" to "X", add this sentence during form initialization.
: Shdonebutton (m_hwnd, shdb_hide); // the button in the upper right corner turns into a cross
Modifystyle (m_hwnd, ws_caption, ws_minimizebox, swp_nosize); the second sentence is also required from the information found, but I can do it without it.
2. intercepts form minimization messages. when OK is changed to X, clicking x minimizes the form. sometimes we want to intercept the minimum message for some processing. for example, if you want to disable the system at point X. then you have to intercept the message and then execute onok (). or, the system message icon is implemented. (As mentioned later ). in this case, you need to reload the windowproc function.
Lresult cdemodlg: windowproc (uint message, wparam, lparam)
{
// Todo: add your specialized code here and/or call the base class
If (Message = wm_size)
{
If (wparam = size_minimized) // We Can Get minsize message here
{
// Onok (); // If You Want To exit by X button.
// Hide window and show icon at Information bar.
Addshnotification ();
This-> showwindow (sw_hide );
Cwnd * desthwnd = getmediatopwindow ();
: Setforegroundwindow (desthwnd-> m_hwnd );
Return 1;
}
}
Return cdialog: windowproc (message, wparam, lparam );
}
3. minimize to the notification bar on the desktop. If you want to minimize it, an icon will appear in the notification bar, and then click the icon to reactivate it.Program. This is similar to the function of mobile QQ. the addshnotification and shnotificationremove APIs are used. this is very detailed on the boring blog. for more information, see. I also referred to his lecture. thank you very much for being bored.
4. landscape switching. in most cases, the position and size of the control are reset in the onsize function. in fact, two forms can be created, and the form interface cannot be loaded during horizontal screen switching. the wizard automatically generates a form ending with _ wide. this is the form of the horizontal screen. On this interface, we can deploy the Form Control for the horizontal screen. when used, Judge in the onsize event. note that the following must be added during initialization:
Fxenabledra (true); // in order to change wide form.
# If defined (_ device_resolution_aware )&&! Defined (win32_platform_wfsp)
Void cdemodlg: onsize (uint/* ntype */, INT/* CX */, INT/* Cy */)
{
If (afxisdraenabled ())
{
Dra: relayoutdialog (
Afxgetresourcehandle (),
This-> m_hwnd,
Dra: getdisplaymode ()! = DRA: portrait?
Makeintresource (idd_demo_dialog_wide ):
Makeintresource (idd_demo_dialog ));
}
}
# Endif
Well, I'm tired of writing so much. I need to attach the source code, OK.
/Files/qqiangsir/comboboxdemo.rar