Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit fea4c6e

Browse files
committed
win32 now accepts uint on SendMessage
1 parent 9f9746a commit fea4c6e

File tree

5 files changed

+159
-42
lines changed

5 files changed

+159
-42
lines changed

Demo Plugin/NppManagedPluginDemo/Demo.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static internal void CommandMenuInit()
7878

7979
// get path of plugin configuration
8080
StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);
81-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
81+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
8282
iniFilePath = sbIniFilePath.ToString();
8383

8484
// if config path doesn't exist, we create it
@@ -134,7 +134,7 @@ static internal void SetToolBarIcon()
134134
tbIcons.hToolbarBmp = tbBmp.GetHbitmap();
135135
IntPtr pTbIcons = Marshal.AllocHGlobal(Marshal.SizeOf(tbIcons));
136136
Marshal.StructureToPtr(tbIcons, pTbIcons, false);
137-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_ADDTOOLBARICON, PluginBase._funcItems.Items[idFrmGotToLine]._cmdID, pTbIcons);
137+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_ADDTOOLBARICON, PluginBase._funcItems.Items[idFrmGotToLine]._cmdID, pTbIcons);
138138
Marshal.FreeHGlobal(pTbIcons);
139139
}
140140

@@ -234,7 +234,7 @@ static void insertCurrentPath(NppMsg which)
234234
msg = NppMsg.NPPM_GETCURRENTDIRECTORY;
235235

236236
StringBuilder path = new StringBuilder(Win32.MAX_PATH);
237-
Win32.SendMessage(PluginBase.nppData._nppHandle, msg, 0, path);
237+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) msg, 0, path);
238238

239239
editor.ReplaceSel(path.ToString());
240240
}
@@ -266,7 +266,7 @@ static void checkInsertHtmlCloseTag()
266266
static internal void doInsertHtmlCloseTag(char newChar)
267267
{
268268
LangType docType = LangType.L_TEXT;
269-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETCURRENTLANGTYPE, 0, ref docType);
269+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_GETCURRENTLANGTYPE, 0, ref docType);
270270
bool isDocTypeHTML = (docType == LangType.L_HTML || docType == LangType.L_XML || docType == LangType.L_PHP);
271271

272272
if (!doCloseTag || !isDocTypeHTML)
@@ -323,18 +323,18 @@ static internal void doInsertHtmlCloseTag(char newChar)
323323

324324
static void getFileNamesDemo()
325325
{
326-
int nbFile = (int)Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETNBOPENFILES, 0, 0);
326+
int nbFile = (int)Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_GETNBOPENFILES, 0, 0);
327327
MessageBox.Show(nbFile.ToString(), "Number of opened files:");
328328

329329
using (ClikeStringArray cStrArray = new ClikeStringArray(nbFile, Win32.MAX_PATH))
330330
{
331-
if (Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETOPENFILENAMES, cStrArray.NativePointer, nbFile) != IntPtr.Zero)
331+
if (Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_GETOPENFILENAMES, cStrArray.NativePointer, nbFile) != IntPtr.Zero)
332332
foreach (string file in cStrArray.ManagedStringsUnicode) MessageBox.Show(file);
333333
}
334334
}
335335
static void getSessionFileNamesDemo()
336336
{
337-
int nbFile = (int)Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETNBSESSIONFILES, 0, sessionFilePath);
337+
int nbFile = (int)Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_GETNBSESSIONFILES, 0, sessionFilePath);
338338

339339
if (nbFile < 1)
340340
{
@@ -345,13 +345,13 @@ static void getSessionFileNamesDemo()
345345

346346
using (ClikeStringArray cStrArray = new ClikeStringArray(nbFile, Win32.MAX_PATH))
347347
{
348-
if (Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETSESSIONFILES, cStrArray.NativePointer, sessionFilePath) != IntPtr.Zero)
348+
if (Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_GETSESSIONFILES, cStrArray.NativePointer, sessionFilePath) != IntPtr.Zero)
349349
foreach (string file in cStrArray.ManagedStringsUnicode) MessageBox.Show(file);
350350
}
351351
}
352352
static void saveCurrentSessionDemo()
353353
{
354-
string sessionPath = Marshal.PtrToStringUni(Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_SAVECURRENTSESSION, 0, sessionFilePath));
354+
string sessionPath = Marshal.PtrToStringUni(Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_SAVECURRENTSESSION, 0, sessionFilePath));
355355
if (!string.IsNullOrEmpty(sessionPath))
356356
MessageBox.Show(sessionPath, "Saved Session File :", MessageBoxButtons.OK);
357357
}
@@ -392,21 +392,21 @@ static void DockableDlgDemo()
392392
IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData));
393393
Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false);
394394

