09-20-2010, 07:32 PM
Hi All,
I created a dialog that:
Function TabControlVariations
Function TC_GetTabText
Note: to get the name of the tab text, I had to create a custom in order to use TCM_GETITEM. From reading MSDN, I learned that if getting an item you have to allocate its string buffer and its max character length (ugh!!). So I reverse-engineered LvGetItemText from the QM grid functions which also defines similar values. It worked!!!!!!! (my first new "user-defined" function based on a MSDN SendMessage
However, I couldn't figure out how to apply all the STYLES or specifically change a tabs size because it required a value DWORD which I didn't know how to define
e.g.
http://msdn.microsoft.com/en-us/library/...S.85).aspx
also this is extended style and I don't know how to apply regular style...
I hope this is a good start and would be interested to see what Gintaras makes of all this.
Stuart
I created a dialog that:
- adds a new tab (1 higher than highest tab number's name. I made the name a number to make this easy ...see code.)
- Deletes the Selected Tab
- Deletes All Tabs
Function TabControlVariations
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
out
if(!ShowDialog("TabControlVariations" &TabControlVariations)) ret
;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 571 63 "Form"
;1 Button 0x54030001 0x4 272 46 48 14 "OK"
;2 Button 0x54030000 0x4 330 46 48 14 "Cancel"
;4 Button 0x54032000 0x4 386 46 18 14 "?"
;3 SysTabControl32 0x54000040 0x0 0 2 266 25 ""
;16 Button 0x54032000 0x0 270 4 50 22 "Add Tab"
;17 Button 0x54032000 0x0 322 4 50 22 "Delete Selected Tab"
;18 Button 0x54032300 0x0 376 4 48 22 "Delete All Tabs"
;END DIALOG
;DIALOG EDITOR: "" 0x2030109 "" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,int+ htb3=id(3 hDlg)
,TCITEM ti.mask=WINAPI.TCIF_TEXT
,ti.pszText="1"
,SendMessage htb3 WINAPI.TCM_INSERTITEMA 0 &ti
,ti.pszText="2"
,SendMessage htb3 WINAPI.TCM_INSERTITEMA 1 &ti
,ti.pszText="3"
,SendMessage htb3 WINAPI.TCM_INSERTITEMA 2 &ti
,
,goto g11
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 16;;add tab htb3
,,int TabCount = SendMessage(htb3 WINAPI.TCM_GETITEMCOUNT 0 0);; wParam and lParam must both be zero (see MSDN link http://msdn.microsoft.com/en-us/library/bb760592(v=VS.85).aspx)
,,str TabText
,,TC_GetTabText htb3 TabCount-1 TabText;;TabCount -1 because zero order tab index but total number of tabs is 1-order
,,int TabTextToVal = val(TabText)
,,str NextHighterTab = TabTextToVal+1
,,TCITEM TabName.mask=WINAPI.TCIF_TEXT
,,TabName.pszText = NextHighterTab
,,SendMessage htb3 WINAPI.TCM_INSERTITEMA TabCount+1 &TabName;; so that it adds it as the nexth (zero-order) tab
,case 17;;Delete Selected Tab
,,int SelectedTab = SendMessage(htb3 WINAPI.TCM_GETCURSEL 0 0);;Determines the currently selected tab in a tab control, wParam and lParam must be zero, returns selected tab index or -1 if no tab selected
,,SendMessage htb3 WINAPI.TCM_DELETEITEM SelectedTab 0 ;; Removes an item from a tab control, wParam = index of item to delete, lParam must be zero)
,case 18;; Delete All Tabs
,,SendMessage htb3 WINAPI.TCM_DELETEALLITEMS 0 0;;
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 _iFunction TC_GetTabText
;/
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.
TCITEM TabText.mask=WINAPI.TCIF_TEXT
BSTR b.alloc(260)
TabText.pszText=b
TabText.cchTextMax=260
SendMessage(htb TCM_GETITEM item &TabText)
s = TabText.pszText
ret s.len!=0Note: to get the name of the tab text, I had to create a custom in order to use TCM_GETITEM. From reading MSDN, I learned that if getting an item you have to allocate its string buffer and its max character length (ugh!!). So I reverse-engineered LvGetItemText from the QM grid functions which also defines similar values. It worked!!!!!!! (my first new "user-defined" function based on a MSDN SendMessage
However, I couldn't figure out how to apply all the STYLES or specifically change a tabs size because it required a value DWORD which I didn't know how to define
e.g.
http://msdn.microsoft.com/en-us/library/...S.85).aspx
also this is extended style and I don't know how to apply regular style...
I hope this is a good start and would be interested to see what Gintaras makes of all this.
Stuart
