C# Класс ACAT.Lib.Core.Utility.Windows

Contains numerous functions for window manipulation, window sizing, window positioning, etc. Has cross-thread invoke-required functions for most of the commonly used windows functions
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Activate ( Form form ) : void

Activates the specified form

ActivateForm ( Form form ) : void

Activates the specified form

ActivateWindow ( IntPtr handle ) : bool

Shows the specified window and brings it to top

ClickOnWindow ( Control control ) : void

Simulates a mouse click on the specified control

CloseAsync ( Form form ) : void

Closes the form asynchronously in a different thread

CloseForm ( Form form ) : void

Closes the specified form This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

DockWithScanner ( Form form, Form scanner, WindowPosition scannerPosition ) : void

Docks the form to the scanner form in the relative position specified

FadeIn ( Form form ) : void

Fades in the specified form

FadeOut ( Form form ) : void

Gradually fades out the form

FindControlAtCursor ( Form form ) : Control

Finds the control under the cursor

FindControlAtPoint ( Control container, Point pos ) : Control

Finds which control of a window is at the specified point

GetCaretPosition ( TextBoxBase textBox ) : int

Returns the caret position in a text box. This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

GetForegroundWindow ( ) : IntPtr

Returns the currently active fg window

GetOSVersion ( ) : WindowsVersion

Returns the OS version

GetOpacity ( Form form ) : double

Gets the transparency of a form This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

GetScannerPosition ( Form form ) : WindowPosition

Gets the position of the specified form. which corner is the scanner at?

GetSelectedText ( TextBoxBase control ) : String

Returns selected text in the text box

GetText ( Control control ) : String

Returns the text value of the control. This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

GetText ( IntPtr hWnd ) : string

Gets text from the speficied window

GetTrackBarValueInt ( TrackBar trackBar ) : int

Returns trackbar value Takes care of cross-thread invokations that would result in .NET exceptions

GetVisible ( Control control ) : bool

Gets the visibility of a control. This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

GetWindowTitle ( IntPtr hwnd ) : String

Returns the window title of the specified window

HideTaskbar ( ) : void

Hide windows taskbar

IsDesktopWindow ( IntPtr handle ) : bool

returns if the specified handle is the desktop window

IsMaximized ( IntPtr handle ) : bool

Checks if window is maximized or not

IsMinimized ( IntPtr handle ) : bool

Checks if window is minimzied or not

IsObscuredByNonACATWindows ( IntPtr windowHandle ) : bool

Checks if any part of the specified window is obscured by a window belonging to a process other than ours

IsObscuredWindow ( IntPtr windowHandle ) : bool

Checks if any part of the specified window is obscured by another window. The other window could be one of this application's windows

MaximizeWindow ( IntPtr handle ) : void

Maximizes the window

MinimizeWindow ( IntPtr handle ) : void

Minimizes a window

PostMessage ( IntPtr hWnd, UInt32 Msg, Int32 wParam, UInt32 lParam ) : bool

Windows PostMessage()

RestoreWindow ( IntPtr handle ) : void

Restores the window from the maximized position

SendMessage ( IntPtr hWnd, int Msg, int wparam, int lparam ) : IntPtr

Windows SendMessage()

SetActiveWindow ( IntPtr hwnd ) : void

Sets the window as the active window

SetBackgroundColor ( Control control, Color color ) : void

Sets the background color of the widget. Takes care of cross-thread invokations that would result in .NET exceptions

SetCaretPosition ( TextBoxBase textBox, int position ) : void

Sets the caret position in a text box. This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

SetFocus ( Control control ) : bool

Sets focus to the control

SetFocusToDesktop ( ) : void

Sets current focus to the desktop window

SetForegroundColor ( Control control, Color color ) : void

Sets the foreground color of the widget. Takes care of cross-thread invokations that would result in .NET exceptions

SetForegroundWindow ( IntPtr hwnd ) : bool

Sets the fg window to the specified window

SetForegroundWindowSizePercent ( WindowPosition scannerPosition, int percent ) : void

Sets the width of the foreground window to a certain percentage of the display monitor width.

SetFormStyles ( CreateParams createParams ) : CreateParams

Sets the form style to not activate and also composited for better viewing experience

SetImage ( PictureBox box, Image image ) : void

