Sign in to follow this  
Cybrosys

[.net] WinXP look + misc questions

Recommended Posts

Cybrosys    186
I'm curious as to how i can get my apps to look like winxp apps, i mean the color toning etc; going from a brighter color to a darker one? What event gets fired when a window is minimized, i thought it'd be resize? I can manage the resize event and check the WindowState if it's minimized but is that propper? After i minimize my window, i remove it's taskbar entry and displays an icon in the system tray, the problem is how do i restore the window to normal state? What message do i have to signal in order for it to get restored to normal size and be visible? Just setting WindowState to normal doesn't cut it but if i call Refresh() on the form it updates correctly most of the times, some times it stays hidden, i know that's not the propper way to do it :S Edit: *_Resize(...) WindowState == FormWindowState.Minimized; Hide(); <- propper way to hide the application instead of setting the Taskbar visibility to false To show it again properly Show(); WindowState = FormWindowState.Normal; You have to call Show() before changing the WindowState, why? No idea, one of those mysteries. [Edited by - Cybrosys on July 19, 2005 5:28:22 PM]

Share this post


Link to post
Share on other sites
ernow    732
This is what I did:

private void MainForm_SizeChanged(object sender, System.EventArgs e)
{
this.ShowInTaskbar = this.WindowState != FormWindowState.Minimized;
}


private void notifyIcon_Click(object sender, System.EventArgs e)
{
if(this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal;
}
else if(this.WindowState == FormWindowState.Normal)
{
this.WindowState = FormWindowState.Minimized;
}
}


Cheers

Share this post


Link to post
Share on other sites
Washu    7829
Look up: Application.EnableVisualstyles
You will also need to set the Flatstyle of the control to System (if supported for that control)

Share this post


Link to post
Share on other sites
Nypyren    12061
Under certain circumstances you might also need to use the "manifest" file to specify which version of the common controls you want.

If you make a file called MyProgram.exe.manifest, put it in the same location as your .exe, and give it the following (XML) contents, it will XP-style-ify most of the controls that you can't normally configure.


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





Most importantly, that "Program.Name.Here" string needs to have the a name that looks like (Anything).(Anything).MyProgram where MyProgram matches your .exe name without the ".exe".

If anyone knows how to bake this into your .EXE without having it crash (like every tutorial I've seen), I would love to know.

[Edited by - Nypyren on July 20, 2005 2:03:55 AM]

Share this post


Link to post
Share on other sites
Cybrosys    186
Thanks for all the help guys.

I'm still wondering about the gradient fill, if i have to overload the OnPaint message or if there's another option? Maybe the gradient fill is just something that exists on Toolbars and i shouldn't expect it on the background of an application?

Edit:

Well a Toolbar didn't gradient fill but the buttons on it sure looked nice with the xp style =)

Edit:

Bah, guess i'll just do it myself, can't expect windows to do everything for me ;)


System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(e.ClipRectangle, Color.LightGray, Color.Gray, 0, false);
e.Graphics.FillRectangle(brush, e.ClipRectangle);



[Edited by - Cybrosys on July 20, 2005 11:53:36 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this