User Tools

Site Tools


example_20property_20sheet

Example property sheet

by Richard Russell, October 2015

The main BBC BASIC for Windows Help documentation contains information on how to create a Property Sheet, but no demonstration program is supplied. For those who prefer to adapt an existing program rather than to write their own from scratch, here is an example of a property sheet in action.

By default the Apply button is not enabled, but here it is. Note that you will receive a notification that the Apply button has been pressed for each page in your property sheet (so in the example below you will receive it twice):

        REM. Program to demonstrate the use of property sheets from BBC BASIC
        REM. Richard Russell 5th August 2002
 
        INSTALL @lib$+"WINLIB2"
        INSTALL @lib$+"WINLIB4"
        DIM Text% 255
 
        REM!WC Windows Constants:
        CB_ADDSTRING = 323
        CB_SETCURSEL = 334
        CBS_DROPDOWNLIST = 3
        CBS_SORT = 256
        EM_SETSEL = &B1
        ES_NUMBER = 8192
        LR_LOADFROMFILE = 16
        LR_LOADMAP3DCOLORS = 4096
        PSM_CHANGED = &468
        PSM_GETCURRENTPAGEHWND = &476
        SS_BITMAP = &E
        SS_CENTERIMAGE = 512
        SS_LEFTNOWORDWRAP = &C
        SS_NOPREFIX = &80
        SS_RIGHT = 2
        STM_SETIMAGE = 370
        UDM_SETRANGE = &465
        WS_GROUP = &20000
        WS_TABSTOP = 65536
 
        chx1 = 101
        chx2 = 102
        chx3 = 103
        chx4 = 104
        chx5 = 105
 
        grp1 = 201
        grp2 = 202
        grp3 = 203
        grp4 = 204
 
        rdb1 = 301
        rdb2 = 302
        rdb3 = 303
        rdb4 = 304
        rdb5 = 305
 
        edt1 = 401
        edt2 = 402
        edt3 = 403
 
        psh2 = 502
 
        cmb4 = 604
 
        stc2 = 702
        stc3 = 703
        stc5 = 705
        stc6 = 706
        stc7 = 707
        stc8 = 708
        stc9 = 709
        stc10 = 710
        stc11 = 711
        stc12 = 712
        stc13 = 713
        stc14 = 714
 
        ico3 = 803
        upd1 = 903
 
        REM. Create the dialogues:
        page0% = FN_newdialog("Page 1", 32, 32, 288, 128, 8, 650)
        PROC_groupbox(page0%, "Printer", grp4, 8, 4, 272, 84, WS_GROUP)
        PROC_static(page0%, "&Name:", stc6, 16, 20, 36, 8, 0)
        PROC_combobox(page0%, "", cmb4, 52, 18, 152, 152, CBS_DROPDOWNLIST OR CBS_SORT OR WS_GROUP)
        PROC_pushbutton(page0%, "&Properties", psh2, 212, 17, 60, 14, WS_GROUP)
        PROC_static(page0%, "Status:", stc8, 16, 36, 36, 10, SS_NOPREFIX)
        PROC_static(page0%, "", stc12, 52, 36, 224, 10, SS_NOPREFIX OR SS_LEFTNOWORDWRAP)
        PROC_static(page0%, "Type:", stc7, 16, 48, 36, 10, SS_NOPREFIX)
        PROC_static(page0%, "", stc11, 52, 48, 224, 10, SS_NOPREFIX OR SS_LEFTNOWORDWRAP)
        PROC_static(page0%, "Where:", stc10, 16, 60, 36, 10, SS_NOPREFIX)
        PROC_static(page0%, "", stc14, 52, 60, 224, 10, SS_NOPREFIX OR SS_LEFTNOWORDWRAP)
        PROC_static(page0%, "Comment:", stc9, 16, 72, 36, 10, SS_NOPREFIX)
        PROC_static(page0%, "", stc13, 52, 72, 152, 10, SS_NOPREFIX OR SS_LEFTNOWORDWRAP)
        PROC_checkbox(page0%, "Print to fi&le", chx1, 212, 70, 64, 12, WS_GROUP)
 
        page1% = FN_newdialog("Page 2", 32, 32, 288, 128, 8, 1100)
        PROC_groupbox(page1%, "Print range", grp1, 8, 4, 144, 64, WS_GROUP)
        PROC_radiobutton(page1%, "&All", rdb1, 16, 18, 20, 12, WS_GROUP)
        PROC_radiobutton(page1%, "Pa&ges", rdb3, 16, 34, 36, 12, -WS_TABSTOP)
        PROC_radiobutton(page1%, "&Selected region", rdb2, 16, 50, 64, 12, 0)
        PROC_static(page1%, "&from:", stc2, 52, 36, 20, 8, SS_RIGHT)
        PROC_editbox(page1%, "", edt1, 74, 34, 26, 12, WS_GROUP OR ES_NUMBER)
        PROC_static(page1%, "&to:", stc3, 102, 36, 14, 8, SS_RIGHT)
        PROC_editbox(page1%, "", edt2, 118, 34, 26, 12, WS_GROUP OR ES_NUMBER)
        PROC_groupbox(page1%, "Copies", grp2, 160, 4, 120, 64, WS_GROUP)
        PROC_static(page1%, "Number of &copies:", stc5, 168, 20, 68, 8, 0)
        PROC_editbox(page1%, "", edt3, 240, 18, 32, 12, WS_GROUP OR ES_NUMBER)
        PROC_dlgctrl(page1%, "", upd1, 0, 0, 12, 12, &50000096, "msctls_updown32")
        PROC_static(page1%, "", ico3, 162, 36, 76, 24, SS_BITMAP OR SS_CENTERIMAGE OR WS_GROUP)
        PROC_checkbox(page1%, "C&ollate", chx2, 240, 42, 36, 12, WS_GROUP)
        PROC_groupbox(page1%, "Syntax highlighting", grp3, 8, 72, 272, 48, WS_GROUP)
        PROC_radiobutton(page1%, "Print in colou&r", rdb4, 16, 86, 60, 12, WS_GROUP)
        PROC_radiobutton(page1%, "Print in blac&k", rdb5, 16, 102, 60, 12, 0)
        PROC_checkbox(page1%, "&Underlined keywords", chx3, 78, 102, 80, 12, WS_GROUP)
        PROC_checkbox(page1%, "&Italic REMarks", chx4, 162, 102, 62, 12, WS_GROUP)
        PROC_checkbox(page1%, "&Bold strings", chx5, 226, 102, 52, 12, WS_GROUP)
 
        REM. Create the property sheet:
        pages% = 2
        DIM dlg%(pages%-1), hdlg%(pages%-1)
        dlg%() = page0%, page1%
        PropSh% = FN_newpropsheet("Property sheet", pages%, 0, 0, dlg%()) : REM. Caption, no. of pages, initial page, list of dialogues
 
        REM. Display the property sheet:
        PROC_showpropsheet(PropSh%, hdlg%())
        ON CLOSE PROCcleanup : QUIT
        ON ERROR SYS "MessageBox", @hwnd%, REPORT$, 0, 0 : PROCcleanup : QUIT
 
        REM. Initialise page 1:
        SYS "SendDlgItemMessage", hdlg%(0), cmb4, CB_ADDSTRING, 0, "HP LaserJet IIIP"
        SYS "SendDlgItemMessage", hdlg%(0), cmb4, CB_ADDSTRING, 0, "HP LaserJet Plus"
        SYS "SendDlgItemMessage", hdlg%(0), cmb4, CB_ADDSTRING, 0, "HP Photosmart 1115"
        SYS "SendDlgItemMessage", hdlg%(0), cmb4, CB_SETCURSEL, 0, 0
 
        SYS "SetDlgItemText", hdlg%(0), stc12, "Default printer; Ready"
        SYS "SetDlgItemText", hdlg%(0), stc11, "HP LaserJet IIIP"
        SYS "SetDlgItemText", hdlg%(0), stc14, "LPT1:"
 
        REM. Initialise page 2:
        SYS "CheckRadioButton", hdlg%(1), rdb1, rdb2, rdb1
        SYS "GetDlgItem", hdlg%(1), rdb2 TO hrad2%
        SYS "EnableWindow", hrad2%, 0
        SYS "SetDlgItemInt", hdlg%(1), edt1, 1
        SYS "SetDlgItemInt", hdlg%(1), edt2, 1
 
        SYS "SetDlgItemInt", hdlg%(1), edt3, 1
        SYS "CheckDlgButton", hdlg%(1), chx2, 1
 
        SYS "CheckRadioButton", hdlg%(1), rdb4, rdb5, rdb5
        SYS "CheckDlgButton", hdlg%(1), chx3, 1
        SYS "CheckDlgButton", hdlg%(1), chx4, 1
        SYS "CheckDlgButton", hdlg%(1), chx5, 1
 
        SYS "SendDlgItemMessage", hdlg%(1), upd1, UDM_SETRANGE, 0, (1 << 16)+9999
        SYS "GetDlgItem", hdlg%(1), chx2 TO hchx2%
        SYS "EnableWindow", hchx2%, 0
 
        SYS "LoadImage", 0, @dir$+"collate.bmp", 0, 97, 41, LR_LOADMAP3DCOLORS OR \
        \                LR_LOADFROMFILE TO hCollate%
        SYS "LoadImage", 0, @dir$+"copies.bmp", 0, 109, 41, LR_LOADMAP3DCOLORS OR \
        \                LR_LOADFROMFILE TO hCopies%
        SYS "SendDlgItemMessage", hdlg%(1), ico3, STM_SETIMAGE, 0, hCollate%
 
        REM. Process page changes and button clicks:
        DIM Q%(31)
        ON SYS Q%() = Q%(0)+1,@wparam%,Q%(1),Q%(2),Q%(3),Q%(4),Q%(5),Q%(6),Q%(7),Q%(8),\
        \ Q%(9),Q%(10),Q%(11),Q%(12),Q%(13),Q%(14),Q%(15),Q%(16),Q%(17),Q%(18),Q%(19),Q%(20),\
        \ Q%(21),Q%(22),Q%(23),Q%(24),Q%(25),Q%(26),Q%(27),Q%(28),Q%(29),Q%(30) : RETURN
 
        oldhdlg% = 0
        REPEAT
          WAIT 1
          click% = 0
          IF Q%(0) click% = Q%(Q%(0)) : Q%(0) -= 1
          SYS "SendMessage", !PropSh%, PSM_CHANGED, hdlg%(0), 0
          SYS "SendMessage", !PropSh%, PSM_GETCURRENTPAGEHWND, 0, 0 TO hdlg%
          oldhdlg% = hdlg%
 
          CASE click% AND &FFFF OF
            WHEN 1:
              PRINT "OK or APPLY pressed"
              SYS "GetDlgItemText", hdlg%(0), stc11, Text%, 255
              PRINT "Printer name = " $$Text%
              SYS "IsDlgButtonChecked", hdlg%(0), chx1 TO ptf%
              IF ptf% THEN PRINT "Print to file"
              SYS "IsDlgButtonChecked", hdlg%(1), rdb1 TO all%
              IF all% THEN
                PRINT "All pages"
              ELSE
                SYS "GetDlgItemInt", hdlg%(1), edt1, 0, 0 TO first%
                SYS "GetDlgItemInt", hdlg%(1), edt2, 0, 0 TO last%
                PRINT "Page range ";first%; " to ";last%
              ENDIF
              SYS "GetDlgItemInt", hdlg%(1), edt3, 0, 0 TO copies%
              PRINT "No. of copies = ";copies%
              IF copies%>1 THEN
                SYS "IsDlgButtonChecked", hdlg%(1), chx2 TO coll%
                IF coll% PRINT "Collate"
              ENDIF
              SYS "IsDlgButtonChecked", hdlg%(1), rdb4 TO col%
              IF col% THEN
                PRINT "Print in colour"
              ELSE
                PRINT "Print in black & white"
              ENDIF
 
            WHEN 2:
              PRINT "CANCEL pressed"
 
            WHEN rdb3:
              SYS "GetDlgItem", hdlg%(1), edt1 TO hedt1%
              SYS "SetForegroundWindow", hedt1%
              SYS "SendDlgItemMessage", hdlg%(1), edt1, EM_SETSEL, 0, -1
 
            WHEN rdb4:
              SYS "GetDlgItem", hdlg%(1), chx3 TO hchx3%
              SYS "EnableWindow", hchx3%, 0
              SYS "GetDlgItem", hdlg%(1), chx4 TO hchx4%
              SYS "EnableWindow", hchx4%, 0
              SYS "GetDlgItem", hdlg%(1), chx5 TO hchx5%
              SYS "EnableWindow", hchx5%, 0
 
            WHEN rdb5:
              SYS "GetDlgItem", hdlg%(1), chx3 TO hchx3%
              SYS "EnableWindow", hchx3%, 1
              SYS "GetDlgItem", hdlg%(1), chx4 TO hchx4%
              SYS "EnableWindow", hchx4%, 1
              SYS "GetDlgItem", hdlg%(1), chx5 TO hchx5%
              SYS "EnableWindow", hchx5%, 1
 
            WHEN chx2:
              SYS "IsDlgButtonChecked", hdlg%(1), chx2 TO collate%
              IF collate% THEN
                SYS "SendDlgItemMessage", hdlg%(1), ico3, STM_SETIMAGE, 0, hCollate%
              ELSE
                SYS "SendDlgItemMessage", hdlg%(1), ico3, STM_SETIMAGE, 0, hCopies%
              ENDIF
 
            WHEN cmb4:
              SYS "GetDlgItemText", hdlg%(0), cmb4, Text%, 255
              SYS "SetDlgItemText", hdlg%(0), stc11, Text%
 
            WHEN edt3:
              SYS "GetDlgItemInt", hdlg%(1), edt3, 0, 0 TO copies%
              SYS "EnableWindow", hchx2%, -(copies%>1)
          ENDCASE
        UNTIL hdlg% = 0
        PROCcleanup
        END
 
        DEF PROCcleanup
        PropSh% += 0   : IF PropSh%   PROC_closepropsheet(PropSh%)  : PropSh% = 0
        hCollate% += 0 : IF hCollate% SYS "DeleteObject", hCollate% : hCollate% = 0
        hCopies% += 0  : IF hCopies%  SYS "DeleteObject", hCopies%  : hCopies% = 0
        ENDPROC
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
example_20property_20sheet.txt · Last modified: 2018/04/15 20:14 by tbest3112