Add music:
Static Library: # pragma comment (Lib, "winmm. lib") // windows multimedia library
Playsound ("1.wav", null, snd_filename | snd_async );
Retrieve window handle
Hinstance = (lpcreatestruct) lparam)-> hinstance;
Add image:
However, it must be a bitmap, that is, BMP format.
Static hbitmap hbitmap1, holdbitmap; // apply for an image handle
Static bitmap BMP Info; // used to obtain BMP image information, such as length and width.
Static int cxbitmap, cybitmap; // used to indicate the length and width of the added image.
Static HDC hdcbackbuffer; // request Resource Space, which can also be called a buffer zone
Hbitmap1
=
(Hbitmap) LoadImage (hinstance, "White. BMP", image_bitmap, 0, 0, lr_loadfromfile | lr_createdibsection );//
Add the white. BMP image and the handle is hbitmap1. This handle represents this image when used elsewhere.
Hdcbackbuffer =
Createcompatibledc (null)
; // Request Buffer
Zone
GetObject (hbitmap1, sizeof (Bitmap), & BMP info)
; // Obtain the information of the added image. The information is stored in the BMP info pointer.
Cxbitmap = BMP info. bmwidth; // get the width and height of the image through BMP info
Cybitmap = BMP info. bmheight;
Holdbitmap = (hbitmap) SelectObject (hdcbackbuffer, hbitmap1); // place the image in the applied buffer zone. You can directly draw the image in the buffer zone.
Stretchblt
(HDC, X1, Y1, A1, B1, hdcbackbuffer, 0, 0, cxbitmap, cybitmap, srccopy); // Where X1 and Y1 are
Position of the image in the window. A1 and B1 indicate the width and height of the image. hdcbackbuffer is the image buffer handle, that is, the image. The following four parameters are the position, width, and height of the original image.
Degrees, srccopy directly copies the source rectangular area to the target rectangular area
Common Information
Case wm_size: // if you use cxclient and cyclient to convert the value to a parameter in the drawing, the image will not disappear when the value is minimized.
{
Cxclient = loword (lparam );
Cyclient = hiword (lparam );
}
Return 0;
Case wm_command: // receive menu Information
Switch (loword (wparam ))
Case wm_keydown: // receives keyboard key information
Switch (wparam)
{
Case ....
}
Mouse value storage location
Mousex = loword (lparam); // access the horizontal and vertical coordinates of the mouse
Mousey = hiword (lparam );