Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer Control Issue

Status
Not open for further replies.

Irwin

IS-IT--Management
Jan 21, 2002
25
US
I can use some help with printer controls. Currently the application I work with uses the &quot;SET DEVICE TO PRINT PROMPT&quot; which brings up the windows printer selection dialog box. Does anyone know of a way to disable the <CANCEL> button? Any help would be appreciated. Thank you in advance for your help.
 
Irwin

I believe you would have to create your own PrintDialog form and not put a cancel button. BTW There are ways to detect if the user hit the cancel button in the Common Dialog Activex if it would be easier. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Irwin

I just have the thing for you, stored in my utilities somewhere, you will notice the cancel button is disabled. You can use this:
Code:
   PUBLIC oform
   oform=CREATEOBJECT(&quot;form1&quot;)
   oform.SHOW
   DEFINE CLASS form1 AS FORM
      AutoCenter = .T.
      Height = 158
      Width = 327
      Caption = &quot;Printer Dialog&quot;
      Name = &quot;Form1&quot;
      DIMENSION aprintarray[1]
      ADD OBJECT combo1 AS COMBOBOX WITH ;
          ROWSOURCETYPE = 5, ;
          ROWSOURCE = &quot;thisform.aPrintArray&quot;, ;
          HEIGHT = 25, ;
          LEFT = 24, ;
          STYLE = 2, ;
          TOP = 48, ;
          WIDTH = 276, ;
          NAME = &quot;Combo1&quot;
      ADD OBJECT command1 AS COMMANDBUTTON WITH ;
          TOP = 108, ;
          LEFT = 48, ;
          HEIGHT = 27, ;
          WIDTH = 84, ;
          CAPTION = &quot;Print Report&quot;, ;
          DEFAULT = .T., ;
          NAME = &quot;Command1&quot;
      ADD OBJECT command2 AS COMMANDBUTTON WITH ;
          TOP = 108, ;
          LEFT = 180, ;
          HEIGHT = 25, ;
          WIDTH = 84, ;
          CANCEL = .T., ;
          Enabled = .f.,;
          CAPTION = &quot;Cancel&quot;, ;
          NAME = &quot;Command2&quot;
      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 &quot;\&quot;
              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
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,

Thank you for your help. I think this may do the trick.

Irwin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top