이 글은 진모씨(필자)가 여러 자료들을 재구성하여 직접 작성한 글로 주소는 아래와 같습니다.
인용 글들
http://msdn.microsoft.com/ko-kr/magazine/cc163435.aspx
http://msdn.microsoft.com/ko-kr/library/aa969512(en-us,VS.85).aspx
http://msdn.microsoft.com/ko-kr/library/bb773244(en-us,VS.85).aspx
DwmExtendFrameIntoClientArea는 Vista에서 새롭게 지원하기 시작한 DWM의 새로운 API입니다.
DWM에 관한 정의는 아래와 같습니다.
Extends the window frame behind the client area.
윈도우 창틀을 클라이언트 창 뒷쪽까지 확장한다.
DWM은 Aero 기능이 활성화되어있지 않으면 사용이 불가능하므로 아래의 API를 먼저 사용해야 합니다.
DwmIsCompositionEnabled()
이 함수 외 다른 API를 선언하기 위해서는 dwmapi.h가 필요합니다.
이 헤더는 C#, C++에서만 이용할 수 있으므로 VB에서는 따로 선언해야 합니다.
각각 언어에 필요한 선언문은 아래와 같습니다.
C#, C#.NET,C++
VB6
Private Declare Function DwmExtendFrameIntoClientArea Lib "dwmapi.dll" (ByVal hWnd As Long, margin As MARGINS) As Long
VB.NET
<DllImport("dwmapi.dll")> _
Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarInset As Margin) As Integer
End Function
이 함수는 창의 핸들, 즉 hWnd라는 값을 사용합니다. 그리고, MARGINS라는 변수가 있습니다.
그러나 이 API를 사용하기 위해서는 하나의 Type0이 더 필요합니다. 그 타입의 이름은 MARGINS인데요, 이에 관한 설명은 http://msdn.microsoft.com/ko-kr/library/bb773244(en-us,VS.85).aspx의 Margin Structure이라는 글에 잘 나와있습니다.
MARGINS의 정의는 아래와 같습니다.
Returned by the GetThemeMargins function to define the margins of windows that have visual styles applied.
GetThemeMargins 함수의 반환값으로 사용되며, 시각 효과가 적용될 창의 테두리 크기를 나타낸다.
GetThemeMargins에 대해서는 다음 글에 소개해드립니다.
MARGIN의 구조는 아래와 같습니다.
MARGINS는 uxtheme.h 파일에 들어있으며, Windows XP부터 사용 가능한 설정입니다.
MARGINS를 선언하기 위해서는 아래의 코드를 사용해야 합니다.
C#
[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int cxLeftWidth; // width of left border that retains its size
public int cxRightWidth; // width of right border that retains its size public int cyTopHeight; // height of top border that retains its size
public int cyBottomHeight; // height of bottom border that retains its size
};
VB6:
Type MARGINS
cxLeftWidth As Long
cxRightWidth As Long
cyTopHeight As Long
cyBottomHeight As Long
End Type
C# 2008
//http://blog.naver.com/kanghuny222?Redirect=Log&logNo=70074822100
struct Margins
{
public Margins(Thickness t)
{
Left = (int)t.Left;
Right = (int)t.Right;
Top = (int)t.Top;
Bottom = (int)t.Bottom;
}
public int Left;
public int Right;
public int Top;
public int Bottom;
}
이제 MARGINS라는 변수를 선언한 뒤 API를 사용하기 위해서는 창의 배경색을 바꿔주야 합니다.
흰 색과 몇몇의 밝은 색들은 작동을 안했는데, 그 색의 목록은 직접 테스트해봐야 될 듯 합니다.
그러나 분명한 점은, 창의 색조가 배경색과 같다는 점이었습니다.
C#에서 이 API를 사용하는 방법은 아래와 같습니다.
HRESULT ExtendIntoClientBottom(HWND hwnd)
{
//Set margins, extend bottom
MARGINS margins = {왼쪽 테두리,오른쪽 테두리,위쪽 테두리,아래쪽 테두리};
HRESULT hr = S_OK;//extend frame on bottom of client area
hr = DwmExtendFrameIntoClientArea(hwnd,&margins);
if (SUCCEEDED(hr))
{
//do more things
}
return hr;
}
VB6:
'http://cafe.naver.com/myvb/25119
Private Sub Form_Load()
Dim Margin As MARGINS
Margin.cxLeftWidth = 왼쪽 테두리
Margin.cxRightWidth = 오른쪽 테두리
Margin.cyTopHeight = 위쪽 테두리
Margin.cyBottomHeight = 아래쪽 테두리
DwmExtendFrameIntoClientArea Me.hWnd, Margin
End Sub
C# NET
아 VB.NET은... C#변환해서 써야하는건가요.. 오류날텐데
답글삭제@PiPS - 2009/12/27 13:03
답글삭제휴... 그래도 거의 같습니다. VB6하고요.
API로 따지자면 별로 차이가 안나니까... hWnd 등은 빼고 말이죠.
@진모씨 - 2009/12/29 14:52
답글삭제음 VB6를 VB.NET으로 코딩하다가 hDC 는 도움말 봐도 안나와 있더군요
포기.