Results 1 to 25 of 25

Thread: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    The title says it already - this is a project which shows how to use the
    uxTheme.dll (without any involvement of the comctl32.dll), to render directly
    onto the default-hWnd of a VB6-UserControl.

    In the compiled binary are currently hosted (and publically available on the outside):
    - cGDIPlusCache.cls (a Class to manage resource-loading from ByteArrays or Files "outside of any Control" - it's comparable to an ImageList, but supports PNG and HighQuality-resizing)
    - cSubClass.cls (a simple SubClasser, which the Controls are using - but it's also available on the outside)
    - ucFrame.ctl (a transparent, unicode-aware replacement for the VB.Frame-Control - interface-calling-compatible)
    - ucSSTab.ctl (also unicode-aware and nearly 100% compatible to the original, with the exception of the Property .TabSelIdx (instead of just .Tab as the original is using).

    Here's what the two Controls look like "in action" on a Win8-machine (with Scaling at 100% = 96dpi):


    And here the same Form on Win-XP (running with a Desktop-Scaling of 125% = 120dpi):


    As already mentioned, due to the quite high compatibility of the two Controls, one should be able
    to just replace (on a given "old Form" with original SSTabs and VB.Frames) the appropriate:
    ProgID in the ... " Begin ProgID ControlName " lines of a VB-*.frm ...
    All the old terms: TabDlg.SSTab ... can be replaced with: ThemedControls.ucSSTab
    and the terms/ProgIDs: VB.Frame ... can be replaced with: ThemedControls.ucFrame

    I've done this Search/Replace within a TextEditor on this original Form here (which is included in the Demo-Project):


    And the result which came out (since I use the same PropBag-formats as the original) after loading the replaced-*.frm file was:
    7

    So, in case you feel encouraged to work on this project (to enhance it about other uxTheme-based
    VB.compatible Controls like e.g. CommandButtons, OptionBoxes, CheckBoxes - please post back here,
    so that it can be included into the Main-OCX-Zip (which I would update when new interesting stuff comes in).

    Oh, and yes, the ucSSTab-replacement is "DesignTime-clickable" (tab-container-wise) -
    it also doesn't have the "Focus- and Tabbing-issues" of the original. What's missing currently
    (as an enhancement on top of the old SSTab) is Auto-Focusing of contained Controls on Tab-Switch -
    but I leave that for interested developers who want to contribute such an extension...

    Here's the Zip: ThemedControls.zip
    (please compile the OCX first into its \CtlSource\-SubFolder - after that you can run the Demo in the ThemedControls-MainFolder.

    Have fun...

    Olaf
    Last edited by Schmidt; Jun 21st, 2017 at 11:01 PM. Reason: Removed Link

  2. #2
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Minor issue in ucSSTab:

    TextWidth(.Caption) / Screen.TwipsPerPixelX 'only works for ANSI.

    Name:  WithTextWidth.png
Views: 3171
Size:  2.4 KB

    For Unicode:

    Name:  WithTextWidthW.png
Views: 3173
Size:  2.6 KB

    Code:
    Private Type SIZEAPI
      cx As Long
      cy As Long
    End Type
    
    Private Declare Function GetTextExtentPoint32W Lib "gdi32" (ByVal hDC As Long, ByVal lpsz As Long, ByVal cbString As Long, lpSize As SIZEAPI) As Long
    
    Private Function TextWidthW(ByVal sString As String) As Long
      Dim lPtr As Long
      Dim s As SIZEAPI
      If LenB(sString) Then
        lPtr = StrPtr(sString)
        If Not (lPtr = 0) Then
          GetTextExtentPoint32W hDC, lPtr, Len(sString), s
          TextWidthW = s.cx
        End If
      End If
    End Function

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Thank you for testing, good point...
    (overlooked that, proper TextOutput was not yet finished - also in terms of respecting the WordWrap-Property of the SSTab, which is now supported).

    So, this should be fixed now with the Unicode-capable GetThemeTextExtent-API (which was already in use within ucFrame).

    Please look at the new ScreenShot (after pressing F5 in your Browser) - and download the updated Demo-Zip again
    (didn't test with other languages/fonts currently - but VBs TextWidth is now definitely gone from the Code).

    Olaf

  4. #4
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    I am finding the left side of any part of the tab control is not shown. Win 10. Ver 1703.

    I also get the following entries in the log file:

    Code:
    Line 67: Property TabHeight in ucSSTab1 had an invalid value.
    Line 68: Property TabMaxWidth in ucSSTab1 had an invalid value.
    Line 108: Property TabHeight in ucSSTab2 had an invalid value.
    Line 109: Property TabMaxWidth in ucSSTab2 had an invalid value.
    All from the latest version of the control posted by Olaf at 06:16 this morning.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Quote Originally Posted by Steve Grant View Post
    I am finding the left side of any part of the tab control is not shown. Win 10. Ver 1703.
    No Win10 here for testing - but I've now changed the type of the (formerly used) Constant:
    TABP_TABITEM = 1
    to
    TABP_TOPTABITEMBOTHEDGE = 8
    in the uxTheme-rendering-routines.

    This produces no change in output on Win8, but might well show the missing left edge on the Win10-Theme (as the constant-name suggests it does).

    Quote Originally Posted by Steve Grant View Post
    I also get the following entries in the log file:

    Code:
    Line 67: Property TabHeight in ucSSTab1 had an invalid value.
    Line 68: Property TabMaxWidth in ucSSTab1 had an invalid value.
    Line 108: Property TabHeight in ucSSTab2 had an invalid value.
    Line 109: Property TabMaxWidth in ucSSTab2 had an invalid value.
    Ah - yes.
    The VB6-PropertyBag (when finally translating its values under the covers into the *.frm Files) is not working "locale-neutral".
    So you were ending up with german Commas as the decimal-points for these Single-Value-Types.

    I've now changed the Code in the WriteProperties-Event to use Rounding (to VB-Longs) instead,
    so that should not happen anymore.

    Please download again from the Zip in the TopPosting...

    Olaf

  6. #6
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Hi Olaf,

    Tested new version. No more log file, but left sides of Tab control still not drawn.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Thanks for checking it out (again)...

    Fixed it "the hard way" now (drawing the surrounding Borders in the correct ThemeColor myself),
    would appreciate, when you could confirm that it now draws the Borders correctly also on Win10
    (checked it myself on Win8.1, Win7 and WinXP already - it is drawn correctly on these 3 OSes).

    Please download again from the Zip-Link in the Opener-Post.

    Olaf

  8. #8
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Hi Olaf, everything is fine now. Many thanks.

  9. #9
    Lively Member
    Join Date
    Mar 2012
    Posts
    68

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Hi Olaf, demo works fine only if theme active.
    If i use classic them on Win7 - Name:  ucSStab.png
Views: 3204
Size:  3.7 KB

    Classic SStab work fine in this situation.


    Edit: Olaf, Is it possible to implement the TabsPerRow property?
    Last edited by Romeo91; Jun 20th, 2017 at 05:37 AM.

  10. #10
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Olaf, thanks for doing all the hard work setting up the themed rendering on this control, It shouldn't be too hard to add unthemed rendering using DrawFrameControl (or other APIs).

  11. #11
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,996

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Thanks Olaf, I see that it needs further testing and developing, but the project is already on the road.

  12. #12
    Lively Member
    Join Date
    Mar 2012
    Posts
    68

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Hi Olaf, in addition to my previous post.
    ucSStab does not show icons in the demo in my system.
    Both in compiled form and in IDE mode
    Name:  no_icons.png
Views: 3839
Size:  25.2 KB

  13. #13
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    There has been considerable confusion as to what links are acceptable. As a result of that discussion, we have decided to clarify what has always been a loose understanding. This will be added to the FAQ for the CodeBank and Utilities forum at some point in the future, but the rules are these:

    1) Post source code to CodeBank and Utilities if at all possible.
    2) No compiled code in CodeBank entries, but permissible in Utilities (as long as the code for it is provided too).
    3) A Link to GitHub for large source code projects when it does not fit into a doesn't fit into a post or zip file is acceptable.
    4) Since we can't ensure that a third party GitHub submission lacks compiled code, we'll have to allow that with regrets.

    The link from the original post was to a modestly sized zip file. Please attach that directly to the post rather than as a link to a third party site. That way, it will remain, and the thread will remain relevant, even if the other site goes away.
    My usual boring signature: Nothing

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Quote Originally Posted by Romeo91 View Post
    Hi Olaf, in addition to my previous post.
    ucSStab does not show icons in the demo in my system.
    Both in compiled form and in IDE mode
    Name:  no_icons.png
Views: 3839
Size:  25.2 KB
    You seem to have changed something in your test-form from the original TestProject-code,
    since the original Project should show the following Startup-Screen (taken on a Win7-machine):

    (note the BackGround-Image, a different TabHeight - and Tab 3 being the "startup-tab")


    So, at this point I'd like to know exactly what you've changed - especially with regards
    to the GDIPlus-Image-Cache (best to show the complete code of your current StartForm).

    Olaf

  15. #15
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Looks like Romeo91 turned on Themes in Win 7 for latest screenshot.
    His original issue was because he had Classic Theme enabled which is not part of UxTheme.dll thus the reason for the control not rendering.
    I tried it here on Win 7 Ultimate with Classic Theme enabled and it does not paint the theme. Something also causes the images not to paint.

    Obs: "Win 7 Starter" and "Win 7 Home Basic" cannot change Themes so you can't set Classic Theme for testing on those versions.
    Many of my controls have a fallback to OwnerDraw since UxTheme will not paint "Classic Theme".

    Screenshot when running demo on Win7 Classic Theme:

    Name:  Win7ClassicTheme.png
Views: 3196
Size:  85.5 KB

  16. #16
    Lively Member
    Join Date
    Mar 2012
    Posts
    68

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Quote Originally Posted by Schmidt View Post
    You seem to have changed something in your test-form from the original TestProject-code,
    since the original Project should show the following Startup-Screen (taken on a Win7-machine):
    (note the BackGround-Image, a different TabHeight - and Tab 3 being the "startup-tab")
    1. Olaf, This is your original code, not change by me, only change starting form to fTestOrigSSTabAfterReplace, and compile - Win7 Aero theme is enable. If add image to tab from IDE, it not showing on tab in IDE and Compile.
    2. If use your fTest form it's look fine. But you need to use always SSTab.GC.Addimage before add image to tab
    May i use
    Set SStab1.TabPicture(0) = Image1.Picture
    or add image to selected tab from IDE?

    P.S. Screenshot on Classic theme in Windows7 - Name:  classic.png
Views: 3211
Size:  70.9 KB

  17. #17

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    My question was with regards to the GDIPlusCache-Handling on Win7 - and your later posted info, that this occured
    when switching the Demo-Project to a different StartForm (fTestOrigSSTabAfterReplace) was helpful...

    This issue (feeding the GDIPlusCache directly from a StdPicture of type vbPicTypeIcon) is now fixed
    (it was an "Alpha-Render-Bug" inside GDIPlus, which doesn't happen on Win8 and higher - fixed the AlphaChannel, adjusting it "by hand" now).

    BTW, I was aware that there was no support for "non-themed classic mode" (thought somebody else would introduce it) -
    but support for that is now also included (over the old DrawEdge-API, also for ucFrame).

    usSSTab now also supports full transparency (like the ucFrame), when the BackColor-Property is set to -1 (&HFFFFFFFF).

    Please download again...

    Olaf

  18. #18
    Lively Member
    Join Date
    Mar 2012
    Posts
    68

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Quote Originally Posted by Schmidt View Post
    fixed the AlphaChannel, adjusting it "by hand" now).
    Now it works' fine
    Quote Originally Posted by Schmidt View Post
    BTW, I was aware that there was no support for "non-themed classic mode" (thought somebody else would introduce it) -
    but support for that is now also included (over the old DrawEdge-API, also for ucFrame).
    Great, I test it - now it works' fine.

    Quote Originally Posted by Schmidt View Post
    usSSTab now also supports full transparency (like the ucFrame), when the BackColor-Property is set to -1 (&HFFFFFFFF).
    Special thanks for this!!!

    Olaf, Is it possible to implement the TabsPerRow property, or autosize/autowidth property for Auto-fit width for stretching tabs on the entire width of the control, how it is implemented in MS SStab for the style:ssStyleTabbedDialog?

  19. #19
    Lively Member
    Join Date
    Mar 2012
    Posts
    68

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Quote Originally Posted by Romeo91 View Post
    Olaf, Is it possible to implement the TabsPerRow property, or autosize/autowidth property for Auto-fit width for stretching tabs on the entire width of the control, how it is implemented in MS SStab for the style:ssStyleTabbedDialog?
    ....
    and also add borderstyle settings.
    Thank you in advance!
    Last edited by Romeo91; Jul 9th, 2017 at 10:42 PM.

  20. #20
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,996

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Removed file. Now can be foud here.

  21. #21
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Eduardo,

    From a cursory look it looks pretty good. However, I'm wondering why you didn't start your own CodeBank thread for it. I'm hesitant to just hijack Olaf's thread to report my findings.

    Best Regards,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  22. #22
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,996

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Quote Originally Posted by Elroy View Post
    Eduardo,

    From a cursory look it looks pretty good. However, I'm wondering why you didn't start your own CodeBank thread for it.

    Best Regards,
    Elroy
    I'm planning to release it inside a component with other controls, but I still want to make some modifications (not to the SSTabEx but to other objects) to make them more general purpose before posting it.

    I thought that posting it here was a natural route...

    Quote Originally Posted by Elroy View Post
    I'm hesitant to just hijack Olaf's thread to report my findings.
    OK, then post the reports here or here so we do not hijack this thread.

  23. #23
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Code:
    Private Declare Function DrawThemeBackground Lib "uxtheme" (ByVal hTheme As Long, ByVal lHDC As Long, ByVal iPartId As Long, ByVal iStateId As Long, pRect As Any, pClipRect As Any) As Long
    
    Sub DrawThemeBGFrame(hTheme As Long, hDC As Long, R() As Long, Optional ByVal PartID As Long = BP_GROUPBOX, Optional ByVal State As Long = 1)
      If hTheme Then
        DrawThemeBackground hTheme, hDC, PartID, State, R(0), R(0)
    Is this an API that can make the control transparent?

    I haven't used this API before, can I directly copy the image in the background area? If the background area is composed of multiple controls, can it be copied? Similar to printwindow

  24. #24
    New Member
    Join Date
    Mar 2022
    Posts
    5

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Hi, I get a strange behaviour on labels: i can't click or double click them when they are in a ucsstab...
    what can I do?
    Thanks
    Alberto

  25. #25
    New Member
    Join Date
    Mar 2022
    Posts
    5

    Re: VB6 ThemedControls.ocx (uxTheme-based replacements for SSTab and VB.Frame)

    Quote Originally Posted by Albey View Post
    Hi, I get a strange behaviour on labels: i can't click or double click them when they are in a ucsstab...
    what can I do?
    Thanks
    Alberto
    Put the Labels you have to click inside a picture!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width