C# Class 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
Afficher le fichier Open project: brlima94/acat-localization Class Usage Examples

Méthodes publiques

Méthode Description
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

Private Methods

Méthode Description
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

Method Details

Activate() public static méthode

Activates the specified form
public static Activate ( Form form ) : void
form System.Windows.Forms.Form form to activate
Résultat void

ActivateForm() public static méthode

Activates the specified form
public static ActivateForm ( Form form ) : void
form System.Windows.Forms.Form form to activate
Résultat void

ActivateWindow() public static méthode

Shows the specified window and brings it to top
public static ActivateWindow ( IntPtr handle ) : bool
handle System.IntPtr window handle
Résultat bool

ClickOnWindow() public static méthode

Simulates a mouse click on the specified control
public static ClickOnWindow ( Control control ) : void
control System.Windows.Forms.Control the control
Résultat void

CloseAsync() public static méthode

Closes the form asynchronously in a different thread
public static CloseAsync ( Form form ) : void
form System.Windows.Forms.Form form to close
Résultat void

CloseForm() public static méthode

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
Résultat void

DockWithScanner() public static méthode

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
Résultat void

FadeIn() public static méthode

Fades in the specified form
public static FadeIn ( Form form ) : void
form System.Windows.Forms.Form form to fade in
Résultat void

FadeOut() public static méthode

Gradually fades out the form
public static FadeOut ( Form form ) : void
form System.Windows.Forms.Form form to fade out
Résultat void

FindControlAtCursor() public static méthode

Finds the control under the cursor
public static FindControlAtCursor ( Form form ) : Control
form System.Windows.Forms.Form form under the cursor
Résultat System.Windows.Forms.Control

FindControlAtPoint() public static méthode

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
Résultat System.Windows.Forms.Control

GetCaretPosition() public static méthode

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
Résultat int

GetForegroundWindow() public static méthode

Returns the currently active fg window
public static GetForegroundWindow ( ) : IntPtr
Résultat System.IntPtr

GetOSVersion() public static méthode

Returns the OS version
public static GetOSVersion ( ) : WindowsVersion
Résultat WindowsVersion

GetOpacity() public static méthode

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
Résultat double

GetScannerPosition() public static méthode

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
Résultat WindowPosition

GetSelectedText() public static méthode

Returns selected text in the text box
public static GetSelectedText ( TextBoxBase control ) : String
control System.Windows.Forms.TextBoxBase text box
Résultat String

GetText() public static méthode

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
Résultat String

GetText() public static méthode

Gets text from the speficied window
public static GetText ( IntPtr hWnd ) : string
hWnd System.IntPtr window handle
Résultat string

GetTrackBarValueInt() public static méthode

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
Résultat int

GetVisible() public static méthode

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
Résultat bool

GetWindowTitle() public static méthode

Returns the window title of the specified window
public static GetWindowTitle ( IntPtr hwnd ) : String
hwnd System.IntPtr handle to the window
Résultat String

HideTaskbar() public static méthode

Hide windows taskbar
public static HideTaskbar ( ) : void
Résultat void

IsDesktopWindow() public static méthode

returns if the specified handle is the desktop window
public static IsDesktopWindow ( IntPtr handle ) : bool
handle System.IntPtr
Résultat bool

IsMaximized() public static méthode

Checks if window is maximized or not
public static IsMaximized ( IntPtr handle ) : bool
handle System.IntPtr window handle
Résultat bool

IsMinimized() public static méthode

Checks if window is minimzied or not
public static IsMinimized ( IntPtr handle ) : bool
handle System.IntPtr window handle
Résultat bool

IsObscuredByNonACATWindows() public static méthode

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
Résultat bool

IsObscuredWindow() public static méthode

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
Résultat bool

MaximizeWindow() public static méthode

Maximizes the window
public static MaximizeWindow ( IntPtr handle ) : void
handle System.IntPtr window handle
Résultat void

MinimizeWindow() public static méthode

Minimizes a window
public static MinimizeWindow ( IntPtr handle ) : void
handle System.IntPtr window handle
Résultat void

PostMessage() public static méthode

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
Résultat bool

RestoreWindow() public static méthode

Restores the window from the maximized position
public static RestoreWindow ( IntPtr handle ) : void
handle System.IntPtr window handle
Résultat void

SendMessage() public static méthode

Windows SendMessage()
public static SendMessage ( IntPtr hWnd, int Msg, int wparam, int lparam ) : IntPtr
hWnd System.IntPtr
Msg int
wparam int
lparam int
Résultat System.IntPtr

SetActiveWindow() public static méthode

Sets the window as the active window
public static SetActiveWindow ( IntPtr hwnd ) : void
hwnd System.IntPtr window handle
Résultat void

SetBackgroundColor() public static méthode

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
Résultat void

SetCaretPosition() public static méthode

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
Résultat void

SetFocus() public static méthode

Sets focus to the control
public static SetFocus ( Control control ) : bool
control System.Windows.Forms.Control control to set focus to
Résultat bool

SetFocusToDesktop() public static méthode

Sets current focus to the desktop window
public static SetFocusToDesktop ( ) : void
Résultat void

SetForegroundColor() public static méthode

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
Résultat void

SetForegroundWindow() public static méthode

Sets the fg window to the specified window
public static SetForegroundWindow ( IntPtr hwnd ) : bool
hwnd System.IntPtr window handle
Résultat bool

SetForegroundWindowSizePercent() public static méthode

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
Résultat void

SetFormStyles() public static méthode

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
Résultat System.Windows.Forms.CreateParams

SetImage() public static méthode

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
Résultat void

SetOpacity() public static méthode

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
Résultat void

SetRegion() public static méthode

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
Résultat void

SetText() public static méthode

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
Résultat void

SetTopMost() public static méthode

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
Résultat void

SetTrackBarValue() public static méthode

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
Résultat void

SetVisible() public static méthode

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
Résultat void

SetWindowPosition() public static méthode

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
Résultat void

SetWindowPosition() public static méthode

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
Résultat void

SetWindowPositionAndNotify() public static méthode

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
Résultat void

SetWindowPositionAndNotify() public static méthode

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
Résultat void

SetWindowSizePercent() public static méthode

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
Résultat void

Show() public static méthode

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
Résultat void

ShowDialog() public static méthode

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
Résultat void

ShowForm() public static méthode

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
Résultat void

ShowInTaskbar() public static méthode

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
Résultat void

ShowInactiveTopmost() public static méthode

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
Résultat void

ShowTaskbar() public static méthode

Show windows taskbar
public static ShowTaskbar ( ) : void
Résultat void

ShowWindowBorder() public static méthode

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
Résultat void

ShowWindowWithoutActivation() public static méthode

Shows a window without setting focus to it
public static ShowWindowWithoutActivation ( Form form ) : void
form System.Windows.Forms.Form the window form
Résultat void

ShowWithoutActivation() public static méthode

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
Résultat void

ToggleFgWindowMaximizeAndPartialMaximize() public static méthode

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
Résultat void

TurnOffDPIAwareness() public static méthode

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
Résultat void

UnselectText() public static méthode

Unselect text in textbox
public static UnselectText ( TextBoxBase control ) : void
control System.Windows.Forms.TextBoxBase the text box control
Résultat void