PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4 5 ... 12

Author Topic: José, if you're bored...  (Read 5152 times)

José Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: José, if you're bored...
« Reply #30 on: August 08, 2018, 02:31:50 PM »

GDI+ would be one of the best options to draw the memory bitmap because you can use any kind of fonts and color, draw images and text, and also make it DPI aware (in this case PPI aware), getting the same results no matter the resolution of the printer. Of course, the users will have to learn to use GDI+, but with it you can go much more far than with the few XPRINT GDI methods to draw lines of boxes.

José Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: José, if you're bored...
« Reply #31 on: August 08, 2018, 02:49:09 PM »

> Not sure that a Print Preview would be an absolute necessity but it would be cool also.

Because I'm a lazy Mediterranean enduring a very hot summer, I try to use more my mind that my fingers. Therefore, I'm thinking of Base64 encode these memory bitmaps, add them to a web page built on the fly and display them in the Preview of Internet Explorer (it can be called separately using COM without having to launch IE).
« Last Edit: August 08, 2018, 02:50:52 PM by José Roca »
Logged

José Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: José, if you're bored...
« Reply #32 on: August 08, 2018, 03:25:05 PM »

A pity that no one else participates. Later, when they will try to use the framework, they will be more lost than a prawn in the desert. There are so many wrappers that the only way is to practice with them little by little and step by step. Testing is also essential to bring to light possible bugs and make suggestions.

SeaVipe

  • FireFly3 User
  • Junior Member
  • *
  • Posts: 129
  • Windows 10
Re: José, if you're bored...
« Reply #33 on: August 08, 2018, 04:14:36 PM »

Hi José,
I've been working with CTime64 and I must say that it was a bit of a learning curve at first but once I had the basics figured out it all started to fall into place.
Initially WinFBE crashed repeatedly but that was just me not understanding what I was doing (not that I do now). I'm using snippets of code from a large FireFly project that utilizes Format() to display dates and time in a specific format like "08-Aug-2018" and "01:23:45". As suggested, I reviewed the Microsoft documentation on-line; the following (from the example) not only works but is much more elegant than my earlier code:
Code: [Select]
DIM ct AS CTime64

ct = ct.GetCurrentTime()

ct.Format("%Y-%m-%d")
I need print functions so that is my next challenge.
Thanks for all your hard work, José, this is really good stuff!
Logged
Clive Richey

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: José, if you're bored...
« Reply #34 on: August 08, 2018, 04:22:50 PM »

Because I'm a lazy Mediterranean enduring a very hot summer, I try to use more my mind that my fingers.

LOL, that made me smile :)
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: José, if you're bored...
« Reply #35 on: August 08, 2018, 04:26:20 PM »

A first try.

The idea is to create an instance of the CPrint class and attach a printer to it with AttachPrinter or ChoosePrinter.

Code: [Select]
'#CONSOLE ON
#define UNICODE
#INCLUDE ONCE "Afx/CPrint.inc"
USING Afx

DIM pPrint AS CPrint
pPrint.AttachPrinter("Bullzip PDF Printer")

Then we can use the CMemBmp class to create a memory bitmap (with the dimensions returned by the GetHorizontalResolution and GetVerticalResolution methods of the CPrint class), draw its contents using GDI or GDI+ and send it to the PrintBitmap method.

For documents with more than one page, we could build an array of memory bitpamps and send it to a future new method of the CPrint class that will print them.

Holy smokes! Awesome! I have saved the class and started looking through it. I have access to a few different types of printers so I will test them to see how the class reacts. Great job  :)
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

José Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: José, if you're bored...
« Reply #36 on: August 08, 2018, 07:40:30 PM »

Hi José,
I've been working with CTime64 and I must say that it was a bit of a learning curve at first but once I had the basics figured out it all started to fall into place.
Initially WinFBE crashed repeatedly but that was just me not understanding what I was doing (not that I do now). I'm using snippets of code from a large FireFly project that utilizes Format() to display dates and time in a specific format like "08-Aug-2018" and "01:23:45". As suggested, I reviewed the Microsoft documentation on-line; the following (from the example) not only works but is much more elegant than my earlier code:
Code: [Select]
DIM ct AS CTime64

ct = ct.GetCurrentTime()

ct.Format("%Y-%m-%d")
I need print functions so that is my next challenge.
Thanks for all your hard work, José, this is really good stuff!


This is what everybody interested in using my framework should do. You don't need to learn everything, but you should become familiar in what interests you for future use and try it.

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: José, if you're bored...
« Reply #37 on: August 08, 2018, 08:48:42 PM »

I think that if people would just browse your library and then compare it to their own code they'll see that they have been missing out on a vast array of incredibly useful functionality. 

I bet that if a user took your library and did this one thing (this is what I did)....... convert their existing program to be fully unicode and high dpi aware..... then they'd instantly see the benefit of your library and the universality it opens up across the winapi and languages across the world. I will never write anything anymore that is not fully unicode by default nor high dpi aware. These are two core things that Jose himself and his code has taught me. The CWSTR dynamic unicode string class alone is worth its weight in gold.

Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

SeaVipe

  • FireFly3 User
  • Junior Member
  • *
  • Posts: 129
  • Windows 10
