hello

dunno if this is the right place to ask
but its a silly and fast answer question

whats the best/fastest way to draw a rect on screen not filled ?

thanks
Posted on 2006-06-07 18:08:53 by GR33d
I'd use the Rectangle Api.


BOOL Rectangle(

    HDC hdc, // handle of device context
    int nLeftRect, // x-coord. of bounding rectangle's upper-left corner
    int nTopRect, // y-coord. of bounding rectangle's upper-left corner
    int nRightRect, // x-coord. of bounding rectangle's lower-right corner 
    int nBottomRect // y-coord. of bounding rectangle's lower-right corner 
  );


Use a Null-Brush as a Filler, and a Pen as the Outline.
Posted on 2006-06-07 19:45:47 by JimmyClif
so if i say that i have a button that calls the Rectangle API or something else that will draw on screen

when i press alt+tab or for some reason the window gets repainted

ill need to Re-Call the Rectangle API or is there any way to keep my drawned stuff on screen without having to draw it again on repain ??
Posted on 2006-06-08 08:38:55 by GR33d
Yes, and No.

As you probably just put a call to Rectangle in your WM_Command Handler, this is what happens. Yes.

To prevent this you could be using a BackBuffer and paint on there when needed. This BackBuffer gets painted on the Window every time WM_Paint is called. That way you could avoid it getting erased when Alt-Tabbed, Minimized etc...

Use following snippet to create a BackBuffer:

;========================================================================
;?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ?  ? GetCompatibleBitmap
;========================================================================
;?  Usage:
;?  invoke GetCompatibleBitmap, ADDR ImageDC, ADDR hImageDC, hwnd, 500, 300
;========================================================================
GetCompatibleBitmap proc AnotherDC:DWORD, HandleOfDC:DWORD, hwnd:DWORD, xLenght:DWORD, yWidth:DWORD
?  ?  invoke CreateCompatibleDC,NULL
?  ?  mov edx,AnotherDC
?  ?  push eax
?  ?  mov ,eax
?  ?  invoke GetDC,hwnd
?  ?  push eax
?  ?  invoke CreateCompatibleBitmap,eax,xLenght,yWidth
?  ?  mov edx,HandleOfDC
?  ?  mov ecx,?  ?  ?  ?  ;pop ecx
?  ?  mov ,eax?  ?  ?  ?  ;push eax
?  ?  mov ,eax
?  ?  invoke ReleaseDC,hwnd,ecx
?  ?  pop eax?  ?  ?  ?  ?  ?  ?  ?  ;HandleOfDC
?  ?  pop ecx?  ?  ?  ?  ?  ?  ?  ?  ;AnotherDC
?  ?  call SelectObject,ecx,eax
?  ?  ret
GetCompatibleBitmap endp


and set in your WM_Paint handler a call to BitBlt which copies the BackBuffer onto the Window DC.

To learn the truth and nothing but the truth about BackBuffers, Images and DC's visit Thomas' Homepage at www.madwizard.org and check out his Mosaic Tutorial.
Posted on 2006-06-08 08:47:09 by JimmyClif