GetWindowRect - Window의 위치및 크기 반환
Programming/C# / 2012. 6. 1. 01:37
GetWindowRect함수는 화면상의 특정 Window에 대한 위치및 크기를 반환하는 함수입니다.
| Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Integer, ByRef lpRect As RECT) As Integer |
| [DllImport("user32")] public static extern int GetWindowRect(int hwnd, ref RECT lpRect); |
선언 GetWindowRect함수의 첫번째 인수는 위치및 크기를 얻고자 하는 Window의 Handle을 지정하고 두번째 인수에 실제 위치와 크기에 대한 값이 저장될 구조체를 지정합니다.
여기서 사용되는 구조체는 다음과 같이 선언됩니다.
| Public Structure RECT Public left As Integer Public top As Integer Public right As Integer Public bottom As Integer End Structure |
| public struct RECT { public int left; public int top; public int right; public int bottom; } |
만일 실행중인 현재 Form에 대한 위치및 크기값을 가져오려면 GetWindowRect함수를 다음과 같이 선언합니다.
Dim stRect As RECT |
RECT stRect = default(RECT); |
출처 : http://lab.cliel.com/m/post/view/id/39
반응형
'Programming > C#' 카테고리의 다른 글
| 윈폼기반 프로그래밍을 할때 Invoke() 이쁘게쓰기! (0) | 2012.06.10 |
|---|---|
| Invoke , BeginInvoke, MethodInvoker (0) | 2012.06.10 |
| 파일경로 지정 및 디렉토리 지정 FolderBrowserDialog (0) | 2012.05.25 |
| 좌표에서 RGB값 받아오기 (0) | 2012.05.24 |
| how to get the RGB value of a pixel inside the Form workspace (0) | 2012.05.24 |