Re: José, if you're bored...
« Reply #38 on: August 08, 2018, 09:20:17 PM »

Indeed,A few examples would be helpful. I spent hours trying to figure out how to get a handle to a bitmap just so I could try CPrint (which is going to be very useful). Looking forward to Print Preview.
I got stumped here:
Code: [Select]
    Dim as ???? h
    Dim as boolean b = pPrint.PrintBitmap ( _
        wsz, _
        h, _
        FALSE, _
        InterpolationModeHighQualityBicubic )
The above returns False as h is not defined.
Logged
Clive Richey

José Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: José, if you're bored...
« Reply #39 on: August 08, 2018, 10:31:00 PM »

CPrint is still preliminary work. I have made an small test using a PDF printer driver and the PrintBitmap method is not working well yet. It would have been a miracle if I had got everything right at the first try.

Code: [Select]
'#CONSOLE ON
#define UNICODE
#INCLUDE ONCE "Afx/CPrint.inc"
#INCLUDE ONCE "Afx/CMemBmp.inc"
USING Afx

DIM pPrint AS CPrint
pPrint.AttachPrinter("Bullzip PDF Printer")
DIM pMemBmp AS CMemBmp = CMemBmp("MyImage.jpg")
pPrint.PrintBitmap("Test", pMemBmp.GethBmp)

PRINT
PRINT "Press any key..."
SLEEP

José Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: José, if you're bored...
« Reply #40 on: August 08, 2018, 10:39:16 PM »

This works, so the problem must be in CMemBmp when loading an image.

Code: [Select]
'#CONSOLE ON
#define UNICODE
#INCLUDE ONCE "Afx/CPrint.inc"
#INCLUDE ONCE "Afx/CMemBmp.inc"
USING Afx

DIM pPrint AS CPrint
pPrint.AttachPrinter("Bullzip PDF Printer")
DIM pMemBmp AS CMemBmp = CMemBmp(pPrint.GetHorizontalResolution, pPrint.GetVerticalResolution)
Rectangle pMemBmp.GetMemDC, 10, 10, 150, 150
LineTo pMemBmp.GetMemDC, 30, 180
pPrint.PrintBitmap("Test", pMemBmp.GethBmp)

PRINT
PRINT "Press any key..."
SLEEP

José Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: José, if you're bored...
« Reply #41 on: August 09, 2018, 12:13:54 AM »

Not sure which is the problem with CMemBmp when loading an image from a file, but if you just want to load a file and print it, this works:

Code: [Select]
'#CONSOLE ON
#define UNICODE
#INCLUDE ONCE "Afx/CPrint.inc"
#INCLUDE ONCE "Afx/AfxGdiplus.inc"
USING Afx

AfxSetProcessDPIAware
DIM pPrint AS CPrint
pPrint.AttachPrinter("Bullzip PDF Printer")
DIM wszFileName AS WSTRING * MAX_PATH = ExePath & "\VEGA_PAZ_01.jpg"
pPrint.PrintBitmap("Test", AfxGdipBitmapFromFile(wszFileName))

PRINT
PRINT "Press any key..."
SLEEP

José Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: José, if you're bored...
« Reply #42 on: August 09, 2018, 02:27:41 AM »

New file. I had forgot to delete the graphic object in the PrintBitmap method.

Joerg Buckel

  • FireFly3 Registered User
  • Junior Member
  • *
  • Posts: 52
  • FF3 and WinFBE+WinFBX User
Re: José, if you're bored...
« Reply #43 on: August 09, 2018, 08:36:00 AM »

Hello José
Thank you for your tirelessness in taking up and implementing new ideas. What you do for the FreeBasic community is indescribable for me. Your WinFBX offers possibilities in programming for everyone, which are normally only available to professionals with corresponding experience. Maybe the feedback doesn't come in the crowd. Maybe it's because your level needs to be understood first. Well, I can't.
Thank you again.
Logged
Greeting from Germany

Joerg

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: José, if you're bored...
« Reply #44 on: August 09, 2018, 08:39:14 AM »

I'm working on doing the conversion of the FB file handling routines to your stream classes. Not sure if I'll get to the print class today but I'll try.

Using the WinFBX help file, I'm thinking that you might need to explain what the HRESULT code is. I remember it from your COM programming but I'm not sure if others would readily identify it. Maybe put a hyperlink in the help file to a general page that describes HRESULT and lists some common codes like are specified at https://docs.microsoft.com/en-us/windows/desktop/seccrypto/common-hresult-values

I realize that your GetErrorInfo will return an empty string if no error but it is cleaner to do an inline error result check when opening a file. Like this:

   dim pStream AS CTextStream
   if pStream.OpenUnicode(wszFileName, IOMode_ForReading) <> S_OK then exit function

Maybe even if you indicate that the Return Value of Open/OpenUnicode is a non-zero HRESULT value. At least then users can do this:

   if pStream.OpenUnicode(wszFileName, IOMode_ForReading) <> 0 then exit function

Just a suggestion... as I think of stuff when I'm working through the conversion, I'll post them for you to consider.

Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor
Pages: 1 2 [3] 4 5 ... 12