Results 1 to 19 of 19

Thread: regions

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Unhappy regions

    HI guys

    how can I manipulate this :
    1-When I click the yellow cube the yellow window comes out ,and clicking the red cube makes the red window do the same .

    2-after ,for example, the red window come out & clicking the button that makes the red cube white one!
    (plz download the attch.)

    I think it's clear now .

    thanx in advance
    Pirate
    Attached Images Attached Images  
    Last edited by Pirate; Oct 19th, 2002 at 06:39 PM.

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    no it's not clear

    are those supposed to be buttons?
    what's the problem? drawing them as regions? or just doing what you said?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    nope . let's say it's imported image and i want to change the color of any cube .Anyway , it's something has to do with mouse position (I got this function but the rest is so hard to).

    Pirate : clear ?
    MrPolite : yes clear Pirate
    Pirate :

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What? You want to dynamically change an imported image? And know what certain boundaries are like the cubes?
    Last edited by Edneeis; Oct 19th, 2002 at 07:58 PM.

  5. #5

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Briefly , I want to change the color of the yellow cube to white one. Can I ?

  6. #6

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I pretend I know the boundaries of the Yellow cube!

  7. #7
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    hmm you could use the floodFill API, but I cant find a way to do this in .NET should be a very easy way
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  8. #8

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I didn't find such API .What about this function :

    Code:
    Declare Function FillRgn Lib "gdi32" Alias "FillRgn" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long
    I'll give it a shot now .

  9. #9
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Here's a VB6 example, see if it helps (probably not)




    Declare Function FloodFill Lib "gdi32" Alias "FloodFill" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long


    VB Code:
    1. Const PS_DOT = 2
    2. Const PS_SOLID = 0
    3. Const RGN_AND = 1
    4. Const RGN_COPY = 5
    5. Const RGN_OR = 2
    6. Const RGN_XOR = 3
    7. Const RGN_DIFF = 4
    8. Const HS_DIAGCROSS = 5
    9. Private Type POINTAPI
    10.     x As Long
    11.     y As Long
    12. End Type
    13. Private Type RECT
    14.     Left As Long
    15.     Top As Long
    16.     Right As Long
    17.     Bottom As Long
    18. End Type
    19. Private Type LOGPEN
    20.     lopnStyle As Long
    21.     lopnWidth As POINTAPI
    22.     lopnColor As Long
    23. End Type
    24. Private Declare Function CreateHatchBrush Lib "gdi32" (ByVal nIndex As Long, ByVal crColor As Long) As Long
    25. Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
    26. Private Declare Function CreatePenIndirect Lib "gdi32" (lpLogPen As LOGPEN) As Long
    27. Private Declare Function CreateRectRgnIndirect Lib "gdi32" (lpRect As RECT) As Long
    28. Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
    29. Private Declare Function ExtractIconEx Lib "shell32.dll" Alias "ExtractIconExA" (ByVal lpszFile As String, ByVal nIconIndex As Long, phiconLarge As Long, phiconSmall As Long, ByVal nIcons As Long) As Long
    30. Private Declare Function FloodFill Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
    31. Private Declare Function FrameRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
    32. Private Declare Function FrameRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    33. Private Declare Function InvertRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long) As Long
    34. Private Declare Function OffsetRgn Lib "gdi32" (ByVal hRgn As Long, ByVal x As Long, ByVal y As Long) As Long
    35. Private Declare Function Pie Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
    36. Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    37. Private Declare Function RoundRect Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
    38. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    39. Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    40. Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
    41. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    42. Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
    43. Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
    44. Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
    45. Private Sub Form_Load()
    46.     'KPD-Team 1998
    47.     'URL: [url]http://www.allapi.net/[/url]
    48.     'E-Mail: [email][email protected][/email]
    49.     Me.ScaleMode = vbPixels
    50. End Sub
    51. Private Sub Form_Paint()
    52.     Dim hHBr As Long, R As RECT, hFRgn As Long, hRRgn As Long, hRPen As Long, LP As LOGPEN
    53.     Dim hFFBrush As Long, mIcon As Long, Cnt As Long
    54.     'Clear the form
    55.     Me.Cls
    56.     'Set the rectangle's values
    57.     SetRect R, 0, 0, Me.ScaleWidth, Me.ScaleHeight
    58.     'Create a new brush
    59.     hHBr = CreateHatchBrush(HS_DIAGCROSS, vbRed)
    60.     'Draw a frame
    61.     FrameRect Me.hdc, R, hHBr
    62.     'Draw a rounded rectangle
    63.     hFRgn = CreateRoundRectRgn(0, 0, Me.ScaleWidth, Me.ScaleHeight, (Me.ScaleWidth / 3) * 2, (Me.ScaleHeight / 3) * 5)
    64.     'Draw a frame
    65.     FrameRgn Me.hdc, hFRgn, hHBr, Me.ScaleWidth, Me.ScaleHeight
    66.     'Invert a region
    67.     InvertRgn Me.hdc, hFRgn
    68.     'Move our region
    69.     OffsetRgn hFRgn, 10, 10
    70.     'Create a new region
    71.     hRRgn = CreateRectRgnIndirect(R)
    72.     'Combine our two regions
    73.     CombineRgn hRRgn, hFRgn, hRRgn, RGN_XOR
    74.     'Draw a frame
    75.     FrameRgn Me.hdc, hRRgn, hHBr, Me.ScaleWidth, Me.ScaleHeight
    76.     'Crete a new pen
    77.     hRPen = CreatePen(PS_SOLID, 5, vbBlue)
    78.     'Select our pen into the form's device context and delete the old pen
    79.     DeleteObject SelectObject(Me.hdc, hRPen)
    80.     'Draw a rectangle
    81.     Rectangle Me.hdc, Me.ScaleWidth / 2 - 25, Me.ScaleHeight / 2 - 25, Me.ScaleWidth / 2 + 25, Me.ScaleHeight / 2 + 25
    82.     'Delete our pen
    83.     DeleteObject hRPen
    84.     LP.lopnStyle = PS_DOT
    85.     LP.lopnColor = vbGreen
    86.     'Create a new pen
    87.     hRPen = CreatePenIndirect(LP)
    88.     'Select our pen into the form's device context
    89.     SelectObject Me.hdc, hRPen
    90.     'Draw a rounded rectangle
    91.     RoundRect Me.hdc, Me.ScaleWidth / 2 - 25, Me.ScaleHeight / 2 - 25, Me.ScaleWidth / 2 + 25, Me.ScaleHeight / 2 + 25, 50, 50
    92.     'Create a new solid brush
    93.     hFFBrush = CreateSolidBrush(vbYellow)
    94.     'Select this brush into our form's device context
    95.     SelectObject Me.hdc, hFFBrush
    96.     'Floodfill our form
    97.     FloodFill Me.hdc, Me.ScaleWidth / 2, Me.ScaleHeight / 2, vbBlue
    98.     'Delete our brush
    99.     DeleteObject hFFBrush
    100.     'Create a new solid brush
    101.     hFFBrush = CreateSolidBrush(vbMagenta)
    102.     'Select our solid brush into our form's device context
    103.     SelectObject Me.hdc, hFFBrush
    104.     'Draw a Pie
    105.     Pie Me.hdc, Me.ScaleWidth / 2 - 15, Me.ScaleHeight / 2 - 15, Me.ScaleWidth / 2 + 15, Me.ScaleHeight / 2 + 15, 20, 20, 20, 20
    106.     'Extract icons from 'shell32.dll' and draw them on the form
    107.     For Cnt = 0 To Me.ScaleWidth / 32
    108.         ExtractIconEx "shell32.dll", Cnt, mIcon, ByVal 0&, 1
    109.         DrawIcon Me.hdc, 32 * Cnt, 0, mIcon
    110.         DestroyIcon mIcon
    111.     Next Cnt
    112.     'Clean up
    113.     DeleteObject hFFBrush
    114.     DeleteObject hRPen
    115.     DeleteObject hRRgn
    116.     DeleteObject hFRgn
    117.     DeleteObject hHBr
    118. End Sub
    119. Private Sub Form_Resize()
    120.     Form_Paint
    121. End Sub
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  10. #10

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    right now

  11. #11

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    thanx for your replay MrPolite.I am changing some values to get my wish .
    another question :

    how can i get the dimensions of any of these cubes (in attach file).?

    thanx
    Attached Images Attached Images  

  12. #12
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    with my knowledge, you cant
    dunno, should be had to get the demention, why do you want it anyways?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  13. #13

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    If get the dimensions of that cube , i would be Bill Gates lol.
    Well , I guess this is the fist step for solving the prob.
    thanx

  14. #14

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Still Unresolved . Any help

  15. #15

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    guys , code in vb6 also acceptable .

  16. #16
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    again, I dont think you would be able to get the dementions of a colored area just by knowing the fact that it exists, at least no easily.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  17. #17

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I believe VB.Net can do more than that !!

  18. #18
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    It's a lie! It's a lie!





























    eeh, I'm not helping at all, I should stop posting
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  19. #19

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I swear it can be done .by vb.

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