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

C / C++ / MFC

 
AnswerRe: How to detect when the view is finished resizing Pin
NormDroid12-Jan-01 4:38
professionalNormDroid12-Jan-01 4:38 
GeneralSelect a pen color Pin
.::RockNix::.12-Jan-01 3:23
.::RockNix::.12-Jan-01 3:23 
GeneralRe: Select a pen color Pin
David Fedolfi12-Jan-01 8:20
David Fedolfi12-Jan-01 8:20 
GeneralRe: Select a pen color Pin
.::RockNix::.15-Jan-01 1:19
.::RockNix::.15-Jan-01 1:19 
GeneralPlease tell me what's wrong in here... Pin
Jason Troitsky12-Jan-01 1:19
Jason Troitsky12-Jan-01 1:19 
GeneralRe: Please tell me what's wrong in here... Pin
Christian Graus12-Jan-01 10:03
protectorChristian Graus12-Jan-01 10:03 
GeneralRe: Please tell me what's wrong in here... Pin
Jason Troitsky13-Jan-01 4:41
Jason Troitsky13-Jan-01 4:41 
GeneralRe: Please tell me what's wrong in here... Pin
Anders Molin13-Jan-01 7:22
professionalAnders Molin13-Jan-01 7:22 
This is just a copy->paste from MSDN:

You can use a bitmap to capture an image, and you can store the captured image in memory, display it at a different location in your application's window, or display it in another window.

In some cases, you may want your application to capture images and store them only temporarily. For example, when you scale or zoom a picture created in a drawing application, the application must temporarily save the normal view of the image and display the zoomed view. Later, when the user selects the normal view, the application must replace the zoomed image with a copy of the normal view that it temporarily saved.

To store an image temporarily, your application must call CreateCompatibleDC to create a DC that is compatible with the current window DC. After you create a compatible DC, you create a bitmap with the appropriate dimensions by calling the CreateCompatibleBitmap function and then select it into this device context by calling the SelectObject function.

After the compatible device context is created and the appropriate bitmap has been selected into it, you can capture the image. The BitBlt function captures images. This function performs a bit block transfer — that is, it copies data from a source bitmap into a destination bitmap. However, the two arguments to this function are not bitmap handles. Instead, BitBlt receives handles that identify two device contexts and copies the bitmap data from a bitmap selected into the source DC into a bitmap selected into the target DC. In this case, the target DC is the compatible DC, so when BitBlt completes the transfer, the image has been stored in memory. To redisplay the image, call BitBlt a second time, specifying the compatible DC as the source DC and a window (or printer) DC as the target DC.

The following example code, from an application that captures an image of the entire desktop, creates a compatible device context and a bitmap with the appropriate dimensions, selects the bitmap into the compatible DC, and then copies the image using the BitBlt function.
// Create a normal DC and a memory DC for the entire screen. The 
// normal DC provides a "snapshot" of the screen contents. The 
// memory DC keeps a copy of this "snapshot" in the associated 
// bitmap. 
 
hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL); 
hdcCompatible = CreateCompatibleDC(hdcScreen); 
 
// Create a compatible bitmap for hdcScreen. 
 
hbmScreen = CreateCompatibleBitmap(hdcScreen, 
                     GetDeviceCaps(hdcScreen, HORZRES), 
                     GetDeviceCaps(hdcScreen, VERTRES)); 
 
if (hbmScreen == 0) 
    errhandler("hbmScreen", hwnd); 
 
// Select the bitmaps into the compatible DC. 
 
if (!SelectObject(hdcCompatible, hbmScreen)) 
    errhandler("Compatible Bitmap Selection", hwnd); 
 
        // Hide the application window. 
 
        ShowWindow(hwnd, SW_HIDE); 
 
         //Copy color data for the entire display into a 
         //bitmap that is selected into a compatible DC. 
 
        if (!BitBlt(hdcCompatible, 
               0,0, 
               bmp.bmWidth, bmp.bmHeight, 
               hdcScreen, 
               0,0, 
               SRCCOPY)) 
 
        errhandler("Screen to Compat Blt Failed", hwnd); 
 
        // Redraw the application window. 
 
        ShowWindow(hwnd, SW_SHOW); 


Hope it helps...

- Anders
QuestionHow to create a custom window class name in MFC Pin
James Spibey12-Jan-01 0:50
James Spibey12-Jan-01 0:50 
AnswerRe: How to create a custom window class name in MFC Pin
Michael Dunn12-Jan-01 13:57
sitebuilderMichael Dunn12-Jan-01 13:57 
GeneralCEditView and... Pin
11-Jan-01 23:45
suss11-Jan-01 23:45 
GeneralRe: CEditView and... Pin
Jason Troitsky12-Jan-01 2:07
Jason Troitsky12-Jan-01 2:07 
GeneralRe: CEditView and... Pin
12-Jan-01 6:28
suss12-Jan-01 6:28 
GeneralRe: CEditView and... Pin
12-Jan-01 6:32
suss12-Jan-01 6:32 
GeneralRe: CEditView and... Pin
12-Jan-01 2:11
suss12-Jan-01 2:11 
GeneralRe: CEditView and... Pin
12-Jan-01 6:35
suss12-Jan-01 6:35 
GeneralFonts in VC++ Code Editor Pin
11-Jan-01 17:51
suss11-Jan-01 17:51 
GeneralRe: Fonts in VC++ Code Editor Pin
Michael Dunn11-Jan-01 20:52
sitebuilderMichael Dunn11-Jan-01 20:52 
QuestionSound?? Pin
11-Jan-01 10:01
suss11-Jan-01 10:01 
QuestionSound?? Pin
11-Jan-01 10:01
suss11-Jan-01 10:01 
AnswerRe: Sound?? Pin
Christian Graus11-Jan-01 12:44
protectorChristian Graus11-Jan-01 12:44 
GeneralRe: Sound?? Pin
12-Jan-01 7:59
suss12-Jan-01 7:59 
GeneralRe: Sound?? Pin
Jim Howard12-Jan-01 9:37
Jim Howard12-Jan-01 9:37 
GeneralRe: Sound?? Pin
13-Jan-01 6:44
suss13-Jan-01 6:44 
GeneralRe: Sound?? Pin
Christian Graus13-Jan-01 8:49
protectorChristian Graus13-Jan-01 8:49 

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.