Reply
Old February 18th, 2005 Top | #1
 
indyjones's Avatar
OSNN.net Adventurer
Joined: November 2002
Location: England
Posts: 1,578
Reputation: 330
Power: 108

Question Visual Basic 6 – Drawing Code Help

Hey all
Learning VB6 at the moment and was wondering if someone could help me please by telling me how to draw an ellipse by using a command button then changing its aspect ratio via a scrollbar.
Any help will be much much appreciated!

IJ



Intel Q9450
, Asus Rampage Formula X48, 4Gig Corsair Dominator 8500 @ 1066mhz, Coolermaster Stacker Case (Internals Painted Black), Logitech G15 & MX1000. Gigabyte 9800GTX, Benq DVDRW, 2x Seagate Barracuda Serial ATA V (In Raid 0), Zalman 9700, MS ForceFeedBack 2, Dell 2005FPW, Xbox360 Adapter, VISTA X64 Ultimate/ Win7 Ultimate
indyjones is offline   Reply With Quote
Old February 18th, 2005 Top | #2
 
Kush's Avatar
High On Life!
Joined: January 2002
Location: Montreal, Quebec
Posts: 4,676
Reputation: 1300
Power: 159

Default Re: Visual Basic 6 – Drawing Code Help

i did this last year, i forgot, sorry man, its kinda confusing at first, but once u get the hang of it it will be easy, it has to do with coordinetes though (x,y) thats all i remember


If Someones post is helpful or makes you laugh, reward the person by clicking on this button--->
Kush is offline   Reply With Quote
Old February 19th, 2005 Top | #3
 
XPos's Avatar
OSNN Addict
Joined: August 2002
Location: Kansas
Posts: 89
Reputation: 20
Power: 93

Default Re: Visual Basic 6 – Drawing Code Help

Hope this will help. Hope I didn't go too overboard.

Don't forget to set your min values to 1. You can set the max values to what ever you want. Just make sure the reset values reflect that number.
Code:
Option Explicit
'Declare variables
  Dim CX As Integer
  Dim CY As Integer
  Dim sngAspect As Single
  Dim intRadius As Integer
  
Private Sub Command1_Click()
'Calculate the aspect ratio
  sngAspect = HScroll1.Value / VScroll1.Value
  
'Clear the form
  Me.Cls
  
'Reset the scroll bar values
  HScroll1.Value = 200
  VScroll1.Value = 200
  
'Draw the circle/ellipse
  Me.Circle (CX, CY), intRadius, vbBlack, , , sngAspect
End Sub

Private Sub Form_Load()
'Reset the scroll bar values
  HScroll1.Value = 200
  VScroll1.Value = 200
End Sub

Private Sub Form_Resize()
'If the form is not minimized resize all object to fit on the form
  If Me.WindowState <> 1 Then
  'Move the command button
    Command1.Move Me.ScaleWidth - 15, Me.ScaleHeight - 15, 15, 15
    
  'Move the scroll bars
    HScroll1.Move 0, Me.ScaleHeight - 15, Me.ScaleWidth - 15, 15
    VScroll1.Move Me.ScaleWidth - 15, 0, 15, Me.ScaleHeight - 15
    
  'Recalculate the center of the circle
    CX = Me.ScaleWidth / 2 - VScroll1.Width
    CY = Me.ScaleHeight / 2 - HScroll1.Height
    
  'Calculate the radius of the circle
    If CX > CY Then
      intRadius = CX / 2
    Else
      intRadius = CY / 2
    End If
  End If
End Sub

Private Sub HScroll1_Change()
'Reset the vertical scroll bar
  VScroll1.Value = 200
  
'Recalculate the aspect ratio
  sngAspect = HScroll1.Value / VScroll1.Value
  
'Clear the form
  Me.Cls
  
'Redraw the circle/ellipse
  Me.Circle (CX, CY), intRadius, vbBlack, , , sngAspect
End Sub

Private Sub VScroll1_Change()
'Reset the horizontal scroll bar
  HScroll1.Value = 200
  
'Recalculate the aspect ratio
  sngAspect = HScroll1.Value / VScroll1.Value
  
'Clear the form
  Me.Cls
  
'Redraw the circle/ellipse
  Me.Circle (CX, CY), intRadius, vbBlack, , , sngAspect
End Sub
XPos is offline   Reply With Quote
Old February 19th, 2005 Top | #4
 
indyjones's Avatar
OSNN.net Adventurer
Joined: November 2002
Location: England
Posts: 1,578
Reputation: 330
Power: 108

Default Re: Visual Basic 6 – Drawing Code Help

^^^ Hey I am sure that will be usefull

Many Thanks



Intel Q9450
, Asus Rampage Formula X48, 4Gig Corsair Dominator 8500 @ 1066mhz, Coolermaster Stacker Case (Internals Painted Black), Logitech G15 & MX1000. Gigabyte 9800GTX, Benq DVDRW, 2x Seagate Barracuda Serial ATA V (In Raid 0), Zalman 9700, MS ForceFeedBack 2, Dell 2005FPW, Xbox360 Adapter, VISTA X64 Ultimate/ Win7 Ultimate
indyjones is offline   Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules

Similar Threads
Thread Thread Starter Forum Replies Last Post
visual basic.net help GhoulScout Web Design & Coding 13 December 16th, 2004 2:12am
Visual Basic 6 Code Request prinsipe Windows Desktop Systems 3 August 18th, 2004 2:13pm
Visual Basic Code NLM Web Design & Coding 4 April 18th, 2003 3:47am
Visual Basic JJH35 Web Design & Coding 2 January 31st, 2003 3:41pm
Visual Basic 6.0 rickang Web Design & Coding 1 March 21st, 2002 2:22am