Skip to content

Commit 6b2733c

Browse files
committed
- update and merged with changes from https://github.com/npp-plugins/plugintemplate v3.1
- corrected build warnings and some VS analysis issues
1 parent 05a11e7 commit 6b2733c

19 files changed

+1268
-737
lines changed

.gitignore

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
test/*
2-
Unicode Realeas/*
3-
Unicode Debug/*
4-
bin/*
5-
ipch/*
6-
*.opensdf
71
*.sdf
2+
*.sln
83
*.suo
9-
4+
bin/
5+
bin64/
6+
*.opensdf
7+
*.exp
8+
*.lib
9+
*.vcxproj.user
10+
*.aps
11+
*.zip

DockingFeature/DockingDlgInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class DockingDlgInterface : public StaticDialog
7272
};
7373

7474
protected :
75-
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
75+
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM /*wParam*/, LPARAM lParam)
7676
{
7777
switch (message)
7878
{

DockingFeature/GoToLineDlg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1717

1818
#include "GoToLineDlg.h"
19-
#include "PluginDefinition.h"
19+
#include "../PluginDefinition.h"
2020

2121
extern NppData nppData;
2222

23-
BOOL CALLBACK DemoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
23+
INT_PTR CALLBACK DemoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
2424
{
2525
switch (message)
2626
{

DockingFeature/GoToLineDlg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public :
3737
};
3838

3939
protected :
40-
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
40+
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
4141

4242
private :
4343

DockingFeature/StaticDialog.cpp

Lines changed: 73 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@
1515
//along with this program; if not, write to the Free Software
1616
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1717

18+
#include <stdio.h>
1819
#include "StaticDialog.h"
1920

2021
void StaticDialog::goToCenter()
2122
{
22-
RECT rc;
23-
::GetClientRect(_hParent, &rc);
24-
POINT center;
25-
center.x = rc.left + (rc.right - rc.left)/2;
26-
center.y = rc.top + (rc.bottom - rc.top)/2;
27-
::ClientToScreen(_hParent, &center);
23+
RECT rc;
24+
::GetClientRect(_hParent, &rc);
25+
POINT center;
26+
center.x = rc.left + (rc.right - rc.left)/2;
27+
center.y = rc.top + (rc.bottom - rc.top)/2;
28+
::ClientToScreen(_hParent, &center);
2829

2930
int x = center.x - (_rc.right - _rc.left)/2;
3031
int y = center.y - (_rc.bottom - _rc.top)/2;
@@ -36,17 +37,25 @@ HGLOBAL StaticDialog::makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplat
3637
{
3738
// Get Dlg Template resource
3839
HRSRC hDialogRC = ::FindResource(_hInst, MAKEINTRESOURCE(dialogID), RT_DIALOG);
40+
if (!hDialogRC)
41+
return NULL;
42+
3943
HGLOBAL hDlgTemplate = ::LoadResource(_hInst, hDialogRC);
40-
DLGTEMPLATE *pDlgTemplate = (DLGTEMPLATE *)::LockResource(hDlgTemplate);
41-
44+
if (!hDlgTemplate)
45+
return NULL;
46+
47+
DLGTEMPLATE *pDlgTemplate = reinterpret_cast<DLGTEMPLATE *>(::LockResource(hDlgTemplate));
48+
if (!pDlgTemplate)
49+
return NULL;
50+
4251
// Duplicate Dlg Template resource
4352
unsigned long sizeDlg = ::SizeofResource(_hInst, hDialogRC);
4453
HGLOBAL hMyDlgTemplate = ::GlobalAlloc(GPTR, sizeDlg);
45-
*ppMyDlgTemplate = (DLGTEMPLATE *)::GlobalLock(hMyDlgTemplate);
54+
*ppMyDlgTemplate = reinterpret_cast<DLGTEMPLATE *>(::GlobalLock(hMyDlgTemplate));
4655

4756
::memcpy(*ppMyDlgTemplate, pDlgTemplate, sizeDlg);
48-
49-
DLGTEMPLATEEX *pMyDlgTemplateEx = (DLGTEMPLATEEX *)*ppMyDlgTemplate;
57+
58+
DLGTEMPLATEEX *pMyDlgTemplateEx = reinterpret_cast<DLGTEMPLATEEX *>(*ppMyDlgTemplate);
5059
if (pMyDlgTemplateEx->signature == 0xFFFF)
5160
pMyDlgTemplateEx->exStyle |= WS_EX_LAYOUTRTL;
5261
else
@@ -61,38 +70,43 @@ void StaticDialog::create(int dialogID, bool isRTL)
6170
{
6271
DLGTEMPLATE *pMyDlgTemplate = NULL;
6372
HGLOBAL hMyDlgTemplate = makeRTLResource(dialogID, &pMyDlgTemplate);
64-
_hSelf = ::CreateDialogIndirectParam(_hInst, pMyDlgTemplate, _hParent, (DLGPROC)dlgProc, (LPARAM)this);
73+
_hSelf = ::CreateDialogIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast<LPARAM>(this));
6574
::GlobalFree(hMyDlgTemplate);
6675
}
6776
else
68-
_hSelf = ::CreateDialogParam(_hInst, MAKEINTRESOURCE(dialogID), _hParent, (DLGPROC)dlgProc, (LPARAM)this);
77+
_hSelf = ::CreateDialogParam(_hInst, MAKEINTRESOURCE(dialogID), _hParent, dlgProc, reinterpret_cast<LPARAM>(this));
6978

7079
if (!_hSelf)
7180
{
81+
DWORD err = ::GetLastError();
82+
char errMsg[256];
83+
sprintf(errMsg, "CreateDialogParam() return NULL.\rGetLastError() == %u", err);
84+
::MessageBoxA(NULL, errMsg, "In StaticDialog::create()", MB_OK);
7285
return;
7386
}
7487

75-
::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGADD, (WPARAM)_hSelf);
88+
// if the destination of message NPPM_MODELESSDIALOG is not its parent, then it's the grand-parent
89+
::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGADD, reinterpret_cast<WPARAM>(_hSelf));
7690
}
7791

78-
BOOL CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
92+
INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7993
{
80-
switch (message)
94+
switch (message)
8195
{
82-
case WM_INITDIALOG :
96+
case WM_INITDIALOG:
8397
{
84-
StaticDialog *pStaticDlg = (StaticDialog *)(lParam);
98+
StaticDialog *pStaticDlg = reinterpret_cast<StaticDialog *>(lParam);
8599
pStaticDlg->_hSelf = hwnd;
86-
::SetWindowLongPtr(hwnd, GWL_USERDATA, (long)lParam);
100+
::SetWindowLongPtr(hwnd, GWLP_USERDATA, static_cast<LONG_PTR>(lParam));
87101
::GetWindowRect(hwnd, &(pStaticDlg->_rc));
88-
pStaticDlg->run_dlgProc(message, wParam, lParam);
89-
102+
pStaticDlg->run_dlgProc(message, wParam, lParam);
103+
90104
return TRUE;
91105
}
92106

93-
default :
107+
default:
94108
{
95-
StaticDialog *pStaticDlg = (StaticDialog *)(::GetWindowLongPtr(hwnd, GWL_USERDATA));
109+
StaticDialog *pStaticDlg = reinterpret_cast<StaticDialog *>(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
96110
if (!pStaticDlg)
97111
return FALSE;
98112
return pStaticDlg->run_dlgProc(message, wParam, lParam);
@@ -102,34 +116,40 @@ BOOL CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPAR
102116

103117
void StaticDialog::alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point)
104118
{
105-
RECT rc, rc2;
106-
::GetWindowRect(handle, &rc);
107-
108-
point.x = rc.left;
109-
point.y = rc.top;
110-
111-
switch (pos)
112-
{
113-
case ALIGNPOS_LEFT :
114-
::GetWindowRect(handle2Align, &rc2);
115-
point.x -= rc2.right - rc2.left;
116-
break;
117-
118-
case ALIGNPOS_RIGHT :
119-
::GetWindowRect(handle, &rc2);
120-
point.x += rc2.right - rc2.left;
121-
break;
122-
123-
case ALIGNPOS_TOP :
124-
::GetWindowRect(handle2Align, &rc2);
125-
point.y -= rc2.bottom - rc2.top;
126-
break;
127-
128-
default : //ALIGNPOS_BOTTOM
129-
::GetWindowRect(handle, &rc2);
130-
point.y += rc2.bottom - rc2.top;
131-
break;
132-
}
133-
134-
::ScreenToClient(_hSelf, &point);
119+
RECT rc, rc2;
120+
::GetWindowRect(handle, &rc);
121+
122+
point.x = rc.left;
123+
point.y = rc.top;
124+
125+
switch (pos)
126+
{
127+
case PosAlign::left:
128+
{
129+
::GetWindowRect(handle2Align, &rc2);
130+
point.x -= rc2.right - rc2.left;
131+
break;
132+
}
133+
case PosAlign::right:
134+
{
135+
::GetWindowRect(handle, &rc2);
136+
point.x += rc2.right - rc2.left;
137+
break;
138+
}
139+
case PosAlign::top:
140+
{
141+
::GetWindowRect(handle2Align, &rc2);
142+
point.y -= rc2.bottom - rc2.top;
143+
break;
144+
}
145+
case PosAlign::bottom:
146+
{
147+
::GetWindowRect(handle, &rc2);
148+
point.y += rc2.bottom - rc2.top;
149+
break;
150+
}
151+
}
152+
153+
::ScreenToClient(_hSelf, &point);
135154
}
155+

DockingFeature/StaticDialog.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@
1515
//along with this program; if not, write to the Free Software
1616
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1717

18-
#ifndef STATIC_DIALOG_H
19-
#define STATIC_DIALOG_H
18+
#pragma once
2019

21-
//#include "resource.h"
2220
#include "Window.h"
23-
#include "Notepad_plus_msgs.h"
21+
#include "..\Notepad_plus_msgs.h"
2422

25-
enum PosAlign{ALIGNPOS_LEFT, ALIGNPOS_RIGHT, ALIGNPOS_TOP, ALIGNPOS_BOTTOM};
23+
enum class PosAlign { left, right, top, bottom };
2624

2725
struct DLGTEMPLATEEX {
2826
WORD dlgVer;
@@ -44,7 +42,7 @@ public :
4442
StaticDialog() : Window() {};
4543
~StaticDialog(){
4644
if (isCreated()) {
47-
::SetWindowLongPtr(_hSelf, GWL_USERDATA, (long)NULL); //Prevent run_dlgProc from doing anything, since its virtual
45+
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (long)NULL); //Prevent run_dlgProc from doing anything, since its virtual
4846
destroy();
4947
}
5048
};
@@ -62,11 +60,10 @@ public :
6260

6361
protected :
6462
RECT _rc;
65-
static BOOL CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
66-
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) = 0;
63+
static INT_PTR CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
64+
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) = 0;
6765

6866
void alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point);
6967
HGLOBAL makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate);
7068
};
7169

72-
#endif //STATIC_DIALOG_H

NotepadSharp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extern NppData nppData;
2626

2727
BOOL APIENTRY DllMain( HANDLE hModule,
2828
DWORD reasonForCall,
29-
LPVOID lpReserved )
29+
LPVOID /*lpReserved*/ )
3030
{
3131
switch (reasonForCall)
3232
{
@@ -169,7 +169,7 @@ extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
169169
// Please let me know if you need to access to some messages :
170170
// http://sourceforge.net/forum/forum.php?forum_id=482781
171171
//
172-
extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam)
172+
extern "C" __declspec(dllexport) LRESULT messageProc(UINT /*Message*/, WPARAM /*wParam*/, LPARAM /*lParam*/)
173173
{/*
174174
if (Message == WM_MOVE)
175175
{

NotepadSharp.sln

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)