2019/07

    GetWindowDC - 현재 Windows화면의 Device Context 구하기

    GetWindowDC는 지정된 Windows화면에 대한 Device Context를 구하는 함수입니다. Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Integer) As Integer - VB.NET 선언 [DllImport("user32")] public static extern int GetWindowDC(int hwnd); - C# 선언 GetWindowDC(handle) - VB.NET 호출 GetWindowDC(handle); - C# 호출 GetWindowDC함수의 인수로는 해당 Device Context를 구할 Windows화면의 Handle을 넘겨주면 됩니다. 이때 만일 현재 화면에 대한 Devic..

    GetDesktopWindow - 현재 Windows 화면의 Handle구하기

    GetDesktopWindow함수는 현재 표시된 Windows화면의 Handle을 반환합니다. Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Integer - VB.NET 선언 [DllImport("user32")] public static extern int GetDesktopWindow(); - C# 선언 GetDesktopWindow() - VB.NET 호출 GetDesktopWindow(); - C# 호출 GetDesktopWindow함수가 성공적으로 실행되면 해당 Handle값을 반환하지만 그렇지 않으면 0을 반환합니다.

    GetDC - Window및 Control의 Device Context 구하기

    GetDC함수는 인수로 전달한 특정 Window나 Control의 Device Context 값을 반환합니다. Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Integer) As Integer - VB.NET 선언 [DllImport("user32")] public static extern int GetDC(int hwnd); - C# 선언 함수의 인수로는 Device Context값을 구할 Window나 Control의 Handle을 지정하면 됩니다. 예를 들어 Program에서 실행할 Form의 Device Context를 구하는 경우라면 다음과 같이 함수를 호출할 수 있습니다. Dim idc As Integer idc = GetD..

    ClipCursor - Mouse의 이동영역 제한

    ClipCursor 함수는 Mouse Cursor를 움직일 수 있는 영역을 제한하는 함수 입니다. Declare Function ClipCursor Lib "user32" Alias "ClipCursor" (ByRef lpRect As Rectangle) As Integer - VB.NET 선언 Dim m_point As Rectangle = New Rectangle(Left, Top, Width, Height) ClipCursor(m_point) - VB.NET 호출 [DllImport("user32.dll")] public static extern int ClipCursor(ref Rectangle lpRect); - C# 선언 Rectangle m_point = new Rectangle(Left, ..

    SwapMouseButton - Mouse 좌우 Button 바꾸기

    SwapMouseButton함수는 Mouse의 좌우 Button을 바꾸어 다른 기능을 수행하도록 하는 함수입니다. Declare Function SwapMouseButton Lib "user32" Alias "SwapMouseButton" (ByVal bSwap As Boolean) As Integer - VB.NET 선언 SwapMouseButton(swap) - VB.NET 호출 [DllImport("user32.dll")] public static extern int SwapMouseButton(bool bSwap); - C# 선언 SwapMouseButton(swap); - C# 호출 swap인수를 true로 하면 좌우 Button을 바꾸고 false로 하면 원래 상태로 되돌립니다. 함수 호출시에..

    SetCaretPos - Caret의 위치 변경

    SetCaretPos함수는 인수로 지정한 위치에 Caret을 표시하도록 합니다. Declare Function SetCaretPos Lib "user32" Alias "SetCaretPos" (ByVal x As Integer, ByVal y As Integer) As Integer - VB.NET 선언 SetCaretPos(x위치, y위치) - VB.NET 호출 [DllImport("user32.dll")] public static extern int SetCaretPos(int x, int y); - C# 선언 SetCaretPos(x위치, y위치); - C# 호출 SetCaretPos함수의 인수로는 Caret을 위치시킬 x값과 y값을 정수형태로 전달합니다.

    GetClientRect - Window나 Control의 좌표값 얻기

    Declare Function GetClientRect Lib "user32" Alias "GetClientRect" (ByVal hwnd As Integer, ByRef lpRect As RECT) As Integer - VB.NET 선언 [DllImport("user32")] public static extern int GetClientRect(int hwnd, ref RECT lpRect); - C# 선언 GetClientRect함수의 첫번째 인수는 좌표를 구하고자할 Window나 Control의 Handle을 넘기고 두번째 인수에는 해당 좌표값을 담아둘 구조체를 기술합니다. 만일 현재 실행중인 Form의 위치및 좌표를 구하고자 한다면 GetClientRect함수는 다음과 같이 선언될 수 있습니다...

    keybd_event - Keyboard또는 Mouse입력함수

    keybd_event 함수는 실제 Keyboard의 특정 Key나 Mouse의 Button을 누른 것과 같은 효과를 발생시킵니다. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer) - VB.NET 선언 Private Const VK_CAPITAL = &H14 keybd_event(VK_CAPITAL, 0, 0, 0) - VB.NET 호출 [DllImport("user32.dll")] public static extern bool keybd_event(byte bVk, byte bScan, int dwFl..