Logo Foltyn Presentation
Table of Contents Previous Page Next Page
Content-Symbol-Img

Ein Programm in der Programmiersprache A program in the programming language
Classic Power Basic for Windows
zum Auswählen von verschiedenen Progammen einer Programmsammlung for selection of different programs of a program-collection

This is: Power BASIC



Das Programm erzeugt ein solches Dialog-Fenster mit einer Listbox zur Auswahl von Funktionen. Der Code ist generiert von den "Power Basic Forms" und so modfiziert, dass nach einem Doppelklick auf den ausgewählten Posten oder einem Einmal-Klick plus Drücken des Knopfes das Fester verschwindet, nachdem es eine Programm-Sub aufgerufen hat.

The program generates such a dialog-window with a listbox for selection of functions. The code is generated by the "Power Basic Forms" and modified so, that after double-click on the selected item or single-click plus button, the window disappears, after is has called a program-sub.

Das Programm ist getestet vor der Publikation, aber es kann keine Garantie gegeben werden, dass es fehlerfrei ist The program ist tested before publication, but there can be given no guarantee, that it is free of errors
30. Sept. 2012 Sept 30th 2012

#PBFORMS CREATED V1.52
'------------------------------------------------------------------------------
' The first line in this file is a PB/Forms metastatement.
' It should ALWAYS be the first line of the file. Other
' PB/Forms metastatements are placed at the beginning and
' end of "Named Blocks" of code that should be edited
' with PBForms only. Do not manually edit or delete these
' metastatements or PB/Forms will not be able to reread
' the file correctly. See the PB/Forms documentation for
' more information.
' Named blocks begin like this: #PBFORMS BEGIN ...
' Named blocks end like this: #PBFORMS END ...
' Other PB/Forms metastatements such as:
' #PBFORMS DECLARATIONS
' are used by PB/Forms to insert additional code.
' Feel free to make changes anywhere else in the file.
'------------------------------------------------------------------------------

#COMPILE EXE
#DIM ALL

'------------------------------------------------------------------------------
' ** Includes **
'------------------------------------------------------------------------------
#PBFORMS BEGIN INCLUDES
#IF NOT %DEF(%WINAPI)
    #INCLUDE "WIN32API.INC"
#ENDIF
#PBFORMS END INCLUDES
'------------------------------------------------------------------------------

'------------------------------------------------------------------------------
' ** Constants **
'------------------------------------------------------------------------------
#PBFORMS BEGIN CONSTANTS
%IDD_DIALOG1 = 101
%IDC_LABEL1 = 1001
%IDC_LISTBOX1 = 1002
%IDC_BUTTON1 = 1003
#PBFORMS END CONSTANTS
'------------------------------------------------------------------------------

'------------------------------------------------------------------------------
' ** Declarations **
'------------------------------------------------------------------------------
DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
DECLARE FUNCTION SampleListBox(BYVAL hDlg AS DWORDBYVAL lID AS LONGBYVAL _
    lCount AS LONGAS LONG
DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORDAS LONG
#PBFORMS DECLARATIONS
'------------------------------------------------------------------------------

'------------------------------------------------------------------------------
' ** Main Application Entry Point **
'------------------------------------------------------------------------------
FUNCTION PBMAIN()
    ShowDIALOG1 %HWND_DESKTOP
END FUNCTION
'------------------------------------------------------------------------------

'------------------------------------------------------------------------------
' ** CallBacks **
'------------------------------------------------------------------------------
CALLBACK FUNCTION ShowDIALOG1Proc()
    DIM txt$
    SELECT CASE AS LONG CBMSG
        CASE %WM_INITDIALOG
            ' Initialization handler
        CASE %WM_NCACTIVATE
            STATIC hWndSaveFocus AS DWORD
            IF ISFALSE CBWPARAM THEN
                ' Save control focus
                hWndSaveFocus = GetFocus()
            ELSEIF hWndSaveFocus THEN
                ' Restore control focus
                SetFocus(hWndSaveFocus)
                hWndSaveFocus = 0
            END IF
        CASE %WM_COMMAND
            ' Process control notifications
            SELECT CASE AS LONG CBCTL
                CASE %IDC_LABEL1
                CASE %IDC_LISTBOX1
                    IF CBCTLMSG = %LBN_DBLCLK THEN
                        LISTBOX GET TEXT CBHNDL, %IDC_LISTBOX1 TO txt$
                        CALL Program(txt$)
                        DIALOG END CBHNDL
                    END IF
                CASE %IDC_BUTTON1
                    IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                        LISTBOX GET TEXT CBHNDL, %IDC_LISTBOX1 TO txt$
                        IF txt$ = "" THEN
                            MSGBOX "no item selected"
                        ELSE
                            CALL Program(txt$)
                            DIALOG END CBHNDL
                        END IF
                   END IF
            END SELECT
    END SELECT
END FUNCTION
'------------------------------------------------------------------------------

'------------------------------------------------------------------------------
' ** Sample Code **
'------------------------------------------------------------------------------
FUNCTION SampleListBox(BYVAL hDlg AS DWORDBYVAL lID AS LONGBYVAL lCount _
    AS LONGAS LONG
    LOCAL i AS LONG

    FOR i = 1 TO lCount
        LISTBOX ADD hDlg, lID, USING$("Test Item #", i)
    NEXT i
END FUNCTION
'------------------------------------------------------------------------------

'------------------------------------------------------------------------------
' ** Dialogs **
'------------------------------------------------------------------------------
FUNCTION ShowDIALOG1(BYVAL hParent AS DWORDAS LONG
    LOCAL lRslt AS LONG

#PBFORMS BEGIN DIALOG %IDD_DIALOG1
    LOCAL hDlg  AS DWORD

    DIALOG NEW hParent, "Dialog1", 303, 164, 154, 140, %WS_POPUP OR _
        %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_CLIPSIBLINGS OR _
        %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _
        %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _
        %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
    CONTROL ADD LABEL,   hDlg, %IDC_LABEL1, "Label1", 30, 10, 100, 10, _
        %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %SS_CENTER OR %SS_SUNKEN, _
        %WS_EX_LEFT OR %WS_EX_LTRREADING
    CONTROL SET COLOR    hDlg, %IDC_LABEL1, -1, %WHITE
    CONTROL ADD LISTBOX, hDlg, %IDC_LISTBOX1, , 30, 25, 100, 80, %WS_CHILD OR _
        %WS_VISIBLE OR %WS_TABSTOP OR %WS_VSCROLL OR %LBS_NOTIFY, _
        %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
        %WS_EX_RIGHTSCROLLBAR
    CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON1, "Button1", 55, 110, 50, 15
#PBFORMS END DIALOG

    SampleListBox  hDlg, %IDC_LISTBOX1, 30

    DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt

#PBFORMS BEGIN CLEANUP %IDD_DIALOG1
#PBFORMS END CLEANUP

    FUNCTION = lRslt
END FUNCTION
'------------------------------------------------------------------------------

 SUB Program(AnyText$)
    MSGBOX AnyText$,,"Program"
  END SUB