How to skin the titlebar

Topics related to the Krypton Toolkit.

Moderators: Phil Wright, Chris Porter

How to skin the titlebar

Postby chrisdouglass » Sat Jun 30, 2007 6:04 am

When you use a ribbon, etc on a standard winform, how can you get the titlebar (control box, min/max/restore buttons, etc) to be skinned using the same theme/palette as the Krypton controls?
chrisdouglass
 
Posts: 13
Joined: Sat Jun 30, 2007 6:02 am

Postby Phil Wright » Sat Jun 30, 2007 9:34 am

Hi

You need to derive your own form from the KryptonForm base class. Then it will have the same custom chrome look and feel. So if you select the default Office 2007 - Blue palette you will get the blue appearance in the titlebar just like Office.

Phil
Phil Wright
Site Admin
 
Posts: 2720
Joined: Thu Apr 13, 2006 2:55 pm
Location: Melbourne, Australia

Postby chrisdouglass » Sun Jul 01, 2007 4:23 am

hey phil, thanks for the response. i derived from kryptonform and it didn't change the appearance of the titlebar. i'll read more through the docs but the seemingly obvious choices of AllowFormChrome in the kryptonManager instance and within the form's properties were both set to true. thanks for any ideas!
chrisdouglass
 
Posts: 13
Joined: Sat Jun 30, 2007 6:02 am

here it is

Postby kelvin » Sun Jul 01, 2007 10:13 am

Hi Chris,

May I answer this question? Here are the easy 123 steps to follow :D
0.
First, make sure you have installed and imported the Krypton toolkit properly.
1.
Now, you create a normal Form in your project call it Form1.
Then you go to the Designer code Form1.Designer.vb or .cs depending on your choice of language.
2.
You will see something like this at the very beginning:
Code: Select all
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

Manually change it to this:
Code: Select all
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits ComponentFactory.Krypton.Toolkit.KryptonForm

3.
Now go back to the design view of Form1 by double clicking Form1.vb or .cs
Ta~da~you have the beautiful krypton title bar all at a sudden.

Cheers,
Kelvin
kelvin
 
Posts: 16
Joined: Fri Jun 22, 2007 11:54 pm

Postby jkr » Sun Jul 01, 2007 3:21 pm

or in c#
Code: Select all
using ComponentFactory.Krypton.Toolkit;
...
public partial class Form1 : KryptonForm
jkr
 
Posts: 165
Joined: Tue May 29, 2007 4:35 pm
Location: Bucharest, Romania

Postby chrisdouglass » Mon Jul 02, 2007 1:59 am

I did that both in the frm.designer.cs and form.cs files. i included the namespace and then dervied from KryptonForm. I'll try again with a new project. I mucked around with the namespace for my solution at one point and perhaps that's part of the problem, though I can compile and run just fine even with these changes.
chrisdouglass
 
Posts: 13
Joined: Sat Jun 30, 2007 6:02 am

Postby chrisdouglass » Mon Jul 02, 2007 6:24 am

I added the code as mentioned and it still isn't working. I created a test project within a single form and that didn't work either. here's some things i tried:

- created basic winform project, c#
- derive in both cs files from KryptonForm
test = same result
- add the kryptonManager component to form
- change globalpalette in manager properties to proper skin
- ensure form PaletteMode is set to Global
test = same result
- add kryptonPalette component to form
- change skin in palatte instance
- assign palette to form's Palette property
test = same result

no sure what else to try...
chrisdouglass
 
Posts: 13
Joined: Sat Jun 30, 2007 6:02 am

Postby jkr » Mon Jul 02, 2007 3:39 pm

- create a project
- add a krypton button (so the assembly is referenced)
- in code view add
using ComponentFactory.Krypton.Toolkit;
- rename "public partial class Form1 : Form" to "public partial class Form1 : KryptonForm"

later edit :
- add a KryptonManager and change the GlobalPaletteMode

the title bar is skinned when the global palette mode is set to one of the 3 office 2007 styles, with the other 2 styles they look like the default windows skin
be sure to have windows themes enabled, because in classic theme the title bar is not skinned
jkr
 
Posts: 165
Joined: Tue May 29, 2007 4:35 pm
Location: Bucharest, Romania

Postby chrisdouglass » Mon Jul 02, 2007 10:06 pm

thanks! i always run with the themes service disabled. after enabling, krypton painted the titlebar as expected.
chrisdouglass
 
Posts: 13
Joined: Sat Jun 30, 2007 6:02 am

Postby DaveThompson » Tue Jul 03, 2007 3:01 am

If you have the (paid-for) source for krypton toolkit, you can hack around and get the skins working in windows classic mode. it's not recommended, though...
DaveThompson
 
Posts: 24
Joined: Mon Mar 05, 2007 6:55 pm
Location: London, England

Postby Waescher » Thu Jul 05, 2007 8:38 pm

