블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-19 21:33

'GetWindowRect'에 해당되는 글 2건

  1. 2012.06.01 GetWindowRect - Window의 위치및 크기 반환
  2. 2010.08.31 getClienteRect 와 getWindowRect

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# 호출



출처 :  http://lab.cliel.com/m/post/view/id/39

반응형
Posted by blueasa
, |

getWindowRect 은 윈도우 전체 화면에 대한 좌표를 말하며

getClientRect 는 각 핸들에 대한 좌표를 말한다.

 

getWindowRect 사용시

 

cRect.left  화면 좌측에서 핸들 좌측까지의 거리

cRect.right 화면 좌측에서 핸들 우측까지의 거리

cRect.top  화면 위쪽에서 핸들 위쪽까지의 거리

cRect.bottom 화면 위쪽에서 핸들 아래쪽까지의 거리

 

즉. 기준은 화면의 좌측과 위쪽이며, 그 기준에서 핸들의 각 위치까지의 거리를 말한다.

따라서 핸들의 가로 길이는 right - left, 세로 길이는 bottom - top 하면 구할 수 있다.

 

getClientRect 사용시

 

cRect.left  핸들 좌측에서 핸들 좌측까지의 거리

cRect.right 핸들 좌측에서 핸들 우측까지의 거리

cRect.top  핸들 위쪽에서 핸들 위쪽까지의 거리

cRect.bottom 핸들 위쪽에서 핸들 아래쪽까지의 거리

 

기본 개념은 getWindowRect와 같다. 다만 기준 위치가 다를 뿐이다.

기준위치가 핸들의 좌측과 위쪽이므로

cRect.left 와 cRect.top은 항상 0이 된다.

cRect.right 는 핸들의 가로 길이 cRect.bottom은 핸들의 세로 길이가 된다.


출처 : http://maximaro.blog.me/50047243920

반응형

'Programming > Win32API' 카테고리의 다른 글

IME 영문만 입력가능하게 하기  (0) 2010.09.03
IME  (0) 2010.09.02
mfc, api 의 HINSTANCE 구하기 GetModuleHandle(NULL)  (0) 2010.06.03
Virtual Keys, Standard Set  (0) 2010.04.21
Drag & Drop 예제 소스  (0) 2010.04.20
Posted by blueasa
, |