Skip to content

Commit fb1fb58

Browse files
committed
Make Resource file open-able and editable in visual studio directly.
1 parent fae3b57 commit fb1fb58

File tree

9 files changed

+252
-82
lines changed

9 files changed

+252
-82
lines changed

NppJSONViewer/JSONDialog.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ Delete all items from the tree and creates the root node
3434
HTREEITEM JSONDialog::initTree(HWND hWndDlg)
3535
{
3636

37-
int TreeCount=TreeView_GetCount(GetDlgItem(this->getHSelf(),IDC_TREE1));
37+
int TreeCount=TreeView_GetCount(GetDlgItem(this->getHSelf(),IDC_TREE));
3838
if(TreeCount>0)
39-
TreeView_DeleteAllItems(GetDlgItem(this->getHSelf(),IDC_TREE1));
39+
TreeView_DeleteAllItems(GetDlgItem(this->getHSelf(),IDC_TREE));
4040

4141
TV_INSERTSTRUCT tvinsert;
4242

@@ -45,7 +45,7 @@ HTREEITEM JSONDialog::initTree(HWND hWndDlg)
4545
tvinsert.item.mask=TVIF_TEXT;
4646

4747
tvinsert.item.pszText=L"JSON";
48-
HTREEITEM item=(HTREEITEM)SendDlgItemMessage(hWndDlg,IDC_TREE1,TVM_INSERTITEM,0,(LPARAM)&tvinsert);
48+
HTREEITEM item=(HTREEITEM)SendDlgItemMessage(hWndDlg,IDC_TREE,TVM_INSERTITEM,0,(LPARAM)&tvinsert);
4949

5050
return item;
5151
}
@@ -69,7 +69,7 @@ HTREEITEM JSONDialog::insertToTree(HWND hWndDlg,HTREEITEM parent, const char *te
6969
MultiByteToWideChar(CP_UTF8, NULL, text, -1, w_msg, len);
7070

7171
tvinsert.item.pszText = w_msg;
72-
item = (HTREEITEM)SendDlgItemMessage(hWndDlg, IDC_TREE1, TVM_INSERTITEM, 0, (LPARAM)&tvinsert);
72+
item = (HTREEITEM)SendDlgItemMessage(hWndDlg, IDC_TREE, TVM_INSERTITEM, 0, (LPARAM)&tvinsert);
7373
delete[] w_msg; // fix memory leak
7474
}
7575

@@ -343,12 +343,12 @@ void JSONDialog::drawTreeSaxParse()
343343

344344
if (strlen(curJSON) == 0) {
345345
insertToTree(this->getHSelf(), tree_root, "Error:Please select a JSON String.");
346-
TreeView_Expand(GetDlgItem(this->getHSelf(), IDC_TREE1), tree_root, TVE_EXPAND);
346+
TreeView_Expand(GetDlgItem(this->getHSelf(), IDC_TREE), tree_root, TVE_EXPAND);
347347
return;
348348
}
349349

350350
populateTreeUsingSax(this->getHSelf(), tree_root, curJSON);
351-
TreeView_Expand(GetDlgItem(this->getHSelf(), IDC_TREE1), tree_root, TVE_EXPAND);
351+
TreeView_Expand(GetDlgItem(this->getHSelf(), IDC_TREE), tree_root, TVE_EXPAND);
352352
}
353353

354354

