Я выполнил руководство и получил сообщение об ошибке с dll.C#

Место общения программистов C#
Ответить
Anonymous
 Я выполнил руководство и получил сообщение об ошибке с dll.

Сообщение Anonymous »

Я использую Visual Studio, C# и .NET Framework.
Я следовал этому руководству: , чтобы 4:20, но после тестирования я получил это сообщение об ошибке и не знаю, как его исправить:
[img]https://i .sstatic.net/oT5N5aVA.png[/img]

Это мой код:

Код: Выделить всё

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Energy_Organizer
{
public partial class Form1 : Form
{
private bool drag;
private int mouseX;
private int mouseY;

private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;

private bool m_aeroEnabled;

private const int CS_DROPSHADOW = 0x00020000;
private const int WM_NCPAINT = 0x0085;
private const int WM_ACTIVEAPP = 0x001C;

[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);

[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);

[System.Runtime.InteropServices.DllImport("dwampi.dll")]
public static extern int DwmIsCompoisionEnabled(ref int pfEnabled);

[System.Runtime.InteropServices.DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect,
int nTopRect,
int nRightRect,
int nBottomRect,
int nWidthEllipse,
int nHeightEllipse
);

public struct MARGINS
{
public int leftWidth;
public int rightWidth;
public int topHeight;
public int bottomHeight;
}

protected override CreateParams CreateParams
{
get
{
m_aeroEnabled = CheckAeroEnabled();
CreateParams cp = base.CreateParams;

if (!m_aeroEnabled)
cp.ClassStyle |= CS_DROPSHADOW; return cp;
}
}

private bool CheckAeroEnabled()
{
if (Environment.OSVersion.Version.Major >= 6)
{
int enabled = 0; DwmIsCompoisionEnabled(ref enabled);
return (enabled == 1) ? true : false;
}

return false;
}

protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_NCPAINT:
if (m_aeroEnabled)
{
var v = 2;
DwmSetWindowAttribute(this.Handle, 2, ref v, 4);
MARGINS margins = new MARGINS()
{
bottomHeight = 1,
leftWidth = 0,
rightWidth = 0,
topHeight = 0
}; DwmExtendFrameIntoClientArea(this.Handle, ref margins);
}
break;

default: break;
}

base.WndProc(ref m);

if (m.Msg == WM_NCHITTEST && (int)m.Result == HTCLIENT)
m.Result = (IntPtr)HTCAPTION;
}

public Form1()
{
InitializeComponent();
}
}
}

Код: Выделить всё

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Forms;

namespace Energy_Organizer
{
internal class Gradient_Sidebar_Panel : System.Windows.Forms.Panel
{
public Color gradientTop {get; set;}
public Color gradientBottom {get;  set;}

protected override void OnPaint(PaintEventArgs e)
{
LinearGradientBrush linear = new LinearGradientBrush(this.ClientRectangle, this.gradientTop, this.gradientBottom, 90F);
Graphics graphics = e.Graphics;

graphics.FillRectangle(linear, this.ClientRectangle);
base.OnPaint(e);
}
}
}
Я уже попробовал основные советы по Visual Studio, но ничего не помогло.
Надеюсь, кто-нибудь сможет мне помочь :) Спасибо

Подробнее здесь: https://stackoverflow.com/questions/783 ... e-with-dll
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»