Results 1 to 1 of 1

Thread: [RESOLVED] Displaying a bitmap on a form (Win32, VC++ 2008 EE)

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    11

    Resolved [RESOLVED] Displaying a bitmap on a form (Win32, VC++ 2008 EE)

    Hi all

    I'm creating a Windows Forms application using Visual C++ 2008 Express Edition. I'm using Win32 as opposed to anything that relies on a .net framework (as I don't want any prerequisits or anything that needs installing).

    So far this is going well - I've got my "Hello World" application up and running and am merrily resizing the window and managed to write a little routine where it puts itself in the centre of the screen.

    But now I'm wanting to put in bitmaps.

    I have a bitmap which I've added to the project as a resource (right-clicked in Solution Explorer etc). So that now appears as "layout.bmp".

    The trouble is getting it into the code.

    I've created an "app.rc" (even though VC++ Express says it's not supported, you can right-click it in Solution Explorer and edit the code) and put in the following:

    Code:
    #include "resource.h"
    MyLayout BITMAP "layout.bmp"
    I've also created a "resource.h":

    Code:
    #define MyLayout 101;
    And I can't get this to find my bmp in the main cpp file:

    Code:
    bmpBG = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(101));
    if(bmpBG == NULL)MessageBox(hWnd,  TEXT("Image is NULL"), TEXT ("Error"), MB_OK | MB_ICONEXCLAMATION);
    Anybody got any ideas? The bitmap SHOULD be defined as 101 (I've also tried just putting MyLayout in there instead of 101 but it throws up errors).

    The program DOES compile and run though, but is caught as it finds the picture is NULL.

    EDIT

    Sorted it now (for anyone interested, using ResEd to manage my resources made a DISCARDABLE appear which seemed to work).
    Last edited by djmcbell; Nov 19th, 2009 at 08:57 AM. Reason: Resolved

Posting Permissions

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



Click Here to Expand Forum to Full Width