I wrote this script to illustrate rather than trying to explain the problem/bug. Can any of you duplicate the problem I'm experiencing?
Instructions:
- 1. Run the Script below
2. Select a window from the List Box
3. Select the same window from the Combo Box
4. View Result
When I run it I get the following results

Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Left = 247
Top = 96
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 378
ClientWidth = 672
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 8
Top = 8
Width = 191
Height = 13
Caption = 'Step 1. Select a window from the list box'
end
object Label2: TLabel
Left = 8
Top = 184
Width = 248
Height = 13
Caption = 'Step 2. Select the same window from the combo box'
Visible = False
end
object Label3: TLabel
Left = 8
Top = 128
Width = 657
Height = 41
AutoSize = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ParentFont = False
end
object Label4: TLabel
Left = 8
Top = 224
Width = 657
Height = 105
AutoSize = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ParentFont = False
Visible = False
WordWrap = True
end
object MSListBox1: tMSListBox
Left = 8
Top = 24
Width = 657
Height = 97
ItemHeight = 13
ScrollWidth = 2000
TabOrder = 0
SelectedIndex = -1
end
object MSComboBox1: tMSComboBox
Left = 8
Top = 200
Width = 657
Height = 21
DropDownCount = 50
TabOrder = 1
Text = 'MSComboBox1'
Visible = False
end
object MSButton1: tMSButton
Left = 8
Top = 344
Width = 121
Height = 25
Caption = 'Trye Again'
TabOrder = 2
Visible = False
DoBrowse = False
BrowseStyle = fbOpen
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,MSListBox1,OnClick,DoListBox
AddDialogHandler>Dialog1,MSComboBox1,OnChange,DoComboBox
AddDialogHandler>Dialog1,MSButton1,OnClick,TryAgain
GetWindowList>winlist
SetDialogProperty>Dialog1,MSListBox1,Text,Select a window from the list%CRLF%%winlist%
SetDialogProperty>Dialog1,MSListBox1,SelectedIndex,0
SetDialogProperty>Dialog1,MSComboBox1,ListText,Select the same window from this list%CRLF%%winlist%
SetDialogProperty>Dialog1,MSComboBox1,ItemIndex,0
Show>Dialog1,Result
SRT>DoListBox
GetDialogProperty>Dialog1,MSListBox1,SelectedIndex,SelectResult
If>SelectResult>0
GetDialogProperty>Dialog1,MSListBox1,SelectedItems,WindowResult
IfWindowOpen>%WindowResult%
Let>Name1Exists=1
GetWindowHandle>WindowResult,Name1_hwnd
Let>WIN_USEHANDLE=1
SetFocus>Name1_hwnd
Let>WIN_USEHANDLE=0
SetDialogProperty>Dialog1,Label3,Caption,Was Focus Set to "%WindowResult%"?%CRLF%Window handle: %Name1_hwnd%%CRLF%Continue with step 2
SetDialogProperty>Dialog1,Label2,Visible,True
SetDialogProperty>Dialog1,Label3,Visible,True
SetDialogProperty>Dialog1,MSButton1,Visible,True
SetDialogProperty>Dialog1,MSComboBox1,Visible,True
Endif
Endif
END>DoListBox
SRT>DoComboBox
GetDialogProperty>Dialog1,MSComboBox1,ItemIndex,SelectResult
If>SelectResult>0
GetDialogProperty>Dialog1,MSComboBox1,Text,WindowResult
IfWindowOpen>WindowResult
GetWindowHandle>WindowResult,Name2_hwnd
Let>WIN_USEHANDLE=1
SetFocus>Name2_hwnd
Let>WIN_USEHANDLE=0
SetDialogProperty>Dialog1,Label4,Visible,True
SetDialogProperty>Dialog1,Label4,Caption,Was Focus Set to "%WindowResult%"?%CRLF%Window handle: %Name2_hwnd%%CRLF%%CRLF%MSListBox1 Handle Result: %Name1_hwnd%%CRLF%MSComboBox1 Handle Result: %Name2_hwnd%%CRLF%Are the handles different and was focus set to the window both times?%CRLF%If your answer is NO then we have a problem!
Endif
Endif
END>DoComboBox
SRT>TryAgain
SetDialogProperty>Dialog1,Label2,Visible,False
SetDialogProperty>Dialog1,Label3,Visible,False
SetDialogProperty>Dialog1,Label4,Visible,False
SetDialogProperty>Dialog1,MSButton1,Visible,False
SetDialogProperty>Dialog1,MSComboBox1,Visible,False
GetWindowList>winlist
SetDialogProperty>Dialog1,MSListBox1,Text,Select a window from the list%CRLF%%winlist%
SetDialogProperty>Dialog1,MSListBox1,SelectedIndex,0
SetDialogProperty>Dialog1,MSComboBox1,ListText,Select the same window from this list%CRLF%%winlist%
SetDialogProperty>Dialog1,MSComboBox1,ItemIndex,0
END>TryAgain