public void GetClassInfo_NotRegistered() { Action action = () => WindowMethods.GetClassInfo(null, Path.GetRandomFileName()); action.ShouldThrow <IOException>().And .HResult.Should().Be((int)ErrorMacros.HRESULT_FROM_WIN32(WindowsError.ERROR_CLASS_DOES_NOT_EXIST)); }
public void RegisterClass_UnregisterClassName() { WindowClass myClass = new WindowClass { ClassName = "RegisterClass_UnregisterClassName", Style = ClassStyle.HorizontalRedraw, WindowProcedure = CallDefaultProcedure }; Atom atom = WindowMethods.RegisterClass(ref myClass); atom.IsValid.Should().BeTrue(); try { var info = WindowMethods.GetClassInfo(ModuleMethods.GetModuleHandle(null), "RegisterClass_UnregisterClassName"); info.ClassName.Should().Be("RegisterClass_UnregisterClassName"); info.ClassAtom.Should().Be(Atom.Null); info.Style.Should().Be(ClassStyle.HorizontalRedraw); } finally { WindowMethods.UnregisterClass("RegisterClass_UnregisterClassName", null); Action action = () => WindowMethods.GetClassInfo(ModuleMethods.GetModuleHandle(null), "RegisterClass_UnregisterClassName"); action.ShouldThrow <IOException>().And .HResult.Should().Be((int)ErrorMacros.HRESULT_FROM_WIN32(WindowsError.ERROR_CLASS_DOES_NOT_EXIST)); } }
public void GetClassInfo_Global() { var info = WindowMethods.GetClassInfo(null, "Button"); info.Background.IsInvalid.Should().BeFalse(); info.Style.Should().Be(ClassStyle.VerticalRedraw | ClassStyle.HorizontalRedraw | ClassStyle.DoubleClicks | ClassStyle.ParentDeviceContext); info.WindowExtraBytes.Should().Be(8); }
public void RegisterClass_GetSetClassLong() { // Some docs claim that 40 is the max, but that isn't true (at least in recent OSes) // https://msdn.microsoft.com/en-us/library/windows/desktop/ms633574.aspx WindowClass myClass = new WindowClass { ClassName = "RegisterClass_GetSetClassLong", Style = ClassStyle.HorizontalRedraw, WindowProcedure = CallDefaultProcedure, ClassExtraBytes = 80 }; Atom atom = WindowMethods.RegisterClass(ref myClass); atom.IsValid.Should().BeTrue(); try { WindowHandle window = WindowMethods.CreateWindow(atom, "RegisterClass_GetSetClassLong_Window", WindowStyles.Diabled | WindowStyles.Minimize); window.IsValid.Should().BeTrue(); try { var info = WindowMethods.GetClassInfo(ModuleMethods.GetModuleHandle(null), atom); info.ClassExtraBytes.Should().Be(80); IntPtr result = WindowMethods.SetClassLong(window, (ClassLong)72, (IntPtr)0x0000BEEF); result.Should().Be(IntPtr.Zero); WindowMethods.GetClassLong(window, (ClassLong)72).Should().Be((IntPtr)0x0000BEEF); } finally { WindowMethods.DestroyWindow(window); } } finally { WindowMethods.UnregisterClass(atom, null); } }
public void GetClassInfo_GlobalAtom() { var info = WindowMethods.GetClassInfo(null, new Atom(32768)); }