Adding bitmap to dialog

This is a discussion on Adding bitmap to dialog within the Windows Programming forums, part of the Platform Specific Boards category; Hello, Recently I've been trying to make a small program that contains a bitmap, but whenever i try to add ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Location
    under your bed....
    Posts
    24

    Adding bitmap to dialog

    Hello,
    Recently I've been trying to make a small program that contains a bitmap, but whenever i try to add the bitmap file to the bitmap control when the dialog is initialized, it doesn't show when compiled.

    Here is my code:

    Code:
    case WM_INITDIALOG:
    {
    	HICON hIcon;
    	HBITMAP hBitmap;
    	hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 32, 32, 0);
    	SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
    	SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
    	hBitmap = LoadBitmap(hInstance,MAKEINTRESOURCE(IDI_MYIMAGE));
    	SendDlgItemMessage(hWnd, IDC_IMG1, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);
    }
    The bitmap control id is IDC_IMG1 and the bitmap hook is HBITMAP.

    Does anyone know how to fix this? If I've forgotten any important code please tell me and ill add it.

    Thanks in advanced.

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,453
    Why is the first parameter of the LoadImage and LoadBitmap different?
    Have you tried to check the return values of the function called and use GetLastError to check what is happening?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Location
    under your bed....
    Posts
    24
    Thanks vart. Changing the first parameter of LoadBitmap to GetModuleHandle(NULL) fixed my problem. I dont see why it didnt work with hInstance though.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 02:42 PM
  2. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  3. Using a bitmap on a Dialog box
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 08-08-2003, 01:45 AM
  4. Adding progress bar to a dialog box.
    By Brian in forum Windows Programming
    Replies: 1
    Last Post: 11-15-2002, 05:27 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21