클리엘
CLIEL LAB
클리엘
전체 방문자
오늘
어제
  • 분류 전체보기 (513)
    • Mobile (47)
      • Kotlin (47)
    • Web (84)
      • NestJS (9)
      • HTML5 & CSS3 (38)
      • Javascript (20)
      • TypeScript (6)
      • JQuery (11)
    • .NET (300)
      • C# (83)
      • 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)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

  • 블로그 정리

인기 글

태그

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

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
클리엘

CLIEL LAB

.NET/Windows API for .NET

GetWindowRect - Window의 위치및 크기 반환

2019. 7. 31. 16:33
728x90

GetWindowRect함수는 화면상의 특정 Window에 대한 위치및 크기를 반환하는 함수입니다.

Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Integer, ByRef lpRect As RECT) As Integer

- VB.NET 선언

[DllImport("user32")]
public static extern int GetWindowRect(int hwnd, ref RECT lpRect);

- C# 선언

 

선언 GetWindowRect함수의 첫번째 인수는 위치및 크기를 얻고자 하는 Window의 Handle을 지정하고 두번째 인수에 실제 위치와 크기에 대한 값이 저장될 구조체를 지정합니다.

여기서 사용되는 구조체는 다음과 같이 선언됩니다.

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

- VB.NET

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

- C#

 

만일 실행중인 현재 Form에 대한 위치및 크기값을 가져오려면 GetWindowRect함수를 다음과 같이 선언합니다.

Dim stRect As RECT
GetWindowRect(Me.Handle, stRect)

- VB.NET 호출

RECT stRect = default(RECT);
GetWindowRect((int)this.Handle, ref stRect);

- C# 호출

728x90
저작자표시 비영리 변경금지

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

PaintDesktop - 배경화면 맞추기  (0) 2019.07.31
GetBinaryType - 실행 File 유형 확인  (0) 2019.07.31
DrawText - 화면에 Text문자열 출력  (0) 2019.07.31
DestroyCursor - Cursor의 제거  (0) 2019.07.31
DrawFrameControl - Frame Control 그리기  (0) 2019.07.31
    '.NET/Windows API for .NET' 카테고리의 다른 글
    • PaintDesktop - 배경화면 맞추기
    • GetBinaryType - 실행 File 유형 확인
    • DrawText - 화면에 Text문자열 출력
    • DestroyCursor - Cursor의 제거
    클리엘
    클리엘
    누구냐 넌?

    티스토리툴바