Solved

FloodFill to Printer Cash $

Posted on 1997-07-19
6
283 Views
Last Modified: 2012-06-27
Answer this one and I'll pay cash ! True.

I can't get FloodFill API call to work to fill an area on the Printer object. It works properly when filling the screen but not to the printer.
The following code does not work.
Printer.ScaleMode = 3           'MUST DRAW IN PIXELS
Printer.FillStyle = 0           'Set FillStyle to solid.
Printer.FillColor = wallColour  'Set FillColor.
FloodFill Printer.hDC, Printer.CurrentX, Printer.CurrentY, 0

I have tried it with numerous printers and drivers.
The point set at CurrentX CurrentY is not 0 ie Black
But the area is bounded by black line.
wallColour is not black.
0
Comment
Question by:watin
  • 3
  • 3
6 Comments
 

Author Comment

by:watin
ID: 1428546
Edited text of question
0
 
LVL 5

Accepted Solution

by:
y96andha earned 170 total points
ID: 1428547
A device isn't required to support the FloodFill API. Use this code to find out whether a certain device supports FloodFill. You will find that Me.hdc supports floodfill, and at least my printer doesn't.

The documentation on the ExtFloodFill function says: "Only memory device contexts and devices that support raster-display operations support the ExtFloodFill function. To determine whether a device supports this technology, use the GetDeviceCaps function. "


Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Const RC_FLOODFILL = &H1000              '  supports FloodFill
Private Const RASTERCAPS = 38        '  Bitblt capabilities


    If (GetDeviceCaps(Printer.hdc, RASTERCAPS) And RC_FLOODFILL) = RC_FLOODFILL Then
        Print "This device supports FloodFill"
    Else
        Print "This device doesn't support FloodFill"
    End If

0
 

Author Comment

by:watin
ID: 1428548
OK Thanks for the reply.
I realise this but assumed that modern printers must support raster displays.
I will try your test code.
But the real question is What do I do to get the area filled on the printout? It is triangular. ?
Phil
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 5

Expert Comment

by:y96andha
ID: 1428549
If you know the coordinates of the triangle, this code should do it.

Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Type POINTAPI
        x As Long
        y As Long
End Type
Private Const PS_SOLID = 0

Private Sub Command1_Click()
    Dim p(3) As POINTAPI
    Dim brold As Long, brnew As Long
    Dim pold As Long, pnew As Long
    p(1).x = 20
    p(2).x = 50
    p(3).x = 50
    p(1).y = 10
    p(2).y = 10
    p(3).y = 40
    brnew = CreateSolidBrush(RGB(0, 255, 0))
    pnew = CreatePen(PS_SOLID, 0, RGB(0, 0, 255))
    brold = SelectObject(Me.hdc, brnew)
    pold = SelectObject(Me.hdc, pnew)
    Polygon Me.hdc, p(1), 3
    SelectObject Me.hdc, brold
    SelectObject Me.hdc, pold
    DeleteObject brnew
    DeleteObject pnew
End Sub



0
 

Author Comment

by:watin
ID: 1428550
I hate to say this but I am using VB 3.0 and the application must run in 16bits. So I can't use the GDI32 library !
Sorry I didn't mention this but most of the target users are running  win3.1.
I'm pretty sure the 16bit GDI doesn't have Polygon ?
Calling the GDI32 from VB3 gives file not found even when running on 95.
Oh well. that's where I'm at now.
I have to present the program and the printout without the triangles filled to about 50 users this Saturday 26th.
HELP !!

My email is watin@hunterlink.net.au

0
 
LVL 5

Expert Comment

by:y96andha
ID: 1428551
I just checked, and Polygon does exist in Win 3.1. The only problem is that I don't have VB 3.0, only the C declarations of the functions, so I won't be able to test it.

I have tried to convert the code to 16-bit Windows equivalents. You can e-mail me on andreas.hansson@mbox303.swipnet.se if you need to reach me.


Declare Function Polygon Lib "gdi" (ByVal hdc As Integer, lpPoint As POINTAPI, ByVal nCount As Integer) As Integer

Declare Function SelectObject Lib "gdi" (ByVal hdc As Integer, ByVal hObject As Integer) As Integer

Declare Function CreateSolidBrush Lib "gdi" (ByVal crColor As Long) As Integer

Declare Function DeleteObject Lib "gdi" (ByVal hObject As Integer) As Integer

Declare Function CreatePen Lib "gdi" (ByVal nPenStyle As Integer, ByVal nWidth As Integer, ByVal crColor As Long) As Integer

Type POINTAPI
 x As Integer
 y As Integer
End Type
Const PS_SOLID = 0

Private Sub Command1_Click()
 Dim p(3) As POINTAPI
 Dim brold As Integer, brnew As Integer
 Dim pold As Integer, pnew As Integer
 p(1).x = 20
 p(2).x = 50
 p(3).x = 50
 p(1).y = 10
 p(2).y = 10
 p(3).y = 40
 brnew = CreateSolidBrush(RGB(0, 255, 0))
 pnew = CreatePen(PS_SOLID, 0, RGB(0, 0, 255))
 brold = SelectObject(Me.hdc, brnew)
 pold = SelectObject(Me.hdc, pnew)
 Polygon Me.hdc, p(1), 3
 SelectObject Me.hdc, brold
 SelectObject Me.hdc, pold
 DeleteObject brnew
 DeleteObject pnew
End Sub

0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

821 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