Results 1 to 8 of 8

Thread: Help Please: Creating A Diamond...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Location
    Kingston, Ontario, Canada
    Posts
    74

    Help Please: Creating A Diamond...

    Here's the dilema:

    I need to create a bbunch of diamonds, all clickable, and have them right beside each-other.

    Picture boxes don't work; they're square.

    Shapes wont work; a) they have no diamond, b) they're not clickable.

    I've been getting a headache over this for the last few days, any ideas from the rest of the world?
    To err is human, to really mess up, you need a computer.

  2. #2
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    It is not so hard. I will give u the general idea and u can have a shot at it first. I am off to noddy land soon but will post again tomorrow if u have had no luck.

    Essentially, you have a picture box containing all of the diamonds. Draw them using the Picture.Line tool

    Now u will have used formulae to position and size the diamonds so all u have to do is to measure the X and Y posn in the Picture MouseDown or MouseUp event and see if that X, Y fits within the diamond formula area.
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  3. #3
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    I think also you could use the CombineRgn API call to set your own shapes instead of the square shape. I have no idea how to do it though, or even if that is definately the right API to use. beachbum's idea is probably better.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Location
    Kingston, Ontario, Canada
    Posts
    74
    Well.... You've successfully confused me...
    To err is human, to really mess up, you need a computer.

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    If you wanted to use different objects, and not just drawn shapes, then try this with pictureboxes

    VB Code:
    1. Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINT, _
    2.                                                        ByVal nCount As Long, _
    3.                                                        ByVal nPolyFillMode As Long) _
    4.                                                        As Long
    5. Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, _
    6.                                                     ByVal hRgn As Long, _
    7.                                                     ByVal bRedraw As Boolean) _
    8.                                                     As Long
    9.  
    10. Private Const ALTERNATE = 1
    11. Private Const WINDING = 2
    12.  
    13. Private Type POINT
    14.     x As Long
    15.     y As Long
    16. End Type
    17.  
    18. Private Sub Form_Load()
    19.     Call CreateDiamond(Picture1)
    20. End Sub
    21.  
    22. Private Sub CreateDiamond(pct As PictureBox)
    23. Dim pWidth As Long, pHeight As Long, hRgn As Long
    24. Dim p(0 To 3) As POINT
    25.  
    26.     With pct
    27.         pWidth = (.Width / Screen.TwipsPerPixelX) - 1
    28.         pHeight = (.Height / Screen.TwipsPerPixelY) - 1
    29.        
    30.         p(0).x = pWidth / 2
    31.         p(0).y = 0
    32.         p(1).x = pWidth
    33.         p(1).y = pHeight / 2
    34.         p(2).x = pWidth / 2
    35.         p(2).y = pHeight
    36.         p(3).x = 0
    37.         p(3).y = pWidth / 2
    38.        
    39.         hRgn = CreatePolygonRgn(p(0), 4, ALTERNATE)
    40.         Call SetWindowRgn(.hWnd, hRgn, True)
    41.     End With
    42.  
    43. End Sub

    And there's your diamond.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Location
    Kingston, Ontario, Canada
    Posts
    74
    You kick ass!

    But, the sides that run this way: \ are jagged... any ideas?
    To err is human, to really mess up, you need a computer.

  7. #7
    Junior Member
    Join Date
    Jul 2002
    Location
    Montreal, Québec
    Posts
    20
    Wait wait wait! Wait!! I have the perfect solution!!

    Just create all your controls as rectangles. Align them and everything, so it looks nice. Done? Good. Now... Flip your monitor either 45° to the right, or 45° to the left.

    ...

    /smartassmode. :P

  8. #8
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    Originally posted by RuneLancer
    Wait wait wait! Wait!! I have the perfect solution!!

    Just create all your controls as rectangles. Align them and everything, so it looks nice. Done? Good. Now... Flip your monitor either 45° to the right, or 45° to the left.

    ...

    /smartassmode. :P
    haha

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