-
I have the following code behind a command button:
Dim OldBrush As Long
Dim OldPen As Long
Dim NewBrush As Long
Dim NewPen As Long
Dim Color As Long
Color = RGB(0, 0, 255)
NewPen = CreatePen(PS_SOLID, 3, Color)
OldPen = SelectObject(Form1.hdc, NewPen)
NewBrush = CreateSolidBrush(Color)
OldBrush = SelectObject(Form1.hdc, NewBrush)
Rectangle Form1.hdc, 50, 50, 100, 50
SelectObject Form1.hdc, OldBrush
SelectObject Form1.hdc, OldPen
DeleteObject NewPen
When I click the button, nothing happens at all.
P.S. I do have all the necessary declerations.
-
If you haven't done it already set the Autoredraw property on the form to True.
-
Thanks, but...
that isn't working. It still doesn't do anything and now this circle method I also have on that form doesn't show up.
none of the graphics APIs I try are doing a thing. i just tried to make a DC using createcompatibledc, draw a circle onto my form, bitblt it to the new DC, use the CLS method on my form, and then bitblt it back. everything worked except for the last step. and the circle wasn't even an API, it was just the form's circle method.
it's really frustrating, because I don't even get errors or anything. it's just that nothing happens :mad:
-
I can't believe that I overlooked this, the rectangle is drawing correctly because both y values are the same therefore there is no height in your rectangle, change this line to ...
Code:
Rectangle Form1.hdc, 50, 50, 100, 50
to this....
Code:
Rectangle Form1.hdc, 50, 50, 100, 51
and (as I stated above) make sure you have Autoredraw set to True and you will finally see the beautiful blue rectangle, enjoy! ;)
-
Doh!