#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    42
    Rep Power
    11

    Bitmaps in dialogs.


    does anybody know how to add a bitmap to a dialog?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,593
    Rep Power
    4207
    Short Answer: Yes I Do

    Long Answer: You haven't specified what platform/environment you're using, so I'll assume Visual C++ on Windoze.

    1. Go to the Resources Tab for your project. Right click on the resources and select Import... Select Files of type as "All Files" and select the BMP file that you wish to use for your dialog. You should then see something like IDB_BITMAP1 created under the Bitmap resources.

    2. Next, go to your dialog box and select a Picture Component. Drag and drop this component on to your form

    3. Right-click on the component and select Properties. Set Type to Bitmap and Image to IDB_BITMAP1 or whatever you got from step 1.

    Voila!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    42
    Rep Power
    11
    Sorry i didn't clarify. i am not using Visual C++, but Dev-C++ and there is no drag-and-drop and that, everything has to be typed out. Know how to do that? Oh, by the way, you were right about one thing, it IS for windows.
  6. #4
  7. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    27
    USe GetDC() to get the DC of the area to draw.

    Create a compatible DC with CreateCompatibleDC()

    LoadImage() the bitmap

    SelectObject() the bitmap into the compatible DC 'catching' the current bitmap (the return from SelectObject)

    Draw to the screen or buffer DC or render in the paint msg with BitBlt() or similar

    Return the original bitmap

    DeleteObject() the bitmap (put the DC back the way you created it before trying to release the GDI memory)
    ReleaseDC() any DC's from GetDC()
    DeleteDC() any you created

    This way the bitmap is not part of the .exe.

    Another way is to load (or include in the exe) a small tile bitmap and use a pattern brush to fill the DC's rect.
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,593
    Rep Power
    4207
    For what it's worth, here's a code sample doing exactly what TechNoFear outlined above:

    http://www.ssv-embedded.de/ssv/pc104/p113.htm

IMN logo majestic logo threadwatch logo seochat tools logo