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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XP Style Controls in D5

Status
Not open for further replies.

Punchinello

Programmer
Apr 25, 2003
116
US
Hi,

I've got Delphi5 on a 98 machine and want to compile a program that will take advantage of XP Style controls if it is run on a XP machine.

I've placed the following code in the main form's OnCreate event and, in a second try, placed the code in the program file above the Application.Initialize line:
Code:
var
CC: Integer;

CC := ComCtrls.GetComCtlVersion;
ComCtrls.InitCommonControl(CC);
Neither try had any effect on the XP machine and the form has a small sample of controls that should look different. (radiobutton, checkbox, edit, scrollbox, combobox)

Can anyone help me with the right way to do this?

 
Well, I've answered my own question and here it is for everyone to see. To make your delphi app have the look and feel of windows XP follow these 2 steps:

Step 1
First you'll need to re-compile your project with a few lines of code added to your project file after the application initializes but before your first form is created. Here's an example:
Code:
program YourProgram;

uses ComCtrls, Forms,        {added ComCtrls}
     YourForm1 in 'YourForm1.pas' {YourForm1};

var                          {added variable}
  ccVersion: Integer;        {declaration}

{$R *.RES}

begin
  Application.Initialize;

  {added the following 2 lines}
  ccVersion := ComCtrls.GetComCtlVersion;
  ComCtrls.InitCommonControl(ccVersion);

  Application.CreateForm(TYourForm1, YourForm1);
  Application.Run;
end.
Step 2
Now create a manifest file with the name YourProgram.exe.manifest and place the file in the same folder as your application's executable file. A manifest file is simply a renamed .XML file. A sample that will work for this purpose as well as a complete description of implementing programs in XP can be found at
That's it. It worked for me, perhaps it will work for you.
 
Don't forget to wipe out some of the errors in the D5 runtime libs.
I found 2 articles on Delphi3000.com to that extent :
In the item 4) mentioned there, you need to save the ActivePageIndex before the loop, and restore it afterward.
and for Delphi 4 the issue of transparent tabsheets

Guess you'll have to register before you can access them, but they are well worth the countdown of your free article count ;-)

I know it's on another forum, but it's the most concentrated info I could find on the subject :-|

HTH
TonHu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top