Drawing dots on an MS form

woknick

Registered User.
Local time
Today, 00:44
Joined
Sep 25, 2004
Messages
85
im responding to the code you submitted to draw lines on a form. I am trying to change it a bit to only draw dots. I have x and y cordinates that I want to draw on the MS form kinda like a scatter graph. So I want to pass values from a table into the function LineX. Then have the function create dots that draw on the for to corespond to the x and y Cordinates. I was wondering if you could help.
thanks in advance


here is the original code
Option Compare Database
Option Explicit


Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, _
ByVal Y As Long) As Long

Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, _
ByVal Y As Long, lpPoint As Any) As Long

Private Declare Function apiGetDC Lib "user32" Alias "GetDC" _
(ByVal hWnd As Long) As Long

Private Declare Function apiGetFocus Lib "user32" _
Alias "GetFocus" _
() As Long

Public Function LineX(Ctrl As Control, X As Long, Y As Long, cx As Long, cy As Long)
Dim DC As Long
'device context
Dim hWndCtrl As Long
'bounding control handle
hWndCtrl = fhWnd(Ctrl)
'get control handle
DC = apiGetDC(hWndCtrl)
'get control DC
MoveToEx DC, X, Y, ByVal 0&
'set starting point
LineTo DC, cx, cy
'draw line from starting point to cx, cy
End Function

Private Function fhWnd(ctl As Control) As Long
'use getfocus to retrieve ctrl handle
On Error Resume Next
ctl.SetFocus
If Err Then
fhWnd = 0
Else
fhWnd = apiGetFocus
End If
On Error GoTo 0
End Function
 

Users who are viewing this thread

Back
Top Bottom