Skip to content

Commit

Permalink
update to 1.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCGDF committed Feb 13, 2022
1 parent 48ee1f1 commit bb20e0a
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 127 deletions.
68 changes: 27 additions & 41 deletions NetSpeed/NetSpeed/Dialog/Dialog_Main/Dialog_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@
#include "../../Text/Text.h"
#include "../Dialog_Setting/Dialog_Setting.h"

COLORREF Dialog_Main::Color_Background_;
COLORREF Dialog_Main::Color_Text_;
LONG Dialog_Main::DialogOriginHeight_;
LONG Dialog_Main::DialogOriginWidth_;
COLORREF Dialog_Main::Color_Background_;
COLORREF Dialog_Main::Color_Text_;
LONG Dialog_Main::DialogOriginHeight_;
LONG Dialog_Main::DialogOriginWidth_;
HBRUSH Dialog_Main::Handle_Bursh_Background_ = NULL;
HBRUSH Dialog_Main::Handle_Bursh_Text_ = NULL;
HFONT Dialog_Main::Handle_Font_Text_ = NULL;
HPEN Dialog_Main::Handle_Pen_Background_ = NULL;
LONG Dialog_Main::TextOriginHeight_;
LONG Dialog_Main::TextOriginWidth_;
HPEN Dialog_Main::Handle_Pen_Background_ = NULL;
LONG Dialog_Main::TextOriginHeight_;
LONG Dialog_Main::TextOriginWidth_;

//public:

