Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VCL XP Look and feel

Status
Not open for further replies.

rcloutie

Programmer
May 26, 2005
164
CA
Hi there,

I've built a bunch of components based on common controls to implement company's rules (standard behavior within all projects).
I have a question about my own derived control of TCheckBox : TMyCheckBox = class(TCheckBox).

When opening existing projects, the look of my controls are standard style (that is, a black check mark on a 3D square).
But when creating brand new projects and inserting the same control, the look is like WinXP style (that is, a green check mark on a gradient flat square)

Is there a way to force the style of my controls according to the user's OS for my existing projects?
It seems that the graphical look and feel is project's reference, not form...

Thanks a lot in advance,

Rej Cloutier
 
just add the XPMan unit to your uses clause to have XP style controls....

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
You need to have an XP controls manifest resource. You can include it as a separate file, but I (personally) prefer it compiled into the executable.

You will find various incantations on the web, but what follows is stripped down to the minimum required.

Program.Manifest
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <dependency>
     <dependentAssembly>
       <assemblyIdentity
         type="win32"
         name="Microsoft.Windows.Common-Controls"
         version="6.0.0.0"
         processorArchitecture="X86"
         publicKeyToken="6595b64144ccf1df"
         language="*"
         />
       </dependentAssembly>
    </dependency>
  </assembly>

xpstyle.rc
Code:
1 24 "Program.Manifest"

Compile your rc file using the Borland Resource compiler:
Code:
C:\prog\myproj> brcc32 xpstyle.rc

That will give you a file named "xpstyle.res". All there is left is to link it into your project. Open the main form unit of your application and include the following in the implementation section:
Code:
implementation

{$R *.dfm}                   // The form's layout definition resource
{$R xpstyle.res xpstyle.rc}  // Make me pretty on XP

Now your application will look pretty on XP.
Just make sure that your custom controls derive from standard controls. For example, if you are making a custom button, derive from tButton. In the custom paint method, call the inherited paint first (to get the pretty control) then do your custom painting.

Hope this helps.
 
Duoas, that's what the XPman unit does.

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Duoas, that's what the XPman unit does.

Heh, I never knew that was there. Slick!

I only recently got Delphi 2006. Those using older versions (like D5) will need to either find the XPMan unit components on the web or do it as I explained above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top