Click here to Skip to main content
16,011,475 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Member var/func deletion Pin
Joaquín M López Muñoz10-Mar-02 8:33
Joaquín M López Muñoz10-Mar-02 8:33 
GeneralRe: Member var/func deletion Pin
Travis D. Mathison10-Mar-02 8:31
Travis D. Mathison10-Mar-02 8:31 
GeneralRe: Member var/func deletion Pin
Joaquín M López Muñoz10-Mar-02 8:41
Joaquín M López Muñoz10-Mar-02 8:41 
GeneralRe: Member var/func deletion Pin
Michael Dunn10-Mar-02 19:51
sitebuilderMichael Dunn10-Mar-02 19:51 
GeneralTab View Pin
10-Mar-02 7:29
suss10-Mar-02 7:29 
GeneralRe: Tab View Pin
Michael Dunn10-Mar-02 8:04
sitebuilderMichael Dunn10-Mar-02 8:04 
GeneralBitmaps Pin
10-Mar-02 7:25
suss10-Mar-02 7:25 
GeneralRe: Bitmaps Pin
Paul M Watt10-Mar-02 7:57
mentorPaul M Watt10-Mar-02 7:57 
If you want to draw the bitmap onto a window using a DC here is how you would do it:

//This code should go inside of your WM_PAINT, or OnPaint handler.
PAINTSTRUCT ps;
HDC hdc;

//C: Get the Device context to paint the bitmap onto your window.
//   hWnd is the handle to the window that you want to paint on.
hdc = ::BeginPaint(hWnd, &ps);
//C: Load the bitmap from your resources.
HBITMAP hBitmap;
::LoadImage(::GetModuleHandle(NULL),          // Can use a global hInstance handle if you have cached one.
            MAKEINTRESOURCE(IDB_RESOURCEID),  // The resource ID of your bitmap.
            IMAGE_BITMAP,                     // You can load cursors and icons as well.
            0,                                // The desired width and height of the bitmap
            0,                                //   0, indicates that you want the default.
            LR_DEFAULTSIZE                    // Flags that determine how the image is loaded.
           );
//C: Check that the bitmap loaded successfully.
if (!hBitmap)
{
//C: The bitmap did not load successfully, perform error handling here.
}

//C: Create a memory device context to load the bitmap into.
HDC memDC;
memDC = ::CreateCompatibleDC(hdc);
//C: Select the resource bitmap into the memory DC, while saving the old bitmap.
HBITMAP hBmpOld;
hBmpOld = (HBITMAP)::SelectObject(memDC, hBitmap);
//C: Get the dimensions of your bitmap.
BITMAP bm;
::GetObject(hBitmap, sizeof(BITMAP), &bm);
//C: Now the bitmap can be painted onto your target window.
//   The bitmap will be painted at 0,0 on the target windows client area, 
//   and it will be its default size.
if (FALSE == ::BitBlt(hdc, 0,0, bm.bmWidth, bm.bmHeight, memDC, 0,0, SRCCOPY))
{
//C: If code reaches this point, the Blt, or paint, did not succeed.

}

//C: Set your memory DC back to its original state.
::SelectObject(memDC, hBmpOld);
//C: Now you can destroy the memory DC and the bitmap that you loaded.
::DeleteDC(memDC);
::DeleteObject(hBitmap);

//C: Now, destroy the painting DC that you created for your paint handler.
::EndPaint(hWnd, &ps);


If you would like to paint a bitmap outside of the paint handler, you can replace the following code:

PAINTSTRUCT ps;
hdc = ::BeginPaint(hWnd, &ps);

...

::EndPaint(hWnd, &ps);


with this:

hdc = ::GetDC(hWnd);
...
::ReleaseDC(hWnd, hdc);


If you have any other questions, feel free to ask.
Generalcommunicate with activex control Pin
10-Mar-02 6:27
suss10-Mar-02 6:27 
GeneralRe: communicate with activex control Pin
Derek Waters10-Mar-02 11:36
Derek Waters10-Mar-02 11:36 
GeneralRe: communicate with activex control Pin
10-Mar-02 14:20
suss10-Mar-02 14:20 
GeneralAccessing a protected directory Pin
Miguel Lopes10-Mar-02 5:48
Miguel Lopes10-Mar-02 5:48 
QuestionHow I can find if my application is running under debugger? Pin
10-Mar-02 5:39
suss10-Mar-02 5:39 
AnswerRe: How I can find if my application is running under debugger? Pin
10-Mar-02 7:02
suss10-Mar-02 7:02 
Generaltypedef question... Pin
User 988510-Mar-02 4:33
User 988510-Mar-02 4:33 
GeneralRe: typedef question... Pin
Tim Smith10-Mar-02 4:52
Tim Smith10-Mar-02 4:52 
GeneralRe: typedef question... Pin
Paul M Watt10-Mar-02 5:59
mentorPaul M Watt10-Mar-02 5:59 
GeneralCompare RGB values Pin
Rickard Andersson2010-Mar-02 4:03
Rickard Andersson2010-Mar-02 4:03 
GeneralRe: Compare RGB values Pin
Gavin Taylor10-Mar-02 4:47
professionalGavin Taylor10-Mar-02 4:47 
GeneralRe: Compare RGB values Pin
Rickard Andersson2010-Mar-02 5:05
Rickard Andersson2010-Mar-02 5:05 
Generalloading images Pin
10-Mar-02 3:24
suss10-Mar-02 3:24 
GeneralRe: loading images Pin
Matt Newman10-Mar-02 3:52
Matt Newman10-Mar-02 3:52 
GeneralHEy Matt Newman Pin
10-Mar-02 4:03
suss10-Mar-02 4:03 
GeneralRe: HEy Matt Newman Pin
Matt Newman10-Mar-02 11:01
Matt Newman10-Mar-02 11:01 
GeneralSHow hide Toolbar Pin
Jon Newman10-Mar-02 2:54
Jon Newman10-Mar-02 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.