+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Senior Member AxessTerminated is a glorious beacon of light AxessTerminated is a glorious beacon of light AxessTerminated is a glorious beacon of light AxessTerminated is a glorious beacon of light AxessTerminated is a glorious beacon of light
    Join Date
    Jan 2004
    Location
    Everywhere
    Posts
    351

    Question 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.

    Code:
    BOOL CCardsDlg::OnInitDialog()
    {
    	CDialog::OnInitDialog();
    
    	HMODULE hModule = LoadLibrary("Cards.dll"); 
    
    	//LOAD THE BITMAP
    	HBITMAP hBitmpap = 
        LoadBitmap(hModule,MAKEINTRESOURCE(IDB_H01)); 
    	//IDB_H01 IS THE ACE OF HEARTS, WHICH CORRESPONDS TO 4001
    
    
        BitBlt(NULL,0,0,10,10,NULL,0,0,SRCAND);
    
    
    	// 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)
    	{
    		CString strAboutMenu;
    		strAboutMenu.LoadString(IDS_ABOUTBOX);
    		if (!strAboutMenu.IsEmpty())
    		{
    			pSysMenu->AppendMenu(MF_SEPARATOR);
    			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
    }
    A_T
    Geek isn't just a four-letter word; it's a six-figure income.

  2. #2
    Banned Katja has much to be proud of Katja has much to be proud of Katja has much to be proud of Katja has much to be proud of Katja has much to be proud of Katja has much to be proud of Katja has much to be proud of
    Join Date
    Jul 2005
    Posts
    511
    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.

    BOOL BitBlt(
    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
    );

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides