Skip to content

Commit

Permalink
added app icon and removed console blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromagician committed Jun 3, 2022
1 parent 7aad14f commit 7c15f7d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ int _tmain(int argc, _TCHAR* argv[])
cmd.Add(CommandLine::_INT, 1, _T("-x"), _T("The 'xxx' argument specifies the position offset along the X coordinate."), &InputBox::position.delta.x);
cmd.Add(CommandLine::_INT, 1, _T("-y"), _T("The 'xxx' argument specifies the position offset along the Y coordinate."), &InputBox::position.delta.y);
cmd.Add(CommandLine::_TRUE, 1, _T("-topmost"), _T("This argument places the window above all windows that are not in the highest position.The window retains its highest position even if it is deactivated."), &InputBox::topMost);
cmd.Add(CommandLine::_STRING, 1, _T("-iconapp"), _T("The 'xxx' argument specifies the icon file for the application. (ICO/BMP)"), &InputBox::iconApp);

if (cmd.ParseCommandLine(argc, argv, correctParameters) != 0) {
cmd.Help();
Expand Down
Binary file modified Bin/InputBox.exe
Binary file not shown.
31 changes: 29 additions & 2 deletions InputBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ wstring InputBox::title = _T("Input Box");
wstring InputBox::prompt = _T("Please input text");
wstring InputBox::def = _T("");

wstring InputBox::iconApp = _T("");

pair<bool, wstring> InputBox::brush = pair<bool, wstring>(false, _T("#000000"));
pair<bool, wstring> InputBox::background= pair<bool, wstring>(false, _T("#000000"));
pair<bool, wstring> InputBox::pen = pair<bool, wstring>(false, _T("#ffffff"));
Expand Down Expand Up @@ -249,6 +251,31 @@ LRESULT CALLBACK InputBox::WndProc(HWND _hWnd, UINT _message, WPARAM _wParam, LP

SetWindowPos(_hWnd, HWND_TOPMOST, x, y, 0, 0, flags);

// icon app
if (InputBox::iconApp.empty() == false) {
HICON hIcon = nullptr;
hIcon = (HICON)LoadImage(hInst, InputBox::iconApp.c_str(), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
if (!hIcon) {
HBITMAP bitmapForIconApp = nullptr;
bitmapForIconApp = (HBITMAP)LoadImage(hInst, InputBox::iconApp.c_str(), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
if (bitmapForIconApp) {
ICONINFO ii = { 0 };
ii.fIcon = TRUE;
ii.hbmColor = bitmapForIconApp;
ii.hbmMask = bitmapForIconApp;

hIcon = ::CreateIconIndirect(&ii);

::DeleteObject(bitmapForIconApp);
}
}

if (hIcon) {
SendMessage(_hWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon);
SendMessage(_hWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon);
}
}

break;
}
case WM_DESTROY: {
Expand Down Expand Up @@ -322,7 +349,7 @@ bool InputBox::GetString(wstring & _result)
WS_POPUPWINDOW | WS_CAPTION | WS_TABSTOP | WS_VISIBLE,
(rc.right - InputBox::width) / 2, (rc.bottom - InputBox::width / 2) / 2,
InputBox::width, 50 + buttonY + buttonHeight,
mhWndParent, nullptr, nullptr, nullptr
/*mhWndParent*/ nullptr, nullptr, nullptr, nullptr
);
if (mhWndInputBox == nullptr) {
return false;
Expand All @@ -340,7 +367,7 @@ bool InputBox::GetString(wstring & _result)
SendMessage(mhWndEdit, EM_SETSEL, 0, -1);
SetFocus(mhWndEdit);

EnableWindow(mhWndParent, FALSE);
//EnableWindow(mhWndParent, FALSE);
ShowWindow(mhWndInputBox, SW_SHOW);
UpdateWindow(mhWndInputBox);

Expand Down
2 changes: 2 additions & 0 deletions InputBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class InputBox
static wstring prompt;
static wstring def;

static wstring iconApp;

static bool GetString(wstring& _result);

private:
Expand Down
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define STRINGIZE(s) STRINGIZE2(s)

#define VERSION_MAJOR 0
#define VERSION_MINOR 5
#define VERSION_PATCH 9
#define VERSION_MINOR 6
#define VERSION_PATCH 0
#define VERSION_REVISION 0

#define VER_COMPANYNAME_STR "Pedro"
Expand Down

0 comments on commit 7c15f7d

Please sign in to comment.