Dynamic display method for the About (about) dialog box

Source: Internet
Author: User

Introduced

The general system Help file displays information about help in a static form that will display the content to the interface. As a result of this project development, I always feel that is too monotonous, so, in each website search after found a good control class (font display control class), So I did the expansion and I did some dynamic display functions, after the completion of a variety of help to display the information can be shown as a movie show the dynamic display, the effect is very good, now the production process code and demo effect written out, I hope that this aspect of the study or find a good way to help people. At the same time, the text displayed in the code of this article, you can make your own changes according to the need.

Body

When I display the Help file, I use a full-screen display method, but if the view Full-screen method I always feel too ugly, so I first in full screen based on a background picture, and then load a feature on the background picture on the display on it. In fact, the simple way is to create a cstatic control on the background image directly, but since my system involves many other functional interface to deal with, so I used a dialog box form, using modeless dialog box form, Then movewindow it to the specified location when she is finished creating it.

Production steps

Start VC, set up a single document function based on CView, the rest remain the default settings on it. The concept of full screen I do not like the traditional way, but the main frame MoveWindow to the screen resolution size, and then remove the title blue, menu bar, toolbar, status bar and so on the display of almost a full-screen effect, and then on the top of the background picture on it can be. Perhaps this simply does not count as a Full-screen concept (^_^). The following steps are implemented:

Modify the InitInstance () function of the app, where it is modified as follows:

// The one and only window has been initialized, so show and update it.
m_pMainWnd->SetMenu(NULL); //去掉菜单
m_pMainWnd->ModifyStyle(WS_THICKFRAME|WS_CAPTION,NULL); //修改窗体属性
m_pMainWnd->MoveWindow(CRect(0,0,::GetSystemMetrics(SM_CXSCREEN),
::GetSystemMetrics(SM_CYSCREEN)),TRUE); //将窗体移动到屏幕的分辨率大小地方?
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED); //这个就不要解释了
m_pMainWnd->UpdateWindow();

Then modify the mainframe class member function to remove the toolbar and the status bar. Modify the PreCreateWindow (createstruct& CS) function as follows:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
  if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  return -1;
     //隐藏任务栏,不隐藏的话,这个东西总是在不适当的时候出现影响整体效果
  FindWindow("Shell_TrayWnd",NULL)->ShowWindow(SW_HIDE);
  return 0;
}

The above steps hide the Windows taskbar, so we have to restore the program when it exits, and do not see it when the program is finished. Because the program exits to send Wm_close message, so we intercept the mainframe WM_CLOSE message on it, here to restore the status bar, 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); //恢复任务栏
  CFrameWnd::OnClose();
}

Here, the basic preparation work we have done, the following task is to paste the background bitmap and create the dialog box displayed. Paste background bitmap: Load the background bitmap, map the view of the WM_PAITN message, and then paste the background bitmap, while mapping the WM_EARSEBKGND message, go to the screen erasing work, the return statement modified to be: returns TRUE.

void CAboutDemoView::OnPaint()
{
  // TODO: Add your message handler code here
  CPaintDC dc(this); // device context for painting?
  HBITMAP hbitmap;
  hbitmap=::LoadBitmap(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BACKBMP));
  HDC hMenDC=::CreateCompatibleDC(NULL);
  SelectObject(hMenDC,hbitmap);
  ::StretchBlt(dc.m_hDC,0,0,1024,768,hMenDC,0,0,1024,768,SRCCOPY);
  ::DeleteDC(hMenDC);
  ::DeleteObject(hbitmap);
  // Do not call CView::OnPaint() for painting messages
}

Create a dialog resource for displaying relevant information, modify the dialog box Properties,style->popup,border->none; and create a dialog class Cshowaboutdlg, and then place a CStatic control on the dialog box and adjust the position. 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); //因为背景图片有一个边框,所以这里应该吧那个位置留出来
m_pAboutDlg->GetClientRect(&rect);
m_pAboutDlg->m_AboutCtrl.MoveWindow(rect,TRUE); //是这个PIC控件占满对话框客户区域
m_pAboutDlg->ShowWindow(SW_SHOW);

The following is the file that adds the font display control class. Add Zgmemdc,zgdraw.h,zgdraw.cpp,titleshow.h,titleshow.cpp,publicclass.cpp,publicclass.h to the project, Then join AutoFont.h and AutoFont.cpp, which is not to mention, as I have described in the previous article. On the basis of the type display control class, I modified the appropriate code to make changes to the text display, because the font of the original class was not suitable for the requirements that we now display on the system (^_^). Then it's OK to load the display message in the dialog box class. The definition shows the CStatic class object bit titleshow, and then adds your message to the initialization: * * * * * One step is to intercept the return and ESC keys to exit the dialog box.

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);
}

So far, the basic work of the program has been completed, compile and run your project to see the effect of it. Here is what I did to simulate the effect of the demo, paste a few pictures up. If you have any questions, you can contact me directly: 13975102873@hnmcc.com

This article supporting source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.