@@ -428,14 +428,14 @@ INT_PTR CALLBACK JSONDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa
428428
switch (message)
429429
{
430430
case WM_INITDIALOG:
431-
hTree=GetDlgItem(this->getHSelf(),IDC_TREE1);// tree control
431+
hTree=GetDlgItem(this->getHSelf(),IDC_TREE);// tree control
432432
drawTreeSaxParse();
433433
return TRUE;
434434

435435
case WM_SIZE:
436436
width=LOWORD(lParam);
437437
height=HIWORD(lParam);
438-
SetWindowPos(GetDlgItem(this->getHSelf(),IDC_TREE1),HWND_TOP,0,0,width,height,SWP_SHOWWINDOW);
438+
SetWindowPos(GetDlgItem(this->getHSelf(),IDC_TREE),HWND_TOP,0,0,width,height,SWP_SHOWWINDOW);
439439
return TRUE;
440440

441441
default :

NppJSONViewer/JSONDialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class JSONDialog : public DockingDlgInterface
3737
//void populateTree (HWND hWndDlg, HTREEITEM tree_root, json_t * json_root, int level);
3838
void populateTreeUsingSax(HWND hWndDlg, HTREEITEM tree_root, char * json);
3939
public :
40-
JSONDialog() : DockingDlgInterface(IDD_TREE){};
40+
JSONDialog() : DockingDlgInterface(IDD_TREEDLG){};
4141

4242
HTREEITEM insertToTree(HTREEITEM parent, const char *text);
4343

NppJSONViewer/NPPJSONViewer.vcxproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
<MultiProcessorCompilation>true</MultiProcessorCompilation>
101101
</ClCompile>
102102
<Link>
103-
<AdditionalDependencies>shlwapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
103+
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
104104
<GenerateDebugInformation>true</GenerateDebugInformation>
105105
<SubSystem>Windows</SubSystem>
106106
<ImportLibrary>$(TargetName).lib</ImportLibrary>
@@ -118,7 +118,7 @@
118118
<MultiProcessorCompilation>true</MultiProcessorCompilation>
119119
</ClCompile>
120120
<Link>
121-
<AdditionalDependencies>shlwapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
121+
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
122122
<GenerateDebugInformation>false</GenerateDebugInformation>
123123
<SubSystem>Windows</SubSystem>
124124
<OptimizeReferences>true</OptimizeReferences>
@@ -138,7 +138,7 @@
138138
<MultiProcessorCompilation>true</MultiProcessorCompilation>
139139
</ClCompile>
140140
<Link>
141-
<AdditionalDependencies>shlwapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
141+
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
142142
<GenerateDebugInformation>false</GenerateDebugInformation>
143143
<SubSystem>Windows</SubSystem>
144144
<OptimizeReferences>true</OptimizeReferences>
@@ -161,7 +161,7 @@
161161
<MultiProcessorCompilation>true</MultiProcessorCompilation>
162162
</ClCompile>
163163
<Link>
164-
<AdditionalDependencies>shlwapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
164+
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
165165
<GenerateDebugInformation>true</GenerateDebugInformation>
166166
<SubSystem>Windows</SubSystem>
167167
<ImportLibrary>$(TargetName).lib</ImportLibrary>
@@ -176,6 +176,7 @@
176176
<ClCompile Include="PluginDefinition.cpp" />
177177
<ClCompile Include="TreeBuilder.cpp" />
178178
<ClCompile Include="StaticDialog.cpp" />
179+
<ClCompile Include="utils.cpp" />
179180
</ItemGroup>
180181
<ItemGroup>
181182
<ClInclude Include="Docking.h" />

NppJSONViewer/NPPJSONViewer.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
<ClCompile Include="TreeBuilder.cpp">
3737
<Filter>Source Files</Filter>
3838
</ClCompile>
39+
<ClCompile Include="utils.cpp">
40+
<Filter>Source Files</Filter>
41+
</ClCompile>
3942
</ItemGroup>
4043
<ItemGroup>
4144
<ClInclude Include="Docking.h">

NppJSONViewer/PluginDefinition.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "menuCmdID.h"
2020
#include "JSONDialog.h"
2121
#include "Hyperlinks.h"
22+
#include "utils.h"
2223
#include "rapidjson/prettywriter.h"
2324
#include "rapidjson/stringbuffer.h"
2425
#include "rapidjson/reader.h"
@@ -81,11 +82,24 @@ void commandMenuInit()
8182
setCommand(2, TEXT("&About"), openAboutDlg, NULL, false);
8283
}
8384

85+
void setVersion(HWND hwndDlg)
86+
{
87+
std::wstring version;
88+
89+
// Get module path
90+
wchar_t moduleFileName[MAX_PATH + 1] = {};
91+
::GetModuleFileName((HINSTANCE)&__ImageBase, moduleFileName, _MAX_PATH);
92+
93+
version = getVersion(moduleFileName);
94+
::SetWindowText(::GetDlgItem(hwndDlg, IDC_VERSION), version.c_str());
95+
}
96+
8497
INT_PTR CALLBACK abtDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM /*lParam*/)
8598
{
8699
switch (uMsg)
87100
{
88101
case WM_INITDIALOG:
102+
setVersion(hwndDlg);
89103
ConvertStaticToHyperlink(hwndDlg, IDC_WEB);
90104
return TRUE;
91105
case WM_COMMAND:

NppJSONViewer/resource.h

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
#ifndef IDC_STATIC
2-
#define IDC_STATIC (-1)
3-
#endif
1+
//{{NO_DEPENDENCIES}}
2+
// Microsoft Visual C++ generated include file.
3+
// Used by resource.rc
4+
//
5+
#define IDD_TREEDLG 101
6+
#define IDD_ABOUTDLG 102
7+
#define IDC_TREE 1001
8+
#define IDC_WEB 1002
9+
#define IDC_VERSION 1003
410

5-
#define IDD_TREE 101
6-
#define IDD_ABOUTDLG 103
7-
#define IDC_TREE1 1002
8-
#define IDC_WEB 1002
11+
// Next default values for new objects
12+
//
13+
#ifdef APSTUDIO_INVOKED
14+
#ifndef APSTUDIO_READONLY_SYMBOLS
15+
#define _APS_NEXT_RESOURCE_VALUE 103
16+
#define _APS_NEXT_COMMAND_VALUE 40001
17+
#define _APS_NEXT_CONTROL_VALUE 1004
18+
#define _APS_NEXT_SYMED_VALUE 101
19+
#endif
20+
#endif

0 commit comments

Comments
 (0)