PlanetSquires Forums

Support Forums => José Roca Software => Topic started by: Petrus Vorster on August 12, 2022, 05:55:03 PM

Title: Cprint Question
Post by: Petrus Vorster on August 12, 2022, 05:55:03 PM
Hi All

How am I supposed to create the CWSTR to use the Getdefaultprinter function?

It is clear I am missing something in the DIM statement.
I am getting all kinds of errors.
I am not yet clued up on this CWSTR use.

And how would I create a list of printers parsed into a combobox?

Your help will be really appreciated.

-Peter
Title: Re: Cprint Question
Post by: Paul Squires on August 12, 2022, 06:27:19 PM
I am on my Linux machine right now so I can't produce a working example, but the code would look something like this:

' Create an instance of the CPrint class
DIM pPrint AS CPrint

' Call the class method to get the default printer and store it in a dynamic unicode string (CWSTR)
DIM wszDefault AS CWSTR = pPrint.GetDefaultPrinter

' Display the printer name that was returned
PRINT wszDefault

Here is Jose's online documentation for the class that should be the very latest. I also have this documentation built into WinFBE's help system.

https://github.com/JoseRoca/WinFBX/blob/master/docs/Printing/CPrint%20Class.md




Title: Re: Cprint Question
Post by: Paul Squires on August 12, 2022, 06:32:32 PM
To get a list of printer names you would use the EnumPrinterNames method and parse out the CHR(13,10) that separates each entry in the returned CWSTR string. Jose probably already has an example of this somewhere on this site. Not sure.

You would use the AfxParse() function from Jose's library. There are many VERY useful string manipulation functions in his AfxStr.inc file. Here is a list of the functions. Get to know them.  :)
https://github.com/JoseRoca/WinFBX/blob/master/docs/String%20Management/String%20Procedures.md
Title: Re: Cprint Question
Post by: Petrus Vorster on August 12, 2022, 06:46:20 PM
I just missed this : pPrint.GetDefaultPrinter
I am very happy that I got that far already!!!

Thanks a million.

-Peter
Title: Re: Cprint Question
Post by: Petrus Vorster on August 12, 2022, 06:54:44 PM
https://github.com/JoseRoca/WinFBX/blob/master/docs/String%20Management/String%20Procedures.md

That is a lot of work right there.
Without you two I still would be at Print "Hello World".

-Regards, Peter
Title: Re: Cprint Question
Post by: Bumblebee on August 13, 2022, 06:23:04 AM
DIM cws AS CWSTR = AfxStrRetain("abacadabra","b")   ' -> "bb"
DIM cws AS CWSTR = AfxStrRetain("Brigitte Bardot","B")   ' -> "BB"

Sorry, couldn't help myself  ;D
Title: Re: Cprint Question
Post by: Petrus Vorster on August 14, 2022, 01:08:44 PM
 ;D  ;D