Posts: 1,006
Threads: 330
Joined: Mar 2007
Hi Gintaras,
I was wondering if it was easy to apply TextColor/background color to Tabs in SysTabControl32. This would be great. Same goes for Icons, BMPs or Jpegs but not as high a priority if that is a lot harder. I have tried to look around on the internet to see if I could do it myself...all I found was which works great but just is a hover effect. Also came across this but I think not something I could use easily: http://www.codeproject.com/KB/tabs/tabbi...ework.aspx
Thanks for any thoughts!
Stuart
Posts: 12,097
Threads: 142
Joined: Dec 2002
Icons - easy.
Colors/bmp - not so easy. Need to add TCS_OWNERDRAWFIXED style and draw tab buttons completely on WM_DRAWITEM. Also then tab control will look like on Windows 2000 (bad), and tabs cannot be variable width.
Try to find an ActiveX control instead.
Posts: 1,006
Threads: 330
Joined: Mar 2007
Thanks, I identified some activex tab controls such as this http://www.planet-source-code.com/vb/scr...2&lngWId=1 online but I don't know where to begin to integrate them into QM. So maybe icon+text will differentiate them sufficiently without a color scheme at this time:
I can't seem to find the TC sendmessage that will place icon or both
i found this on MSDN:
Quote:Tab Control Image Lists
Each tab can have an icon associated with it, which is specified by an index in the image list for the tab control. When a tab control is created, it has no image list associated with it. An application can create an image list by using the ImageList_Create function and then assign it to a tab control by using the TCM_SETIMAGELIST message.
You can add images to a tab control's image list just as you would to any other image list. However, an application should remove images by using the TCM_REMOVEIMAGE message instead of the ImageList_Remove function. This message ensures that each tab remains associated with the same image as before.
Destroying a tab control does not destroy an image list that is associated with it. You must destroy the image list separately. This is useful if you want to assign the same image list to multiple tab controls.
To retrieve the handle to the image list currently associated with a tab control, you can use the TCM_GETIMAGELIST message.
Still looking around on internet for some sample code to work off of. Thanks for sending me in the right direction
Stuart
Posts: 12,097
Threads: 142
Joined: Dec 2002
Function dlg_tab_icons
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
if(!ShowDialog("" &dlg_tab_icons)) ret
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 SysTabControl32 0x54030040 0x0 0 0 224 110 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030300 "" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,__ImageList-- il.Load("$qm$\il_qm.bmp") ;;load an imagelist craeted with QM imagelist editor
,int htb=id(3 hDlg)
,SendMessage htb TCM_SETIMAGELIST 0 il
,TCITEM ti.mask=TCIF_TEXT|TCIF_IMAGE
,ti.pszText="A"; ti.iImage=2; SendMessage htb TCM_INSERTITEMA 0 &ti
,ti.pszText="B"; ti.iImage=3; SendMessage htb TCM_INSERTITEMA 0 &ti
,ti.pszText="C"; ti.iImage=15; SendMessage htb TCM_INSERTITEMA 0 &ti
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Posts: 12,097
Threads: 142
Joined: Dec 2002
This function makes easier to add tab control tabs.
Function TabControlAddTabs
;/
function hwnd $tabs
;Adds tabs to control of SysTabControl32 class.
;hwnd - control handle.
;tabs - list of tabs in CSV format.
;;;Line format: label,imageIndex,lParam
;;;label - tab text.
;;;imageIndex - icon index in imagelist.
;;;lParam - an integer number to assign to the tab.
;;;imageIndex and lParam are optional, so it can be simply list of labels.
;EXAMPLE
;,case WM_INITDIALOG
;,__ImageList-- il.Load("$qm$\il_qm.bmp") ;;load an imagelist craeted with QM imagelist editor
;,int htb=id(3 hDlg)
;,SendMessage htb TCM_SETIMAGELIST 0 il
;,TabControlAddTabs htb "A,2[]B[]C,15"
ICsv x=CreateCsv(1)
x.FromString(tabs)
int i param nc=x.ColumnCount
lpstr s
for i 0 x.RowCount
,TCITEMW ti.mask=TCIF_TEXT
,ti.pszText=@x.Cell(i 0)
,if nc>1
,,s=x.Cell(i 1)
,,if(!empty(s)) ti.iImage=val(s); ti.mask|TCIF_IMAGE
,if nc>2
,,s=x.Cell(i 2)
,,if(!empty(s)) ti.lParam=val(s); ti.mask|TCIF_PARAM
,SendMessageW hwnd TCM_INSERTITEMW i &ti
example
Function dlg_tab_icons2
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
if(!ShowDialog("" &dlg_tab_icons2)) ret
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 SysTabControl32 0x54030040 0x0 0 0 224 110 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030300 "" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,__ImageList-- il.Load("$qm$\il_qm.bmp") ;;load an imagelist craeted with QM imagelist editor
,int htb=id(3 hDlg)
,SendMessage htb TCM_SETIMAGELIST 0 il
,TabControlAddTabs htb "A,2[]B[]C,15"
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case TCN_SELCHANGE
,_i=SendMessage(nh.hwndFrom TCM_GETCURSEL 0 0)
,out "Tab selected: %i" _i
Posts: 1,006
Threads: 330
Joined: Mar 2007
Thanks so much......
I found this program to make imagelists
http://www.imagine-programming.com/Product/11/
I haven't tried it yet but looks like it should do the trick.
This is really amazing Gintaras!
S
Posts: 1,006
Threads: 330
Joined: Mar 2007
Hey All,
I Just discovered the ImageList Editor in More Tools menu (as well as Explore Windows, Remap Keyboard Keys). I use that menu to go the Regex menu so many times a day and never noticed those other options.... :oops:
Gintaras' continual improvement of QM is unbelievable as always.....!!!!!
Stuart
Posts: 769
Threads: 263
Joined: Jul 2012
I adjusted the first example a little to be able to create an imagelist from 3 icons, see below "icns"-string
I can not get it to work, it only shows the last icon (3.ico).
The 3 icons I used are all 16x16 and .ico format.
What is the correct way to create a usable image-list from 3 icons (like shown below)?
Macro Macro5
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 SysTabControl32 0x54030040 0x0 0 0 224 110 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030300 "" "" ""
if(!ShowDialog(dd &sub.DlgProc 0)) ret
#sub DlgProc
function# hDlg message wParam lParam
int- main_dlg=hDlg
sel message
,case WM_INITDIALOG
,,str icns=
,,;c:\icons\1.ico
,,;c:\icons\2.ico
,,;c:\icons\3.ico
,,__ImageList-- il.Create(icns)
,,;; __ImageList-- il.Load("$qm$\il_qm.bmp") ;;load an imagelist craeted with QM imagelist editor
,,int htb=id(3 hDlg)
,,SendMessage htb TCM_SETIMAGELIST 0 il
,,TCITEM ti.mask=TCIF_TEXT|TCIF_IMAGE
,,ti.pszText="A"; ti.iImage=2; SendMessage htb TCM_INSERTITEMA 0 &ti
,,ti.pszText="B"; ti.iImage=3; SendMessage htb TCM_INSERTITEMA 0 &ti
,,ti.pszText="C"; ti.iImage=15; SendMessage htb TCM_INSERTITEMA 0 &ti
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Posts: 1,338
Threads: 61
Joined: Jul 2006
11-26-2019, 09:44 PM
(This post was last modified: 12-07-2019, 12:53 AM by Kevin.)
your ti.iImage numbers are incorrect
this works
,,ti.pszText="A"; ti.iImage=0; SendMessage htb TCM_INSERTITEMA 0 &ti
,,ti.pszText="B"; ti.iImage=1; SendMessage htb TCM_INSERTITEMA 0 &ti
,,ti.pszText="C"; ti.iImage=2; SendMessage htb TCM_INSERTITEMA 0 &ti
Posts: 769
Threads: 263
Joined: Jul 2012
Yes it works now!
Thanks!!!
|