Announcement

Collapse
No announcement yet.

DDT and %GWL_USERDATA

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

  • DDT and %GWL_USERDATA

    I like to use SetWindowLong(hWnd, %GWL_USERDATA , VARPTR(udt)) when creating dialogs to avoid global variables. This can not be done in DDT because DDT uses %GWL_USERDATA.
    Instead i have tried the following method: Define
    %DDT_USERDATA = %DWL_MSGRESULT
    and then use SetWindowLong(hWnd, %DDT_USERDATA , VARPTR(udt)).
    It seems to work OK. But is it OK?
    %DWL_MSGRESULT is explained as: "Sets the return value of a message processed in the dialog box procedure".

    Regards
    Peter

  • #2
    Peter --
    Perhaps, this is Ok for WM_INITDIALOG and 99,99% sure that DDT doesn't use it for own purposes.
    But when %WM_INITDIALOG is processed, this field will be destroyed.
    Sample:
    Code:
       #Compile Exe
       #Register None
       #Dim All
       #Include "win32api.inc"
       CallBack Function hDlg_CB()
          Select Case CbMsg
             Case %WM_INITDIALOG
                SetWindowText CbHndl, Time$ + Str$(GetWindowLong(CbHndl, %DWL_MSGRESULT))
             Case %WM_ERASEBKGND
    '            SetWindowText CbHndl, Time$ + Str$(GetWindowLong(CbHndl, %DWL_MSGRESULT))
          End Select
       End Function
    
       Function PbMain
         Dim hDlg As Long
         Dialog New 0, "Select Test", , , 500, 260, %WS_SYSMENU To hDlg
         Control Add TextBox, hDlg, 101, "", 10, 120, 480,  110
         SetWindowLong hDlg, %DWL_MSGRESULT, 125
         Dialog Show Modal hDlg, Call hDlg_CB
       End Function
    Uncomment second SetWindowText, try another event (WM_SIZE, WM_PAINT).

    Why I thought about caption ?
    Clear that not DDT, not OS will touch it.

    PS. Interesting, what DDT keeps in GWL / DWL USERDATA ?
    Could be something useful ?


    [This message has been edited by Semen Matusovski (edited April 01, 2000).]

    Comment


    • #3
      Thanks Semen.
      You are right. Interesting what DDT keeps in GWL_USERDATA.

      Regards
      Peter

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

      Comment


      • #4
        R&D have not released any information on what DDT uses the
        %GWL_USERDATA storage for, except to say that it is definately reserved for use by the DDT engine and therefore must not be used by applications using DDT.



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

        Comment

        Working...
        X