XP look and feel problems.

clearz

Newcomer
Joined
Jul 21, 2003
Messages
22
Hi

I use textpad to code my c# programs. To get a xp lookandfeel I use a manifest file and a ((ButtonBase)Btn).FlatStyle = FlatStyle.System; line of code for the buttons. This all works fine when I compile and run it from textpad. When my program is complete I use the command line to do the final compilation to get rid of the console window and add an Icon. I use something like

csc /t:winexe /r:System.dll /r:System.Drawing.dll /r:System.Windows.Forms.dll /win32icon:Icon1.ico /res:Icon1.ico /out:"Name.exe" BankApp.cs

This compiles OK but when I run the program I get the old windows look and feel. Can anyone please tell me were I am going wrong.

Thanks
John Cleary.
 
Yes everything is in the same directory. It runs fine when running it from textpad. Is there a way of changing the current working directory from within a c# program.
 
What do you mean "when running it from textpad"? When any program at all compiles and runs it, it generates a usable EXE...
 
If you'd like to embed the manifest in the EXE, you can. But you have to do it manually after each recompile. Visual Studio will let you do it, but it's a somewhat tedious process (less than 2 minutes, but 5 to 10 steps). I don't know how to do it outside of Visual Studio.

But, as Volte said, as long as the EXE and manifest file are in the same folder, it should work fine.

-Nerseus
 
You can't embed the manifest using .NET resource files, I don't think. Windows only lets you do it with the standard .RES files that C++ and VB6 and the like generate.
 
I had an article from MSDN that showed how to embed the manifest file in the EXE. The steps were something like open up the compiled EXE in Visual Studio (shows a tree, including resources and such). You could then add a new item, give it a very specific name and include the text that the manifest file contained. You would then resave your EXE with the newly embedded manifest. In fact, you could open up ANY EXE (even non .NET) and do this. It might not work if the controls didn't have their FlatStyle set (or whatever the "real" windows name is for that style), but you could still embed the info and save the new EXE.

When my buddy gets back in from lunch I'll see if he still has a link to the article.

-Nerseus
 
One more note, the following is all you need in your manifest file. This is a trimmed down version from what most people use and has one major benefit: You don't have to update it for every project you have. You can use this contents for any EXE, just make sure you rename the file to match your EXE's name plus the manifest extension.

If your EXE is named "Project1.Test1.EXE" then the manifest file should be named "Project1.Test1.EXE.manifest".

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

edit: Added the following:
Here are the instructions for embedding the manifest in the EXE (the original link I have isn't working - it's on gotdotnet.com but redirects somewhere else):
1. Open your exe in VS (file -> open file)
2. Right click on it and select add resource
3. Click "Import..." from the dialog
4. Select your manifest file
5. In the "Resource Type" field, enter "RT_MANIFEST"
6. In the property grid, change the resource ID from "101" to "1".
7. Save the exe.

-Nerseus
 
Last edited:
Back
Top