Theos PowerBasic Museum 2017

Archive => Discussion - Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Topic started by: Eros Olmi on September 05, 2008, 05:30:36 PM

Title: I need help on TAB control
Post by: Eros Olmi on September 05, 2008, 05:30:36 PM
Hi all,

I'm using PBWIN9 and I'm having problems when setting %TCS_VERTICAL in TAB style.
When TABs are horizontal all is ok, when are vertical I get no labels written but just empty tabs.
The attached images are from a thinBasic script but the same situation is present if I modify PB9 example using TAB.

Maybe it is a font problem, I do not know.

Any idea?

Thanks a lot
Eros
Title: Re: I need help on TAB control
Post by: Chris Boss on September 05, 2008, 05:39:22 PM
Eros,

Vertical Tabs require some tweaking of your tab text and the font.

If you use a horizontal font, you would have to embed CRLF's after each character so they will line up vertically, but I haven't tested this so I don't know if the tab control tolerates CRLF's in text.

The proper solution is to create a vertical font (front is rotated 90 degrees) and use that.

The tab control will not rotate the text for you, if you use a horizontal (normal) font.

Title: Re: I need help on TAB control
Post by: Eros Olmi on September 05, 2008, 05:44:28 PM
Thank you Chris.

Imagine I do not want vertical font but horizontal font. How can I set TABs a little more wider so horizontal font can be visible?

Thanks a lot
Eros
Title: Re: I need help on TAB control
Post by: Edwin Knoppert on September 05, 2008, 06:06:17 PM
Check if windows theming is an issue.
Title: Re: I need help on TAB control
Post by: Eros Olmi on September 05, 2008, 06:14:25 PM
Edwin, you got it.

Attached official PB9 example themed and not themed. Not themed one shows vertical tabs correctly.
Anyhow I have no clue on how to solve it. I presume some hours in MSDN ;)

Thanks
Eros
Title: Re: I need help on TAB control
Post by: José Roca on September 05, 2008, 06:25:40 PM
 
Quote
Anyhow I have no clue on how to solve it.

Unless you write your own control...

Windows common controls and themes are a never ending source of troubles. In the SED editor I had to move the tabs from the bottom to the top because if you use themes and locate the tabs at the bottom they are incorrectly drawn.

See: http://www.codeproject.com/KB/tabs/XPTabApp.aspx

M$ solution: Switch to .NET.
Title: Re: I need help on TAB control
Post by: Eros Olmi on September 05, 2008, 06:31:50 PM
Thanks José.

I just found the same link and looking at the C++ source code I've decided to give up. Too much work for a (maybe) not needed option.
At least now I know the problem details.

Ciao
Eros
Title: Re: I need help on TAB control
Post by: Edwin Knoppert on September 05, 2008, 07:04:02 PM
You can unset theming for a specific control.
Not sure if that will help then.
Title: Re: I need help on TAB control
Post by: Eros Olmi on September 05, 2008, 09:02:39 PM
Interesting: how, if you do not mind?
I'm not very expert on this area  :-[
Title: Re: I need help on TAB control
Post by: Edwin Knoppert on September 05, 2008, 10:24:38 PM
This is how i do it in PwrDev:
    Local T As String
    T = UCode$( " " )
    VD_UxTheme_SetWindowTheme( nCbHndl, %ID_FORM1_TEXT1, T, T )

See:
http://msdn.microsoft.com/en-us/library/ms649781(VS.85).aspx#turnoff
Title: Re: I need help on TAB control
Post by: José Roca on September 05, 2008, 10:28:59 PM
 

'//---------------------------------------------------------------------------
'//  SetWindowTheme()
'//                      - redirects an existing Window to use a different
'//                        section of the current theme information than its
'//                        class normally asks for.
'//
'//  hwnd                - the handle of the window (cannot be NULL)
'//
'//  pszSubAppName       - app (group) name to use in place of the calling
'//                        app's name.  If NULL, the actual calling app
'//                        name will be used.
'//
'//  pszSubIdList        - semicolon separated list of class Id names to
'//                        use in place of actual list passed by the
'//                        window's class.  if NULL, the id list from the
'//                        calling class is used.
'//---------------------------------------------------------------------------
'// The Theme Manager will remember the "pszSubAppName" and the
'// "pszSubIdList" associations thru the lifetime of the window (even
'// if themes are subsequently changed).  The window is sent a
'// "WM_THEMECHANGED" msg at the end of this call, so that the new
'// theme can be found and applied.
'//---------------------------------------------------------------------------
'// When "pszSubAppName" or "pszSubIdList" are NULL, the Theme Manager
'// removes the previously remember association.  To turn off theme-ing for
'// the specified window, you can pass an empty string (L"") so it
'// won't match any section entries.
'//---------------------------------------------------------------------------
'THEMEAPI SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName,
'    LPCWSTR pszSubIdList);

#IF %USELOADLIBRARY <> 0

FUNCTION SetWindowTheme (BYVAL hwnd AS DWORD, BYVAL pszSubAppName AS DWORD, _
   BYVAL pszSubIdList AS DWORD) AS LONG

   LOCAL hr AS LONG
   LOCAL hLib AS DWORD
   LOCAL pProc AS DWORD

   hLib = LoadLibrary("UxTheme.dll")
   IF hLib THEN
      pProc = GetProcAddress(hLib, "SetWindowTheme")
      IF pProc THEN
         CALL DWORD pProc USING SetWindowTheme(hwnd, pszSubAppName, pszSubIdList) TO hr
         FUNCTION = hr
      END IF
      FreeLibrary hLib
   END IF

END FUNCTION

#ELSE

DECLARE FUNCTION SetWindowTheme LIB "UxTheme.dll" ALIAS "SetWindowTheme" ( _
   BYVAL DWORD _                            ' HWND hwnd
, BYVAL DWORD _                            ' LPCWSTR pszSubAppName
, BYVAL DWORD _                            ' LPCWSTR pszSubIdList
) AS LONG                                  ' HRESULT

#ENDIF


Call it as SetWindowTheme(hWnd, 0, 0)
Title: Re: I need help on TAB control
Post by: Eros Olmi on September 05, 2008, 10:50:31 PM
Thanks José but it seems not to work.
I've tested both in thinBasic and in PB90 Tab control example.

I've called SetWindowTheme(hWnd, 0, 0) just after CONTROL ADD TAB ... with hWnd equal to the handle of the tab control.

Is it right?

http://msdn.microsoft.com/en-us/library/ms997646.aspx#xptheming_topic8
Title: Re: I need help on TAB control
Post by: Edwin Knoppert on September 05, 2008, 10:54:46 PM
You may need to redraw + i don't think 0's are good.
Please test :)
Title: Re: I need help on TAB control
Post by: Edwin Knoppert on September 05, 2008, 10:57:33 PM
Just tested, not even redraw required, works fine right away.
(With the strings)
Title: Re: I need help on TAB control
Post by: Eros Olmi on September 05, 2008, 11:12:43 PM
Yes, now it works passing two pointers to a null string:


        Dim s1 As String
        s1 = ""
        SetWindowTheme(hControlHandle, StrPtr(s1), StrPtr(s1))


Thanks to all !!!
Title: Re: I need help on TAB control
Post by: Edwin Knoppert on September 05, 2008, 11:21:09 PM
Sigh, why don't read my post and msdn?
It is passed with a space in unicode.
I remember that this space was an issue.