Announcement

Collapse
No announcement yet.

DDT SetWindowLong workaround ?

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

  • DDT SetWindowLong workaround ?

    Hi there,

    learned from the BBS that DDT uses SetWindowLong it's own.
    But how shall i assign my vars to a dialog ? Has anyone a
    better idea ? Code below is very ineffective.

    Code:
    #DIM ALL
    #REGISTER NONE
    #OPTION VERSION4
    #INCLUDE "win32api.inc"
    
    $appTitle = "SetWindowLong"
    
    TYPE user_type
         NetName   AS ASCIIZ * 80
         mappings  AS ASCIIZ * 80
         rights    AS DWORD
         connected AS LONG
    END TYPE
    
    FUNCTION DIALOG_SET_Pointer( BYVAL hDlg AS LONG, BYVAL pVal AS LONG ) AS LONG
        LOCAL hLabel AS LONG
        CONTROL ADD LABEL, hDlg, 2345, FORMAT$(pval), 0,0,0,0, %WS_CHILD
        FUNCTION = ERRCLEAR
    END FUNCTION
    
    FUNCTION DIALOG_GET_Pointer( BYVAL hDlg AS LONG ) AS LONG
        LOCAL sRet AS STRING
        CONTROL GET TEXT hDlg, 2345 TO sRet
        FUNCTION = VAL( sRet )
    END FUNCTION
    
    CALLBACK FUNCTION MAINDlgProc
        LOCAL utp AS user_type PTR
        SELECT CASE CBMSG
          CASE %WM_INITDIALOG
             utp = DIALOG_GET_Pointer( CBHNDL )
             @utp.NetName = "Micky"
             
          CASE %WM_DESTROY
        END SELECT
    END FUNCTION
    
    FUNCTION PBMAIN() AS LONG
        LOCAL ut   AS user_type
        LOCAL hdlg AS LONG
        
        DIALOG NEW 0, $AppTitle,,, 278, 213, %WS_SYSMENU OR %WS_THICKFRAME OR %DS_CENTER OR %DS_CONTEXTHELP TO hDlg
        IF hdlg = 0 THEN EXIT FUNCTION  ' Error occurred
        DIALOG_SET_Pointer hdlg, VARPTR( ut )
        DIALOG SHOW MODAL hdlg, CALL MAINDlgProc
    
    END FUNCTION
    ------------------

  • #2
    Ralph --
    1) Set/GetProp
    2) direct call callback function
    Code:
      #Dim All
      #Compile Exe
      #Register None
      #Include "WIN32API.INC"
    
      CallBack Function DlgCallBack
         Select Case CbMsg
            Case %WM_USER + 1: SetWindowText CbHndl, Str$(CbWparam) + Str$(CbLparam)
         End Select
      End Function
    
      Function PbMain
        Dim hDlg As Long
        Dialog New 0, "DDTExample",,, 120, 30, %WS_CAPTION Or %WS_SYSMENU To hDlg
        CallWindowProc CodePtr(DlgCallBack), hDlg, %WM_USER + 1, 25, 50
        Dialog Show Modal hDlg Call DlgCallBack
    End Function
    and so on

    ------------------
    E-MAIL: [email protected]

    Comment


    • #3
      Semen,

      thanks for the reply.
      My sample doesn't excatly show what i need.

      FUNCTION newDialog( zInit as asciiz ) AS LONG
      LOCAL ut AS user_type
      LOCAL hdlg AS LONG
      ut.NetName = zInit
      DIALOG NEW 0, $AppTitle,,, 278, 213, %WS_SYSMENU OR %WS_THICKFRAME OR %DS_CENTER OR %DS_CONTEXTHELP TO hDlg
      IF hdlg = 0 THEN EXIT FUNCTION ' Error occurred
      DIALOG_SET_Pointer hdlg, VARPTR( ut )
      DIALOG SHOW MODELESS hdlg, CALL MAINDlgProc
      function = hdlg
      END FUNCTION

      function pbmain()
      local dlg1 as long
      local dlg2 as long
      dlg1 = newDialog("mickey")
      dlg2 = newDialog("mouse")

      msgbox "click to finish"
      end function

      1) SetProp need to be deleted by RemoveProp before a %WM_DESTROY
      msg reaches the window's msg q. Played some nights with that.
      My app works on some PC's on other's i get ugly GPF's when
      i call RemoveProp. Does it work for you ?

      2) direct call callback function works only for one instance



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

      Comment


      • #4
        Ralph,

        1) SetProp need to be deleted by RemoveProp before a %WM_DESTROY msg reaches the window's msg q. Played some nights with that. My app works on some PC's on other's i get ugly GPF's when i call RemoveProp. Does it work for you ?
        I use SetProp() and RemoveProp() successfully in my own code, but although you say you have problems, so if you can post some code that demonstrates your problem we can probably help further. A GPF usually occurs when your code reference memory that is not allocated to your app, or has been deallocated (such as can happen when using pointers in one Sub/Function that refer to LOCAL variable storage in a different Sub/Function).

        Also, your latest code posting uses a MODELESS dialog box, yet your code does not have a message pump, so the code will not run as you expect. Please review the Dynamic Dialog Tools section of the help file and search the BBS for "DIALOG DOEVENTS".

        Finally, I'm not at all clear when you say CallWindowProc() only works once... maybe I'm missing something here.



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

        Comment

        Working...
        X