Solved

FloodFill to Printer Cash $

Posted on 1997-07-19
6
278 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 code to programmatically convert pdf to excel 21 70
vb6 connector to SQL Server 2 34
Notepad++ how to remove delimiter : from beggning of the line? 3 94
MsgBox 4 48
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

867 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

25 Experts available now in Live!

Get 1:1 Help Now