PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Roger Garstang on January 25, 2009, 09:54:08 PM

Title: Tab Control / Label Question....
Post by: Roger Garstang on January 25, 2009, 09:54:08 PM
I am trying to hide the grey boarder at the top of a tab control with a label control that matches the color of the form background. I can click the "Bring to front" for the label and get the expected results when viewing in the designer, but when I run the program, the label is hiding behind the tab.

Any ideas?

Gary
Title: Re: Tab Control / Label Question....
Post by: TechSupport on January 25, 2009, 11:17:50 PM
Hi Gary,

Not sure why you want to overlay the Tab headers with Labels but the code below should position a label over the currently selected tab item. There may be better ways to do this, but this approach seems to work.


Function FRMMAINFORM_TABCONTROL1_TCN_SELCHANGE ( _
                                               ControlIndex  As Long,      _  ' index in Control Array
                                               hWndForm      As Dword,     _  ' handle of Form
                                               hWndControl   As Dword,     _  ' handle of Control
                                               ByVal lpNMHDR As NMHDR Ptr  _  ' pointer to NMHDR
                                               ) As Long

   Local nCurSel As Long
   Local rcItem  As Rect
   Local rc      As Rect
   
   nCurSel = TabCtrl_GetCurSel( hWndControl )
   TabCtrl_GetItemRect hWndControl, nCurSel, rcItem
   
   GetWindowRect hWndControl, rc
   MapWindowPoints %HWND_DESKTOP, hWndForm, rc, 2
   
   SetWindowPos HWND_FRMMAINFORM_LABEL1, %HWND_TOP, _
                rc.nLeft + rcItem.nLeft, _
                rc.nTop + rcItem.nTop, _
                rcItem.nRight - rcItem.nLeft, _
                rcItem.nBottom - rcItem.nTop, _
                0
   
End Function

Title: Re: Tab Control / Label Question....
Post by: Roger Garstang on January 25, 2009, 11:32:15 PM
Paul,

I am not trying to cover the tabs themselves, but rather the gray portion to the right of the tabs. That grey area has always annoyed me, so I usually create a label to match the form background that hides the grey area. If the form background is grey, it is not noticeable, but if the form is colored, it justs looks weird. VB and EZGUI both do the same thing, so it is a Windows issue and not a Firefly designer issue.

Hopefully this makes sense.....basic question is how to make the label appear in front of the tab control.
Gary
Title: Re: Tab Control / Label Question....
Post by: TechSupport on January 25, 2009, 11:37:19 PM
aaaaahhhhhh! Okay, Now I understand!

I'm off to bed now but I'll pop something together in the morning (if I can figure out an easy way to do it).
Title: Re: Tab Control / Label Question....
Post by: TechSupport on January 26, 2009, 09:02:27 AM
Hi Gary,

I modified the previous example a little bit. You may have to play around with the positioning a bit - not sure. It seemed to work okay in my simple test.

All I do is find out the item rectangle for the last tab header and then position the label immediately to the right of it. I do the positioning in the WM_CREATE message handler because the TabControl has already been created at that point. I use the SetWindowPos api command (you should learn it - I use it A LOT), to position, size, and set the zorder so that it displays on top of the Tab Control.

Please let me know if it doesn't work or needs further tweaking.  :)


Function FRMMAINFORM_WM_CREATE ( _
                               hWndForm As Dword, _  ' handle of Form
                               ByVal UserData As Long _  'optional user defined Long value
                               ) As Long

   Local nCount As Long
   Local rcItem As Rect
   Local rc     As Rect
   Local hWndControl As Long
   
   hWndControl = HWND_FRMMAINFORM_TABCONTROL1
   
   nCount = TabCtrl_GetItemCount( hWndControl )
   TabCtrl_GetItemRect hWndControl, nCount-1, rcItem
   
   GetWindowRect hWndControl, rc
   MapWindowPoints %HWND_DESKTOP, hWndForm, rc, 2
   
   SetWindowPos HWND_FRMMAINFORM_LABEL1, %HWND_TOP, _
                rc.nLeft + rcItem.nRight + 2, _
                rc.nTop + rcItem.nTop - 2, _
                rc.nRight - rcItem.nRight, _
                rcItem.nBottom - rcItem.nTop, _
                0

End Function


Title: Re: Tab Control / Label Question....
Post by: Roger Garstang on January 26, 2009, 12:05:17 PM
Thanks Paul.... I will give this a whirl!

Gary