Solved

Paint Fill

Posted on 1998-08-27
7
253 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
  • 4
  • 3
7 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 20 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:bradsoblesky
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry about all the trouble. Thanks.
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
No problem.  Glad I could help.  :)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now