PDA

View Full Version : استفاده از Theme ویندوز XP برای برنامه ها؟



khafanovich
پنج شنبه 30 تیر 1384, 19:36 عصر
سلام خسته نباشید دوستان.
چگونه میتوان از امکانات theme ویندوز Xp در برنامه ها استفاده کرد.
آموزش حوه استفاده از آن در اینترنت هست ولی من تا کنون نتوانسته ام ملا از آن استفاده کنم.
اگر تجربه ای دارید لطفا راهنمایی کنید.
ممنون.

مطهر
پنج شنبه 30 تیر 1384, 20:40 عصر
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}

Kamran.K
جمعه 31 تیر 1384, 00:13 صبح
برای کنترل هایی که خاصیت Flat Style دارند، باید این خاصیت با مقدار system مقداردهی شود!

khafanovich
جمعه 31 تیر 1384, 08:50 صبح
با تشکر از تمامی دوستان.
خیلی جالبه تمام نکاتی که در ایترت من پیدا کردم برای انجام این کار استفاده ازفایل های Manifest رو پیشهاد کرده بودند و باید ریسورس های برنامه رو دستکاری میکردیم.
فقط یک مشکل کوچک در مورد کامپننت هایی که خاصیت Flat Style دارند :
در مورد Button ها ، من از Image List استفاده کردم به محض اینکه FlatStyle رو برابر System میکنم تصاویر حذف شده و با مقدار دهی مجدد آنها تصویری در آنها مشاهده نمیشود.
لطفا راهنمایی کنید.
ممنون.

khafanovich
شنبه 01 مرداد 1384, 18:55 عصر
دوستان کسی نظری نداره؟

sh
یک شنبه 02 مرداد 1384, 00:26 صبح
و برای اینکه در تولبار بتوانید آیکن بگذارید در بین دو خط کد بالا بنویسید

Application.DoEvent

PalizeSoftware
یک شنبه 02 مرداد 1384, 00:41 صبح
اگر اصرار دارید تا ظاهر برنامه‌های شما مانند XP‌ هماهنگ باشد، بعد از کمپایل برنامه، فایل اجرایی آنرا به برنامه StyleItXP بدهید تا همه کارها را تنظیم کند.

khafanovich
یک شنبه 02 مرداد 1384, 08:54 صبح
باسلام . دوستان مشکل تولبار با دو راه حل بالا حل شد.( با تشکر از دوستان)
ولی مشکل تصاویر مربوط به دکمه ها همچنان باقی است.
تصاویر مربوط به دمه ها با تغییر فلت استایل به سیستم از بین رفته ؟!
لطفا راهنمایی کنید.

rezanew
یک شنبه 02 مرداد 1384, 11:44 صبح
بعضی از کنترل ها مثل NumericUpDown چطوری xpstyle می شن؟

khafanovich
دوشنبه 03 مرداد 1384, 10:15 صبح
فقط یک مشکل کوچک در مورد کامپننت هایی که خاصیت Flat Style دارند :
در مورد Button ها ، من از Image List استفاده کردم به محض اینکه FlatStyle رو برابر System میکنم تصاویر حذف شده و با مقدار دهی مجدد آنها تصویری در آنها مشاهده نمیشود.
لطفا راهنمایی کنید.
ممنون.

لطفا راهنمایی فرمایید.

khafanovich
چهارشنبه 05 مرداد 1384, 08:26 صبح
یعی واقعا تا به حال به این مشکل بر نخوردید؟

khafanovich
پنج شنبه 06 مرداد 1384, 08:31 صبح
آقا من اینترنتو زیر و رو کردم....مثل اینکه تا به حال کسی به این مشکل دکمه و imageList بر نخورده. :D

بابک زواری
پنج شنبه 06 مرداد 1384, 15:40 عصر
و در نسخه 2005 ویژوال استودیو تمام مسائل فرق میکنه

رضا عربلو
جمعه 07 مرداد 1384, 00:03 صبح
"آقا من اینترنتو زیر و رو کردم....مثل اینکه تا به حال کسی به این مشکل دکمه و imageList بر نخورده"

تو سایت CodeProject.com این مشکل به چشم من خورده است.

رضا عربلو
جمعه 07 مرداد 1384, 03:28 صبح
این لینک رو ببین
http://www.codeproject.com/buglist/EnableVisualStylesBug.asp

رضا عربلو
جمعه 07 مرداد 1384, 08:43 صبح
این رو یادم نیست از کجا گرفته ام

How to add Visual Styles (the Windows XP look and feel) to your C# Application
By Gildeoni Nogueira Santos
Hello buddies! I have spending my time working a lot and haven't time to write articles or show some sample applications. This article demonstrates how to add Visual Styles to your application.
The first way to afford Visual Styles is by the use of an XML application manifest file. This file must be in the same directory as the application itself and this file must have the same name of your application followed by the file extension ".manifest". The file must contain an attribute called "dependency" and under this attribute we must set the identity of the component our application is dependent, in this case the new "Microsoft Windows Common-Controls" version 6.0. The following example shows the appearance of this application manifest file.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ASSEMBLY manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">


