Results 1 to 7 of 7

Thread: [RESOLVED] Making shapes in picture boxes

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2010
    Posts
    51

    Resolved [RESOLVED] Making shapes in picture boxes

    Im trying to make an application where you type 4 numbers... an x1 coordinate, a y1 coordinate, an x2 coordinate, and a y2 coordinate in text boxes. When you type these in and click the command button a line with these coordinates appears inside a picture box. I have the form all set up frmlines.frm Thanks




  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Making shapes in picture boxes

    Yes it is possible. Use the Picture1.Line to draw the shape

    Code:
    Private Sub DrawSquare()
        '~~> This will draw a square
        '~~> You can replace the hardcoded values
        '~~> with the textboxes values
        Picture1.Line (2500, 2200)-(3000, 2200), vbBlue
        Picture1.Line (3000, 2200)-(3000, 1800), vbBlue
        Picture1.Line (3000, 1800)-(2500, 1800), vbBlue
        Picture1.Line (2500, 1800)-(2500, 2200), vbBlue
    End Sub
    Edit:

    Similarly to draw a circle, you can use

    Code:
    Picture1.Circle (2050, 2200), 1000
    Last edited by Siddharth Rout; Mar 31st, 2010 at 01:46 PM.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Making shapes in picture boxes

    Quote Originally Posted by koolsid View Post
    Yes it is possible. Use the Picture1.Line to draw the shape

    Code:
    Private Sub DrawSquare()
        '~~> This will draw a square
        '~~> You can replace the hardcoded values
        '~~> with the textboxes values
        Picture1.Line (2500, 2200)-(3000, 2200), vbBlue
        Picture1.Line (3000, 2200)-(3000, 1800), vbBlue
        Picture1.Line (3000, 1800)-(2500, 1800), vbBlue
        Picture1.Line (2500, 1800)-(2500, 2200), vbBlue
    End Sub
    Sid's code above draws lines not squares/rectangles as his comments say. Squares/rectangles can be drawn with additional parameters to the .Line method: B (block) or BF (block fill)
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Making shapes in picture boxes

    Sid's code above draws lines not squares/rectangles as his comments say.
    Attaching an example...
    Attached Files Attached Files
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2010
    Posts
    51

    Re: Making shapes in picture boxes

    Quote Originally Posted by LaVolpe View Post
    Sid's code above draws lines not squares/rectangles as his comments say. Squares/rectangles can be drawn with additional parameters to the .Line method: B (block) or BF (block fill)

    Could you show me a line using these methods?




  6. #6
    Addicted Member
    Join Date
    Oct 2009
    Posts
    164

    Re: Making shapes in picture boxes

    Help files
    Syntax
    object.Line [Step] (x1, y1) [Step] - (x2, y2), [color], [B][F]

    The Line method syntax has the following object qualifier and parts:

    Part Description
    object Optional. Object expression that evaluates to an object in the Applies To list. If object is omitted, the Form with the focus is assumed to be object.
    Step Optional. Keyword specifying that the starting point coordinates are relative to the current graphics position given by the CurrentX and CurrentY properties.
    (x1, y1) Optional. Single values indicating the coordinates of the starting point for the line or rectangle. The ScaleMode property determines the unit of measure used. If omitted, the line begins at the position indicated by CurrentX and CurrentY.
    Step Optional. Keyword specifying that the end point coordinates are relative to the line starting point.
    (x2, y2) Required. Single values indicating the coordinates of the end point for the line being drawn.
    color Optional. Long integer value indicating the RGB color used to draw the line. If omitted, the ForeColor property setting is used. You can use the RGB function or QBColor function to specify the color.
    B Optional. If included, causes a box to be drawn using the coordinates to specify opposite corners of the box.
    F Optional. If the B option is used, the F option specifies that the box is filled with the same color used to draw the box. You cannot use F without B. If B is used without F, the box is filled with the current FillColor and FillStyle. The default value for FillStyle is transparent.


    Remarks

    To draw connected lines, begin a subsequent line at the end point of the previous line.

    The width of the line drawn depends on the setting of the DrawWidth property. The way a line or box is drawn on the background depends on the setting of the DrawMode and DrawStyle properties.

    When Line executes, the CurrentX and CurrentY properties are set to the end point specified by the arguments.

  7. #7
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Making shapes in picture boxes

    @idecoyx: Did you even check the sample project that I uploaded?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width