June 27th, 2005 09:37 PM
Trying to display a bitmap in a dialog.
I can't get a bitmap to display in a dialog. I have a DLL that someone else wrote. It's called cards.dll (not the windows one). I also have a header he included, renamed to "defines.h", which defines names for all the cards in the DLL.
I loaded the DLL in the OnInitDialog() function, but do not understand how to use BitBlt, so I set the HDC crap to NULL for now, hoping someone can both explain this to me, and help me display the bitmap. Also, if there is a better way to go about doing this, explain please, and include source. Keep in mind I do not know VC++ very well, and am learning through trial and error.
My goal is to create a card simulator. It will display cards, and you can move them, flip them, etc...but there are no rules. This way, you can play any game you want. I have a few quirks to work out in the logic, but I need to get the basics of the code down first.
HMODULE hModule = LoadLibrary("Cards.dll");
//LOAD THE BITMAP
HBITMAP hBitmpap =
//IDB_H01 IS THE ACE OF HEARTS, WHICH CORRESPONDS TO 4001
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
Geek isn't just a four-letter word; it's a six-figure income.
July 1st, 2005 03:47 PM
Instead of NULL, try using hBitmpap. And use the handle of another bitmap for the second bitmap.
The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.
HDC hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
DWORD dwRop // raster operation code