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
Solved

FloodFill to Printer Cash $

Posted on 1997-07-19
6
286 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

856 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