本文整理汇总了C#中MARGINS类的典型用法代码示例。如果您正苦于以下问题:C# MARGINS类的具体用法?C# MARGINS怎么用?C# MARGINS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MARGINS类属于命名空间,在下文中一共展示了MARGINS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DwmExtendFrameIntoClientArea
public static void DwmExtendFrameIntoClientArea(Control c, MARGINS marg)
{
if (DwmIsCompositionEnabled())
{
DwmExtendFrameIntoClientArea(c.Handle, ref marg);
}
}
示例2: ExtendGlassFrame
/// <summary>
/// Extends the Aero Glass area on a given window.
/// </summary>
/// <param name="window">The window to extend glass onto.</param>
/// <param name="margin">The distances from the border to extend the glass by.</param>
/// <returns>True if glass was extended successfully, otherwise false.</returns>
public static bool ExtendGlassFrame(Window window, Thickness margin)
{
if (window == null) {
throw new ArgumentNullException("window");
}
bool result = false;
try {
if (DwmIsCompositionEnabled()) {
IntPtr hwnd = new WindowInteropHelper(window).Handle;
if (hwnd == IntPtr.Zero)
throw new InvalidOperationException("The Window must be shown before extending glass.");
// Set the background to transparent from both the WPF and Win32 perspectives
window.Background = Brushes.Transparent;
HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;
MARGINS margins = new MARGINS(margin);
DwmExtendFrameIntoClientArea(hwnd, ref margins);
result = true;
}
} catch { }
return result;
}
示例3: ConvertMp3_Load
private void ConvertMp3_Load(object sender, EventArgs e)
{
MARGINS margins = new MARGINS();
margins.cxLeftWidth = 0;
margins.cxRightWidth = 0;
margins.cyTopHeight = 45;
margins.cyBottomHeight = 0;
IntPtr hWnd = this.Handle;
int result = DwmExtendFrameIntoClientArea(hWnd, ref margins);
Process bacon = new Process();
ProcessStartInfo p = new ProcessStartInfo();
string sArgs = String.Format(" -i {0} {1}", SourcePath, TargetPath);
p.FileName = Directory.GetCurrentDirectory()[email protected]"\ffmpeg.exe";
p.CreateNoWindow = true;
p.RedirectStandardOutput = true;
p.UseShellExecute = false;
bacon.Exited += new EventHandler(myProcess_Exited);
p.Arguments = sArgs;
bacon.StartInfo = p;
bacon.Start();
bacon.WaitForExit();
bacon.StandardOutput.ReadToEnd();
if (FileToDelte != null)
{
try { File.Delete(FileToDelte); }
catch { }
}
this.Close();
}
示例4: OpenAreo
private void OpenAreo()
{
en = 0;
MARGINS mg = new MARGINS(); //定义透明扩展区域的大小,这里全部-1,即全部透明
mg.m_Buttom = -1;
mg.m_Left = -1;
mg.m_Right = -1;
mg.m_Top = -1;
//判断是否Vista及以上的系统
if (System.Environment.OSVersion.Version.Major >= 6)
{
DwmIsCompositionEnabled(ref en); //检测Aero是否为打开
if (en > 0)
{
DwmExtendFrameIntoClientArea(this.Handle, ref mg); //透明
}
else
{
MessageBox.Show("Desktop Composition is Disabled!"); //未开启透明桌面
}
}
else
{
MessageBox.Show("Please run this at least on Windows Vista."); //至少在vista运行
}
this.Paint += new PaintEventHandler(Form1_Paint);
}
示例5: ExtendGlassFrame
public static bool ExtendGlassFrame(Window window, Thickness margin)
{
// Get the Operating System From Environment Class
OperatingSystem os = Environment.OSVersion;
// Get the version information
Version vs = os.Version;
if (vs.Major < 6)
return false;
if (!DwmIsCompositionEnabled())
return false;
IntPtr hwnd = new WindowInteropHelper(window).Handle;
if (hwnd == IntPtr.Zero)
throw new InvalidOperationException("Glass cannot be extended before the window is shown.");
// Set the background to transparent from both the WPF and Win32 perspectives
window.Background = Brushes.Transparent;
HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;
MARGINS margins = new MARGINS(margin);
DwmExtendFrameIntoClientArea(hwnd, ref margins);
return true;
}
示例6: ApplyGlass
public static void ApplyGlass(Form form)
{
MARGINS m = new MARGINS(-1, -1, -1, -1);
//MARGINS m = new MARGINS(1, 1, 1, 1);
form.Paint += new PaintEventHandler(form_Paint);
DwmExtendFrameIntoClientArea(form.Handle, m);
}
示例7: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
this.BackColor = Color.Black;
MARGINS m=new MARGINS();
m.cxLeftWidth = 20;
m.cxRightWidth = 20;
m.cyBottomHeight = 20;
m.cyTopHeight = 20;
DwmExtendFrameIntoClientArea(this.Handle,m);
}
示例8: ShowShadowUnderWindow
public static void ShowShadowUnderWindow(IntPtr intPtr)
{
MARGINS marInset = new MARGINS();
marInset.m_bottomHeight = -1;
marInset.m_leftWidth = -1;
marInset.m_rightWidth = -1;
marInset.m_topHeight = -1;
DwmExtendFrameIntoClientArea(intPtr, ref marInset);
}
示例9: WndStart
void WndStart()
{
var margins = new MARGINS() { cxLeftWidth = -1 };
var hwnd = FindWindow(null, "CooldogAssistant");
SetWindowLong(hwnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
DwmExtendFrameIntoClientArea(hwnd, ref margins);
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 512, 512, SWP_NOMOVE);
}
示例10: AeroEffect
public static void AeroEffect(Form f1)
{
MARGINS m = new MARGINS()
{
left = -1
};
DwmExtendFrameIntoClientArea(f1.Handle, ref m);
Color aeroColor = Color.FromArgb(155, 155, 155);
f1.TransparencyKey = aeroColor;
f1.BackColor = aeroColor;
}
示例11: ExtendFrameIntoClientArea
/// <summary>
/// Extends the window frame into the client area.
/// </summary>
/// <param name="hWnd">The handle to the window in which the frame will be extended into the client area.</param>
/// <param name="left">The left margin.</param>
/// <param name="top">The top margin.</param>
/// <param name="right">The right margin.</param>
/// <param name="bottom">The bottom margin.</param>
/// <returns></returns>
public static bool ExtendFrameIntoClientArea(IntPtr hWnd, int left, int top, int right, int bottom)
{
if (IsPlatformSupported)
{
MARGINS m = new MARGINS();
m.cxLeftWidth = left;
m.cyTopHeight = top;
m.cxRightWidth = right;
m.cyBottomHeight = bottom;
return NativeMethods.DwmExtendFrameIntoClientArea(hWnd, ref m).Succeeded;
}
return false;
}
示例12: Form1_Load
/// <summary>
/// Define some element properties and init Aero Glass if using Vista or newer
/// </summary>
private void Form1_Load(object sender, EventArgs e)
{
box_output.ScrollBars = RichTextBoxScrollBars.None;
box_output.Font = new Font("Consolas", 8);
box_output.BackColor = Color.White;
if (Environment.OSVersion.Version.Major >= 6)
{
this.BackColor = Color.DarkMagenta; this.TransparencyKey = Color.DarkMagenta;
MARGINS marg = new MARGINS() { Left = -1, Right = -1, Top = -1, Bottom = -1 };
DwmExtendFrameIntoClientArea(this.Handle, ref marg);
}
}
示例13: GlassifyHwnd
public static bool GlassifyHwnd(IntPtr ptr)
{
if (Environment.OSVersion.Version.Major >= 6 && DwmIsCompositionEnabled())
{
MARGINS margins = new MARGINS();
margins.Left = -1;
margins.Right = -1;
margins.Top = -1;
margins.Bottom = -1;
return !DwmExtendFrameIntoClientArea(ptr, ref margins);
}
return false;
}
示例14: Start
void Start()
{
// #if !UNITY_EDITOR
var margins = new MARGINS() { cxLeftWidth = -1 };
// Get a handle to the window
var hwnd = GetActiveWindow();
// Set properties of the window
// See: [url]https://msdn.microsoft.com/en-us/library/windows/desktop/ms633591%28v=vs.85%29.aspx[/url]
SetWindowLong(hwnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
// Extend the window into the client area
See:https://msdn.microsoft.com/en-us/library/windows/desktop/aa969512%28v=vs.85%29.aspx[/url]
DwmExtendFrameIntoClientArea(hwnd, ref margins);
//#endif
}
示例15: Form1
public Form1()
{
//MessageBox.Show(Environment.Is64BitOperatingSystem.ToString());
// check os
Version v = System.Environment.OSVersion.Version;
double ver = v.Major + v.Minor / 10.0;
if (ver <= 6.0)
{
MessageBox.Show("This software only run on Windows 7 or later!!!");
Environment.Exit(0);
return;
}
if (!IsRunAsAdmin())
{
// Launch itself as administrator
ProcessStartInfo proc = new ProcessStartInfo();
proc.UseShellExecute = true;
proc.WorkingDirectory = Environment.CurrentDirectory;
proc.FileName = Application.ExecutablePath;
proc.Verb = "runas";
try
{
Process.Start(proc);
}
catch(Exception ex)
{
// The user refused to allow privileges elevation.
// Do nothing and return directly ...
}
Environment.Exit(0); // Quit itself
return;
}
InitializeComponent();
if (DwmIsCompositionEnabled())
{
MARGINS m = new MARGINS();
m.Right = m.Bottom = -1;
m.Left = m.Top = -1;// this.Width + this.Height;
DwmExtendFrameIntoClientArea(this.Handle, ref m);
}
bgWorker = new BGWorkReport(ReportProcess);
backgroundWorker1.RunWorkerAsync();
this.BringToFront();
}