WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Dialog Editor version 6.X
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Synchronize Two Itemboxes

Keywords: 	   Synchronize Two Itemboxes

Question:

how do i trigger the event that the top item in an itembox has changed (or when the user has pressed the up or down button, or used the slider) ?

The usage of this: i want to synchronize two itemboxes. Do you have any suggestions how i can synchronize two itemboxes making use of DialogControlGet request 10 ?

Answer:

You can try this , I assume that the itemboxes have different items.

I only tested it with that small list , using the timer probably is not very reliable.

NB: As of version 2002k the "Dialog" function supports an optional second parameter. The parameter turns on/off execution of the "Dialog" function statement (and, therefore, the displaying of the dialog.)

Why would you want to put a statement in a WIL script and then not have it execute with the rest of the script? Well, it so happens that the Dialog Editor uses the "Dialog" function to load dialog templates and the Dialog editor will load the template no mater how the second parameter is set. This allows you to easily edit the template without having a script that explicitly runs the template. This is handy in more elaborate scripts and script archives.

BTW, set the second parameter to zero (0) to turn of function execution. Set it to one (1) or don't even include the parameter for normal execution.

#definesubroutine dlgproc(handle,msg,id,p4,p5)
select msg
  case 0 ;Init
    user32=dllload(strcat(dirwindows(1),"user32.dll"))
    strbuf=binaryalloc(255)
    POINT=binaryalloc(8)
    LB_GETTEXT=393
    LB_FINDSTRINGEXACT=418 

    hlist1=dllcall(user32,long:"GetDlgItem",long:handle,long:102)
    hlist2=dllcall(user32,long:"GetDlgItem",long:handle,long:103)

    DialogProcOptions(handle,2,1)  ;buttons
    DialogProcOptions(handle,1,10) ;timer

  case 1 ;timer
    if MouseInfo(8)==4 
      mc=MouseInfo(3)
      binarypoke4(POINT,0,itemextract(1,mc," "))
      binarypoke4(POINT,4,itemextract(2,mc," "))
      dllcall(user32,long:"ScreenToClient",long:handle,lpbinary:POINT)
      
      select dllcall(user32,long:"ChildWindowFromPoint",long:handle,long:binarypeek4(POINT,0),long:binarypeek4(POINT,4))
        case hlist1
          dllcall(user32,long:"SendMessageA",long:hlist1,long:LB_GETTEXT,long:DialogControlGet(handle,3,10)-1,lpbinary:strbuf)
          binaryeodset(strbuf,255)
          i=dllcall(user32,long:"SendMessageA",long:hlist2,long:LB_FINDSTRINGEXACT,long:-1,lpstr:binarypeekstr(strbuf,0,255)) 
          if i<>-1 then DialogControlSet(handle,4,10,i+1)
          break

        case hlist2
          dllcall(user32,long:"SendMessageA",long:hlist2,long:LB_GETTEXT,long:DialogControlGet(handle,4,10)-1,lpbinary:strbuf)
          binaryeodset(strbuf,255)
          i=dllcall(user32,long:"SendMessageA",long:hlist1,long:LB_FINDSTRINGEXACT,long:-1,lpstr:binarypeekstr(strbuf,0,255)) 
          if i<>-1 then DialogControlSet(handle,3,10,i+1)
      endselect
    endif    

endselect
return -1
#endsubroutine

MyVariable1=strcat("a",@tab,"b",@tab,"c",@tab,"d",@tab,"z")
MyVariable3=strcat("a",@tab,"b",@tab,"z",@tab,"f",@tab,"e")

MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`Sync Lists`
MyDialogX=002
MyDialogY=045
MyDialogWidth=168
MyDialogHeight=078
MyDialogNumControls=004
MyDialogProcedure=`dlgproc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`009,059,036,012,PUSHBUTTON,DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`119,057,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`007,007,070,034,ITEMBOX,MyVariable1,DEFAULT,DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`093,007,062,034,ITEMBOX,MyVariable3,DEFAULT,DEFAULT,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog",1)

dllfree(user32)
binaryfree(POINT)
binaryfree(strbuf)


Article ID:   W15479
File Created: 2003:05:13:11:28:06
Last Updated: 2003:05:13:11:28:06