• Welcome to Theos PowerBasic Museum 2017.

I need help on TAB control

Started by Eros Olmi, September 05, 2008, 05:30:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Eros Olmi

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
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Chris Boss

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.


Eros Olmi

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
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Edwin Knoppert

Check if windows theming is an issue.

Eros Olmi

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
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

José Roca

#5
 
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.

Eros Olmi

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
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Edwin Knoppert

You can unset theming for a specific control.
Not sure if that will help then.

Eros Olmi

Interesting: how, if you do not mind?
I'm not very expert on this area  :-[
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Edwin Knoppert

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

José Roca

 

'//---------------------------------------------------------------------------
'//  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)

Eros Olmi

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
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Edwin Knoppert

You may need to redraw + i don't think 0's are good.
Please test :)

Edwin Knoppert

Just tested, not even redraw required, works fine right away.
(With the strings)

Eros Olmi

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 !!!
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB