PDA

View Full Version : سوال: حذف حاشیه های فرم



امیر مهرشاد
پنج شنبه 12 دی 1392, 22:56 عصر
سلام جستجویی که کردم برای اینکه حاشیه فرم رو بتونم به اینصورت در بیارم فایده ای نداشت البته رفرنسم همین سایت بود لطفا دوستان یه نگاهی بندازن چطوری میشه حاشیه باطراف فرم رو به این شکل درآورد و اشیاء رو روی اون قرار داد ؟

غیر از wpf میشه ؟

114753

mahdi.compute
پنج شنبه 12 دی 1392, 23:47 عصر
اینو سرچ کن
glasess form in win 7

mamadcity
پنج شنبه 12 دی 1392, 23:53 عصر
اینو یه امتحان کن :




private void Form1_Paint(object sender, PaintEventArgs e) { Form frm = (Form)sender; ControlPaint.DrawBorder(e.Graphics, frm.ClientRectangle, Color.LightBlue, 5, ButtonBorderStyle.Solid, Color.LightBlue, 5, ButtonBorderStyle.Solid, Color.LightBlue, 5, ButtonBorderStyle.Solid, Color.LightBlue, 5, ButtonBorderStyle.Solid); }

alireza_s_84
جمعه 13 دی 1392, 00:21 صبح
قبلا مقاله ای در این زمینه توی همین سایت من قرار دادم
به امضای من مراجعه کنید

khokhan
جمعه 13 دی 1392, 02:03 صبح
سلام جستجویی که کردم برای اینکه حاشیه فرم رو بتونم به اینصورت در بیارم فایده ای نداشت البته رفرنسم همین سایت بود لطفا دوستان یه نگاهی بندازن چطوری میشه حاشیه باطراف فرم رو به این شکل درآورد و اشیاء رو روی اون قرار داد ؟

غیر از wpf میشه ؟

114753
یه کلاس ساده :لبخند::لبخند:

