mirror of https://github.com/dahall/Vanara.git
Completed work on ComDlg32
parent
96ab21f382
commit
9067493f09
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -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>
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue