PDA

Click to See Complete Forum and Search --> : VB6 - Transparent UserControls for XP/Vista


Jottum
Jul 30th, 2007, 06:19 PM
Title : Transparent UserControls for XP/Vista
Description : XpControls allow you to make real XP/Vista TabStrips.
Feature list :

XpGroupbox with 5 different borderstyles
XpOptionCheck
XpDivider

Screen-shots:
Default VB TabStrip
http://www.uitdeschriften.com/files/VB6/vbcontrols.jpg

XpControls TabStrip
http://www.uitdeschriften.com/files/VB6/xpcontrols.jpg

See sample project for more.

Author name: Jottum
System Requirements: XP/Vista (W2K legacy support)
License info: Freeware

Jottum
Aug 1st, 2007, 02:58 AM
Not sure how this happened, but the attached sample project has a few drawing errors when on W2K or if themes are disabled on XP/Vista.

I've corrected this and attached the new project, I'm sorry for the inconvenience.

SwapsRulez
Feb 3rd, 2008, 01:34 PM
The controls you have given are not the transparent one's. But they are having the white color as the background when you are using the property as transparent & its of no use if you have the background color or image rather than just having the white color. Is it possible to make them actually transparent so that the text caption of the checkbox or radio button will be displayed even if on the image. Waiting for your reply though the post is too old. thanks in advance... :)

Jottum
Feb 3rd, 2008, 02:35 PM
The controls you have given are not the transparent one's. But they are having the white color as the background when you are using the property as transparent & its of no use if you have the background color or image rather than just having the white color. Is it possible to make them actually transparent so that the text caption of the checkbox or radio button will be displayed even if on the image. Waiting for your reply though the post is too old. thanks in advance... :)

Hi,

Have you looked at the sample project?

If you follow the few guidelines there are, they are transparent. Or better, they look as if they are.

I wrote these controls to enable a programmer to create Tabbed dialogs with the XP gradient on a tab. (Vista no longer has a gradient TabBody)

First, they don't work with the SP6 controls, because they are not theme aware. You'll have to use the SP5 TabStrip.

Second, even the SP5 TabStrip doesn't paint the gradient on XP and to show it anyway I'm using a trick.

I wrote a function called DrawTabStripCheat, this draws the gradient on the form the Tabstrip is on, precisely where the TabStrip is on the form.

Each Transparent control has a UseParenFormhDC property and if you set that to True for each Transparent control, it will use that to paint its background, effectively rendering the control transparent.

This means, if you draw anything else on the form and set UseParenFormhDC to True it will use that as its background. If that's what you're after, you shouldn't use the DrawTabStripCheat function of course.

So, the steps you have to take:


Put a Tabstrip on a form
Use XpGroupBoxes with BorderStyle = None as your Tabpage containers
Place other XpGroupboxes with whatever borderstyle and the OptionCheckboxes on the TabPage containers and if what ever you want as transparent background is drawn on the form, set for each and every Transparent Control the UseParenFormhDC property to true.


It works, as the sample project shows and this screenshot I just made on my XP box.

http://www.uitdeschriften.com/files/VB6/screenshot.jpg

HTH

SwapsRulez
Feb 3rd, 2008, 02:49 PM
Hi there, thanks for that quick reply, but i think in the project controls were locked. I removed that lock. After that i've taken picture box control & put one of those radio button on that picture control. You can see here in the screenshot that the checkbox is having the white as the background color though i've selected the property as the transparent. see here the screenshots...

The output window

http://img249.imageshack.us/img249/4831/18798251ke7.png

The VB IDE window

http://img249.imageshack.us/img249/4800/2343lw7.png

Also my OS is Windows XP with that Vista Inspirat 2 theme, Waiting for your reply... thanks in advance... :)

Jottum
Feb 3rd, 2008, 03:02 PM
Hi,

Your'e welcom. :) I can't see it from your screenshots, but I think you didn't set the UseParentFormhDC to False for the checkbox you've put on that picturebox.

Please note that in the IDE the result isn't always imidiatly visible, closing and opening the form again will solve that.

Let me know if you can get it to work.

SwapsRulez
Feb 3rd, 2008, 03:52 PM
it was set to false already, but i've set it once again. Saved the project. & Then run it. But still no chances, same output.
After that i've closed the project & opened it again, as my bad luck, the project is showing again the same output with that UseParentFormhDC to False. Waiting for the reply. Thanks in advance. :)

Jottum
Feb 3rd, 2008, 05:08 PM
it was set to false already, but i've set it once again. Saved the project. & Then run it. But still no chances, same output.
After that i've closed the project & opened it again, as my bad luck, the project is showing again the same output with that UseParentFormhDC to False. Waiting for the reply. Thanks in advance. :)

To be honest, I don't get it. I just did the same thing you have done on the same form and this is the result:

http://www.uitdeschriften.com/files/VB6/screenshot2.jpg

If it works for me, but doesn't for you, I really don't know what else to advise you. I'm sorry. One more thing, you are using a Picturebox and not an Image control are you? It doesn't work with an Image control because it doesn't have DC.

SwapsRulez
Feb 3rd, 2008, 06:27 PM
Can u send that project to me in the zip file. Really i swear... here its not working though i've tried with both the image & picture controls. Thanks in advance... :)

Jottum
Feb 4th, 2008, 03:07 AM
Can u send that project to me in the zip file. Really i swear... here its not working though i've tried with both the image & picture controls. Thanks in advance... :)

