Well 1st of all, hi everyone, this is my first post 2 this messageboard, so before u go on u can't say that i didn't warned you :-). im a total beginner with win32asm, so my question may seem silly 4 1st.

my problem is the next: i wrote a prog that superclasses the static label control 2 be a kind of a button, this all works kinda well 2 me, but i've got a problem with the WM_PAINT section of the prog. What i want to do here is 2 draw somekind of a basic border to my window (i have the WS_POPUP style for the window style i dont know is this important) and yeas i tried also with DrawEdge to draw the border, but that didn't worked as i expected, so i tried instead to draw with simple lines. So here is the code:

invoke BeginPaint,hWnd,addr ps ; gets the windows dc
mov hDc1,eax

invoke CreateSolidBrush,0h ; creates the black brush
mov BbrUsh,eax

invoke CreateSolidBrush,0ffffffh ; creates the white brush
mov WbrUsh,eax

invoke SelectObject,hDc1,BbrUsh ; selects the black brush into the dc & saves the old
mov OldBrush,eax

invoke MoveToEx,hDc1,0,16,addr pNt ; draws the 1st rectangle
invoke LineTo,hDc1,399,16
invoke LineTo,hDc1,399,199
invoke LineTo,hDc1,0,199
invoke LineTo,hDc1,0,16

invoke SelectObject,hDc1,WbrUsh ; selects the white brush into the dc

invoke MoveToEx,hDc1,0,14,addr pNt ; and here although it draws the 2nd rectangle
invoke LineTo,hDc1,0,0? ? ? ? ? ? ? ? ? ?; but with black color !!!!!
invoke LineTo,hDc1,399,0? ? ? ? ? ? ? ? ; although i selected the white brush into the dc !!
invoke LineTo,hDc1,399,14
invoke LineTo,hDc1,0,14

invoke SelectObject,hDc1,OldBrush ; restores the brush and stops painting
invoke EndPaint,hWnd,addr ps

So my question here is, why the heck the 2nd rectangle isn't drawed with white color, because i did selected the white brush into the dc before drawing it ???

Posted on 2005-05-24 11:31:20 by berril
Select a Pen into the DC if you're using LineTo.
Posted on 2005-05-24 12:13:37 by JimmyClif
A "Brush" is used for fills.? The insides of a drawn rectangle use a "Brush".

A "Pen" is used for lines.? The borders of a drawn rectangle use a "Pen".

You can, for example, select a green pen and a blue brush in order to draw a blue rectangle with a green outline.

Since you are drawing individual lines but didn't change pens, the line is still drawn in the DEFAULT pen, which is a black, minimum-width, undashed pen.

BTW, if you're creating GDI objects in your WM_PAINT proc, I suggest you delete them at the end of WM_PAINT.
Posted on 2005-05-24 21:16:05 by AmkG
and if you select something onto DC, remember to store the return value and select it after you finish drawing, but BEFORE you delete the DC. otherwise you may exhaust system resources
Posted on 2005-05-25 07:26:53 by ti_mo_n