Post

 Resources 

Console

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

 All Forums
 VBGamer
 VBGamer
 [HELP]Map Editor

Note: You must be registered in order to post a reply.

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
PW7962 Posted - May 22 2006 : 3:51:36 PM
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
6   L A T E S T    R E P L I E S    (Newest First)
Dizzee Posted - May 24 2006 : 11:06:32 PM
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
Walrus Posted - May 24 2006 : 6:44:23 PM
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?

PW7962 Posted - May 24 2006 : 2:48:44 PM
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.
Eric Coleman Posted - May 23 2006 : 6:28:33 PM
Are you sure X1, Y1, X, and Y are of data type LONG?
PW7962 Posted - May 23 2006 : 5:41:54 PM
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?
Eric Coleman Posted - May 23 2006 : 1:36:53 PM
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.

VBGamer © Go To Top Of Page
This page was generated in 0.09 seconds. Snitz Forums 2000

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