2010-05-24 4 views
1

WPF를 사용하여 양식 주위에 얇은 테두리가있는 창을 만들고 싶습니다. 즉, 아이콘/캡션 및 최소/최대/닫기 버튼이있는 제목 표시 줄의 공간이 없습니다. 예를 들어, "추가"아이콘이 새로운 Windows 7 작업 표시 줄의 형성 : WPF 창에서가는 경계선?

Example Image http://img576.imageshack.us/img576/6196/border.png

내가이 그러나 나는 또한 것을 요구하는 DwmExtendFrameIntoClientArea API를 사용하고있는 WindowStyle = None 속성을 설정하여 수행 할 수 있습니다 이해 Background 속성은 투명해야합니다. 이렇게하면 창이나 테두리가 그려지지 않으며 양식의 불투명 컨트롤 만 그려집니다.

폼의 본체에 에어로 글래스 효과를 유지하면서 어떻게 얇은 테두리를 만들 수 있습니까?

답변

2

WindowStyle="None"을 창에 사용하십시오. See MSDN for details.

<Window x:Class="WpfApplication1.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MainWindow" Height="100" Width="100" WindowStyle="None"> 
    Hello World 
</Window> 
+0

당신은 또한 두께를 설정 요소를 추가 할 수 있습니다 –

+0

'DwmExtendFrameIntoClientArea' API를 사용하여 전체 양식에 Aero Glass 배경을 사용하고 있습니다. 'WindowStyle = "None"을 설정하면 양식의 불투명 한 부분 만 그려지며 테두리는 표시되지 않습니다. – Rezzie

+0

'WindowStyle = "None"'은 스크린 샷처럼 윈도우 주위에 경계를 그립니다. – bitbonk

1

은 당신이 뒤에서 코드에서 다음 다음 ResizeMode=CanResize을 설정 할 수와 필요가 무엇 :

protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr LParam, ref bool handled) 
{ 
    switch (msg) 
    { 
     case WM_NCHITTEST: 
        //if the mouse pointer is not over the client area of the tab 
        //ignore it - this disables resize on the glass chrome 
        //a value of 1 is the HTCLIENT enum value for the Client Area 
        if (DefWindowProc(hwnd, WM_NCHITTEST, wParam, LParam).ToInt32() == 1) 
        { 
         handled = true; 
        } 
        break; 
    } 
} 

[DllImport("user32.dll")] 
     public static extern IntPtr DefWindowProc(IntPtr hWnd, int uMsg, IntPtr wParam, 
      IntPtr lParam); 
관련 문제