Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Choose Printer Dialog

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Choose Printer Dialog

    Please direct comments to:
    http://www.powerbasic.com/support/pb...ad.php?t=36615


    '
    Code:
    #Compile Exe  
    #Include "WIN32API.INC"
     
     
     
    '********************************************************************
    '********************************************************************
    '*******     Choose Printer Dialog **********************************
    '********************************************************************
    '*******  by Gösta H. Lovgren March 2008 ****************************
    '********************************************************************
    '********************************************************************
    '
    ''             adapted from the Help File  
    '
     
     
     
    CallBack Function z_CB_Printer As Long
      Global hdlg_printer As Dword  
      Global Printer_Btns%(), Printer_Btn_Labels$()
      Global g_Parameters_Prnter  As Asciiz * 250
     
        Select Case CbMsg     'This is TO determine the message TYPE 
          '       
          Case %WM_INITDIALOG'<- Initialiaton when the program loads 
          '
          Case %WM_COMMAND  'This processes command messages
            Select Case CbCtl    'Determine which CONTROL sending message
               Case 1700 To 1799
                  g_Parameters_Prnter = Printer_Btn_Labels$(CbCtl - 1700)
                 Dialog Set Text CbHndl, g_Parameters_Prnter
            End Select      
        End Select
    End Function
    '*********************************
    '
    Sub z_Choose_Printer
    '  Common_Locals
      Local ctr&, wdth&, hght&, stile&   
      Local hdlg, hDlg_Printer As Dword   
      Local Btn_Width&, Btn_Height&, row&, col&
      Local caption$                  
      
      If Len(g_Parameters_Prnter) < 1 Then
         g_Parameters_Prnter = "No Printer Chosen Yet"
      End If
      
      wdth = Len(g_Parameters_Prnter) * 6
      For ctr = 1 To PrinterCount
         ReDim Preserve Printer_Btns%(1 To ctr), _
                        Printer_Btn_Labels$(1 To ctr)
         Printer_Btn_Labels$(ctr) = Printer$(Name, ctr)
         Printer_Btns%(ctr) = ctr + 1700
         'dialog dimensions
         Hght = ctr * 15 
         If Len(Printer_Btn_Labels$(ctr)) * 5 > Wdth Then
           wdth = Len(Printer_Btn_Labels$(ctr)) * 5 
         End If
      Next
          
      
    '     Main dialog window     
       Dialog Font "Comic Sans", 10
        Caption$ =  g_Parameters_Prnter '"Pick a Printer, Baby"
         ' Wdth = 100'800
          'Hght = 200'600          
          
          
     Local lb_Len&
     lb_Len = Wdth - 20 
     
        Stile = _
           %WS_CAPTION    Or _
           %WS_SYSMENU
        
       Dialog New hDlg, Caption$,,, Wdth, Hght,_
           Stile, _
           %WS_Ex_WindowEdge, _
           To hDlg_Printer
     
        Dialog Set Color hDlg_Printer, -1&, 252 + (241 * 256) + (167 * 256 * 256) 'cream
        'Dialog Set Icon hDlg_Printer, "Zero"    
        
        Stile = %BS_Center
        Btn_Width = Wdth - 10
        Btn_Height = 12
         Col = 5
         Row = 3         
        For ctr = LBound(Printer_Btns%()) To UBound(Printer_Btns%())
           Control Add Button, hDlg_Printer, _
              Printer_Btns%(ctr), _
              Printer_Btn_Labels$(ctr), _
              Col, Row, _
              Btn_Width, Btn_Height,_
              Stile    
           Row = Row + Btn_Height + 2   
        Next ctr          
                  
       Dialog Show Modal hDlg_Printer  Call z_CB_Printer
     
    End Sub 
    '********************************************************************
    '************ End of Printer Dialog *********************************
    '********************************************************************
    '********************************************************************
     
    Function PBMain
      Call z_Choose_Printer
    End Function
    '
    It's a pretty day. I hope you enjoy it.

    Gösta

    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/
Working...
X