I studied Latigo, tutorial about creating Tab Control, I coded this example again, but without using a resource file. Instead of invoke DialogBoxParam,,,, I used invoke CreateWindowEx,,,,,. Everything is working well. I can have as many Tabs as I like. I can even change the color of the Tab Control Window. But well. I can't change the color of the text in Control Window Tabs. I raked again through all the relevant Iczelion tutorials and Vom-bonjour notes, but nothing. It would make me very happy if any good soul in here could set me in the right direction or could help. Thanks forge
You need to make the tab control OWNERDRAW. Ewayne
Thank you Ewayne I have never coded OWNERDRAW tab control before, but I will give a try. I will let you know if it will cover the whole area of the Tab. forge
LOCAL tci:TC_ITEM LOCAL dis:DRAWITEMSTRUCT ; You might want to make this global LOCAL hBrush:DWORD .if wMsg == WM_DRAWITEM .if wParam == 702 ; ID of your tab control mov esi, lParam mov edi, offset dis mov ecx, sizeof dis rep movsb .if dis.itemID != -1 mov tci.imask, TCIF_TEXT lea eax, szBuff0 mov tci.pszText, eax mov tci.cchTextMax, 60 INVOKE SendMessage, hTab, TCM_GETITEM, dis.itemID, addr tci INVOKE CreateSolidBrush, 00ffff00h mov hBrush, eax INVOKE FillRect, dis.hdc, addr dis.rcItem, eax INVOKE SetTextColor, dis.hdc, 00000000h INVOKE SetBkColor, dis.hdc, 00ffff00h INVOKE DrawText, dis.hdc, tci.pszText, -1, addr dis.rcItem, DT_CENTER or DT_VCENTER or DT_SINGLELINE INVOKE DeleteObject, hBrush .endif mov dis.itemState, ODS_DEFAULT mov dis.hdc, 0 .endif .endif
Thanks Ewayne for the code snippet. Only one more thing is not clear to me.
Could I use the ID 702 this way???From win32hlp: You can use the GetDlgItem function with any parent-child window pair, not just with dialog boxes. As long as the hDlg parameter specifies a parent window and the child window has a unique identifier (as specified by the hMenu parameter in the CreateWindow or CreateWindowEx function that created the child window), GetDlgItem returns a valid handle to the child window.
Thanks again forge
invoke CreateWindowEx,0, ADDR TabClrtCl,ADDR lpText, WS_VISIBLE or WS_CHILD or TCS_OWNERDRAWFIXED, 33,43,333,233,hWin,702,hInstance,0 . . . . .if wMsg == WM_DRAWITEM .if wParam == 702 ; ID of your tab control mov esi, lParam
forge your ID can be any number you want it to be as long as it is unique from the other ID's in your .const section. a better method is to use ID's that makes your code readable. so in your .const section for your tabcontrol id set it like this: .const TabControlID equ 1001 ;<--- the name can be anything you like as long as isnt a reserved name. the number should also be unique. so your code would look like this:
invoke CreateWindowEx,0, ADDR TabClrtCl,ADDR lpText, WS_VISIBLE or WS_CHILD or TCS_OWNERDRAWFIXED, 33,43,333,233,hWin,TabControlID,hInstance,0 . . .if wMsg == WM_DRAWITEM .if wParam == TabControlID mov esi, lParam
Thanks smurf, I will try this one and I will let you know if it will solve my problem. I think this way I am forced to have all tabs to be same size. forge
Your Tab size will be based on their text length. Ewayne
just curious, how can i change the text color of my tabs?
flanders, Make it OWNERDRAW invoke SetTextColor,DrawItem.hdc,DrawItem.itemData it will change the color and it will create another different problems.
Ewayne, You stated: Your Tab size will be based on their text length. This is not working. If I make a style TCS_OWNERDRAWFIXED, then this message invoke SendMessage,HandleSysTabContr,TCM_SETITEMSIZE,0,00220085h set up 22 pixels height but not the 85 with???? If I don't use TCS_OWNERDRAWFIXED then the with is set with no problem. Anyone could help me ??? forge