Karl-Heinz ,
The signature is really not that important I think. This will most likely be used by people that have many, many untyped variables, so whatever you do, there will always be a runtime check needed.
If you declare the parameter as __FoxArray and a USUAL variable is used then there will be an automatic runtime error when the usual is of the incorrect type. When you do not declare it then you can have more control over the error message.
W.r.t. INT or DWORD: I personally prefer INT over DWORD, because signed ints are less likely to cause numeric overflows when you accidentally subtract 1 from a value of 0. This may happen in downto loops.
For unsigned ints you always have to be careful and have to consider if code is being compiled with overflow checking enabled or disabled.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
FUNCTION APrinters ( ArrayName , nValue) AS INT CLIPPER
LOCAL cPrinterName AS STRING
LOCAL iCount AS INT
LOCAL oSearcher AS ManagementObjectSearcher
Default ( @nValue , 0 )
IF ( iCount := PrinterSettings:InstalledPrinters.Count ) > 0
IF ! IsArray( ArrayName ) .or. ( IsArray ( ArrayName ) .and. ! ArrayName IS __FoxArray )
THROW ArgumentException {"parameter must be a Fox Array", nameof ( ArrayName ) }
ELSEIF ! IsNumeric ( nValue )
THROW ArgumentException {"wrong parameter type, must be numeric", nameof ( nValue ) }
ELSEIF nValue < 0 .or. nValue > 1
THROW ArgumentException {"parameter value must be either 0 or 1", nameof ( nValue ) }
ENDIF
i also added a GetPrinter() function. The VFP GetPrinter() dialog doesn´t show e.g. "print rage" and "copies" groupboxes ás the .net PrinerDialog does. But OOB the .net Printerdialog can´t be customized to get a more VFP compatible appearance. i think: "better that than nothing"
regards
Karl-Heinz
Attachments
[The extension viaef has been deactivated and can no longer be displayed.]
IMO, trying to use the .net PrinterDialog to mimic the dialog that VFP opens when the GetPrinter() is called doesn´t make sence. Attached is a core winform viaef that might be a replacement. Of course the text you see is not yet regionalzied, but as a quick view i attached two images. Fox.png shows the VFP dialog, and mine.png my dialog . For the moment the "Status" description shows numbers only. It would be interesting to know which other values than 3 do you see when you run the app.
btw. Chris, it´s a real pleasure to build winforms with XIDE !
regards
Karl-Heinz
Attachments
[The extension viaef has been deactivated and can no longer be displayed.]
Glad you like it Karl-Heinz! Thanks for the code as well, I'm just not qualified to comment on what should be used, I'll just let Fox designers and/or Robert to decide on this.
1. Instead of a number you´ll see now one of the following values. However, I don't know if these descriptions match the descriptions that an english windows displays by default.
robert wrote:Karl Heinz,
Thanks. I will have a look at this after the weekend.
Robert
i noticed that the APrinters() function uses a wrong property. In the APrinters() sources the property name "Description" must be changed to "Comment".
Is it already known that there´s a VFP GetPrinter() "easter egg" ?
1. start VFP
2. Enter in the command window "? GetPrinter()"
3. As expected, the focus is set to the combobox. Now press the <Tab> and then the <Space> or <Enter> key. Magic, isn't it . There seems to be a hidden, but not disabled [Properties] button. I tried to open the additional dialog by mouse clicks inside the dialog area, but I did not succeed.
.
regards
Karl-Heinz