Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Output current selected tab name (SysTabControl32)
#1
sorry for this stupid question, but how do you get the name (not id number) of the current selected tab of a SysTabControl32 in a dialog.

I'm testing some examples from the Archive.qml, and found this example which I want to use.
it's altered slightly to output the selected tab #id, but I want to output the current selected tab name. (if possible).
(has it something to do with WS_CAPTION ?)

Function tabtest
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("tabtest" &tabtest)) ret

;BEGIN DIALOG
;0 "" 0x10C80A48 0x100 0 0 265 163 "Form"
;1001 Static 0x44020000 0x4 94 60 48 13 "Page0"
;1002 Edit 0x54030080 0x200 78 78 96 14 ""
;1101 Static 0x44020000 0x4 104 62 48 13 "Page1"
;1201 Static 0x44020000 0x4 110 70 48 13 "Page2"
;1301 Static 0x44020000 0x4 110 70 48 13 "Page3"
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;3 SysTabControl32 0x54000040 0x0 0 2 266 132 ""
;5 Static 0x54000010 0x20004 4 138 257 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040003 "" "0" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,
,int htb=id(3 hDlg)
,TCITEM ti.mask=WINAPI.TCIF_TEXT
,ti.pszText="A"
,SendMessage htb WINAPI.TCM_INSERTITEMA 0 &ti
,ti.pszText="B"
,SendMessage htb WINAPI.TCM_INSERTITEMA 1 &ti
,ti.pszText="C"
,SendMessage htb WINAPI.TCM_INSERTITEMA 2 &ti
,ti.pszText="D"
,SendMessage htb WINAPI.TCM_INSERTITEMA 3 &ti
,goto g11
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,,str tst.getwintext(id(1002 hDlg))
,,out tst
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case WINAPI.TCN_SELCHANGE
,_i=SendMessage(nh.hwndFrom WINAPI.TCM_GETCURSEL 0 0)
,;g11
,DT_Page hDlg _i
,out "Tab selected: %i" _i
#2
Try accessible objects.
Also tab control should have a TCM_x message for it, look in MSDN library.
#3
OK, Thank you!

EDIT, update for others. There is a function on the forum that does the heavy work for you, made by the man himself (no not me):

Removing Tabs from tab control

Function TC_GetTabText_
Code:
Copy      Help
;/
function! htb item str&s

;Gets tab control item text.
;Returns 1 if not empty, 0 if empty.

;htb - SysTabControl32 handle
;item - 0-based tab index
;s - receives text.

TCITEMW TabText.mask=WINAPI.TCIF_TEXT
BSTR b.alloc(260)
TabText.pszText=b
TabText.cchTextMax=260
SendMessageW(htb TCM_GETITEMW item &TabText)
s.ansi(b)
ret s.len!=0

To call the function:
Function tabtest
Code:
Copy      Help
TC_GetTabText_(id(3 hDlg) _i _s)
- id(3 hDlg): SysTabControl32 handle, don't use '3' look in the green commented part of your dialog declaration function look for 'SysTabControl32 '
- _i: index of the tab
- _s: contains name of the tab

It helps if you first download and setup the Windows API Declerations. How to setup is explained by the man himself (no...not me):
More Windows API declarations for QM


Forum Jump:


Users browsing this thread: 1 Guest(s)