In VC + + use the message to make the start cover

Source: Internet
Author: User
Tags resource

1. Use AppWizard to create an empty SDI project Splash;

2. Import the picture used as the starting cover;

(1) In the new project created splash, select ResourceView Panel to open the Resource editor. Right-click Splash Resources, select Insert on the Open shortcut menu, select the Bitmap option, and then click the Import button to prepare to import a BMP graphics file to be used as the launch cover.

(2) in the ResourceView panel, right-click the "Idb_mitmap1" bitmap resource just imported, select "Properties" from the Open shortcut menu, and change the ID value to "Id_splash" for easy understanding and memory.

3. Create a new dialog resource in which to add the imported bitmap;

(1) In the ResourceView panel, right-click the "Dialog" resource. Select the Insert Dialog command on the shortcut menu that opens to create a new dialog box resource. Remove the "OK" Cancel button in the dialog box and choose the style of your favorite dialog box.

(2) Add a picture control to the dialog resource to open its Picture Properties dialog box. Select the "General" tab and select the "Bitmap" option in the "Tpye" drop-down box, in the "Image" In the Drop-down box, select the ID value "Idb_splash" for the bitmap resource you imported earlier. Adjusts the resource size of the dialog box to the same size as the picture control.

(3) Right-click the Resource Editor, select the ClassWizard command on the Open shortcut menu, pop-up the Adding a class dialog box, and add a new class for the newly created dialog resource. Enter the dialog box class name in the Name text box of the New Class dialog box Csplashdlg, and then click the OK button to close the New Class and ClassWizard dialog boxes.

4. Write code to achieve the function of starting cover;

(1) Add a pointer member variable "*splash". Select the "ClassView" Panel in the project workspace, expand the class tree, right-click the "CMainFrame" class, and select "ADD member Variable ..." from the pop-up shortcut menu. command, open the ADD Member Variable dialog box, enter "Csplashdlg" in the Variable type text box, and enter "Splash" in the Variable Name text box. Click the OK button to close the add Member Variable dialog box, add the following include statement to the Splash.cpp file: #include "SplashDlg.h"

(2) Select the "ClassWizard" command in the "View" drop-down menu to open the ClassWizard dialog box. Select the "Message Maps" tab, select the "CMainFrame" class in the Class name Drop-down box, and then in the Messages: Select the message "Wm_timer" in the list box. Click the Add Function button to add the OnTimer function.

(3) Double-click the OnTimer function in the Member Function list box to edit the function. The list of functions is as follows:

void CMainFrame::OnTimer(UINT nIDEvent)
{
if (nIDEvent == 1)
{if (splash->IsWindowVisible())
{//启动封面设置为当前活动窗口;
splash->SetActiveWindow();
splash->UpdateWindow();
//启动封面停留时间;
Sleep(2000);
splash->SendMessage(WM_CLOSE);
}
else
{//应用程序窗口设置为当前活动窗口;
SetActiveWindow();
//清除WM_TIMER事件;
KillTimer(1);
}
}
//CFrameWnd::OnTimer(nIDEvent);
}

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.