Announcement

Collapse
No announcement yet.

arrays

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

  • arrays

    I am have trubal set an array as global in order to use array data in
    more then one sub. I am all so try to put the data in the array in
    to a listbox at the cdlick of a button. what do I have to put in
    a call back function to make %WS_MAXIMIZEBOX OR %WS_MINIMIZEBOX
    show up in the uper right on the dialog box.

    here is my program as I have it working now


    thanks
    Joe


    #COMPILE EXE
    #INCLUDE "win32api.inc"


    'all global veribal will be deceard here
    %id_nlabel = 100
    %id_himsgs = 101
    %id_name = 102
    %id_disp = 110
    GLOBAL lin%

    'all callback function will be deceard here
    DECLARE CALLBACK FUNCTION dlgpro

    DECLARE SUB joe(firstname$)
    DECLARE SUB fscreen

    FUNCTION PBMAIN 'START PBMAIN FUNCTION

    CALL fscreen

    END FUNCTION

    CALLBACK FUNCTION dlgpro
    LOCAL ntext AS STRING
    CONTROL GET TEXT CBHNDL, %id_name TO ntext
    SELECT CASE CBMSG
    CASE %wm_initdialog
    CASE %wm_command

    SELECT CASE LOWRD(CBWPARAM)
    CASE %idok
    DIALOG END CBHNDL
    CALL joe(ntext$)
    CASE %idcancel
    DIALOG END CBHNDL
    CASE %id_disp
    MSGBOX "when done this will display all" & $CR & "entered name in listbox"

    DIALOG END CBHNDL



    END SELECT
    END SELECT
    END FUNCTION

    SUB joe (firstname$)



    MSGBOX "hi " & firstname$
    DIM bob$(50)
    lin% = lin%+1%
    bob$(lin%)=firstname$
    MSGBOX bob$(lin%)
    CALL fscreen



    END SUB


    SUB fscreen

    LOCAL hdlg AS LONG 'local veribals deceard here

    DIALOG NEW 0, "My Program" ,,,250,100, %WS_MAXIMIZEBOX OR %WS_MINIMIZEBOX TO hdlg

    CONTROL ADD TEXTBOX, hdlg, %id_name, "",75,1,100,14
    CONTROL ADD LABEL, hdlg, %id_nlabel, "ENTER YOUR NAME",5,5,70,14


    CONTROL ADD LISTBOX, hDlg, 100, , 4, 20, 100, 70, %WS_TABSTOP OR %WS_VSCROLL, %WS_EX_CLIENTEDGE

    CONTROL ADD BUTTON, hdlg, %idok, "&OK",175,25,40,14
    CONTROL ADD BUTTON, hdlg, %idcancel, "&CANCEL",175,40,40,14
    CONTROL ADD BUTTON, hdlg, %id_disp, "&DISPLAY",175,55,40,14
    DIALOG SHOW MODAL hdlg CALL dlgpro

    END SUB

    ------------------

  • #2
    To get the maximize & minimize boxes to show, you need to specify a system menu (and explicitly specifying a caption is recommended)...
    Code:
        DIALOG NEW 0, "My Program" ,,,250,100, _
          %WS_MAXIMIZEBOX OR %WS_MINIMIZEBOX OR _
          %WS_CAPTION OR %WS_SYSMENU TO hdlg
    Your code has one more serious problem... your TEXTBOX control shares the same ID value as your LISTBOX, so a LISTBOX ADD statement is certain to fail! You must give each control a unique ID. Also,

    Next, there is no need to destroy the dialog & recreate it with each additional name. Here is a slightly modified version of your code to show you what I mean (whether it is how you want your application to work like this is a different question!) These mods are not perfect, but it should give you something to go on with.

    Code:
    #COMPILE EXE
    #INCLUDE "win32api.inc"
     
    'all global veribal will be deceard here
      %id_nlabel = 100
      %id_himsgs = 101
      %id_name   = 102
      %id_disp   = 110
      %id_listbox = 111
      GLOBAL lin%
     
    'all callback function will be deceard here
     DECLARE CALLBACK FUNCTION dlgpro
     
    FUNCTION PBMAIN          'START PBMAIN FUNCTION
        LOCAL hdlg AS LONG       'local veribals deceard here
     
        DIALOG NEW 0, "My Program" ,,,250,100, %WS_MAXIMIZEBOX OR %WS_MINIMIZEBOX OR %WS_CAPTION OR %WS_SYSMENU TO hdlg
     
        CONTROL ADD TEXTBOX, hdlg, %id_name, "",75,1,100,14
        CONTROL ADD LABEL, hdlg, %id_nlabel, "ENTER YOUR NAME",5,5,70,14
        CONTROL ADD LISTBOX, hDlg, %id_listbox , , 4, 20,  100,  70, %WS_TABSTOP OR %WS_VSCROLL OR %LBS_DISABLENOSCROLL, %WS_EX_CLIENTEDGE
        CONTROL ADD BUTTON, hdlg, %idok, "&OK",175,25,40,14
        CONTROL ADD BUTTON, hdlg, %idcancel, "&CANCEL",175,40,40,14
        CONTROL ADD BUTTON, hdlg, %id_disp, "&DISPLAY",175,55,40,14
        DIALOG SHOW MODAL hdlg CALL dlgpro
    END FUNCTION
     
    CALLBACK FUNCTION dlgpro
        LOCAL ntext AS STRING
        CONTROL GET TEXT CBHNDL, %id_name TO ntext
        IF CBMSG <> %WM_COMMAND THEN EXIT FUNCTION
        SELECT CASE CBCTL
           CASE %idok
               IF LEN(nText) THEN
                   LISTBOX ADD CBHNDL, %id_listbox , nText
                   BEEP
                   CONTROL SET FOCUS CBHNDL, %id_name
                   CONTROL SET TEXT CBHNDL, %id_name, ""
                   FUNCTION = 1
                   EXIT FUNCTION
               END IF
           CASE %idcancel
               DIALOG END CBHNDL
               FUNCTION = 1
           CASE %id_disp
               MSGBOX "when done this will display all" & $CR & "entered name in listbox"
               DIALOG END CBHNDL
               FUNCTION = 1
        END SELECT
    END FUNCTION


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Joe,

      Take some friendly advice from someone whose just been
      through stage 1 of learning Windows and PowerBasic;

      1. Get the windows programming books by Petzold and the
      one by Rector/Newcomer. These will get you started into
      wonderful world of Windows.

      2. Dump DDT for now and start learning the Windows API.
      Your going to need this believe me. Even DDT is no short
      cut to learning Windows, only confusion from my point of
      view. Don't get me wrong, DDT is good but LEARN the API
      for now then go on.

      3. If you didn't get the Docs when you ordered PB, buy the
      DOCS. Some useful info in that book!!!

      Happy programming,
      Cecil

      ------------------

      Comment


      • #4
        Let me second Cecil's suggestion to learn Windows programming "the API way" before relying on DDT.

        Just today I had na application to do; so I sez to myself, "let's try this with DDT".

        Well, building the dialog screens and recompiling is a lot easier with DDT; but to do anything really useful you have to understand all the CONTROL SET and CONTROL GET and CONTROL SEND stuff.

        Those commands are pretty easy to understand once you've used SendMessage or PostMessage; but absent that experience, I'd still be tryig to figure out where to go next.

        MCM


        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment

        Working...
        X