<ASSEMBLYIDENTITY p <>
version="1.0.0.0"
processorArchitecture="X86"
name="MyVisualStyleApp"
type="win32"
/>
<DESCRIPTION>Your app description here</DESCRIPTION>
<DEPENDENCY>
<DEPENDENTASSEMBLY>


<ASSEMBLYIDENTITY p <>
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</DEPENDENTASSEMBLY>
</DEPENDENCY>
</ASSEMBLY>
MyVisualStyleApp.exe.manifest
If you run the sample application you will see the effect. Legacy applications can take advantage of this approach also, but on some you may experience bugs like incorrect rendering. The following table shows the description of each element in the application manifest file.
My Assembly:
Attribute Description

Version Version of the manifest. The version must be in the form
major.minor.revision.build (that is, n.n.n.n, where n < = 65535).
processorArchitecture Processor for which your application is developed.
Name Includes company name, product name and application name.
Type Type of your application, such as Microsoft Win32.
My Assembly Dependency:
Attribute Description

Type Type of the dependency component, such as Win32.
Name Name of the component.
Version Version of the component.
processorArchitecture Processor that the component is designed for.
publicKeyToken Key token used with this component.
Language Language of the component.
And the button? The button wasn't rendered like a Windows XP button. Can we apply Visual Style to the button? Yes we can. So how? Accessing Windows API and drawing the button manually. All the functions necessary to draw a Windows XP style button is in "UxTheme.dll" under the system directory. Before draw your custom control you must take care of one thing, the "UxTheme.dll" is found only in Windows XP actually, this means if you try running an application on the Windows 98 for example, your application will crash. How can I take care of this? Verifying the Windows version and ID. The following lines of code show you how to do that.
PlatformID platformId = Environment.OSVersion.Platform;

Version version = Environment.OSVersion.Version;
Version targetVersion = new Version("5.1.2600.0");

if ((version > = targetVersion) && (platformId == PlatformID.Win32NT))
There's another thing, the user can disable Visual Styles under Windows XP and your application could crash again. And now, how can I handle this? Verifying if Visual Styles are enabled or disabled with the following piece of code.
if (NativeMethods.IsThemeActive() == 1)
The "IsThemeActive" method of the "UxTheme.dll" library will return the value 1 if Visual Styles are enabled or 0 if not.
To apply the theme call the "OpenThemeData" method this way.
hTheme = NativeMethods.OpenThemeData(this.Handle, "Button");
"hTheme" holds the handle returned from the "OpenThemeData" method containing the Visual Style (if exists). The following methods could be used to draw Windows XP style controls.
- DrawThemeBackground
- DrawThemeText
- DrawThemeParentBackground
And don't forget to close the theme handle when you exit the program! You can do it by using "CloseThemeData" method.
There are other controls that don't take the advantage of application manifest files, like RadioButton for example.
You can now draw your Windows XP style control. Good programming for all of you.
WindowsXPLook.zip (http://www.csharphelp.com/archives2/files/archive319/WindowsXPLook.zip)




و یا در Code Project دنبال این تاپیک بگرد

Adding XP Themes to Custom .NET Controls

khafanovich
جمعه 07 مرداد 1384, 10:19 صبح
با تشکر از همه دوستان ...مثل اینکه نمیشه این کار رو در 2003 انجام داد....از همه دوستان متشکرم...
آخههههههههههه چراااااا !!!!

بابک زواری
جمعه 07 مرداد 1384, 10:46 صبح
چرا نمیشه همین کدی که آقای مطهر دادن رو اجرا کن و تنظیماتی که سایر دوستان گفتن انجام بده حتما میشه.
در نسخه 2005 هم به اینا احتیاج نداری و اتوماتیک این کار برات انجام میشه

bi_edea
شنبه 08 مرداد 1384, 02:43 صبح
سلام
من 2 روز است عضو سایت شده ام! این ضمیمه را نگاه کنید و برای من هم توضیح بدهید که کد نویس آن چگونه این کار را کرده است!
امید وارم به دردتان بخورد

khafanovich
شنبه 08 مرداد 1384, 11:33 صبح
دوستان خسته نباشید مثل اینکه مشکل منو شما متوجه نشدید.
بنده در فعال سازی Xp Theme مشکلی ندارم.
در زمینه نمایش تصاویر روی toolbar Button ها هم مشکلی ندارم.

مشکل اینه :
وقتی Xp theme رو با توجه به نکاتی که دوستان گفتند فعال میکنیم، دکمه هایی که از Imagelist استفاده میکنند تصاویرشان از بین میروند ( دکمه های معمولی نه دکمه های toolbar )

و تا کنون هیچ راه حلی براش پیدا نکردم.

باز هم تاکید میکنم با راهنماییهای دوستان بنده مشکلی در زمینه فعال سازی تم ندارم. مشکل فقط مربوط به دکمه های مشود.

اگر راه حلی دارید بسم الله ما منتظریم تا بشنویم.