?
Solved

Paint Fill

Posted on 1998-08-27
7
Medium Priority
?
260 Views
Last Modified: 2010-04-30
I would like to know how to get the screen to fill or be painted with respect to lines as boundries. Like the paint bucket in MSPaint.
0
Comment
Question by:bradsoblesky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 80 total points
ID: 1431529
The following subroutine will flood from the X-Y point you pass it in the color you pass it:

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

Private Sub FillArea(X As Long, Y As Long, lColor As Long)
  Dim lOldColor As Long
  Dim lFillType As Long
  Dim lRes      As Long
  Const FLOODFILLBORDER = 0  ' Fill until crColor& color encountered.
  Const FLOODFILLSURFACE = 1 ' Fill surface until crColor& color not
                             ' encountered.
  Picture1.FillColor = lColor
  lOldColor = Picture1.Point(X, Y)
  lFillType = FLOODFILLSURFACE
  lRes = ExtFloodFill(Picture1.hdc, X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY, lOldColor, lFillType)
End Sub

0
 

Author Comment

by:bradsoblesky
ID: 1431530
Where do I put each of these? So I click on the picture or form and it does it.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1431531
I would suggest the MouseUp event of the picture control:

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Button = vbLeftButton Then
    'lColor is set elsewhere
    FillArea X, Y, lColor
  End If
End Sub

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bradsoblesky
ID: 1431532
This is not working for me it tells me that lcolor is not defined and something about the part of the sub int "()" is not valid. Help.  

0
 
LVL 6

Expert Comment

by:clifABB
ID: 1431533
You need to define lColor either globally or at module level and assign it a value (it would default to 0 which is black)

In the FillArea procedure, add the following line just before the FillColor line:
  Picture1.FillStyle = vbFSSolid
Finally, in the MouseUp routine, make this small change to the Call to FillArea():
    FillArea CLng(X), CLng(Y), lColor

0
 

Author Comment

by:bradsoblesky
ID: 1431534
Sorry about all the trouble. Thanks.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1431535
No problem.  Glad I could help.  :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question