CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2002
    Posts
    3

    Paint an irregular shape

    How can I paint an irregular shape (no boxes, no circles,); when the program is running makes these shapes with lines using LINE(X,Y)-(X2,Y2).....I want the program paint these solids....I made a program to simulate the movement of a mechanism....I need those solids filled of color.


  2. #2
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Paint an irregular shape

    Check the API FloodFill and ExtFloodFill. They allow you to fill a region of DC with a color specified by the border...

    RK

  3. #3
    Join Date
    Feb 2002
    Posts
    3

    Re: Paint an irregular shape

    These days I tried to use API, according to your tip, but it's my first time.
    And I receive a lot error messages...syntax error...function colorref not defined...function uint not defined.....Don't you mind if I ask you, say me, which conditions I have to follow to use ExtFloodFill....declarations, modules, types,..anything .
    I REALLY APPRECIATE YOUR HELP..THANKS A LOT



  4. #4
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Paint an irregular shape

    Hi, here is what you need:

    'in the declarations:
    private Declare Function ExtFloodFill Lib "gdi32" _
    (byval hdc as Long, byval X as Long, _
    byval Y as Long, byval crColor as Long, _
    byval wFillType as Long) as Long



    'then in the routine to floodfill:
    ExtFloodFill YourControl.hdc, X, Y, TheColorOfTheOutline, 0&

    ' the X and Y coords are in pixels, not twips!!! typically, anywhere inside the shape will do.



    Let me know how it goes.

    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  5. #5
    Join Date
    Feb 2002
    Posts
    3

    Re: Paint an irregular shape

    I try the code that you sent me, it doesn't fail, but does nothing....
    may be my problem is that my shape is a different screen, where the API works...I try some API samples, but all of them create an object ellipse, circle (in a different way than using CIRCLE(X,Y)...)
    in the screen I have my drawing the closest result is with FILLCOLOR and FILLSTYLE, but it fills CIRCLES(X,Y)..doesn't detect my shape....until know, with API, I only can fill with color circles, ellipses, created inside the API ... I REALLY APPRECIATE YOUR HELP


  6. #6
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Paint an irregular shape

    First, make sure the FillStyle for your picturebox or whatever is set to Solid. Also, make sure the X and Y coords for the api are in pixels, even if you are using twips for the shape. You may also have to set AutoRefresh to True. Be sure to use the real color value, not a system color value. Let me know how it goes.

    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

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

Featured