Announcement

Collapse
No announcement yet.

Callback functions

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

  • Callback functions

    Before all else - I HAVE ordered Mr. Petzold's Big Book (on the 22nd, delivery 6-10 days, of which the six have expired but not the ten, so hope springs eternal ...).

    I have a little program with two dialogs, the first modal and the second modeless. The second starts clear and is populated with the appropriate controls according to what is selected on the first.

    The "second level" screen comes up very nicely, BUT some of the controls thereon respond as expected, and others not at all. Have tried DIALOG SHOW for this one with callback function specified (and no callback on the ADD CONTROL for the buttons, and also vice versa. No good. No callback, either way.

    The WINMAIN function sets up some popup menus and then ends with --
    Code:
     Local Style As Long
     Style = %WS_POPUP Or _
             %DS_SETFONT Or _
             %DS_NOFAILCREATE Or _
             %DS_MODALFRAME Or _
             %DS_3DLOOK
     Dialog New 0, "", 0, 63, 530, 315, Style To hDlg&
    
     Style = %WS_SYSMENU Or _
             %WS_MINIMIZEBOX
     Dialog New 0, "WINpeAc MAIN MENU", 0, 0, 534, 370, Style, _                %WS_EX_TOPMOST To pDlg&
    ' ** Add controls to it
     Call WndProc (pDlg&, %WM_CREATE, 4, 2) '(create decorative toolbar)
     Menu Attach hMenu, pDlg&               '(attach popups)
     Call MakeMainMenu                      '(create buttons, FIRST screen) 
     Fa%=0
     Dialog Show Modeless hDlg&              ', Call hDlgCallBack
     Dialog Show Modal pDlg&, Call DlgProc   ' To result
     End Function
    Last edited by Gary Beene; 12 Jul 2014, 08:29 PM. Reason: Code: tags

  • #2
    All MODELESS dialogs require a message pump in the form of a DIALOG DOEVENTS loop. There was not enough of your code to be 100% sure, but it sure looks like you are missing a DIALOG DOEVENTS from your code.

    Commonly, you would construct the app so that the callback for the modal dialog launches the modeless dialog, and then immediately runs a message loop.

    Commonly, this would be in response to a %WM_COMMAND in the modal dialog callback (ie, launch a modeless dialog in repsonse to a button click, etc). Another technique is for the modal callback function to send a 'private' message to itself which in turn launches the modeless dialog, and starts running the message pump loop. This way it is possible to launch a modeless dialog in response to say a %WM_INITDIALOG event.

    Check out ADDRESS.BAS for a 'basic' example of how to construct DDT message pump loops.

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

    Comment


    • #3
      To whom it may concern!

      The unique ID& (as in "CONTROL ADD BUTTON, hDlg&, *ID&* ...) MUST NOT EXCEED 65535. This great wisdom has been arrived at by use of the very advanced MsgBox method, in conjunction with "try, try and try again"
      (a two-byte field maximum). This info may be somewhere in HELP, but I have not come across it as yet.

      Waiting for the Charles Petzold book as I am, this represents a bit of a breakthrough, as I had used larger numbers than that. Why? In terms of a planned code structure for a menu hierachry, for (say) eight sub-systems, some of which may have second and third-level sub-structures (and once also a fourth before the options sequence is resolved to a self-contained task, i.e., programme module. So, providing more than one digit for just ONE that exceeds (or may in the near future exceed) 9 options, a code such as "73412" would more or less readably define "Sub=system 7, level 3, sub-level 4, task 12". A long integer such as ID& comfortably accommodates this.

      HELP says:

      Words are 16-bit (two-byte) unsigned integers with a range of 0 to 65535. The type declaration character for a Word is: ??.

      Maybe ID& should read ID?? ... ? (my ... ?)

      I post this in the interest of all/any other raw beginners, in high hopes that it is correct. See MicroSoft disclaimer.

      Comment


      • #4
        That is true for Windows 95/98 but not Windows NT/2000 which accept values larger than that.

        --Dave


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

        Home of the BASIC Gurus
        www.basicguru.com

        Comment

        Working...
        X