Completed work on ComDlg32

pull/211/head
dahall 2020-12-25 20:41:41 -07:00
parent 96ab21f382
commit 9067493f09
4 changed files with 4389 additions and 171 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,8 @@ OPENFILENAME
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\Vanara.Core.csproj" />
<ProjectReference Include="..\Kernel32\Vanara.PInvoke.Kernel32.csproj" />
<ProjectReference Include="..\Shared\Vanara.PInvoke.Shared.csproj" />
<ProjectReference Include="..\User32\Vanara.PInvoke.User32.csproj" />
</ItemGroup>
</Project>

View File

@ -3,6 +3,7 @@ using NUnit.Framework.Internal;
using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.ComDlg32;
using static Vanara.PInvoke.User32;
namespace Vanara.PInvoke.Tests
{
@ -19,6 +20,19 @@ namespace Vanara.PInvoke.Tests
{
}
[Test]
public void ChooseColorTest()
{
var cc = new CHOOSECOLOR
{
lStructSize = (uint)Marshal.SizeOf(typeof(CHOOSECOLOR)),
rgbResult = System.Drawing.Color.Red,
Flags = CC.CC_RGBINIT,
hwndOwner = GetDesktopWindow()
};
Assert.That(ChooseColor(ref cc), Is.True);
}
[Test]
public void GetOpenFileNameTest()
{
@ -33,8 +47,45 @@ namespace Vanara.PInvoke.Tests
nFilterIndex = 1,
Flags = OFN.OFN_PATHMUSTEXIST | OFN.OFN_FILEMUSTEXIST
};
Assert.That(GetOpenFileName(ref ofn), ResultIs.Successful);
Assert.That(GetOpenFileName(ref ofn), Is.True);
Assert.That(ofn.lpstrFilter.Length, Is.GreaterThan(0));
}
[Test]
public void FindTextTest()
{
using var wnd = new DlgWin(RegisterWindowMessage(FINDMSGSTRING));
var fwch = new char[261];
var fw = new string(fwch);
var fr = new FINDREPLACE
{
lStructSize = (uint)Marshal.SizeOf(typeof(FINDREPLACE)),
hwndOwner = wnd.MessageWindowHandle,
lpstrFindWhat = fw,
wFindWhatLen = (ushort)fwch.Length,
};
Assert.That(wnd.hdlg = FindText(ref fr), Is.True);
}
class DlgWin : SystemEventHandler
{
uint rmsg;
internal HWND hdlg = default;
public DlgWin(uint m)
{
rmsg = m;
}
protected override bool PreprocessMessage(in MSG msg) => IsDialogMessage(hdlg, msg);
protected override bool MessageFilter(HWND hwnd, uint msg, IntPtr wParam, IntPtr lParam, out IntPtr lReturn)
{
lReturn = default;
if (msg == rmsg)
return true;
return false;
}
}
}
}