클리엘
CLIEL LAB
클리엘
전체 방문자
오늘
어제
  • 분류 전체보기 (514) N
    • Mobile (47)
      • Kotlin (47)
    • Web (84)
      • NestJS (9)
      • HTML5 & CSS3 (38)
      • Javascript (20)
      • TypeScript (6)
      • JQuery (11)
    • .NET (301) N
      • C# (84) N
      • ASP.NET (67)
      • Windows API for .NET (128)
    • Server (53)
      • SQL Server (10)
      • MariaDB (18)
      • Windows Server (6)
      • node.js (19)
    • System (12)
      • 작업LOG (12)
    • Review (11)
    • ETC (6)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

  • 블로그 정리

인기 글

태그

  • CSS3
  • asp.net core
  • MariaDB
  • jQuery
  • exception
  • NestJS
  • ASP.NET
  • c#
  • JavaScript
  • Windows API
  • LINQ
  • Entity Framework
  • Kotlin
  • asp.net core web api
  • 변수
  • android studio
  • android
  • .NET
  • HTML5
  • node.js

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
클리엘

CLIEL LAB

.NET/Windows API for .NET

GetClientRect - Window나 Control의 좌표값 얻기

2019. 7. 31. 14:07
728x90
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함수는 다음과 같이 선언될 수 있습니다.

Public Structure RECT
        Public left As Integer
        Public top As Integer
        Public right As Integer
        Public bottom As Integer
End Structure

Dim norRECT As RECT
GetClientRect(Me.Handle, norRECT)

- VB.NET 호출

public struct RECT
{
            public int left;
            public int top;
            public int right;
            public int bottom;
}

RECT norRECT = default(RECT);
GetClientRect((int)button1.Handle, ref norRECT);

- C# 호출

 

GetClientRect함수가 성공적으로 수행되면 해당 구조체의 left, top에 x, y에 해당하는 위치값이 그리고 right, bottom에는 left와 top으로 부터의 크기값이 저장됩니다.

GetClientRect함수는 정상적으로 실행되지 못한 경우 0을 반환합니다.

728x90
저작자표시 비영리 변경금지 (새창열림)

'.NET > Windows API for .NET' 카테고리의 다른 글

SwapMouseButton - Mouse 좌우 Button 바꾸기  (0) 2019.07.31
SetCaretPos - Caret의 위치 변경  (0) 2019.07.31
keybd_event - Keyboard또는 Mouse입력함수  (0) 2019.07.31
EnableWindow - Program(Window)및 특정 Control사용가능여부설정  (0) 2019.07.31
LoadCursorFromFile - 새로운 Mouse Cursor의 Load  (0) 2019.07.31
    '.NET/Windows API for .NET' 카테고리의 다른 글
    • SwapMouseButton - Mouse 좌우 Button 바꾸기
    • SetCaretPos - Caret의 위치 변경
    • keybd_event - Keyboard또는 Mouse입력함수
    • EnableWindow - Program(Window)및 특정 Control사용가능여부설정
    클리엘
    클리엘
    누구냐 넌?

    티스토리툴바