PUBLIC oform
oform=CREATEOBJECT("form1")
oform.SHOW
DEFINE CLASS form1 AS FORM
AutoCenter = .T.
Height = 158
Width = 327
Caption = "Printer Dialog"
Name = "Form1"
DIMENSION aprintarray[1]
ADD OBJECT combo1 AS COMBOBOX WITH ;
ROWSOURCETYPE = 5, ;
ROWSOURCE = "thisform.aPrintArray", ;
HEIGHT = 25, ;
LEFT = 24, ;
STYLE = 2, ;
TOP = 48, ;
WIDTH = 276, ;
NAME = "Combo1"
ADD OBJECT command1 AS COMMANDBUTTON WITH ;
TOP = 108, ;
LEFT = 48, ;
HEIGHT = 27, ;
WIDTH = 84, ;
CAPTION = "Print Report", ;
DEFAULT = .T., ;
NAME = "Command1"
ADD OBJECT command2 AS COMMANDBUTTON WITH ;
TOP = 108, ;
LEFT = 180, ;
HEIGHT = 25, ;
WIDTH = 84, ;
CANCEL = .T., ;
Enabled = .f.,;
CAPTION = "Cancel", ;
NAME = "Command2"
PROCEDURE combo1.INIT
LOCAL lnI
FOR lnI = 1 TO APRINTERS(THISFORM.aprintarray)
* Note below that you are adding a leading space. This
* prevents a network printer in Windows NT from appearing
* disabled in the combo due the leading "\"
THISFORM.aprintarray[lnI,1] = SPACE(1) + ;
THISFORM.aprintarray[lnI,1]
ENDFOR
* Set initial value of combo
THIS.Requery()
IF '5.0' $ VERSION()
* This sets the combo initial value of the dropdown to the
* default printer - This will not work in 3.0/3.0b since
* SET('PRINTER', 2) is not available
FOR EACH a_element IN THISFORM.aprintarray
IF UPPER(SET('PRINTER',2))$UPPER(a_element)
THIS.Value = a_element
ENDIF
ENDFOR
ELSE
* If in 3.0/3.0b, set to first element in list.
THIS.Value = THISFORM.aprintarray[1]
ENDIF
ENDPROC
PROCEDURE command1.CLICK
SET PRINTER TO NAME (ALLTRIM(THISFORM.combo1.VALUE))
REPORT FORM test TO PRINTER NOCONSOLE
RELEASE THISFORM
ENDPROC
PROCEDURE command2.CLICK
RELEASE THISFORM
ENDPROC
ENDDEFINE