395-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData);
395+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData);
396396
// Following message will toogle both menu item state and toolbar button
397-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[idFrmGotToLine]._cmdID, 1);
397+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[idFrmGotToLine]._cmdID, 1);
398398
}
399399
else
400400
{
401401
if (!frmGoToLine.Visible)
402402
{
403-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMSHOW, 0, frmGoToLine.Handle);
404-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[idFrmGotToLine]._cmdID, 1);
403+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_DMMSHOW, 0, frmGoToLine.Handle);
404+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[idFrmGotToLine]._cmdID, 1);
405405
}
406406
else
407407
{
408-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMHIDE, 0, frmGoToLine.Handle);
409-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[idFrmGotToLine]._cmdID, 0);
408+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_DMMHIDE, 0, frmGoToLine.Handle);
409+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[idFrmGotToLine]._cmdID, 0);
410410
}
411411
}
412412
frmGoToLine.textBox1.Focus();

Demo Plugin/NppManagedPluginDemo/Forms/frmGoToLine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void FrmGoToLineVisibleChanged(object sender, EventArgs e)
5757
{
5858
if (!Visible)
5959
{
60-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK,
60+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_SETMENUITEMCHECK,
6161
PluginBase._funcItems.Items[Main.idFrmGotToLine]._cmdID, 0);
6262
}
6363
}

Visual Studio Project Template C#/PluginInfrastructure/NotepadPPGateway.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class NotepadPPGateway : INotepadPPGateway
2424

2525
public void FileNew()
2626
{
27-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_MENUCOMMAND, Unused, NppMenuCmd.IDM_FILE_NEW);
27+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_MENUCOMMAND, Unused, NppMenuCmd.IDM_FILE_NEW);
2828
}
2929

3030
/// <summary>
@@ -33,7 +33,7 @@ public void FileNew()
3333
public string GetCurrentFilePath()
3434
{
3535
var path = new StringBuilder(2000);
36-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETFULLCURRENTPATH, 0, path);
36+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_GETFULLCURRENTPATH, 0, path);
3737
return path.ToString();
3838
}
3939

@@ -43,13 +43,13 @@ public string GetCurrentFilePath()
4343
public unsafe string GetFilePath(int bufferId)
4444
{
4545
var path = new StringBuilder(2000);
46-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETFULLPATHFROMBUFFERID, bufferId, path);
46+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_GETFULLPATHFROMBUFFERID, bufferId, path);
4747
return path.ToString();
4848
}
4949

5050
public void SetCurrentLanguage(LangType language)
5151
{
52-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_SETCURRENTLANGTYPE, Unused, (int) language);
52+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) NppMsg.NPPM_SETCURRENTLANGTYPE, Unused, (int) language);
5353
}
5454
}
5555

@@ -63,7 +63,7 @@ class NppResource
6363

6464
public void ClearIndicator()
6565
{
66-
Win32.SendMessage(PluginBase.nppData._nppHandle, (NppMsg) Resource.NPPM_INTERNAL_CLEARINDICATOR, Unused, Unused);
66+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint) Resource.NPPM_INTERNAL_CLEARINDICATOR, Unused, Unused);
6767
}
6868
}
6969
}

Visual Studio Project Template C#/PluginInfrastructure/NppPluginNETBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal static void SetCommand(int index, string commandName, NppFuncItemDelega
3939
internal static IntPtr GetCurrentScintilla()
4040
{
4141
int curScintilla;
42-
Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_GETCURRENTSCINTILLA, 0, out curScintilla);
42+
Win32.SendMessage(nppData._nppHandle, (uint) NppMsg.NPPM_GETCURRENTSCINTILLA, 0, out curScintilla);
4343
return (curScintilla == 0) ? nppData._scintillaMainHandle : nppData._scintillaSecondHandle;
4444
}
4545

0 commit comments

Comments
 (0)