Sure, you can grab it here (http://www.uitdeschriften.com/files/VB6/xpcsource.zip). Let me know if it works.

SwapsRulez
Feb 4th, 2008, 06:01 AM
mate.... hurray..... it worked.... but what was problem with mine. also the buttons are not working properly in your project also. Its ok though, i've switched to now Visual Studio VB.net 2008 Professional. By the way, thanks for that much help. But if this control is meant ot improve then lemme know. i'll work as beta tester. Thanks for all that help. :)

Jottum
Feb 4th, 2008, 07:19 AM
mate.... hurray..... it worked.... but what was problem with mine. also the buttons are not working properly in your project also. Its ok though, i've switched to now Visual Studio VB.net 2008 Professional. By the way, thanks for that much help. But if this control is meant ot improve then lemme know. i'll work as beta tester. Thanks for all that help. :)

Great! :) There's always a chance you accidently changed something, why your "version" didn't work. I used the same project, so it's a bit weird.

The whole idea behind the XpControls (http://www.uitdeschriften.com/files/VB6/) is to enable VB6 programmers to create true theme aware Tab dialogs, like property pages, Option dialogs etc. That's why the "transparency" focuses on that and not just any background. It will work (eventually:)) tho.

XpControls.ocx is a work in progress and much improved since I released the source you've tried. At the moment I'm working on a transparent scrollable lable, that looks just like a Textbox, but read only. :)

I'm considering to add a Tab control as well, that way you'll have one control to create great looking themed dialogs. :)

I wish you luck with VB 2008, I've been playing with it and the code hardly looks like VB6, it is more a new language all together. :)

Take care,

aikidokid
Apr 22nd, 2008, 12:09 PM
Hi Jottum.

Firstly, thanks for these great controls. :thumb:

I am using the tabstrip, but I am having a problem with the colour. I have a white form, but the top of the tabstrip is still buttonface colour. I tried to change the backcolor but it wouldn't let me for some reason.

I have tried to use the DrawTabStripCheat, but I get the error message Variable not defined PSZ_TAB

I don't know if I am putting, or calling the code fom the right place?

This is what I get:

Jottum
Apr 23rd, 2008, 04:27 AM
Hi Jottum.

Firstly, thanks for these great controls. :thumb:

Hi aikidokid,

You are welcome. :)

I am using the tabstrip, but I am having a problem with the colour. I have a white form, but the top of the tabstrip is still buttonface colour. I tried to change the backcolor but it wouldn't let me for some reason.

I'm sorry to say this has nothing to do with my controls, the vbTabStrip draws its background in vbButtonFace internally and doesn't have a BackColor property. :(

I have tried to use the DrawTabStripCheat, but I get the error message Variable not defined PSZ_TAB

Uhm... That's odd, all the PSZ_* should be declared in XpControls.bas.


' General
Public Type pszClassList
PSZ_BUTTON As String
PSZ_COMBOBOX As String
PSZ_EDIT As String
PSZ_EXPLORERBAR As String
PSZ_HEADER As String
PSZ_LISTVIEW As String
PSZ_MENU As String
PSZ_PAGE As String
PSZ_PROGRESS As String
PSZ_REBAR As String
PSZ_SCROLLBAR As String
PSZ_SPIN As String
PSZ_STARTPANEL As String
PSZ_STATUS As String
PSZ_TAB As String
PSZ_TASKBAND As String
PSZ_TASKBAR As String
PSZ_TASKBARCLOCK As String
PSZ_TOOLBAR As String
PSZ_TOOLTIPS As String
PSZ_TRACKBAR As String
PSZ_TRAYNOTIFY As String
PSZ_TREEVIEW As String
End Type
____________________________________

Public Function ClassListItems() As pszClassList

Dim tmpClassListItems As pszClassList

With tmpClassListItems
.PSZ_BUTTON = "Button"
.PSZ_COMBOBOX = "ComboBox"
.PSZ_EDIT = "Edit"
.PSZ_EXPLORERBAR = "ExplorerBar"
.PSZ_HEADER = "Header"
.PSZ_LISTVIEW = "ListView"
.PSZ_MENU = "Menu"
.PSZ_PAGE = "Page"
.PSZ_PROGRESS = "Progress"
.PSZ_REBAR = "Rebar"
.PSZ_SCROLLBAR = "Scrollbar"
.PSZ_SPIN = "Spin"
.PSZ_STARTPANEL = "StartPanel"
.PSZ_STATUS = "Status"
.PSZ_TAB = "Tab"
.PSZ_TASKBAND = "TaskBand"
.PSZ_TASKBAR = "TaskBar"
.PSZ_TASKBARCLOCK = "Taskbar Clock"
.PSZ_TOOLBAR = "Toolbar"
.PSZ_TOOLTIPS = "Tooltips"
.PSZ_TRACKBAR = "Trackbar"
.PSZ_TRAYNOTIFY = "Tray Notify"
.PSZ_TREEVIEW = "TreeView"
End With

ClassListItems = tmpClassListItems

End Function


I don't know if I am putting, or calling the code fom the right place?

When using a vbTabStrip you should use the DrawTabStripCheat function, or you want have the gradient body. (On Vista you wont see the difference, since Vista no longer has a gradient TabBody)

The sample project - attached to my original post above - actually has two projects, XpControls.vbp and TabStripSample.vbp. Have a look at the last one to see how to use these controls with a vbTabStrip and how to use the TabStripCheat function.

Please note: Set the form's Autoredraw to True when using TabStripCheat, and UseParentFormhDC to True for all XpControls you use on that TabStrip.

This is what I get:

[...]

Let me know if you can get it to work.

HTH

rmorrison100
Mar 3rd, 2011, 11:52 PM
Thanks for the tips. I will try later if I can make also transparent box.