Skip to content

Commit

Permalink
fix: focus, output text
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromagician committed May 6, 2022
1 parent 7c22693 commit dee98e5
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
9 changes: 6 additions & 3 deletions App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

int _tmain(int argc, _TCHAR* argv[])
{
_setmode(_fileno(stdout), _O_U8TEXT);

int correctParameters = 0;
bool help = false;
wstring monitor = _T("primary");
Expand Down Expand Up @@ -55,7 +57,7 @@ int _tmain(int argc, _TCHAR* argv[])
}

if (InputBox::prompt.empty()) {
_tprintf(_T("Error - message is emnpty\n"));
wcout << _T("Error - message is emnpty") << endl;
return 1;
}

Expand All @@ -69,8 +71,9 @@ int _tmain(int argc, _TCHAR* argv[])
}

wstring result = _T("");
if (InputBox::GetString(result) != 0)
_tprintf(result.c_str());
if (InputBox::GetString(result) != 0) {
wcout << result;
}

return 0;
}
Binary file modified Bin/InputBox.exe
Binary file not shown.
22 changes: 11 additions & 11 deletions CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ CommandLine::~CommandLine()

void CommandLine::Help()
{
_tprintf(_T("InputBox 0.5.3\n"));
_tprintf(_T(" InputBox for command line. Amiga Rulez!\n"));
_tprintf(_T("\nUsage:\n"));
_tprintf(_T(" InputBox [options]\n"));
_tprintf(_T("\nOptions:\n"));
wcout << _T("InputBox 0.5.4") << endl;
wcout << _T(" InputBox for command line. Amiga Rulez!") << endl << endl;
wcout << _T("Usage:") << endl;
wcout << _T(" InputBox [options]") << endl << endl;
wcout << _T("Options:") << endl;

for (const auto& it : mArguments)
{
for (const auto& text : it.text) {
_tprintf((_T(" ") + text + _T(" xxx\n")).c_str());
wcout << _T(" ") + text + _T(" xxx") << endl;
}
_tprintf((_T(" ") + it.help + _T("\n")).c_str());
wcout << _T(" ") + it.help << endl;
}
}

Expand All @@ -47,7 +47,7 @@ void CommandLine::Add(ARGUMENT_TYPE _type, int _num, ...)
for (const auto& itArg : mArguments) {
for (const auto& itParam : itArg.text) {
if (itParam == Conversion::ToLower(Conversion::TrimWhiteChar(tmp)))
_tprintf(_T("Error - the same switch, you will not be able to use it\n"));
wcout << _T("Error - the same switch, you will not be able to use it") << endl;
}
}
#endif // DEBUG
Expand Down Expand Up @@ -116,21 +116,21 @@ int CommandLine::ParseCommandLine(int _argc, _TCHAR* _pArgv[], int& _correctPara
unknown = false;
}
else {
_tprintf(wstring(_T("Error - bad argument: ") + mArguments[a].text[0] + _T(" ") + key + _T("\n")).c_str());
wcout << _T("Error - bad argument: ") + mArguments[a].text[0] + _T(" ") + key << endl;
return 1;
}
_correctParameters++;
}
break;
}
else {
_tprintf(_T("Error - unknown type\n"));
wcout << _T("Error - unknown type") << endl;
return 1;
}
}
}
if (unknown) {
_tprintf(wstring(_T("Error - unknown argument: ") + (wstring)_pArgv[i] + _T("\n")).c_str());
wcout << wstring(_T("Error - unknown argument: ") + (wstring)_pArgv[i]) << endl;
return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void Conversion::HexToRGB(wstring _hex, int& _r, int& _g, int& _b)
sb = _hex.substr(2, 1);
}
else {
_tprintf(_T("Error - bad color\n"));
wcout << _T("Error - bad color") << endl;
}
_r = ToInt(sr, 16);
_g = ToInt(sg, 16);
Expand Down
11 changes: 5 additions & 6 deletions InputBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ LRESULT CALLBACK InputBox::WndProc(HWND _hWnd, UINT _message, WPARAM _wParam, LP
break;
}
default:
_tprintf(wstring(_T("Error - unknown position: ") + to_wstring(InputBox::position.type) + _T("\n")).c_str());
wcout << _T("Error - unknown position: ") << to_wstring(InputBox::position.type) << endl;
InputBox::position.type = _CENTER;
monitor = Monitors::GetMonitorInfoPrimary(monitorSize);
x = GetDiameterX(monitorSize) - GetWidth(dialogRect) / 2;
Expand All @@ -231,7 +231,7 @@ LRESULT CALLBACK InputBox::WndProc(HWND _hWnd, UINT _message, WPARAM _wParam, LP
}
}
else {
_tprintf(wstring(_T("Error - problem loading information from the monitor")).c_str());
wcout << _T("Error - problem loading information from the monitor") << endl;
InputBox::position.monitor = _PRIMARY;
InputBox::position.type = _XY;
x = monitorSize.left;
Expand Down Expand Up @@ -273,9 +273,9 @@ LRESULT CALLBACK InputBox::WndProc(HWND _hWnd, UINT _message, WPARAM _wParam, LP

bool InputBox::GetString(wstring & _result)
{
HWND hWnd = GetDesktopWindow();
mhWndParent = GetActiveWindow();
RECT rc;
GetWindowRect(hWnd, &rc);
GetWindowRect(mhWndParent, &rc);

HINSTANCE hInst = GetModuleHandle(nullptr);
WNDCLASSEX wcex;
Expand All @@ -295,13 +295,12 @@ bool InputBox::GetString(wstring & _result)
wcex.hIconSm = nullptr;

if (RegisterClassEx(&wcex) == 0) {
_tprintf(_T("Error - register class\n"));
wcout << _T("Error - register class") << endl;
return false;
}
}

// window
mhWndParent = hWnd;
int inputY = 10 + fontSize / 2 + fontSize * linesOfText;
int inputHeight = fontSize + 2;
int buttonY = inputY + inputHeight + 15;
Expand Down
2 changes: 1 addition & 1 deletion Monitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bool Monitors::GetMonitorInfoId(UINT _id, RECT& _monitor)
Monitors monitors;

if (_id > monitors.iMonitors.size() - 1) {
_tprintf(wstring(_T("Error - problem with monitor ") + to_wstring(_id)).c_str());
wcout << _T("Error - problem with monitor ") << to_wstring(_id) << endl;
_id = 0;
}

Expand Down
Binary file modified project.rc
Binary file not shown.
6 changes: 2 additions & 4 deletions stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
#include <string>
#include <algorithm>
#include <atlbase.h>
#include <activscp.h>
#include <comdef.h>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include "tchar.h"
#include "resource.h"
#include <io.h>
#include <fcntl.h>

using namespace std;

0 comments on commit dee98e5

Please sign in to comment.