Ok BitBlting, here comes the hard part and the part that will drive you insane if you have anything wrong.
You will need to have the HDC of the device you want to paint to. You can use GetDC to get it or you can catch the WM_PAINT message and use PAINTSTRUCT. Since this is your first time you should just use GetDC for right now.
Example:
Once you have that you need to know the size of the bitmap and the size of the device you are painting to. You can get that using a number of different ways but for now just write the sizes down when you make your static object, and most bitmap editors will give you the size. I would make the bitmap the same size as your static object to make your life easier for right now.Code:HDC hdc_topaint; hdc_topaint = GetDC(hWndOfTheDeviceToPaint);
Ok now BitBlt:
Now for some bad news, the image is not "actually" on that object. What the means is that each time the object is refreshed it will disapear. I can tell you how to fix that, but try to get it up there first then we will work on the refresh.Code:BitBlt(hdc_topaint, Xdest, Ydest, Width, Height, hdc, Xsrc, Ysrc, SRCOPY); //hdc_topaint is the hdc of the device to paint to //Xdest, put the X position to start painting at, you will prob use 0 most of the time //Ydest, put the Y position to start painting at, you will prob use 0 most of the time //Width, this is the exact width of the static device you are painting to //Height, this is the exact height of the static device you are painting to //hdc, this is the DC of the bitmap we loaded into memory //Xsrc, put the X position to start copying the bitmap from, you will prob use 0 most of the time //Ysrc, put the Y position to start copying the bitmap from, you will prob use 0 most of the time //SRCOPY, this is the raster code we will use, this means exact copy from bitmap to device. There are a bunch of others that do different things, just look up BitBlt in the MSDN.




Reply With Quote