Skip to content

Commit a561017

Browse files
committed
Use custom function for messagebox
1 parent 5aa80a3 commit a561017

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

NppJSONViewer/NppJsonViewer/JsonNode.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,24 @@
33

44
enum class JsonNodeType
55
{
6-
UNKNOWN = 0x00,
7-
STRING = 0x01,
8-
NUMBER = 0x02,
9-
BOOL = 0x04,
10-
ARRAY = 0x08,
11-
OBJECT = 0x10
6+
UNKNOWN = 0x00,
7+
STRING = 0x01,
8+
NUMBER = 0x02,
9+
BOOL = 0x04,
10+
ARRAY = 0x08,
11+
OBJECT = 0x10
1212
};
1313

1414
struct JsonNodePos
1515
{
16-
int line = 0;
17-
int col = 0;
16+
int line = 0;
17+
int col = 0;
1818
};
1919

2020
struct JsonNode
2121
{
22-
std::string key;
23-
std::string value;
24-
JsonNodeType type = JsonNodeType::UNKNOWN;
25-
JsonNodePos pos = {};
22+
std::string key;
23+
std::string value;
24+
JsonNodeType type = JsonNodeType::UNKNOWN;
25+
JsonNodePos pos = {};
2626
};
27-

NppJSONViewer/NppJsonViewer/JsonViewDlg.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void JsonViewDlg::FormatJson()
8484
// Intimate user
8585
std::string err = std::format("\n\nError: ({} : {})", res.error_code, res.error_str);
8686

87-
::MessageBox(m_NppData._nppHandle, (JSON_ERR_VALIDATE + StringHelper::ToWstring(err)).c_str(), JSON_ERROR_TITLE, MB_OK | MB_ICONERROR);
87+
ShowMessage(JSON_ERROR_TITLE, (JSON_ERR_VALIDATE + StringHelper::ToWstring(err)).c_str(), MB_OK | MB_ICONERROR);
8888
}
8989
}
9090

@@ -109,7 +109,7 @@ void JsonViewDlg::CompressJson()
109109
// Intimate user
110110
std::string err = std::format("\n\nError: ({} : {})", res.error_code, res.error_str);
111111

112-
::MessageBox(m_NppData._nppHandle, (JSON_ERR_VALIDATE + StringHelper::ToWstring(err)).c_str(), JSON_ERROR_TITLE, MB_OK | MB_ICONERROR);
112+
ShowMessage(JSON_ERROR_TITLE, (JSON_ERR_VALIDATE + StringHelper::ToWstring(err)).c_str(), MB_OK | MB_ICONERROR);
113113
}
114114
}
115115

@@ -139,7 +139,7 @@ void JsonViewDlg::ValidateJson()
139139

140140
if (res.success)
141141
{
142-
::MessageBox(m_NppData._nppHandle, JSON_ERR_VALIDATE_SUCCESS, JSON_INFO_TITLE, MB_OK | MB_ICONINFORMATION);
142+
ShowMessage(JSON_INFO_TITLE, JSON_ERR_VALIDATE_SUCCESS, MB_OK | MB_ICONINFORMATION);
143143
}
144144
else
145145
{
@@ -151,7 +151,7 @@ void JsonViewDlg::ValidateJson()
151151
// Intimate user
152152
std::string err = std::format("\n\nError: ({} : {})", res.error_code, res.error_str);
153153

154-
::MessageBox(m_NppData._nppHandle, (JSON_ERR_VALIDATE + StringHelper::ToWstring(err)).c_str(), JSON_ERROR_TITLE, MB_OK | MB_ICONERROR);
154+
ShowMessage(JSON_ERROR_TITLE, (JSON_ERR_VALIDATE + StringHelper::ToWstring(err)).c_str(), MB_OK | MB_ICONERROR);
155155
}
156156
}
157157

@@ -314,12 +314,12 @@ void JsonViewDlg::PopulateTreeUsingSax(HTREEITEM tree_root, const std::string &j
314314
// Intimate user
315315
if (jsonText.empty())
316316
{
317-
::MessageBox(m_NppData._nppHandle, JSON_ERR_PARSE, JSON_ERROR_TITLE, MB_OK | MB_ICONERROR);
317+
ShowMessage(JSON_ERROR_TITLE, JSON_ERR_PARSE, MB_OK | MB_ICONERROR);
318318
}
319319
else
320320
{
321321
std::string err = std::format("\n\nError: ({} : {})", res.error_code, res.error_str);
322-
::MessageBox(m_NppData._nppHandle, (JSON_ERR_VALIDATE + StringHelper::ToWstring(err)).c_str(), JSON_ERROR_TITLE, MB_OK | MB_ICONERROR);
322+
ShowMessage(JSON_ERROR_TITLE, (JSON_ERR_VALIDATE + StringHelper::ToWstring(err)).c_str(), MB_OK | MB_ICONERROR);
323323
}
324324
}
325325

@@ -492,9 +492,9 @@ auto JsonViewDlg::CopyPath() const -> std::wstring
492492
return std::wstring();
493493
}
494494

495-
int JsonViewDlg::ShowMessage(const std::wstring& title, const std::wstring& msg, int flag, bool bForceShow)
495+
int JsonViewDlg::ShowMessage(const std::wstring &title, const std::wstring &msg, int flag, bool bDontShow)
496496
{
497-
return bForceShow ? ::MessageBox(_hParent, msg.c_str(), title.c_str(), flag) : IDOK;
497+
return !bDontShow ? ::MessageBox(_hParent, msg.c_str(), title.c_str(), flag) : IDOK;
498498
}
499499

500500
void JsonViewDlg::ToggleMenuItemState(bool bVisible)
@@ -651,7 +651,7 @@ INT_PTR JsonViewDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
651651
break;
652652

653653
case IDC_BTN_SEARCH:
654-
MessageBox(_hSelf, L"IDC_BTN_SEARCH", L"OK", MB_OK);
654+
ShowMessage(L"OK", L"IDC_BTN_SEARCH", MB_OK);
655655
break;
656656

657657
// context menu entries

NppJSONViewer/NppJsonViewer/JsonViewDlg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class JsonViewDlg : public DockingDlgInterface
4646
auto CopyValue() const->std::wstring;
4747
auto CopyPath() const->std::wstring;
4848

49-
int ShowMessage(const std::wstring& title, const std::wstring& msg, int flag, bool bForceShow = false);
49+
int ShowMessage(const std::wstring &title, const std::wstring &msg, int flag, bool bDontShow = false);
5050

5151
void ToggleMenuItemState(bool bVisible);
5252

0 commit comments

Comments
 (0)