PDA

View Full Version : رنگ نوار بالای ویندوها



hooooman
سه شنبه 02 مرداد 1386, 17:30 عصر
سلام
اگه بخوام رنگ نوار بالای ویندوها رو عوض کنم چه راهی پیشنهاد میکنین؟؟؟:افسرده:

رضا عربلو
سه شنبه 02 مرداد 1386, 22:56 عصر
دو راه داری.
1- استفاده از توابع api
2- بردر فرم ات را none کنی و خودت یک image در بالای فرمت بگذاری.

hooooman
چهارشنبه 03 مرداد 1386, 00:36 صبح
دو راه داری.
1- استفاده از توابع api
2- بردر فرم ات را none کنی و خودت یک image در بالای فرمت بگذاری.


خیلی خیلی لطف کردی ممنونم .اگر تابع API ای که باید declare بشه و رویداد تغییر رنگو 1 توضیح مختصر بدین خیلی محبت کردین

رضا عربلو
چهارشنبه 03 مرداد 1386, 21:58 عصر
ببین این کد بدردت می خورد.


class WinAPI
{
//const variables
public const int SM_CXSIZE = 30;
public const int SM_CYSIZE = 31;
public const int SM_CXBORDER = 5;
public const int SM_CXFRAME = 32;
public const int SM_CYFRAME = 33;
public const int COLOR_ACTIVECAPTION = 3;
public const int DT_LEFT = 0x0;
public const int WM_NCPAINT = 0x85;
//Win API methods
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
public static extern int GetSystemMetrics(int abc);
[System.Runtime.InteropServices.DllImport("User32.dll")]
public static extern IntPtr GetWindowDC(IntPtr hwnd);
//[System.Runtime.InteropServices.DllImport("gdi32.dll", CharSet = CharSet.Auto)]
//public static extern int GetTextExtentPoint32(IntPtr hDC, string lpsz, int cbString, [In, Out] StringSize lpSize);
}


و بعد در اونت WndProc فرمت بنویس



protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WinAPI.WM_NCPAINT)
{
int x = WinAPI.GetSystemMetrics(WinAPI.SM_CXSIZE) +
WinAPI.GetSystemMetrics(WinAPI.SM_CXBORDER) +
WinAPI.GetSystemMetrics(WinAPI.SM_CXFRAME);
int y = WinAPI.GetSystemMetrics(WinAPI.SM_CYFRAME);

IntPtr hdc = WinAPI.GetWindowDC(m.HWnd);
Graphics g = Graphics.FromHdc(hdc);
Size size = TextRenderer.MeasureText(this.Text, SystemFonts.CaptionFont);
g.FillRectangle(new SolidBrush(SystemColors.ControlLight), x, y, size.Width, size.Height);
g.Clear(SystemColors.GrayText);
g.DrawString("عنوان فرم", new Font("Traffic", 9f, FontStyle.Bold), new SolidBrush(SystemColors.ControlLight), x, y);
}
}