Click here to Skip to main content
15,887,435 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralOpening system menu with code don’t work Pin
Patric_J5-Aug-05 10:27
Patric_J5-Aug-05 10:27 
GeneralRe: Opening system menu with code don’t work Pin
GKarRacer5-Aug-05 11:35
GKarRacer5-Aug-05 11:35 
GeneralRe: Opening system menu with code don’t work Pin
Patric_J8-Aug-05 3:25
Patric_J8-Aug-05 3:25 
GeneralCommon Language Runtime Debugging Services Error Pin
sysx5-Aug-05 8:52
sysx5-Aug-05 8:52 
GeneralRe: Common Language Runtime Debugging Services Error Pin
Trollslayer5-Aug-05 10:20
mentorTrollslayer5-Aug-05 10:20 
GeneralRe: Common Language Runtime Debugging Services Error Pin
sysx5-Aug-05 15:45
sysx5-Aug-05 15:45 
GeneralRe: Common Language Runtime Debugging Services Error Pin
sysx6-Aug-05 7:19
sysx6-Aug-05 7:19 
GeneralDrawing in a Memory DC Pin
Axonn Echysttas5-Aug-05 6:59
Axonn Echysttas5-Aug-05 6:59 
Hi everybody. Long time no posting. Been busy working at the freeware Application and I'm almost done with the first beta : ). Also, I'm preparing an article for the Code Project. Anyway, I posted this message to see if any of you got any clue about the following problem:

Grabbing the DC of a window, copying it in a memory DC, drawing something (like a square for example) and then BitBlt-ing the result in the original window whenever you wish.

Take a look at this short code. It's supposed to grab a window DC and put it in a memory DC and return a handle to a DDB. It's from a book. My problem is that I want to do something similar, but I can't make it work. My experiments are kind of failed... so I won't post them. Here's the original code:

HBITMAP CaptureWindow(HWND hWnd)<br />
{<br />
  RECT wnd;<br />
<br />
  if ( ! GetWindowRect(hWnd, & wnd) )<br />
    return NULL;<br />
<br />
  HDC hDC = GetWindowDC(hWnd);<br />
<br />
  HBITMAP hBmp = CreateCompatibleBitmap(hDC, wnd.right—wnd.left,<br />
                     wnd.bottom - wnd.top);<br />
<br />
  if ( hBmp )<br />
  {<br />
    HDC hMemDC   = CreateCompatibleDC(hDC);<br />
    HGDIOBJ hOld = SelectObject(hMemDC, hBmp);<br />
<br />
    BitBlt(hMemDC, 0, 0, wnd.right - wnd.left, wnd.bottom - wnd.top,<br />
        hDC, 0, 0, SRCCOPY);<br />
<br />
    SelectObject(hMemDC, hOld);<br />
    DeleteObject(hMemDC);<br />
  }<br />
  ReleaseDC(hWnd, hDC);<br />
<br />
  return hBmp;<br />
}


Now... could I somehow keep that Memory DC, draw something in it (say, a rectangle) and then bitblt it over the original window from which I created it? And perhaps after 2 seconds I want to do it again. Could I just bitblt it from my memory DC over the original window?

-= E C H Y S T T A S =-
The Greater Mind Balance
GeneralRe: Drawing in a Memory DC Pin
Jose Lamas Rios6-Aug-05 16:46
Jose Lamas Rios6-Aug-05 16:46 
Generalcomplex numbers error Pin
Oriented5-Aug-05 6:00
Oriented5-Aug-05 6:00 
GeneralRe: complex numbers error Pin
BlackDice5-Aug-05 7:36
BlackDice5-Aug-05 7:36 
Generalit dosn't work either!! Pin
Oriented5-Aug-05 8:03
Oriented5-Aug-05 8:03 
GeneralRe: complex numbers error Pin
Gary R. Wheeler5-Aug-05 15:36
Gary R. Wheeler5-Aug-05 15:36 
QuestionInterlockedExchangeAdd - how much contention? Pin
peterchen5-Aug-05 5:33
peterchen5-Aug-05 5:33 
GeneralRe: InterlockedExchangeAdd - how much contention? Pin
Alexander M.,7-Aug-05 4:46
Alexander M.,7-Aug-05 4:46 
QuestionHow to find the memory usage programatically? Pin
appuanbu5-Aug-05 5:01
appuanbu5-Aug-05 5:01 
AnswerRe: How to find the memory usage programatically? Pin
Blake Miller5-Aug-05 6:09
Blake Miller5-Aug-05 6:09 
GeneralRe: How to find the memory usage programatically? Pin
appuanbu5-Aug-05 6:18
appuanbu5-Aug-05 6:18 
GeneralRe: How to find the memory usage programatically? Pin
Blake Miller8-Aug-05 6:26
Blake Miller8-Aug-05 6:26 
Generalcall graph Pin
jaycush5-Aug-05 4:57
jaycush5-Aug-05 4:57 
GeneralRe: call graph Pin
RChin5-Aug-05 5:16
RChin5-Aug-05 5:16 
GeneralRe: call graph Pin
jaycush5-Aug-05 5:30
jaycush5-Aug-05 5:30 
GeneralGDI+ stretching Pin
lroels5-Aug-05 4:56
lroels5-Aug-05 4:56 
QuestionWIN32 API question: WNDCLASS.cbWndExtra ? Pin
Anonymous5-Aug-05 4:33
Anonymous5-Aug-05 4:33 
AnswerRe: WIN32 API question: WNDCLASS.cbWndExtra ? Pin
Blake Miller5-Aug-05 6:13
Blake Miller5-Aug-05 6:13 

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.