[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
internal static extern void DwmExtendFrameIntoClientArea(System.IntPtr hWnd, ref Margins pMargins);

[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
internal static extern void DwmIsCompositionEnabled(ref bool isEnabled);

internal struct Margins
{

114760

kasraaa
جمعه 13 دی 1392, 08:55 صبح
[QUOTE=khokhan;1944461]یه کلاس ساده :لبخند::لبخند:

[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
internal static extern void DwmExtendFrameIntoClientArea(System.IntPtr hWnd, ref Margins pMargins);

[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
internal static extern void DwmIsCompositionEnabled(ref bool isEnabled);

internal struct Margins
{


این آکولاذ بسته اش کجا باید باشد

امیر مهرشاد
جمعه 13 دی 1392, 10:17 صبح
یه کلاس ساده :لبخند::لبخند:

[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
internal static extern void DwmExtendFrameIntoClientArea(System.IntPtr hWnd, ref Margins pMargins);

[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
internal static extern void DwmIsCompositionEnabled(ref bool isEnabled);

internal struct Margins
{

114760

با تشکر از شما لطفا کد رو کامل بزارید ممنون

sagggad
جمعه 13 دی 1392, 11:10 صبح
اینو یه امتحان کن :




private void Form1_Paint(object sender, PaintEventArgs e) { Form frm = (Form)sender; ControlPaint.DrawBorder(e.Graphics, frm.ClientRectangle, Color.LightBlue, 5, ButtonBorderStyle.Solid, Color.LightBlue, 5, ButtonBorderStyle.Solid, Color.LightBlue, 5, ButtonBorderStyle.Solid, Color.LightBlue, 5, ButtonBorderStyle.Solid); }



این که بدرد نخورد؟؟
یعنی اصلا عمل نکرد..

khokhan
جمعه 13 دی 1392, 11:35 صبح
با تشکر از شما لطفا کد رو کامل بزارید ممنون
با سلام
امیر خان .....!! :لبخند:
یه کلاس ایجاد می کنی و dll مربوط به Aero style ویندوز ویستا رو درونش فراخوانی می کنی :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mash_kokab
{
internal class VistaApi
{
[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
internal static extern void DwmExtendFrameIntoClientArea(System.IntPtr hWnd, ref Margins pMargins);

[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
internal static extern void DwmIsCompositionEnabled(ref bool isEnabled);

internal struct Margins
{
public int Left, Right, Top, Bottom;
}
}
}
بعد توی فرم یه دونه پانل اضافه می کنی به نحوی که توی قسمت بالای فرمت تون dockبشه :لبخند:
وکدهای فرم تون جهت فراخونی کلاس ایجاد شده به این شکل خواهد بود :لبخند:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace mash_kokab
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();


if (!this.IsGlassEnabled())
{
return;
}


VistaApi.Margins marg;
marg.Top = panel1.Height;
marg.Left = 0;
marg.Right = 0;
marg.Bottom = 0;


VistaApi.DwmExtendFrameIntoClientArea(this.Handle, ref marg);
}

private bool IsGlassEnabled()
{
if (Environment.OSVersion.Version.Major < 6)
{
MessageBox.Show(
"How about trying this on Vista?");
return false;
}


bool isGlassSupported = false;
VistaApi.DwmIsCompositionEnabled(ref isGlassSupported);
return isGlassSupported;
}

private void Form1_Load(object sender, EventArgs e)
{
Color c = Color.FromArgb(255, 221, 220, 220);
this.TransparencyKey = c;
panel1.BackColor = c;

}

private void pictureBox2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
این هم نمونه :لبخند: حالشو ببرین :چشمک:

sagggad
جمعه 13 دی 1392, 11:38 صبح
بازم ایولا khokhan (http://barnamenevis.org/member.php?131732-khokhan) خودمون.
واقعا گل کاشتی...

alireza_s_84
جمعه 13 دی 1392, 14:44 عصر
توی این لینک http://barnamenevis.org/showthread.php?t=210549 شما میتونید نحوه ی ایجاد یک فرم رو توی سیستم عامل ویندوز ببنید و با دونستن چگونگی ایجاد یک فرم میتونید تغییرات دلخواهتون رو اعمال کنید.

alireza_s_84
جمعه 13 دی 1392, 14:45 عصر
با سلام
امیر خان .....!! :لبخند:
یه کلاس ایجاد می کنی و dll مربوط به Aero style ویندوز ویستا رو درونش فراخوانی می کنی :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mash_kokab
{
internal class VistaApi
{
[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
internal static extern void DwmExtendFrameIntoClientArea(System.IntPtr hWnd, ref Margins pMargins);

[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
internal static extern void DwmIsCompositionEnabled(ref bool isEnabled);

internal struct Margins
{
public int Left, Right, Top, Bottom;
}
}
}
بعد توی فرم یه دونه پانل اضافه می کنی به نحوی که توی قسمت بالای فرمت تون dockبشه :لبخند:
وکدهای فرم تون جهت فراخونی کلاس ایجاد شده به این شکل خواهد بود :لبخند:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace mash_kokab
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();


if (!this.IsGlassEnabled())
{
return;
}


VistaApi.Margins marg;
marg.Top = panel1.Height;
marg.Left = 0;
marg.Right = 0;
marg.Bottom = 0;


VistaApi.DwmExtendFrameIntoClientArea(this.Handle, ref marg);
}

private bool IsGlassEnabled()
{
if (Environment.OSVersion.Version.Major < 6)
{
MessageBox.Show(
"How about trying this on Vista?");
return false;
}


bool isGlassSupported = false;
VistaApi.DwmIsCompositionEnabled(ref isGlassSupported);
return isGlassSupported;
}

private void Form1_Load(object sender, EventArgs e)
{
Color c = Color.FromArgb(255, 221, 220, 220);
this.TransparencyKey = c;
panel1.BackColor = c;

}

private void pictureBox2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
این هم نمونه :لبخند: حالشو ببرین :چشمک:



اینکار فقط توی ویندوز 7 و یا ویستا جواب میده و توی ویندوز XP قابل استفاده نیست

امیر مهرشاد
شنبه 14 دی 1392, 15:51 عصر
از هردو اساتید بزرگ جناب علیرضا و khokhan تشکر میکنم اگر نمونه ها رو توی برنامه های کوچک و کاربردی بزارید تا بچه ها هم استفاده کنن جای زهی سعادت درهر حال از هر دوی شما واقعا ممنونم گل کاشتید:قلب:

fmehrvarzi
شنبه 14 دی 1392, 17:04 عصر
مایکروسافت تم آئرو را از ویندوز 8 حذف کرده پس دیگه باید جوری برنامه بنویسیند که تو تمام سیستم عامل یکسان کار کنند
من هم از ویندوز 7 استفاده میکنم و تم آئرو رو از کار انداختم
به نظرم فقط گرافیک میگیره