Sets the image in a picturebox and invalidates the picture box This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

SetOpacity ( Form form, double arg ) : void

Sets the transparency of a form This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

SetRegion ( Control control, Region region ) : void

Set region for a control

SetText ( Control control, String text ) : void

Sets the text for the control. This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

SetTopMost ( Form form, bool topMost = true ) : void

Sets topmost to true

SetTrackBarValue ( TrackBar trackBar, int positionValue ) : void

Sets value of a tackbar as an integer Takes care of cross-thread invokations that would result in .NET exceptions

SetVisible ( Control control, bool visible ) : void

Sets the visibility of the control This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

SetWindowPosition ( Form form, IntPtr insertAfter, WindowPosition position ) : void

Set the window position

SetWindowPosition ( Form form, WindowPosition position ) : void

Set the window position

SetWindowPositionAndNotify ( Form form, IntPtr insertAfter, WindowPosition position ) : void

Set window pos to the specified position and notify when window position has changed

SetWindowPositionAndNotify ( Form form, WindowPosition position ) : void

Set window pos to the specified position and notify when window position has changed

SetWindowSizePercent ( IntPtr handle, WindowPosition scannerPosition, int percent ) : void

Partial maximize. Sets the window width to a percent of the display width.

Show ( Form parent, Form child ) : void

Shows the child window, assigns parent as the owner This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

ShowDialog ( Form parent, Form child ) : void

Shows the child window as a dialog of the parent window This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

ShowForm ( Form form ) : void

Shows the specified form This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.

ShowInTaskbar ( Form control, bool show ) : void

Show or hide the specified form in the Windows taskbar

ShowInactiveTopmost ( Form parentForm, Form form ) : void

Show the window as topmost without activating it. Sets the form's parent to parentForm

ShowTaskbar ( ) : void

Show windows taskbar

ShowWindowBorder ( Form form, bool show, String title = "" ) : void

If show is set to true, shows the window borders and title

ShowWindowWithoutActivation ( Form form ) : void

Shows a window without setting focus to it

ShowWithoutActivation ( Form parent, Form child ) : void

Sets the child's owner to parent and shows it without setting focus to it

ToggleFgWindowMaximizeAndPartialMaximize ( WindowPosition scannerPosition, int percent ) : void

Toggles size of the fg window between maximized to partially maximized

TurnOffDPIAwareness ( ) : void

In Win8 and Win10, there are undesirable side-effects where the scanners are scaled imporperly. Turn off DPI awareness to fix this

UnselectText ( TextBoxBase control ) : void

Unselect text in textbox

Приватные методы