would it be possible to add a property to enable toolbar-skinning on non-themed windows versions? Phil?
In my case, I would appreciate to skin a form running on server systems like windows 2000 oder server 2003.

I know that this feature was disabled deliberately... but ... please ... :(
Waescher
 
Posts: 219
Joined: Thu Jun 14, 2007 10:11 pm
Location: Germany

Postby Phil Wright » Thu Jul 05, 2007 10:27 pm

Because I cannot get the code to work in all circumstances it is not possible to release it as a feature. Sorry.
Phil Wright
Site Admin
 
Posts: 2720
Joined: Thu Apr 13, 2006 2:55 pm
Location: Melbourne, Australia

Postby DaveThompson » Sat Jul 07, 2007 12:20 am

I've been playing with themed KryptonForm on unthemed windows xp and 2003 and found that solving the problem with the title bar buttons redrawing at odd times is to add the following code to the KryptonForm WndProc...

Code: Select all
                    case PI.WM_SETCURSOR:
                        processed = OnSetCursor(ref m);
                       break;


You need to add your own method, and associated methods added into the PI class...

Code: Select all
private bool OnSetCursor(ref Message m)
        {
            uint val = PI.GetWindowLong(Handle, -16);
            uint newVal = (val - PI.WS_VISIBLE);
            PI.SetWindowLong(Handle, PI.GWL_STYLE, (int)newVal); // val & PI.WS_VISIBLE);
            try
            {
                DefWndProc(ref m); // base.WndProc(ref m);
            }
            finally
            {
                PI.SetWindowLong(Handle, PI.GWL_STYLE, (int)val);
            }

            return true;
        }


This does seem to fix the drawing issue. I've observed this is how other products seem to have solved the drawing in non-themed mode on XP and 2003.

If someone with the source could have a look and confirm, please...

Dave
DaveThompson
 
Posts: 24
Joined: Mon Mar 05, 2007 6:55 pm
Location: London, England

Postby Phil Wright » Sun Jul 08, 2007 1:36 pm

Thanks for the info, I will give that a try during the coming week and let you know if it seems to work in all circumstances. Phil
Phil Wright
Site Admin
 
Posts: 2720
Joined: Thu Apr 13, 2006 2:55 pm
Location: Melbourne, Australia

Still no skinned titlebar

Postby rito2k » Sat Jul 14, 2007 3:44 am

Hello everybody,

i have been working with the Toolkit through version 2.1.0 to 2.4.1 and never had any problems, apparently.

2 days ago i uninstalled previous version for installing the brand new 2.5.1 version.

Now i can´t get the titlebars of any of my applications skinned like before. Also tried to create a whole new project, simple, with just a standard Form, reference the toolkit dll, include the using statement, derive the form from Krypton Tooolkit and insert a Krypton Manager (set as global) and still no success!!

Have tried everything written in this post, nothing to do... What i have observed, if i re-reference to old 2.4.1 DLL, voilá! There it is...

May I be missing something? Thank you very much.
rito2k
 
Posts: 2
Joined: Wed Apr 11, 2007 7:38 pm

Postby Phil Wright » Mon Jul 16, 2007 1:08 pm

I tried the WM_SETCURSOR change and it did not work quite as required. The cursor was not correctly set when the mouse was over the client area of the application.
Phil Wright
Site Admin
 
Posts: 2720
Joined: Thu Apr 13, 2006 2:55 pm
Location: Melbourne, Australia

Postby DaveThompson » Mon Jul 16, 2007 8:59 pm

Try the info available here - http://www.vbaccelerator.com/home/VB/Code/Controls/Skins/article.asp - it's where I got the mouse cursor hack from.

On my machine, all the WM_SETCURSOR thing does is just hide the overdraw of the minimize/maximize buttons - but it could be a fluke.

Dave
DaveThompson
 
Posts: 24
Joined: Mon Mar 05, 2007 6:55 pm
Location: London, England

Postby Waescher » Fri Jul 27, 2007 11:59 pm

... any good news by now ? :(
Waescher
 
Posts: 219
Joined: Thu Jun 14, 2007 10:11 pm
Location: Germany

Postby Phil Wright » Sat Jul 28, 2007 1:15 pm

This hack does not work for Krypton. Also you need to remember that with Krypton you can turn on and off the custom border rendering and so any solution has to work when you change between approaches.
Phil Wright
Site Admin
 
Posts: 2720
Joined: Thu Apr 13, 2006 2:55 pm
Location: Melbourne, Australia

Postby valdain » Tue Oct 02, 2007 2:43 am

Any update on adding skinning to non-themed windows (mainly Windows 2003)? I did some code modifications myself, but would always feel better if the control supported it natively.

Joe
valdain
 
Posts: 4
Joined: Sat Sep 29, 2007 4:52 am

Next

Return to Krypton Toolkit

Who is online

Users browsing this forum: Bing [Bot] and 0 guests