|
-
Feb 19th, 2002, 04:31 AM
#1
Thread Starter
Member
Stupid User Question
Hi all,
can anybody help me ?
I'd like to do some API stuff.
I got this code from VBAPI.com
1) Declare Function LineTo Lib "gdi32.dll" (ByVal hdc As Long, x As Long, ByVal y As Long) As Long
2)' Draw a red line from (0,40) to (100,50) on the window Form1.
Dim pt As POINT_TYPE ' needed for another API function
Dim retval As Long ' return value
3)Form1.ForeColor = RGB(255, 0, 0) ' set the foreground drawing color of Form1 to red
retval = MoveToEx(Form1.hdc, 0, 40, pt) ' set the current point to (0,40)
retval = LineTo(Form1.hdc, 100, 50) ' draw a line from current point to (100,50)
Questions :
Where to declare 1) ???
In General declarations ???
Where to declare 2) ???
Last question : I have to declare the POINT_TYPE structure with Type POINT_TYPE
x as long
y as long
End Type
Where to declare this ???
Any help would be very much appreciated !!!
Greets
Tom
-
Feb 19th, 2002, 04:48 AM
#2
PowerPoster
All ion General decleration section
-
Feb 19th, 2002, 05:18 AM
#3
Thread Starter
Member
Thank you ver much amitabh !!
Anyway, I don't get it !?
General Declaration
Declare Function LineTo Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Type POINT_Type
x As Long
y As Long
End Type
Dim pt As POINT_Type
Dim retval As Long
Private Sub Command1_Click()
Form1.ForeColor = RGB(255, 0, 0)
retval = MoveToEx(Form1.hdc, 0, 40, pt)
retval = LineTo(Form1.hdc, 100, 50)
End Sub
gives the following error message:
Compile error : Cannot define a public user-defined type within a private object module.
???
Can you help me again, please ?!
Thank you !!
Thomas
-
Feb 19th, 2002, 06:47 AM
#4
Frenzied Member
If you wish to use the code in a form or a class module then the declarations must be private thus:
Code:
Private Declare Function LineTo Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Type POINT_Type
x As Long
y As Long
End Type
Otherwise they must be declared in a .bas standard code module.
HTH,
Duncan
-
Feb 20th, 2002, 03:15 AM
#5
Thread Starter
Member
Thanks MerrionComputin !
It works !
I was close sometimes but always forgot to declare the MoveToEx , and stupid enough NOT to understand the error message !
Thanks !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|