Метод Описание
DeleteObject ( [ hObject ) : bool
SetProcessDpiAwareness ( _Process_DPI_Awareness value ) : int
closeFormThreadProc ( Form form ) : void

Thread proc for CloseAsync()

fadeInProc ( Form form ) : void

Threadproc for fade-in

fadeOutProc ( Form form ) : void

Thread proc for fading out

Описание методов

Activate() публичный статический метод

Activates the specified form
public static Activate ( Form form ) : void
form System.Windows.Forms.Form form to activate
Результат void

ActivateForm() публичный статический метод

Activates the specified form
public static ActivateForm ( Form form ) : void
form System.Windows.Forms.Form form to activate
Результат void

ActivateWindow() публичный статический метод

Shows the specified window and brings it to top
public static ActivateWindow ( IntPtr handle ) : bool
handle System.IntPtr window handle
Результат bool

ClickOnWindow() публичный статический метод

Simulates a mouse click on the specified control
public static ClickOnWindow ( Control control ) : void
control System.Windows.Forms.Control the control
Результат void

CloseAsync() публичный статический метод

Closes the form asynchronously in a different thread
public static CloseAsync ( Form form ) : void
form System.Windows.Forms.Form form to close
Результат void

CloseForm() публичный статический метод

Closes the specified form This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static CloseForm ( Form form ) : void
form System.Windows.Forms.Form Form to close
Результат void

DockWithScanner() публичный статический метод

Docks the form to the scanner form in the relative position specified
public static DockWithScanner ( Form form, Form scanner, WindowPosition scannerPosition ) : void
form System.Windows.Forms.Form form to dock
scanner System.Windows.Forms.Form scanner form to dock to
scannerPosition WindowPosition relative position
Результат void

FadeIn() публичный статический метод

Fades in the specified form
public static FadeIn ( Form form ) : void
form System.Windows.Forms.Form form to fade in
Результат void

FadeOut() публичный статический метод

Gradually fades out the form
public static FadeOut ( Form form ) : void
form System.Windows.Forms.Form form to fade out
Результат void

FindControlAtCursor() публичный статический метод

Finds the control under the cursor
public static FindControlAtCursor ( Form form ) : Control
form System.Windows.Forms.Form form under the cursor
Результат System.Windows.Forms.Control

FindControlAtPoint() публичный статический метод

Finds which control of a window is at the specified point
public static FindControlAtPoint ( Control container, Point pos ) : Control
container System.Windows.Forms.Control the container window
pos Point point to examine
Результат System.Windows.Forms.Control

GetCaretPosition() публичный статический метод

Returns the caret position in a text box. This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static GetCaretPosition ( TextBoxBase textBox ) : int
textBox System.Windows.Forms.TextBoxBase
Результат int

GetForegroundWindow() публичный статический метод

Returns the currently active fg window
public static GetForegroundWindow ( ) : IntPtr
Результат System.IntPtr

GetOSVersion() публичный статический метод

Returns the OS version
public static GetOSVersion ( ) : WindowsVersion
Результат WindowsVersion

GetOpacity() публичный статический метод

Gets the transparency of a form This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static GetOpacity ( Form form ) : double
form System.Windows.Forms.Form Form object
Результат double

GetScannerPosition() публичный статический метод

Gets the position of the specified form. which corner is the scanner at?
public static GetScannerPosition ( Form form ) : WindowPosition
form System.Windows.Forms.Form the scanner form
Результат WindowPosition

GetSelectedText() публичный статический метод

Returns selected text in the text box
public static GetSelectedText ( TextBoxBase control ) : String
control System.Windows.Forms.TextBoxBase text box
Результат String

GetText() публичный статический метод

Returns the text value of the control. This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static GetText ( Control control ) : String
control System.Windows.Forms.Control
Результат String

GetText() публичный статический метод

Gets text from the speficied window
public static GetText ( IntPtr hWnd ) : string
hWnd System.IntPtr window handle
Результат string

GetTrackBarValueInt() публичный статический метод

Returns trackbar value Takes care of cross-thread invokations that would result in .NET exceptions
public static GetTrackBarValueInt ( TrackBar trackBar ) : int
trackBar System.Windows.Forms.TrackBar the trackbar object
Результат int

GetVisible() публичный статический метод

Gets the visibility of a control. This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static GetVisible ( Control control ) : bool
control System.Windows.Forms.Control
Результат bool

GetWindowTitle() публичный статический метод

Returns the window title of the specified window
public static GetWindowTitle ( IntPtr hwnd ) : String
hwnd System.IntPtr handle to the window
Результат String

HideTaskbar() публичный статический метод

Hide windows taskbar
public static HideTaskbar ( ) : void
Результат void

IsDesktopWindow() публичный статический метод

returns if the specified handle is the desktop window
public static IsDesktopWindow ( IntPtr handle ) : bool
handle System.IntPtr
Результат bool

IsMaximized() публичный статический метод

Checks if window is maximized or not
public static IsMaximized ( IntPtr handle ) : bool
handle System.IntPtr window handle
Результат bool

IsMinimized() публичный статический метод

Checks if window is minimzied or not
public static IsMinimized ( IntPtr handle ) : bool
handle System.IntPtr window handle
Результат bool

IsObscuredByNonACATWindows() публичный статический метод

Checks if any part of the specified window is obscured by a window belonging to a process other than ours
public static IsObscuredByNonACATWindows ( IntPtr windowHandle ) : bool
windowHandle System.IntPtr Window to check for
Результат bool

IsObscuredWindow() публичный статический метод

Checks if any part of the specified window is obscured by another window. The other window could be one of this application's windows
public static IsObscuredWindow ( IntPtr windowHandle ) : bool
windowHandle System.IntPtr Window to check for
Результат bool

MaximizeWindow() публичный статический метод

Maximizes the window
public static MaximizeWindow ( IntPtr handle ) : void
handle System.IntPtr window handle
Результат void

MinimizeWindow() публичный статический метод

Minimizes a window
public static MinimizeWindow ( IntPtr handle ) : void
handle System.IntPtr window handle
Результат void

PostMessage() публичный статический метод

Windows PostMessage()
public static PostMessage ( IntPtr hWnd, UInt32 Msg, Int32 wParam, UInt32 lParam ) : bool
hWnd System.IntPtr
Msg System.UInt32
wParam System.Int32
lParam System.UInt32
Результат bool

RestoreWindow() публичный статический метод

Restores the window from the maximized position
public static RestoreWindow ( IntPtr handle ) : void
handle System.IntPtr window handle
Результат void

SendMessage() публичный статический метод

Windows SendMessage()
public static SendMessage ( IntPtr hWnd, int Msg, int wparam, int lparam ) : IntPtr
hWnd System.IntPtr
Msg int
wparam int
lparam int
Результат System.IntPtr

SetActiveWindow() публичный статический метод

Sets the window as the active window
public static SetActiveWindow ( IntPtr hwnd ) : void
hwnd System.IntPtr window handle
Результат void

SetBackgroundColor() публичный статический метод

Sets the background color of the widget. Takes care of cross-thread invokations that would result in .NET exceptions
public static SetBackgroundColor ( Control control, Color color ) : void
control System.Windows.Forms.Control
color Color Color to set
Результат void

SetCaretPosition() публичный статический метод

Sets the caret position in a text box. This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static SetCaretPosition ( TextBoxBase textBox, int position ) : void
textBox System.Windows.Forms.TextBoxBase
position int
Результат void

SetFocus() публичный статический метод

Sets focus to the control
public static SetFocus ( Control control ) : bool
control System.Windows.Forms.Control control to set focus to
Результат bool

SetFocusToDesktop() публичный статический метод

Sets current focus to the desktop window
public static SetFocusToDesktop ( ) : void
Результат void

SetForegroundColor() публичный статический метод

Sets the foreground color of the widget. Takes care of cross-thread invokations that would result in .NET exceptions
public static SetForegroundColor ( Control control, Color color ) : void
control System.Windows.Forms.Control
color Color Color to set
Результат void

SetForegroundWindow() публичный статический метод

Sets the fg window to the specified window
public static SetForegroundWindow ( IntPtr hwnd ) : bool
hwnd System.IntPtr window handle
Результат bool

SetForegroundWindowSizePercent() публичный статический метод

Sets the width of the foreground window to a certain percentage of the display monitor width.
public static SetForegroundWindowSizePercent ( WindowPosition scannerPosition, int percent ) : void
scannerPosition WindowPosition where to position the window?
percent int the percent width
Результат void

SetFormStyles() публичный статический метод

Sets the form style to not activate and also composited for better viewing experience
public static SetFormStyles ( CreateParams createParams ) : CreateParams
createParams System.Windows.Forms.CreateParams Windows create params
Результат System.Windows.Forms.CreateParams

SetImage() публичный статический метод

Sets the image in a picturebox and invalidates the picture box This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static SetImage ( PictureBox box, Image image ) : void
box System.Windows.Forms.PictureBox
image Image
Результат void

SetOpacity() публичный статический метод

Sets the transparency of a form This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static SetOpacity ( Form form, double arg ) : void
form System.Windows.Forms.Form Form object
arg double opacity value
Результат void

SetRegion() публичный статический метод

Set region for a control
public static SetRegion ( Control control, Region region ) : void
control System.Windows.Forms.Control control to set region for
region System.Drawing.Region region to set
Результат void

SetText() публичный статический метод

Sets the text for the control. This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static SetText ( Control control, String text ) : void
control System.Windows.Forms.Control
text String text to set
Результат void

SetTopMost() публичный статический метод

Sets topmost to true
public static SetTopMost ( Form form, bool topMost = true ) : void
form System.Windows.Forms.Form which form?
topMost bool set to true for topmost, false otherwise
Результат void

SetTrackBarValue() публичный статический метод

Sets value of a tackbar as an integer Takes care of cross-thread invokations that would result in .NET exceptions
public static SetTrackBarValue ( TrackBar trackBar, int positionValue ) : void
trackBar System.Windows.Forms.TrackBar
positionValue int
Результат void

SetVisible() публичный статический метод

Sets the visibility of the control This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static SetVisible ( Control control, bool visible ) : void
control System.Windows.Forms.Control
visible bool
Результат void

SetWindowPosition() публичный статический метод

Set the window position
public static SetWindowPosition ( Form form, IntPtr insertAfter, WindowPosition position ) : void
form System.Windows.Forms.Form form to reposition
insertAfter System.IntPtr insert after this window
position WindowPosition new position
Результат void

SetWindowPosition() публичный статический метод

Set the window position
public static SetWindowPosition ( Form form, WindowPosition position ) : void
form System.Windows.Forms.Form form to reposition
position WindowPosition the new position
Результат void

SetWindowPositionAndNotify() публичный статический метод

Set window pos to the specified position and notify when window position has changed
public static SetWindowPositionAndNotify ( Form form, IntPtr insertAfter, WindowPosition position ) : void
form System.Windows.Forms.Form The form
insertAfter System.IntPtr
position WindowPosition Where to set the position
Результат void

SetWindowPositionAndNotify() публичный статический метод

Set window pos to the specified position and notify when window position has changed
public static SetWindowPositionAndNotify ( Form form, WindowPosition position ) : void
form System.Windows.Forms.Form The form
position WindowPosition Where to set the position
Результат void

SetWindowSizePercent() публичный статический метод

Partial maximize. Sets the window width to a percent of the display width.
public static SetWindowSizePercent ( IntPtr handle, WindowPosition scannerPosition, int percent ) : void
handle System.IntPtr handle of the window
scannerPosition WindowPosition which corner should the window be positioned at?
percent int percentage of display monitor width
Результат void

Show() публичный статический метод

Shows the child window, assigns parent as the owner This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static Show ( Form parent, Form child ) : void
parent System.Windows.Forms.Form
child System.Windows.Forms.Form
Результат void

ShowDialog() публичный статический метод

Shows the child window as a dialog of the parent window This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static ShowDialog ( Form parent, Form child ) : void
parent System.Windows.Forms.Form
child System.Windows.Forms.Form
Результат void

ShowForm() публичный статический метод

Shows the specified form This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static ShowForm ( Form form ) : void
form System.Windows.Forms.Form
Результат void

ShowInTaskbar() публичный статический метод

Show or hide the specified form in the Windows taskbar
public static ShowInTaskbar ( Form control, bool show ) : void
control System.Windows.Forms.Form form
show bool set to true to show
Результат void

ShowInactiveTopmost() публичный статический метод

Show the window as topmost without activating it. Sets the form's parent to parentForm
public static ShowInactiveTopmost ( Form parentForm, Form form ) : void
parentForm System.Windows.Forms.Form the parent of the form
form System.Windows.Forms.Form the form
Результат void

ShowTaskbar() публичный статический метод

Show windows taskbar
public static ShowTaskbar ( ) : void
Результат void

ShowWindowBorder() публичный статический метод

If show is set to true, shows the window borders and title
public static ShowWindowBorder ( Form form, bool show, String title = "" ) : void
form System.Windows.Forms.Form the target form
show bool true to show border/title
title String title to set
Результат void

ShowWindowWithoutActivation() публичный статический метод

Shows a window without setting focus to it
public static ShowWindowWithoutActivation ( Form form ) : void
form System.Windows.Forms.Form the window form
Результат void

ShowWithoutActivation() публичный статический метод

Sets the child's owner to parent and shows it without setting focus to it
public static ShowWithoutActivation ( Form parent, Form child ) : void
parent System.Windows.Forms.Form parent form
child System.Windows.Forms.Form child form
Результат void

ToggleFgWindowMaximizeAndPartialMaximize() публичный статический метод

Toggles size of the fg window between maximized to partially maximized
public static ToggleFgWindowMaximizeAndPartialMaximize ( WindowPosition scannerPosition, int percent ) : void
scannerPosition WindowPosition where to position the window
percent int the partial maximize percentage
Результат void

TurnOffDPIAwareness() публичный статический метод

In Win8 and Win10, there are undesirable side-effects where the scanners are scaled imporperly. Turn off DPI awareness to fix this
public static TurnOffDPIAwareness ( ) : void
Результат void

UnselectText() публичный статический метод

Unselect text in textbox
public static UnselectText ( TextBoxBase control ) : void
control System.Windows.Forms.TextBoxBase the text box control
Результат void