Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Handle Both Itembox Select and Itembox Doubleclick Double Single Click MSG_ITEMSELECT MSG_ITEMBOXDOUBLECLICK
; Demonstration of ITEMBOXDOUBLECLICK ; Try both procedures by (un)commenting "MyDialogProcedure=" IntControl(33,0,0,0,0) items = '' For i = 10 To 50 items = ItemInsert(i, -1, items, @TAB) Next MSG_INIT =0 ; The one-time initialization MSG_BUTTONPUSHED =2 ; Pushbutton or Picturebutton MSG_ITEMSELECT =7 ; Itembox MSG_ITEMBOXDOUBLECLICK=13 ; Get double-click message on an ItemBox RET_DO_DEFAULT =-1 ; Continue with default processing for control DCSTATE_SETFOCUS =1 DPO_DISABLESTATE =1000 ; codes -1=GetSetting 0=EnableDialog 1=DisableDialog #DefineFunction UpdateCursor() ;-- Force cursor update xy = MouseCoords('', '') MouseMove(ItemExtract(1,xy,' '),ItemExtract(2,xy,' '), '','') #EndFunction ;-- vanilla, see MyDialogProcedure #DefineSubRoutine MyDialogCallbackProc_vanilla(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo) ON_EQUAL = @TRUE Switch MyDialog_Message Case MSG_INIT DialogProcOptions(MyDialog_Handle,MSG_ITEMSELECT,@TRUE) DialogProcOptions(MyDialog_Handle,MSG_ITEMBOXDOUBLECLICK,@TRUE) Return(RET_DO_DEFAULT) Case MSG_ITEMSELECT TimeDelay(1) Return(RET_DO_DEFAULT) Case MSG_ITEMBOXDOUBLECLICK sel = DialogControlGet(MyDialog_Handle, "ItemBox_1", 6) Pause('ItemDoubleClick', sel) Return(RET_DO_DEFAULT) EndSwitch Return(RET_DO_DEFAULT) #EndSubRoutine #DefineSubRoutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo) ON_EQUAL = @TRUE Switch MyDialog_Message Case MSG_INIT DialogProcOptions(MyDialog_Handle,MSG_ITEMSELECT,@TRUE) DialogProcOptions(MyDialog_Handle,MSG_ITEMBOXDOUBLECLICK,@TRUE) preselected = '' ;<-----------------XXXX Return(RET_DO_DEFAULT) Case MSG_ITEMSELECT selected = DialogControlGet(MyDialog_Handle, "ItemBox_1", 6) If selected == preselected Then Return(RET_DO_DEFAULT) ;<-----------------XXXX DialogProcOptions(MyDialog_Handle, DPO_DISABLESTATE, 2) UpdateCursor() ;-- Force cursor update ;-- do something... Display(0.5,'selected ':selected,selected == preselected) preselected = selected ;<-----------------XXXX DialogProcOptions(MyDialog_Handle, DPO_DISABLESTATE, 0) UpdateCursor() ;-- Force cursor update DialogControlState(MyDialog_Handle, "ItemBox_1", DCSTATE_SETFOCUS, 0) ;<-- Focus back to ItemBox_1 Return(RET_DO_DEFAULT) Case MSG_ITEMBOXDOUBLECLICK sel = DialogControlGet(MyDialog_Handle, "ItemBox_1", 6) Pause('ItemDoubleClick', sel) Return(RET_DO_DEFAULT) EndSwitch Return(RET_DO_DEFAULT) #EndSubRoutine MyDialogFormat=`WWWDLGED,6.2` MyDialogCaption=`WIL Dialog 1` MyDialogX=120 MyDialogY=241 MyDialogWidth=164 MyDialogHeight=176 MyDialogNumControls=003 ;-- choose one of these ------------------------- ;-- MyDialogProcedure=`MyDialogCallbackProc` ;MyDialogProcedure=`MyDialogCallbackProc_vanilla` ;------------------------------------------------ MyDialogFont=`DEFAULT` MyDialogTextColor=`DEFAULT` MyDialogBackground=`DEFAULT,DEFAULT` MyDialogConfig=0 MyDialog001=`057,149,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,0,DEFAULT,DEFAULT,DEFAULT` MyDialog002=`105,149,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog003=`051,019,062,110,ITEMBOX,"ItemBox_1",Items,DEFAULT,DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ButtonPushed=Dialog("MyDialog", 1) Exit
So I did figure out how to accomplish this (very consistently, at least in my environment). Basically, "the" issue is that when you dbl-click, the dialog first handles the "first click", or the selection event, and then if Windows still thinks there is a Double-Click in the queue, your dialog will have an opportunity to process that. Windows can loose the "Double-Click" event if the Itembox Selection routine does certain behaviors (I am not sure i could precisely list all the reasons Windows discards the queued event, however for simplicity of the explanation, lets just say the more complex the selection routine is, and the longer it takes to return control to the dialog, the more likely you are going to loose the dbl-click)
So here is a way to never loose either events. NOTE: It relies on a timer event to "cleanup", and your code may already have a timer event and you may not want to mess with the timing...
; Force Single Selection Only IntControl(33,0,0,0,0) ;Create a list of "Fake" stuff to List items = '' For i = 10 To 50 items = ItemInsert(i, -1, items, @TAB) Next MSG_INIT =0 ; The one-time initialization MSG_TIMER =1 ; Call DialogCallback on "heartbeat" timer MSG_BUTTONPUSHED =2 ; Pushbutton or Picturebutton MSG_ITEMSELECT =7 ; Itembox MSG_ITEMBOXDOUBLECLICK=13 ; Get double-click message on an ItemBox RET_DO_DEFAULT =-1 ; Continue with default processing for control DCSTATE_SETFOCUS =1 DPO_DISABLESTATE =1000 ; codes -1=GetSetting 0=EnableDialog 1=DisableDialog ;************************************************************************************************** ; CHANGE ME to TRUE if a DBL-CLICK in Itembox should FIRST Execute the SELECTION in ItemBox Routine DO_ITEMBOX_SELECTION_AND_DBL = @FALSE ;************************************************************************************************** #DefineSubRoutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo) Switch MyDialog_Message Case MSG_INIT DialogProcOptions(MyDialog_Handle,MSG_TIMER,250) ;max # of ms your dialog can appropriately wait to show the results of the Item Selection DialogProcOptions(MyDialog_Handle,MSG_ITEMSELECT,@TRUE) DialogProcOptions(MyDialog_Handle,MSG_ITEMBOXDOUBLECLICK,@TRUE) ItemBoxSelectionNeedsHelp=@FALSE ; <--- A FLAG TO KNOW WHEN AN UNPROCESSED SINGLE CLICK HAS HAPPENED WhichItemBoxNeedsHelp = "" ; In-case we have More than one Item Box Return(RET_DO_DEFAULT) Case MSG_TIMER If ItemBoxSelectionNeedsHelp Then ItemBoxSelectionNeedsHelp = @FALSE ; I, as the Timer, will be handling the ItemBox Selection Needs ;Do whatever needs to be done when we select an item Selection = DialogControlGet(MyDialog_Handle, WhichItemBoxNeedsHelp, 6) Pause('Item Selected' , selection) End If ; Do other Timer Tasks you were already doing Return(RET_DO_DEFAULT) Case MSG_ITEMSELECT ;Get in, get Out... We will deal with the Procedure to process this soon ItemBoxSelectionNeedsHelp=@TRUE WhichItemBoxNeedsHelp = MyDialog_Name Return(RET_DO_DEFAULT) Case MSG_ITEMBOXDOUBLECLICK If ItemBoxSelectionNeedsHelp Then ItemBoxSelectionNeedsHelp = @FALSE ; I, as the ItemBox_DblClick routine, will be handling the ItemBox Selection Needs If DO_ITEMBOX_SELECTION_AND_DBL Then ;Do whatever needs to be done when we select an item Selection = DialogControlGet(MyDialog_Handle, WhichItemBoxNeedsHelp, 6) Pause('Item Selected' , selection); and YES you dbl-clicked, and we will get to that in a moment End If End If selection = DialogControlGet(MyDialog_Handle, MyDialog_Name, 6) Pause('Item Double Clicked', selection) Return(RET_DO_DEFAULT) EndSwitch Return(RET_DO_DEFAULT) #EndSubRoutine MyDialogFormat=`WWWDLGED,6.2` MyDialogCaption=`WIL Dialog 1` MyDialogX=120 MyDialogY=241 MyDialogWidth=164 MyDialogHeight=176 MyDialogNumControls=003 MyDialogProcedure=`MyDialogCallbackProc` MyDialogFont=`DEFAULT` MyDialogTextColor=`DEFAULT` MyDialogBackground=`DEFAULT,DEFAULT` MyDialogConfig=0 MyDialog001=`057,149,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,0,DEFAULT,DEFAULT,DEFAULT` MyDialog002=`105,149,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog003=`051,019,062,110,ITEMBOX,"ItemBox_1",Items,DEFAULT,DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ButtonPushed=Dialog("MyDialog", 1) Exit
Article ID: W17723
Filename: Handle Both Itembox Select and Itembox Double-Click.txt
File Created: 2014:02:11:08:22:42
Last Updated: 2014:02:11:08:22:42