Date: 02-16-2022
Return to Index
created by gbSnippets
'The TAB order of a control can be set in several ways. The WS_Tabstop style
'or simply the order in which a control is added to a dialog are the usual two
'ways. 'But during execution, the SetWindowPOS and BringWindowToTop can also be used.
'The SetWindowPOS can set TAB order specifically, whereas the BringWindowToTop
'has no option except to bring the window to the top of the zorder.
'Primary Code:
BringWindowToTop GetDlgItem(hDlg,100)
'Compilable Example: (Jose Includes)
'Here, 3 buttons are placed on a control. Pressing a button moves it to the
'top of the zorder (TAB order).
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
%ID_Label = 1000 : %ID_TextboxA = 1001 : %ID_TextboxB = 1002
%ID_BtnA = 2000 : %ID_BtnB = 2001 : %ID_BtnC = 2002
Global hDlg, hLabel, hBox as DWord
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add TextBox, hDlg, %ID_TextboxB, String$(30,"z"), 20,60,160,20
Control Handle hDlg, %ID_TextboxB To hBox
Control Add Label, hDlg, %ID_Label,String$(30,"x"), 20,90,160,10
Control Handle hDlg, %ID_Label To hLabel
Control Set Color hDlg, %ID_Label, %Black, %Red
Control Add Button, hDlg, %ID_BtnA,"Label", 10,150,40,20
Control Add Button, hDlg, %ID_BtnB,"TextBox", 70,150,50,20
Control Add Button, hDlg, %ID_BtnC,"Special", 130,150,50,20
Control Add TextBox, hDlg, %ID_TextboxA,"TextBoxA", 50,10,100,120
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = %ID_BtnA Then BringWindowToTop hLabel : Dialog Redraw hDlg
If CB.Msg = %WM_Command AND CB.Ctl = %ID_BtnB Then BringWindowToTop hBox : Dialog Redraw hDlg
If CB.Msg = %WM_Command AND CB.Ctl = %ID_BtnA Then SetWindowPos hLabel, %HWnd_TopMost,0,0,0,0, %SWP_NOMOVE Or %SWP_NOSIZE : Dialog Redraw hDlg
If CB.Msg = %WM_Command AND CB.Ctl = %ID_BtnB Then SetWindowPos hBox, %HWND_TopMost , 0,0,0,0, %SWP_NOMOVE Or %SWP_NOSIZE : Dialog Redraw hDlg
If CB.Msg = %WM_Command AND CB.Ctl = %ID_BtnC Then
Control Kill hDlg, %ID_TextBoxB
Control Kill hDlg, %ID_Label
Control Add TextBox, hDlg, %ID_TextboxB, String$(30,"z"), 20,60,160,20
Control Handle hDlg, %ID_TextboxB To hBox
Control Add Label, hDlg, %ID_Label,String$(30,"x"), 20,90,160,10
Control Handle hDlg, %ID_Label To hLabel
Control Set Color hDlg, %ID_Label, %Black, %Red
End If
End Function
'gbs_00685
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm