Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hexadecimal233 committed Sep 12, 2021
1 parent d9386e2 commit 6acd470
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 28 deletions.
15 changes: 2 additions & 13 deletions Windows Store Downloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,7 @@
<Compile Include="code\Language.cs" />
<Compile Include="code\Post.cs" />
<Compile Include="code\Program.cs" />
<Compile Include="code\WinUtils\Dialogs\InputBox.cs" />
<Compile Include="code\WinUtils\Dialogs\PickIconDialog.cs" />
<Compile Include="code\WinUtils\Dialogs\TaskDialog.cs" />
<Compile Include="code\WinUtils\DPI.cs" />
<Compile Include="code\WinUtils\FormUtils.cs" />
<Compile Include="code\WinUtils\IconManager.cs" />
<Compile Include="code\WinUtils\LayeredWindowHelper.cs" />
<Compile Include="code\WinUtils\ToolStripNonClientRenderer.cs" />
<Compile Include="code\WinUtils\Win10Style.cs" />
<Compile Include="code\WinUtils\Win7Style.cs" />
<Compile Include="code\WinUtils\WinAPI.cs" />
<Compile Include="code\WinUtils\WinVer.cs" />
<Compile Include="code\WinAPI.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="code\global.cs" />
<Compile Include="code\zh-CN.cs" />
Expand Down Expand Up @@ -182,6 +171,6 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(ProjectDir)\resources\acrylic.dll" "$(TargetDir)\acrylic.dll"
E:\Program\upx.exe "$(TargetDir)\acrylic.dll"</PostBuildEvent>
rem E:\Program\upx.exe "$(TargetDir)\acrylic.dll"</PostBuildEvent>
</PropertyGroup>
</Project>
23 changes: 8 additions & 15 deletions code/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,12 @@
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Management;
using WinUtils;

namespace Windows_Store_Downloader
{
public partial class Form1 : Form
{

protected override void WndProc(ref Message m)

{
if (m.Msg == 0x0014) // 禁掉清除背景消息

return;

base.WndProc(ref m);

}

public static string OSVersion = get_OSVersion();

Expand Down Expand Up @@ -467,20 +456,24 @@ private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
return path;
}

public static void DragWindow(IntPtr hwnd)
{
WinAPI.ReleaseCapture();
WinAPI.SendMessage(hwnd, Constants.WM_SYSCOMMAND, (IntPtr)(Constants.SC_MOVE + Constants.HTCAPTION), IntPtr.Zero);
}


private void label2_MouseDown(object sender, MouseEventArgs e)
private void label2_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{

} else
{
FormUtils.DragWindow(this.Handle);
DragWindow(this.Handle);
}

}//拖拽窗口

private void downloadButton_MouseEnter(object sender, EventArgs e)
{
downloadButton.BackColor = Color.FromArgb(0x4a,0x5f,0xbd);
Expand Down
159 changes: 159 additions & 0 deletions code/WinAPI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;

namespace Windows_Store_Downloader
{

#region Structs
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
};

[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int x;
public int y;

public POINT(int x, int y)
{
this.x = x;
this.y = y;
}
};

[StructLayout(LayoutKind.Sequential)]
public struct SIZE
{
public int cx;
public int cy;

public SIZE(int cx, int cy)
{
this.cx = cx;
this.cy = cy;
}
}

[StructLayout(LayoutKind.Sequential)]
public struct BLENDFUNCTION
{
byte BlendOp;
byte BlendFlags;
byte SourceConstantAlpha;
byte AlphaFormat;

public BLENDFUNCTION(byte op, byte flags, byte alpha, byte format)
{
BlendOp = op;
BlendFlags = flags;
SourceConstantAlpha = alpha;
AlphaFormat = format;
}
}
#endregion


public static class WinAPI
{

static WinAPI()
{
InitCommonControls();
}


[DllImport("user32.dll")]
public static extern uint ReleaseCapture();
[DllImport("user32.dll", EntryPoint = "PostMessage", CallingConvention = CallingConvention.Winapi)]
public static extern uint PostMessage(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
public static extern uint SendMessage(IntPtr hwnd, uint wMsg, IntPtr wParam, IntPtr lParam);
[DllImport("comctl32.dll")]
public static extern bool InitCommonControls();
}

public static class Constants
{
public const byte AC_SRC_OVER = 0x00;
public const byte AC_SRC_ALPHA = 0x01;

public const int ULW_COLORKEY = 0x00000001;
public const int ULW_ALPHA = 0x00000002;
public const int ULW_OPAQUE = 0x00000004;
public const int ULW_EX_NORESIZE = 0x00000008;

public const int GWL_WNDPROC = -4;
public const int GWL_HINSTANCE = -6;
public const int GWL_HWNDPARENT = -8;
public const int GWL_STYLE = -16;
public const int GWL_EXSTYLE = -20;
public const int GWL_USERDATA = -21;
public const int GWL_ID = -12;

public const uint WM_SYSCOMMAND = 0x0112;
public const uint WM_LBUTTONDOWN = 0x0201;
public const uint WM_NCLBUTTONDOWN = 0x00A1;
public const uint WM_PAINT = 0x000F;
public const uint WM_MOVE = 0x0003;
public const uint WM_CTLCOLORMSGBOX = 0x0132;
public const uint WM_CTLCOLOREDIT = 0x0133;
public const uint WM_CTLCOLORLISTBOX = 0x0134;
public const uint WM_CTLCOLORBTN = 0x0135;
public const uint WM_CTLCOLORDLG = 0x0136;
public const uint WM_CTLCOLORSCROLLBAR = 0x0137;
public const uint WM_CTLCOLORSTATIC = 0x0138;
public const uint WM_CAPTURECHANGED = 0x0215;

public const int WS_EX_LAYERED = 0x00080000;
public const int WS_CLIPCHILDREN = 0x2000000;
public const int WS_THICKFRAME = 0x00040000;
public const int WS_MINIMIZEBOX = 0x20000;
public const int WS_MAXIMIZEBOX = 0x10000;
public const int WS_SYSMENU = 0x80000;
public const int WS_CHILD = 0x40000000;

public const uint SC_MOVE = 0xF010;
public const uint SC_CLOSE = 0xF060;
public const uint SC_SIZE = 0xF000;

public const uint HTCAPTION = 0x0002;

public const uint BCM_SETSHIELD = 0x160c;

public const uint TPM_RETURNCMD = 0x0100;
public const uint TPM_LEFTBUTTON = 0x0;


public const int DTT_COMPOSITED = (int)(1UL << 13);
public const int DTT_GLOWSIZE = (int)(1UL << 11);

//Text format consts
public const int DT_SINGLELINE = 0x00000020;
public const int DT_CENTER = 0x00000001;
public const int DT_VCENTER = 0x00000004;
public const int DT_NOPREFIX = 0x00000800;

//Const for BitBlt
public const int SRCCOPY = 0x00CC0020;


//Consts for CreateDIBSection
public const int BI_RGB = 0;
public const byte DIB_RGB_COLORS = 0;
public const byte DIB_PAL_COLORS = 1;

//DWM
public const uint DWM_BB_ENABLE = 0x00000001;
public const uint DWM_BB_BLURREGION = 0x00000002;
public const uint DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004;
}

}
Binary file modified resources/acrylic.dll
Binary file not shown.

0 comments on commit 6acd470

Please sign in to comment.