Keyword Help File Information Display
Name of original author Qi Gao
ArticleOriginal Source
Introduction
When a general system help file displays help information, most of the methods used are static display of the content to be displayed on the interface. As this project was developed, I always think that is too monotonous, so I found a good control class (font display control class) after searching on various websites ), so I expanded and completed some dynamic display functions. After that, all the help information to be displayed can be dynamically displayed like a screening movie. The effect is quite good. Now, the production process is combined.CodeAnd the demo effect. I hope that someone who has research on this aspect or is looking for a good method will help.
You can modify the text information displayed in the code of this article as needed.
Body
I used the full screen display method when displaying help files. However, if I used the full screen view method, I always thought it was too ugly, so I first pasted a background image on the full screen, and then loaded a function display on the background image. in fact, the simple method is to directly create a cstatic control on the background image, but because my system involves many other functional interfaces, so I used a dialog box in the form of a non-modal dialog box, and then movewindow to the specified position after she was created.
creation procedure:
Start VC and create a cview-based Single-document function. Keep the default settings for others.
the concept of full screen is not as traditional as it is. Instead, the movewindow of the main frame is scaled to the screen resolution, and the title LAN, menu bar, and toolbar are removed, the status bar is almost a full screen, and then you can paste a background image on it. maybe this concept cannot be regarded as full screen at all (pai_^ ). the specific implementation steps are as follows:
modify the initinstance () function of the app. The modification is as follows:
// The one and only window has been initialized, so show and update it.
m_pmainwnd-> setmenu (null); // remove the menu
m_pmainwnd-> modifystyle (ws_thickframe | ws_caption, null ); // modify the form attributes
m_pmainwnd-> movewindow (crect (,: getsystemmetrics (sm_cxscreen),
:: getsystemmetrics (sm_cyscreen), true ); // move the form to the resolution of the screen
M_pmainwnd-> showwindow (sw_showmaximized); // do not explain this.
M_pmainwnd-> updatewindow ();
Modify the mainframe class member function and remove the toolbar and the status bar. Modify the precreatewindow (createstruct & CS) function as follows:
Int cmainframe: oncreate (maid)
{
If (cframewnd: oncreate (lpcreatestruct) =-1)
Return-1;
Findwindow ("shell_traywnd", null)-> showwindow (sw_hide); // hide the taskbar. If it is not hidden, this always affects the overall effect when it is inappropriate.
Return 0;
}
The Windows taskbar is hidden in the above steps, so we mustProgramRestore the program when it exits. It will not be seen if the program is over. the wm_close message is sent when the program exits, so we can intercept the wm_close message of mainframe. Here, the status bar is restored. The Code is as follows:
Void cmainframe: onclose ()
{
// Todo: add your message handler code here and/or call default
Findwindow ("shell_traywnd", null)-> showwindow (sw_show); // restore the taskbar
Cframewnd: onclose ();
}
Now, the basic preparation is complete. The following task is to paste the background bitmap and create the displayed dialog box.
Paste background bitmap: load the background bitmap, map the wm_paitn message of the view, paste the background bitmap, and map the wm_earsebkgnd message to erase the screen and modify the return statement: return true.
Void caboutdemoview: onpaint ()
{
// Todo: add your message handler code here
Cpaintdc DC (this); // device context for painting
Hbitmap;
Hbitmap =: loadbitmap (: AfxGetInstanceHandle (), makeintresource (idb_backbmp ));
HDC hmendc =: createcompatibledc (null );
SelectObject (hmendc, hbitmap );
: Stretchblt (DC. m_hdc, 1024,768, 1024,768, hmendc, srccopy );
: Deletedc (hmendc );
: Deleteobject (hbitmap );
// Do not call cview: onpaint () for painting messages
}
Create a dialog box resource for displaying relevant information, modify the dialog box properties, style-> popup, border-> none, and create a dialog box class cshowaboutdlg. Then, place a cstatic control on the dialog box, and adjust the location.
Create this modeless dialog box in view and then display:
Cshowaboutdlg * m_paboutdlg;
Crect rect;
M_paboutdlg = new cshowaboutdlg ();
M_paboutdlg-> Create (idd_about );
M_paboutdlg-> movewindow (crect (18,18,: getsystemmetrics (sm_cxscreen)-13,: getsystemmetrics (sm_cyscreen)-16), true); // because the background image has a border, so here we should leave it out.
M_paboutdlg-> getclientrect (& rect );
M_paboutdlg-> m_aboutctrl.movewindow (rect, true); // This PIC Control occupies the customer region of the dialog box
M_paboutdlg-> showwindow (sw_show );
The following is a file added to the dashboard control class. set zgmemdc and zgdraw. h, zgdraw. CPP, titleshow. h, titleshow. CPP, publicclass. CPP, publicclass. h join the project, and then add autofont. H and autofont. CPP, this class function needless to say, I have already introduced it in the previous article. on the basis of the class that provided the dashboard control, I modified the right amount of code and made changes in text display, because the font of the original class is not suitable for our current system display requirements (^_^ ).
Then, load the Display message in the dialog box class.
Define the display cstatic Class Object Location titleshow, and then add your information display content in the initialization:
****
Another step is to intercept the exit of the dialog box between the carriage return and the ESC key pair.
Bool cshowaboutdlg: pretranslatemessage (MSG * PMSG)
{
// Todo: add your specialized code here and/or call the base class
If (PMSG-> message = wm_keydown)
{
Switch (PMSG-> wparam)
{
Case vk_return:
Return true;
Case vk_escape:
Return true;
}
}
Return cdialog: pretranslatemessage (PMSG );
}
At this point, the basic work of the program has been completed. Compile and run your project to see the effect.