To Mike D Sutton 
Author Message
 To Mike D Sutton

Can you help me with this?

I make a object like a progressbar using 2 shapes, this is for a report os
my app, how can I print these shapes like it is showed in the form???

thanks



Thu, 12 May 2005 22:58:06 GMT  
 To Mike D Sutton

Quote:
> I make a object like a progressbar using 2 shapes, this is for a report os
> my app, how can I print these shapes like it is showed in the form???

I was hoping someone else was going to give you a more definitive answer to
your previous post before I jumped in (I'm really no expert when it comes to
printing) however here's a couple of things you could try:  Either draw your
progress bar to a picture box and print the picture box or draw it directly
to the printers .hDC.  The latter requires you to use the API's shape
drawing methods which you'll find explained in the later chapters of the
"Basic introduction to graphics programming in VB" tutorial on my site, and
wrapped up for you in the APIDraw library.  You've not said much about how
the report is generated though so these options may not be of any use to
you.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Fri, 13 May 2005 00:05:17 GMT  
 To Mike D Sutton

Quote:
> I make a progreebar using 2 shapes, see the picture, and I need to print
> this progressbar exactly how it is showed in the app.

This is just two rectangles, using pure VB on a picture box you could use:

'***
Dim Perc As Long
Perc = 65 '%

With Picture1 ' Set up canvas
    .AutoRedraw = True
    .ScaleMode = vbPixels
    .FillColor = vbWhite
    .FillStyle = vbFSSolid
    .BorderStyle = 0

    ' Draw background
    Picture1.Line (0, 0)-(.ScaleWidth - 1, _
        .ScaleHeight - 1), vbBlack, B

    .FillColor = vbBlue ' Draw bar
    Picture1.Line (0, 0)-((.ScaleWidth - 1) * _
        (Perc / 100), .ScaleHeight - 1), vbBlack, B
End With
'***

Or you could use the APIDraw library off my page with this code:

'***
Dim Perc As Long
Perc = 65 '%

With Picture1 ' Set up canvas
    .AutoRedraw = True
    .ScaleMode = vbPixels
    .BorderStyle = 0

    ' Draw background
    Call DrawDCRect(.hdc, NewPointAPI(0, 0), _
        NewPointAPI(.ScaleWidth, .ScaleHeight))

    ' Draw bar
    Call DrawDCRect(.hdc, NewPointAPI(0, 0), _
        NewPointAPI(.ScaleWidth * (Perc / 100), _
        .ScaleHeight), vbBlue)
End With
'***

It will scale itself to the size of the picture box, declare and set "Perc"
(Percentage) outside the routine or pass it as a parameter to the function.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Fri, 13 May 2005 06:07:40 GMT  
 To Mike D Sutton
Thank you!!

but I got an error message when I try to use Printer.PaintPicture Picture1,
x, y

do you have a sugestion?
thanks



Quote:
> Can you help me with this?

> I make a object like a progressbar using 2 shapes, this is for a report os
> my app, how can I print these shapes like it is showed in the form???

> thanks



Fri, 13 May 2005 06:16:04 GMT  
 To Mike D Sutton

Quote:
> but I got an error message when I try to use Printer.PaintPicture
Picture1,
> x, y

You've not told us what error you're receiving (Or if there was no error but
it just didn't work) so it makes it a bit tricky to debug the problem,
however try these two methods:
Either use the .Image property exclusively:

'***
Call Printer.PaintPicture(Picture1.Image, 1, 1)
'***

Alternatively try the BitBlt() API call:

'***
' First add the declare in General: declarations
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _
    ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _
    ByVal nHeight As Long, ByVal hSrcDC As Long, _
    ByVal xSrc As Long, ByVal ySrc As Long, _
    ByVal dwRop As Long) As Long

' ...

' Then this code to your output module
Dim SrcX As Long, SrcY As Long

SrcX = Picture1.ScaleX(Picture1.Image.Width, vbHimetric, vbPixels)
SrcY = Picture1.ScaleY(Picture1.Image.Height, vbHimetric, vbPixels)

Call BitBlt(Printer.hDC, 1, 1, SrcX, SrcY, Picture1.hDC, 0, 0, vbSrcCopy)
'***

If you still get an error post the error text here too.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Fri, 13 May 2005 15:43:28 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. one for Mike Sutton

2. WordXP Open DS for MailMerge

3. problem with BindingContext(Ds).EndCurrentEdit()

4. Active DS Type Library

5. System.Drawing.SafeNativeMethods

6. Does ds.execute throw error properly?

7. Ds.Updatable is always false

8. ds.Move (move to row)

9. OLE Server sample not working (DS.VBP/THINGTST.VBP)

10. Help - How to make docking forms/toolbars like in VB5 IDE/DS IDE

11. OLE Server sample not working (DS.VBP/THINGTST.VBP)

12. ds

 

 
Powered by phpBB® Forum Software