|
Home > Archive > Programming with dBASE > February 2006 > chooseprinter() on my form.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
chooseprinter() on my form.
|
|
| Paul Robichaud 2006-02-16, 9:23 am |
| In dbaseplus, when you chooseprinter(), it opens a new window on top of my
form. Is there a way to make this window, part of my form ?
ie: on my password screen, show chooseprinter on same form/screen.
thanks
Paul
| |
| Ken Mayer [dBVIPS] 2006-02-16, 9:23 am |
| Paul Robichaud wrote:
> In dbaseplus, when you chooseprinter(), it opens a new window on top of my
> form. Is there a way to make this window, part of my form ?
>
> ie: on my password screen, show chooseprinter on same form/screen.
Not that I'm aware of. The ChoosePrinter() screen is not something you
have that kind of control over. However, you can create your own, just
like with a login screen, and set the values for a report by querying
the information returned ... it's not that easy, as you have to get
information out of the registry for printers available. However, if you
check the dUFLP, I think you'll find some of that is available to you.
Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/
*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/dbase/dBASEBook.htm
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
| |
| Jan Hoelterling 2006-02-16, 9:23 am |
| Paul, I generally only let the user choose the printer name (most of the
other options are "fixed" for the printout). For this purpose, I have a
custom Combobox with this method:
function getPrinterChoices
local winstd,x,aprinters,i
winstd = "Windows Standard"
aprinters=new array()
x = new OleAutoClient("WScript.Network")
oPrinters = x. EnumPrinterConnectio
ns()
for i = 0 to oPrinters.count() -1 step 2
aprinters.add(oPrinters.Item(i+1))
next i
aprinters.sort(1)
this.printers = new array()
this.printers.add(winstd)
for i=1 to aprinters.size
this.printers.add(aprinters[i])
next
return(this.printers)
Where I use this ComboBox, I add these two lines to the Form_onOpen
// ChosenPrinter is the name of the ComboBox
form.chosenprinter.getprinterchoices()
form.chosenprinter.datasource = "array form.chosenprinter.printers"
Hope this helps,
Jan
| |
| Paul Robichaud 2006-02-16, 9:23 am |
| trying it like this on a test form, I get the following error:
variasble undefined: getprinterchoices
what am I doing wrong (again) ?
thanks
Paul
"Jan Hoelterling" <jan@hoelterling.com> wrote in message
news:ajSsfMwMGHA.2320@news-server...
> Paul, I generally only let the user choose the printer name (most of the
> other options are "fixed" for the printout). For this purpose, I have a
> custom Combobox with this method:
>
> function getPrinterChoices
> local winstd,x,aprinters,i
> winstd = "Windows Standard"
> aprinters=new array()
> x = new OleAutoClient("WScript.Network")
> oPrinters = x. EnumPrinterConnectio
ns()
> for i = 0 to oPrinters.count() -1 step 2
> aprinters.add(oPrinters.Item(i+1))
> next i
> aprinters.sort(1)
> this.printers = new array()
> this.printers.add(winstd)
> for i=1 to aprinters.size
> this.printers.add(aprinters[i])
> next
> return(this.printers)
>
> Where I use this ComboBox, I add these two lines to the Form_onOpen
> // ChosenPrinter is the name of the ComboBox
> form.chosenprinter.getprinterchoices()
> form.chosenprinter.datasource = "array
> form.chosenprinter.printers"
>
> Hope this helps,
>
> Jan
>
| |
| Jan Hoelterling 2006-02-16, 11:23 am |
| Copy all of the below into a single file and run (watch for line breaks):
Jan
** END HEADER -- do not remove this line
//
// Generated on 02/16/2006
//
parameter bModal
local f
f = new PaulPrintersForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class PaulPrintersForm of FORM
with (this)
onOpen = class::FORM_ONOPEN
metric = 6 // Pixels
height = 94
left = 259
top = 90
width = 224
text = ""
endwith
this.CHOSENPRINTER = new JHCOMBOBOX(this)
with (this.CHOSENPRINTER)
height = 22
left = 26
top = 37
width = 172
endwith
this.TEXTLABEL1 = new TEXTLABEL(this)
with (this.TEXTLABEL1)
height = 22
left = 24
top = 13
width = 120
text = "Available Printers:"
endwith
function form_onOpen
form.chosenprinter.getprinterchoices()
form.chosenprinter.datasource = "array form.chosenprinter.printers"
return
endclass
// Encapsulate the method in a generic Combobox class that
// we can re-use
class JHCOMBOBOX(parentObj
) of COMBOBOX(parentObj) custom
with (this)
style = 2 // DropDownList
dropDownHeight = 132
fontSize = 8
endwith
function enable
this.when={|| true}
this.colorNormal = "Windowtext/window"
this.mousepointer=0
this.fakeenabled=true
if this.dosetfocus
clear typeahead
this.setfocus()
endif
return
function disable
this.when={|| true}
this.colorNormal = "Windowtext/0xd9d9d9"
this.mousepointer=1
if this.dosetfocus
if this.fakeenabled=true
this.setfocus()
keyb(chr(9))
this.fakeenabled=false
endif
endif
this.when={|| false}
return
function getPrinterChoices
local winstd,x,aprinters,i
winstd = "Windows Standard"
aprinters=new array()
x = new OleAutoClient("WScript.Network")
oPrinters = x. EnumPrinterConnectio
ns()
for i = 0 to oPrinters.count() -1 step 2
aprinters.add(oPrinters.Item(i+1))
next i
aprinters.sort(1)
this.printers = new array()
this.printers.add(winstd)
for i=1 to aprinters.size
this.printers.add(aprinters[i])
next
return(this.printers)
endclass
| |
| Paul Robichaud 2006-02-16, 1:23 pm |
| works great !
thanks alot.
Paul
"Jan Hoelterling" <jan@hoelterling.com> wrote in message
news:sqDaQoxMGHA.1152@news-server...
> Copy all of the below into a single file and run (watch for line breaks):
>
> Jan
>
>
> ** END HEADER -- do not remove this line
> //
> // Generated on 02/16/2006
> //
> parameter bModal
> local f
> f = new PaulPrintersForm()
> if (bModal)
> f.mdi = false // ensure not MDI
> f.readModal()
> else
> f.open()
> endif
>
> class PaulPrintersForm of FORM
> with (this)
> onOpen = class::FORM_ONOPEN
> metric = 6 // Pixels
> height = 94
> left = 259
> top = 90
> width = 224
> text = ""
> endwith
>
> this.CHOSENPRINTER = new JHCOMBOBOX(this)
> with (this.CHOSENPRINTER)
> height = 22
> left = 26
> top = 37
> width = 172
> endwith
>
> this.TEXTLABEL1 = new TEXTLABEL(this)
> with (this.TEXTLABEL1)
> height = 22
> left = 24
> top = 13
> width = 120
> text = "Available Printers:"
> endwith
>
>
> function form_onOpen
> form.chosenprinter.getprinterchoices()
> form.chosenprinter.datasource = "array form.chosenprinter.printers"
> return
> endclass
> // Encapsulate the method in a generic Combobox class that
> // we can re-use
> class JHCOMBOBOX(parentObj
) of COMBOBOX(parentObj) custom
>
> with (this)
> style = 2 // DropDownList
> dropDownHeight = 132
> fontSize = 8
> endwith
>
> function enable
> this.when={|| true}
> this.colorNormal = "Windowtext/window"
> this.mousepointer=0
> this.fakeenabled=true
> if this.dosetfocus
> clear typeahead
> this.setfocus()
> endif
> return
>
> function disable
> this.when={|| true}
> this.colorNormal = "Windowtext/0xd9d9d9"
> this.mousepointer=1
> if this.dosetfocus
> if this.fakeenabled=true
> this.setfocus()
> keyb(chr(9))
> this.fakeenabled=false
> endif
> endif
> this.when={|| false}
> return
>
> function getPrinterChoices
> local winstd,x,aprinters,i
> winstd = "Windows Standard"
> aprinters=new array()
> x = new OleAutoClient("WScript.Network")
> oPrinters = x. EnumPrinterConnectio
ns()
> for i = 0 to oPrinters.count() -1 step 2
> aprinters.add(oPrinters.Item(i+1))
> next i
> aprinters.sort(1)
> this.printers = new array()
> this.printers.add(winstd)
> for i=1 to aprinters.size
> this.printers.add(aprinters[i])
> next
> return(this.printers)
> endclass
>
| |
| Jan Hoelterling 2006-02-16, 1:23 pm |
| Glad to help!
Jan
|
|
|
|
|