Use VC5 to start the sequence

zhaozj2021-02-17  77

Use VC5 to start the sequence

Use VC5 to start the sequence

Many large-scale applications have enabled seals such as Word, etc., MPS software and VC equivalents. Through the opening cover, in addition to the display of the programming screen name and version, it is also possible to avoid a large amount of data initialized by the application program startup. The wait for a long time, and adds a multi-dynamic characteristic and specializi style. Given that the VC development tool should be widely used, this is an example of the prevention of the latent surface with VC5 as an example.

---- 1. Making the sealing position

---- Mechanic Application Program Lift Removal Frame Real Color Bitmap, Recording the height and width of bitmap, and build a document such as his sounds.

---- 2. Construction of the application

---- Use the file > New menu to build a multi-document application program frame named Start, and use the class wizard AppWizard to increase the new class CSPlashWnd of Generic CWnd, will new classes The file is renamed Splash.h and Splash.cpp and adds WM -CREATB and WM -PAINT messaging function.

---- 3. Define variables and functions

---- Defining the variables and functions of the following in Splash.h:

PUBLIC:

Bool create (CWND * pParentWnd = NULL);

Handle HbitsSrc;

LPSTR PBITSRC;

UINT IW, IH;

---- 4. Jianli launched window window

---- Add Create Function in Splash.cpp, build a pop-up window of the display bitmap:

#Include "windowsx.h" / / increasing expansion window

...

Struct {/ / bitmap file head structure

BitmapInfoheader Header;

} Info;

Bool csplashWnd :: Create (CWND * PParentWnd)

{/ / Set up a population window

Return Createex (0, AFXREGISTERWNDCLASS (0, AFXGetApp () -> LoadStandardCursor

(IDC_ARROW),

NULL, WS_POPUP | WS_VISIBLE, 0, 0, 672, 480,

PparentWnd -> getsafehwnd (), null;

}

INT CSPLASHWND :: OnCreate (lpcreatestruct lpcreatestruct)

{... ...

/ / TODO: Add Your Specialized Creation Code Here

CenterWindow (); / / make the pop-out window

Return 0;

}

---- 5. Functory function

---- Treatment of the pattern function in splash.cpp, preparation for display of bitmap: csplashwnd :: csplashWnd () / / full parsing function

{IW = 672; IH = 480; / / bitmap width and high degree

Info.Header.bisize = sizeof (BitmapInfoHead);

Info.Header.biWidth = IW;

Info.Header.biheight = IH;

Info.Header.Biplanes = 1L;

Info.Header.biBitcount = 24L;

HbitsSRC = :: Globalalloc (ghnd, (long) (iW * ih * 3)); / / distribution memory

PBITSRC = (LPSTR) :: Globalock (hbitsSRC); / / plus lock memory

}

CSPLASHWND :: CSPlashWnd ()

{:: globalunlock (hbitssrc); / / unlock memory

:: GlobalFree (hbitssrc); / / Release memory

}

---- 6. Display true color bitmap

---- Take the onpaint function in splash.cpp, realize the real color bitmap display:

Void csplashwnd :: onpaint ()

{... ... / / tDO: Add Your Message Handler Code Here

Cfile FBMP;

FBmp.Open ("c: //windows//emc1.bmp", cfile :: moderad |

Cfile :: typebinary | cfile :: ShareExClusive); / / Open the document

FBmp.seek (54, cfile :: begin); / / bit map file header is 54-byte

FBmp.Readhuge (Pbitssrc, (long) (iW * ih * 3)): / / read file

FBmp.close (); / / Close file

Hbitmap hbitmap = :: createdibitmap (dc.m_hdc,

(BitMapInfoHeader Far *) & (Info.Header), CBM_INIT,

Pbitssrc, (lpbitmapinfo) & info, dib_rgb_colors; / / build bitmap

HDC hmemdc = :: createcompatibledc (dc.m_hdc); / / Construction

Hbitmap hbitmapold = selectbitmap (hmemdc, hbitmap); / / Select an object

:: Stretchblt (Dc.m_HDC, 0, 0, IW, IH, HMEMDC, 0, 0, IW, IH, SRCCOPY);

/ / Display true color bitmap

:: DeleteObject (SelectObject (HMEMDC, HbitMapold); / / Delete bitmap

}

---- 7. Playing the window

---- Add code in mainfrm.h, prepare for display and withdrawing pop-out window:

Class CsplashWnd: / / flash window class

...

Class CMAINFRAME: PUBLIC CMDIFRAMEWND

{... ...

Pubiic:

CSPlashWnd SplashWnd; / / Sound Class

}

---- 8. Reality of the real color cover

---- Increase the display of the pop-up window, play the sound music, delay function, and withdrawal pop-up window in mainfrm.cpp, to realize the entire process of real color sealing :

#Include "splash.h" / / new class support

#Include "mmsystem.h" / / multimedia support

#Pragma comment (lib, "winmm.lib") / / multimedia support

...

INT CMAINFRAME :: OnCreate (lpcreatestruct lpcreatestruct)

{

SplashWnd.create (this); / / creation population window

SplashWnd.ShowWindow (sw_show); / / Display pop-up window

SplashWnd.UpdateWindow (); / / update pop-up window

INT DD = SNDPLAYSOUND ("c: //windows/reminder.wav", SND_ASYNC | SND_LOOP);

/ / Distread WAV file

IF (DD == false) {/ / parameter SND_ASYNC | SND_LOOP can be looped

AfxMessageBox ("Wav WAM Faults");

}

:: Sleep (2000); / / Circuit sleep 2 seconds

... / / Application Program Initialization

DD = SNDPLAYSOUND ("", SND_ASYNC); / / Final broadcast .WAV file

SplashWnd.destroyWindow (); / / withdrawal pop

Return 0;

}

---- The whole real color start sealing is completed, if you need to add and move and move

The subtitles and other multimedia functions.

-------------------------------------------------- ------------------------------

转载请注明原文地址:https://www.9cbs.com/read-31491.html

New Post(0)