Thread: Bitmap Problem

  1. #1
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005
    Posts
    80

    Bitmap Problem

    Sorrie Guys for posting 2 msg in a day. I have a problem with loading bitmaps, been testing for 2 days but can't get the bitmap to show. I apologise for posting the whole code but i just don't understand why the bitmap doesn't load.
    Code:
    #include <windows.h>
    #include "Bitmap.h"
    
    HINSTANCE hinst;
    LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
    
    char szClassName[ ] = "Skeleton";
    
    int WINAPI WinMain (HINSTANCE hThisInstance,
                        HINSTANCE hPrevInstance,
                        LPSTR lpszArgument,
                        int nFunsterStil)
    {
        HWND hwnd;
        MSG messages;
        WNDCLASSEX wincl;
        wincl.hInstance = hThisInstance;
        wincl.lpszClassName = szClassName;
        wincl.lpfnWndProc = WindowProcedure;
        wincl.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
        wincl.cbSize = sizeof (WNDCLASSEX);
        wincl.hIcon = LoadIcon (NULL, IDI_HAND);
        wincl.hIconSm = LoadIcon (NULL, IDI_WARNING);
        wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
        wincl.lpszMenuName = NULL;
        wincl.cbClsExtra = 0;
        wincl.cbWndExtra = 0;
        wincl.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
        
        if (!RegisterClassEx (&wincl))
            return 0;
    
        hwnd = CreateWindowEx (
               0,
               szClassName,
               "Skeleton",
               WS_OVERLAPPEDWINDOW | WS_VISIBLE,
               CW_USEDEFAULT,
               CW_USEDEFAULT,
               CW_USEDEFAULT,
               CW_USEDEFAULT,
               NULL,
               NULL,
               hThisInstance,
               NULL
               );
    
        while (GetMessage (&messages, NULL, 0, 0))
        {
            TranslateMessage(&messages);
            DispatchMessage(&messages);
        }
        return messages.wParam;
    }
    
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	HDC hdc,hdcold;
    	HBITMAP Skull;
    	PAINTSTRUCT ps;
        switch (message)
        {
            case WM_DESTROY:     
                PostQuitMessage (0);
                break;
    		case WM_PAINT:
    			hdc = BeginPaint(hwnd, &ps);
    			Skull = LoadBitmap(hinst, MAKEINTRESOURCE(IDB_BITMAP1));
    			hdcold = CreateCompatibleDC(hdc);
    			SelectObject(hdc, Skull);
    	 		BitBlt(hdc, 10, 10, 450, 400, hdcold, 0, 0, SRCCOPY);
    	        DeleteDC(hdcold);
    	        DeleteObject(Skull);
    			EndPaint(hwnd, &ps);
    			break;
            default:
                return DefWindowProc (hwnd, message, wParam, lParam);
        }
    
        return 0;
    }
    Code:
    #define IDB_BITMAP1                     101
    I can't post the picture but i loaded it into the resource and visual c++ generated that .h file for me so im sure im right in that part. The window loaded but no bitmaps, im frustrated, please help me get past this stage.
    /* Have a nice day */

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Just a typo issue:
    Code:
    			Skull = LoadBitmap(hinst, MAKEINTRESOURCE(IDB_BITMAP1));
    			hdcold = CreateCompatibleDC(hdc);
    			SelectObject(hdcold, Skull);
    	 		BitBlt(hdc, 10, 10, 450, 400, hdcold, 0, 0, SRCCOPY);

  3. #3
    rEtaRD r HUMANS TOO !!! rEtard's Avatar
    Join Date
    Feb 2005
    Posts
    80
    anonytmous, THANZ ! now it works !
    Last edited by rEtard; 04-11-2005 at 11:19 AM.
    /* Have a nice day */

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bitmap saving problem
    By geek@02 in forum Windows Programming
    Replies: 3
    Last Post: 10-01-2007, 08:44 PM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. Bitmap Displaying Problem
    By MadCow257 in forum Game Programming
    Replies: 0
    Last Post: 01-25-2005, 05:21 PM
  4. Reading Bitmap File Header Problem.
    By StanleyC in forum C Programming
    Replies: 7
    Last Post: 08-26-2004, 05:54 PM
  5. Problem With My Bitmap
    By Sebastiani in forum Windows Programming
    Replies: 9
    Last Post: 10-29-2001, 09:54 PM