Solved

FloodFill to Printer Cash $

Posted on 1997-07-19
6
275 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
Comment Utility
Edited text of question
0
 
LVL 5

Accepted Solution

by:
y96andha earned 170 total points
Comment Utility
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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 5

Expert Comment

by:y96andha
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…

771 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

10 Experts available now in Live!

Get 1:1 Help Now