INT_PTR Dialog_Main::Process(HWND Handle_Dialog, UINT DialogMessage, WPARAM ParamWORD, LPARAM ParamLONG) {
Dialog_Main::Handle_Set(Handle_Dialog);
BOOL ProcessResult = TRUE;
switch (DialogMessage) {
switch(DialogMessage) {
case WM_COMMAND: {
switch (LOWORD(ParamWORD)) {
switch(LOWORD(ParamWORD)) {
case WA_INACTIVE: {
SetWindowPos(Handle_Dialog, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
case WM_MENU_EXIT: {
Menu::Item_Exit();
break;
Expand Down Expand Up @@ -116,7 +119,7 @@ INT_PTR Dialog_Main::Process(HWND Handle_Dialog, UINT DialogMessage, WPARAM Para
break;
}
case WM_NOTIFYICON: {
switch (ParamLONG) {
switch(ParamLONG) {
case WM_RBUTTONUP: {
Menu::Pop();
return TRUE;
Expand Down Expand Up @@ -144,10 +147,10 @@ INT_PTR Dialog_Main::Process(HWND Handle_Dialog, UINT DialogMessage, WPARAM Para

VOID Dialog_Main::ColorBackground_Set(COLORREF Background_Color) {
Color_Background_ = Background_Color;
if (Handle_Bursh_Background_ != NULL) {
if(Handle_Bursh_Background_ != NULL) {
DeleteObject(Handle_Bursh_Background_);
}
if (Handle_Pen_Background_ != NULL) {
if(Handle_Pen_Background_ != NULL) {
DeleteObject(Handle_Pen_Background_);
}
Handle_Bursh_Background_ = CreateSolidBrush(Color_Background_);
Expand All @@ -165,10 +168,10 @@ POINT Dialog_Main::Position_Get() {
HWND Handle_Dialog = Dialog_Main::Handle_Get();
GetWindowRect(Handle_Dialog, &PositionRect);
MapWindowPoints(HWND_DESKTOP, GetParent(Handle_Dialog), (LPPOINT)&PositionRect, sizeof(RECT) / sizeof(POINT));
POINT PositionPoint;
PositionPoint.x = PositionRect.left;
PositionPoint.y = PositionRect.top;
return PositionPoint;
return POINT{
.x = PositionRect.left,
.y = PositionRect.top
};
}

VOID Dialog_Main::Position_Set(POINT Position) {
Expand All @@ -181,13 +184,8 @@ BOOL Dialog_Main::Show_Get() {

VOID Dialog_Main::Show_Set(BOOL Show) {
HWND Handle_Dialog = Dialog_Main::Handle_Get();
if (Show == TRUE) {
ShowWindow(Handle_Dialog, SW_SHOW);
}
else {
ShowWindow(Handle_Dialog, SW_HIDE);
}
if (Handle_Dialog != NULL) {
ShowWindow(Handle_Dialog, Show ? SW_SHOW : SW_HIDE);
if(Handle_Dialog != NULL) {
Dialog_Setting::Gather_Check_Show();
}
}
Expand All @@ -200,7 +198,7 @@ VOID Dialog_Main::Size_Set(INT Size) {
FontInfo.lfHeight = -MulDiv(Size, GetDeviceCaps(Handle_DC, LOGPIXELSY), 72);
wcscpy_s(FontInfo.lfFaceName, LF_FACESIZE, L"Consolas");
FontInfo.lfWeight = 400;
if (Handle_Font_Text_ != NULL) {
if(Handle_Font_Text_ != NULL) {
DeleteObject(Handle_Font_Text_);
}
Handle_Font_Text_ = CreateFontIndirectW(&FontInfo);
Expand All @@ -222,34 +220,22 @@ VOID Dialog_Main::Size_Set(INT Size) {
NULL,
NULL,
NULL,
TextOriginWidth_*Size / 12,
TextOriginHeight_*Size / 12,
TextOriginWidth_ * Size / 12,
TextOriginHeight_ * Size / 12,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER
);
SetWindowPos(
GetDlgItem(Handle_Dialog, ID_Static_Upload),
NULL,
DialogOriginWidth_ * Size / 12 / 2 + 2 * TextOriginWidth_ / 28,
NULL,
TextOriginWidth_*Size / 12,
TextOriginHeight_*Size / 12,
TextOriginWidth_ * Size / 12,
TextOriginHeight_ * Size / 12,
SWP_NOACTIVATE | SWP_NOZORDER
);
InvalidateRect(Handle_Dialog, NULL, TRUE);
}

VOID Dialog_Main::Topmost_Check() {
BOOL TopState = GetWindowLong(Dialog_Main::Handle_Get(), GWL_EXSTYLE) & WS_EX_TOPMOST;
static BOOL First = TRUE;
if (First == FALSE) {
return;
}
if (TopState == FALSE) {
MessageBoxW(NULL, L"top error", L"top error", MB_OK);
First = FALSE;
}
}

VOID Dialog_Main::Transparency_Set(INT Transparency) {
SetLayeredWindowAttributes(Dialog_Main::Handle_Get(), 0, (255.0* Transparency) / 100.0 + 0.5, LWA_ALPHA);
SetLayeredWindowAttributes(Dialog_Main::Handle_Get(), 0, (255.0 * Transparency) / 100.0 + 0.5, LWA_ALPHA);
}
5 changes: 2 additions & 3 deletions NetSpeed/NetSpeed/Dialog/Dialog_Main/Dialog_Main.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ class Dialog_Main :public Dialog<Dialog_Main> {
public:
static VOID ColorBackground_Set(COLORREF Background_Color);
static VOID ColorText_Set(COLORREF Text_Color);
static POINT Position_Get();
static POINT Position_Get();
static VOID Position_Set(POINT Position);
static BOOL Show_Get();
static VOID Show_Set(BOOL Show);
static VOID Size_Set(INT Size);
static VOID Topmost_Check();
static VOID Transparency_Set(INT Transparency);
private:
static COLORREF Color_Background_;
Expand All @@ -23,7 +22,7 @@ class Dialog_Main :public Dialog<Dialog_Main> {
static LONG DialogOriginWidth_;
static HBRUSH Handle_Bursh_Background_;
static HBRUSH Handle_Bursh_Text_;
static HFONT Handle_Font_Text_;
static HFONT Handle_Font_Text_;
static HPEN Handle_Pen_Background_;
static LONG TextOriginHeight_;
static LONG TextOriginWidth_;
Expand Down
64 changes: 35 additions & 29 deletions NetSpeed/NetSpeed/Dialog/Dialog_Setting/Dialog_Setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
INT_PTR Dialog_Setting::Process(HWND Handle_Dialog, UINT DialogMessage, WPARAM Param_WORD, LPARAM Param_LONG) {
Handle_Set(Handle_Dialog);
BOOL Result_Process = TRUE;
switch (DialogMessage) {
switch(DialogMessage) {
case WM_CLOSE: {
DestroyWindow(Handle_Dialog);
return 0;
}
case WM_COMMAND: {
switch (LOWORD(Param_WORD)) {
switch(LOWORD(Param_WORD)) {
case ID_Button_BackgroundColor: {
COLORREF Color_Background = Registry::ColorBackground_Get();
SelectColor(&Color_Background);
Expand All @@ -44,7 +44,7 @@ INT_PTR Dialog_Setting::Process(HWND Handle_Dialog, UINT DialogMessage, WPARAM P
break;
}
case ID_Combo_Language: {
switch (HIWORD(Param_WORD)) {
switch(HIWORD(Param_WORD)) {
case CBN_SELCHANGE: {
HWND Handle_Combo_Language = GetDlgItem(Handle_Dialog, ID_Combo_Language);
INT Languae_Index = ComboBox_GetCurSel(Handle_Combo_Language);
Expand All @@ -71,15 +71,15 @@ INT_PTR Dialog_Setting::Process(HWND Handle_Dialog, UINT DialogMessage, WPARAM P
break;
}
case ID_Edit_Size: {
switch (HIWORD(Param_WORD)) {
switch(HIWORD(Param_WORD)) {
case EN_CHANGE: {
WCHAR Size_Text[4];
GetDlgItemTextW(Handle_Dialog, ID_Edit_Size, Size_Text, 4);
INT Size = _wtoi(Size_Text);
if (Size == 0) {
if(Size == 0) {
break;
}
if (Size > 128) {
if(Size > 128) {
SetDlgItemTextW(Handle_Dialog, ID_Edit_Size, L"128");
Size = 128;
}
Expand All @@ -101,9 +101,9 @@ INT_PTR Dialog_Setting::Process(HWND Handle_Dialog, UINT DialogMessage, WPARAM P
}
case WM_HSCROLL: {
HWND Handle_Slider_Transparency = GetDlgItem(Handle_Dialog, ID_Slider_Transparency);
if (Param_LONG == (LPARAM)Handle_Slider_Transparency) {
if(Param_LONG == (LPARAM)Handle_Slider_Transparency) {
INT Position_Slider = HIWORD(Param_WORD);
switch (LOWORD(Param_WORD)) {
switch(LOWORD(Param_WORD)) {
case TB_THUMBTRACK: {
Dialog_Main::Transparency_Set(Position_Slider);
std::wstring Transparency_wstring = Dialog_Setting::Transparency_String(Position_Slider);
Expand Down Expand Up @@ -138,24 +138,25 @@ INT_PTR Dialog_Setting::Process(HWND Handle_Dialog, UINT DialogMessage, WPARAM P

//public:

VOID Dialog_Setting::SelectColor(COLORREF *Color_Bind) {
CHOOSECOLOR ColorChooser;
VOID Dialog_Setting::SelectColor(COLORREF* Color_Bind) {
COLORREF Color_Custom[16];
for (INT ColorCustomIndex = 0; ColorCustomIndex <= 15; ColorCustomIndex++) {
for(INT ColorCustomIndex = 0; ColorCustomIndex <= 15; ColorCustomIndex++) {
Color_Custom[ColorCustomIndex] = Registry::ColorCustom_Get(ColorCustomIndex);
}
ColorChooser.lStructSize = sizeof(CHOOSECOLOR);
ColorChooser.hwndOwner = Dialog_Setting::Handle_Get();
ColorChooser.hInstance = NULL;
ColorChooser.rgbResult = *Color_Bind;
ColorChooser.lpCustColors = Color_Custom;
ColorChooser.Flags = CC_FULLOPEN | CC_RGBINIT;
ColorChooser.lCustData = 0;
ColorChooser.lpfnHook = NULL;
ColorChooser.lpTemplateName = NULL;
CHOOSECOLOR ColorChooser{
.lStructSize = sizeof(CHOOSECOLOR),
.hwndOwner = Dialog_Setting::Handle_Get(),
.hInstance = NULL,
.rgbResult = *Color_Bind,
.lpCustColors = Color_Custom,
.Flags = CC_FULLOPEN | CC_RGBINIT,
.lCustData = 0,
.lpfnHook = NULL,
.lpTemplateName = NULL,
};
ChooseColor(&ColorChooser);
*Color_Bind = ColorChooser.rgbResult;
for (INT ColorCustomSetIndex = 0; ColorCustomSetIndex <= 15; ColorCustomSetIndex++) {
for(INT ColorCustomSetIndex = 0; ColorCustomSetIndex <= 15; ColorCustomSetIndex++) {
Registry::ColorCustom_Set(ColorCustomSetIndex, Color_Custom[ColorCustomSetIndex]);
}
}
Expand Down Expand Up @@ -199,21 +200,27 @@ VOID Dialog_Setting::Gather_Check_Startup() {
VOID Dialog_Setting::Gather_Combo_Language() {
HWND Handle_Combo_Language = GetDlgItem(Dialog_Setting::Handle_Get(), ID_Combo_Language);
ComboBox_ResetContent(Handle_Combo_Language);
for (INT Index = 0; Index <= Text::Language::Total - 1; Index++) {
for(INT Index = 0; Index <= Text::Language::Total - 1; Index++) {
ComboBox_AddString(Handle_Combo_Language, Text::Name(Index).c_str());
}
ComboBox_SetCurSel(Handle_Combo_Language, Registry::Language_Get());
}

VOID Dialog_Setting::Gather_Edit_Size() {
INT Size = Registry::Size_Get();
SetDlgItemTextW(Dialog_Setting::Handle_Get(), ID_Edit_Size, std::to_wstring(Size).c_str());
SetDlgItemTextW(
Dialog_Setting::Handle_Get(),
ID_Edit_Size,
std::to_wstring(Registry::Size_Get()).c_str()
);
}

VOID Dialog_Setting::Gather_Slider_Transparency() {
HWND Handle_Slider_Transparency = GetDlgItem(Dialog_Setting::Handle_Get(), ID_Slider_Transparency);
INT Transparency = Registry::Transparency_Get();
SendMessageW(Handle_Slider_Transparency, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)Transparency);
SendMessageW(
GetDlgItem(Dialog_Setting::Handle_Get(), ID_Slider_Transparency),
TBM_SETPOS,
(WPARAM)TRUE,
(LPARAM)Registry::Transparency_Get()
);
}

VOID Dialog_Setting::Gather_Static_Language() {
Expand All @@ -225,8 +232,7 @@ VOID Dialog_Setting::Gather_Static_Size() {
}

VOID Dialog_Setting::Gather_Static_Transparency() {
INT Transparency = Registry::Transparency_Get();
std::wstring Transparency_wstring = Dialog_Setting::Transparency_String(Transparency);
std::wstring Transparency_wstring = Dialog_Setting::Transparency_String(Registry::Transparency_Get());
SetDlgItemTextW(Dialog_Setting::Handle_Get(), ID_Static_Transparency, Transparency_wstring.c_str());
}

Expand Down
52 changes: 24 additions & 28 deletions NetSpeed/NetSpeed/Menu/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ HMENU Menu::Handle_ = NULL;

VOID Menu::Init() {
Handle_ = CreatePopupMenu();
for (INT Index = 0; Index <= Item::Total - 1; Index++) {
for(INT Index = 0; Index <= Item::Total - 1; Index++) {
InsertMenuW(Handle_, 0, MF_STRING, NULL, NULL);
}
}

VOID Menu::Pop() {
//Show
BOOL Show = IsWindowVisible(Dialog_Main::Handle_Get());
if (Show == TRUE) {
ModifyMenu(Handle_, Item::Show, MF_BYPOSITION | MF_STRING, WM_MENU_SHOW, Text::MenuItem_Hide().c_str());
}
else if (Show == FALSE) {
ModifyMenu(Handle_, Item::Show, MF_BYPOSITION | MF_STRING, WM_MENU_SHOW, Text::MenuItem_Show().c_str());
}
ModifyMenu(
Handle_,
Item::Show,
MF_BYPOSITION | MF_STRING,
WM_MENU_SHOW,
(IsWindowVisible(Dialog_Main::Handle_Get()) ? Text::MenuItem_Hide() : Text::MenuItem_Show()).c_str()
);
//Startup
BOOL Startup = Registry::Startup_Get();
if (Startup == TRUE) {
ModifyMenuW(Handle_, Item::Startup, MF_BYPOSITION | MF_STRING | MF_CHECKED, WM_MENU_STARTUP, Text::MenuItem_Startup().c_str());
}
else if (Startup == FALSE) {
ModifyMenuW(Handle_, Item::Startup, MF_BYPOSITION | MF_STRING | MF_UNCHECKED, WM_MENU_STARTUP, Text::MenuItem_Startup().c_str());
}
ModifyMenuW(
Handle_,
Item::Startup,
MF_BYPOSITION | MF_STRING | (Registry::Startup_Get() ? MF_CHECKED : MF_UNCHECKED),
WM_MENU_STARTUP,
Text::MenuItem_Startup().c_str()
);
//Setting
ModifyMenu(Handle_, Item::Setting, MF_BYPOSITION | MF_STRING, WM_MENU_SETTING, Text::MenuItem_Setting().c_str());
//Exit
Expand All @@ -50,7 +50,7 @@ VOID Menu::Pop() {
//public:

VOID Menu::Item_Exit() {
if (Dialog_Setting::Handle_Get() != NULL) {
if(Dialog_Setting::Handle_Get() != NULL) {
Dialog_Setting::Destroy();
}
NotifyIcon::Destroy();
Expand All @@ -59,30 +59,26 @@ VOID Menu::Item_Exit() {

VOID Menu::Item_Setting() {
HWND Handle_DialogSetting = Dialog_Setting::Handle_Get();
if (Handle_DialogSetting != NULL) {
if(Handle_DialogSetting != NULL) {
SetForegroundWindow(Handle_DialogSetting);
return;
}
DialogBoxW(NULL, MAKEINTRESOURCE(ID_Dialog_Setting), NULL, Dialog_Setting::Process);
}

VOID Menu::Item_Show() {
BOOL Show = Dialog_Main::Show_Get();
if (Show == TRUE) {
ShowWindow(Dialog_Main::Handle_Get(), SW_HIDE);
}
else if (Show == FALSE) {
ShowWindow(Dialog_Main::Handle_Get(), SW_SHOW);
}
if (Dialog_Setting::Handle_Get() != NULL) {
ShowWindow(
Dialog_Main::Handle_Get(),
Dialog_Main::Show_Get() ? SW_HIDE : SW_SHOW
);
if(Dialog_Setting::Handle_Get() != NULL) {
Dialog_Setting::Gather_Check_Show();
}
}

VOID Menu::Item_Startup() {
BOOL Startup = Registry::Startup_Get();
Registry::Startup_Set(!Startup);
if (Dialog_Setting::Handle_Get() != NULL) {
Registry::Startup_Set(!Registry::Startup_Get());
if(Dialog_Setting::Handle_Get() != NULL) {
Dialog_Setting::Gather_Check_Startup();
}
}
Loading

0 comments on commit bb20e0a

Please sign in to comment.