?
Solved

FloodFill to Printer Cash $

Posted on 1997-07-19
6
Medium Priority
?
302 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
[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
  • 3
  • 3
6 Comments
 

Author Comment

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

Accepted Solution

by:
y96andha earned 510 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
Technology Partners: 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!

 
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

Industry Leaders: 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!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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.
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…
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 Month9 days, 19 hours left to enroll

762 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