Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 [HELP]Map Editor
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

PW7962
Squire

USA
33 Posts

Posted - May 22 2006 :  3:51:36 PM  Show Profile  Visit PW7962's Homepage  Send PW7962 an AOL message  Reply with Quote
Ok for a game of mine I am making a map editor, which is really just a paint program and the game will check for the colors. I am using SetPixel for just putting dots, but I would like to know how to make a line (squares and circles would not be nescesary, but helpful). I tried to use MovetoEX and LineTO but I keep getting errors and I was wondering if there was an easier way. Thanks in advance, pw

Star Fantasy Unlimited Programmer

http://starfantasy.forumer.com

Eric Coleman
Gladiator

USA
811 Posts

Posted - May 23 2006 :  1:36:53 PM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
Private Type POINTAPI  
    X As Long
    Y As Long
End Type
Private Declare Function Polyline Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
  
Sub DrawLine(ByVal hDC as Long, X1 as Long, Y1 as Long, X2 as Long, Y2 As Long)  
    Dim lpPoint(0 to 1) as POINTAPI  
    lpPoint(0).X = X1  
    lpPoint(0).Y = Y1  
    lpPoint(1).X = X2  
    lpPoint(1).Y = Y2  
    Call Polyline(hDC, lpPoint(0), 2&)  
End Sub


If you use a picturebox make sure your scale mode is pixels.

Go to Top of Page

PW7962
Squire

USA
33 Posts

Posted - May 23 2006 :  5:41:54 PM  Show Profile  Visit PW7962's Homepage  Send PW7962 an AOL message  Reply with Quote
Ok, so I use the code like this "Call DrawLine(picMap.hdc, X1, Y1, X, Y)" and I get a ByRef Argument Type Mismatch error, and I do not see anything wrong. Any sugestions?

Star Fantasy Unlimited Programmer

http://starfantasy.forumer.com
Go to Top of Page

Eric Coleman
Gladiator

USA
811 Posts

Posted - May 23 2006 :  6:28:33 PM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
Are you sure X1, Y1, X, and Y are of data type LONG?
Go to Top of Page

PW7962
Squire

USA
33 Posts

Posted - May 24 2006 :  2:48:44 PM  Show Profile  Visit PW7962's Homepage  Send PW7962 an AOL message  Reply with Quote
I am possitive that they are all Longs, I just double checked and saw that the Click sub has X and Y as Singles, but I just made X2 and Y2 variables as longs and get the same error at the X1.

Star Fantasy Unlimited Programmer

http://starfantasy.forumer.com
Go to Top of Page

Walrus
Squire

Slovenia
34 Posts

Posted - May 24 2006 :  6:44:23 PM  Show Profile  Reply with Quote
Forgive me, but are you absolutely sure they are all Longs? Could it be that you declared X1 and X2 like this: Dim X1, X2 as Long(which results in X1 being a Variant)?

Anyway, you can solve the problem by declaring all arguments with ByVal:
Sub DrawLine(ByVal hDC As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long)  

This way VB won't complain if the variables don't have the precise data type expected.

Another thing: I might be missing something, but why not simply use VB's Line method?

Go to Top of Page

Dizzee
Squire

USA
13 Posts

Posted - May 24 2006 :  11:06:32 PM  Show Profile  Visit Dizzee's Homepage  Send Dizzee an AOL message  Click to see Dizzee's MSN Messenger address  Reply with Quote
in class we made a green globs programs

the line function works great and so does the pset
pset (x,y) (i think) and
line (x,y) (something like this) and for a box:
line (x,y), bf (the line should be the diagnol of the box


www.ClanTemplates.com
Free Clan Templates for the masses!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.12 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.