You draw lines, rectangles, etc... in the WM_PAINT handler for the Form. Here is some example code to get you started. You do all kinds of fancy things by using the WM_PAINT handler.
Function FORM1_WM_PAINT ( _
hWndForm As Dword _ ' handle of Form
) As Long
Local hDC As Dword
Local hPen As Dword
Local hBrush As Dword
' Get the DC for this form
hDC = GetDC( hWndForm )
' Save the DC's contents so we can restore them later
SaveDC hDC
' Create a pen to use with our rectangle. The width is 1 and
' uses a red color.
hPen = CreatePen( %PS_SOLID, 1, %Red )
' If we want our rectangle to have a solid background color
' then we create a solid brush, otherwise I just use a hollow brush.
'hBrush = CreateSolidBrush( %Blue )
hBrush = GetStockObject(%HOLLOW_BRUSH)
' Select the objects into the DC
SelectObject hDC, hPen
SelectObject hDC, hBrush
' Draw the rectangle. The rectangle uses the currently defined
' pen to draw the border and brush to fill the inside. We could
' use RoundRect api if we want a rectangle with rounded corners.
Rectangle hDC, 20, 20, 200, 200
' To draw a line, simple use the MoveTo and LineTo api.
MoveTo hDC, 20, 225
LineTo hDC, 500, 225
' Restore the contents of our saved DC
RestoreDC hDC, -1
' Delete the objects that we created
DeleteObject hPen
DeleteObject hBrush
' Release the DC.
ReleaseDC hWndForm, hDC
End Function
Can you tell me how this could be used to draw inside a control such as a picture or fireImage control? My attempts so far have failed :(
Thanks,
Bob
I'd be interested in learning how do draw graphics on a control as well.
I was able to get the above example to work by putting it in the "custom" message handler of the control. I also had to turn off the two redraw options in the ClassStyles options for the main form.
But you should probably look at this thread:
http://www.planetsquires.com/protect/forum/index.php?topic=2020.0 (http://www.planetsquires.com/protect/forum/index.php?topic=2020.0)
I'm in the process of working my way though that one ;D
Quote from: Robert Eaton on November 14, 2009, 12:49:28 PM
I'm in the process of working my way though that one ;D
..and we're all chomping at the bit to see how you are progressing! Any problems just ask. Post your code if you want a second set of eyes to look it over for any potential problem areas.
What I've done so far is to take the Filelines control, rename all of the commands, and then per your instructions add it to a project, position it, and send commands to it ;D (It had me scratching my head at first but finally got it all working!)
So next is to start writing my control. (Pesky stuff like broken clothes washers getting in the way :'()