Hi Frank,
what does it mean "not satisfied". It doesn't work?
Here is bare bones drawing example:
[code=thinbasic]
Uses "UI"
' -- ID numbers of controls
Begin Const
%bClose = 1000
%cCanvas
End Const
' -- Create dialog here
Function TBMAIN()
Local hDlg As DWord
Dialog NEW 0, "Click to paint",-1,-1, 320, 220, _
%WS_POPUP Or %WS_VISIBLE Or %WS_CAPTION Or %WS_SYSMENU Or %WS_MINIMIZEBOX To hDlg
' -- Place controls here
Control ADD CANVAS, hDlg, %cCanvas, "", 5, 5, 310, 190
Control ADD BUTTON, hDlg, %bClose, "Click to close", 255, 200, 60, 14, Call bCloseProc
Dialog SHOW MODAL hDlg, Call dlgProc
End Function
' -- Callback for dialog
CallBack Function dlgProc()
Dim mousePosition As POINTAPI
Static lastMousePosition As POINTAPI
Dim locX, locY As Long
Dim lastPos As POINTAPI
' -- Test for messages
Select Case CBMSG
Case %WM_INITDIALOG
' -- Put code to be executed after dialog creation here
CANVAS_Attach(CBHNDL, %cCanvas, %FALSE)
CANVAS_Clear(%BLACK)
CANVAS_Scale PIXELS
Case %WM_MOUSEMOVE
If CBWPARAM = %MK_LBUTTON Then
' -- Get mouse position, convert it to canvas local coordinates
Control GET LOC CBHNDL, %cCanvas To locX, locY
WIN_GetCursorPos(mousePosition)
WIN_ScreenToClient(CBHNDL, mousePosition)
mousePosition.x -= locX
mousePosition.y -= locY
' -- Paint a line
If lastMousePosition.x > -1 Then
CANVAS_Line((lastMousePosition.x, lastMousePosition.y), (mousePosition.x, mousePosition.y), %WHITE)
CANVAS_Redraw
End If
lastMousePosition.x = mousePosition.x
lastMousePosition.y = mousePosition.y
End If
Case %WM_LBUTTONDOWN
' -- Get mouse position, convert it to canvas local coordinates
Control GET LOC CBHNDL, %cCanvas To locX, locY
WIN_GetCursorPos(lastMousePosition)
WIN_ScreenToClient(CBHNDL, lastMousePosition)
lastMousePosition.x -= locX
lastMousePosition.y -= locY
Case %WM_LBUTTONUP
lastMousePosition.x = -1
lastMousePosition.y = -1
Case %WM_CLOSE
' -- Put code to be executed before dialog end here
End Select
End Function
' -- Callback for close button
CallBack Function bCloseProc()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
' -- Closes the dialog
Dialog End CBHNDL
End If
End If
End Function
[/code]
Bookmarks