특히 버튼을 제거하는 것뿐만 아니라 최대화를 완전히 비활성화하는 것입니다. 이것은 제목 표시 줄을 두 번 클릭하거나 제목 표시 줄을 Windows 7의 화면 맨 위로 끌어 오면 작동하지 않는다는 것을 의미합니다. 나는 여전히 창을 꽤 큰 크기로 만들고 싶다.WPF에서 창 최대화를 방지 할 수 있습니까?
답변
CanMinimize 필드를 살펴보십시오.
그건 내가 원하는 것을하지 않습니다. 최대화를 비활성화하고 크기를 조정할 수 있습니다. CanMinimize는 크기 조정을 방지합니다. –
... 사람들의 철자가 틀리지 않을 때 바꾸는 것은 무례합니다. 우리는 당신이 알고있는 모든 미국인이 아닙니다;) –
미안 합니다만, 가치가있는 "Maximize"는 MSDN 문서와 일치합니다 :) –
시스템 메뉴에서 최대화를 제거하면 충분합니다. Win7 "도킹"을 위해 작동하는지 모르겠다면 알려주십시오. http://www.codeguru.com/csharp/csharp/cs_misc/userinterface/article.php/c9327/
그것은하지만 당신은 창 핸들을하기 만하기 때문에, 윈폼을 가정
다음은 윈도우의 시스템 메뉴를 수정하기위한 헬퍼 클래스와 기사입니다. WPF에서는 WindowInteropHelper를 사용하여이 작업을 수행 할 수 있습니다.
업데이트 된이 코드는 불가지론 UI 프레임 워크
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
[Flags]
public enum SystemMenuFlags
{
Unchecked = 0x0000,
String = 0x0000,
Disabled = 0x0002,
Grayed = 0x0001,
Checked = 0x0008,
Popup = 0x0010,
BarBreak = 0x0020,
Break = 0x0040,
ByPosition = 0x0400,
ByCommand = 0x0000,
Separator = 0x0800,
}
public enum SystemMenuCommand
{
Size = 0xF000,
Move = 0xF010,
Minimize = 0xF020,
Maximize = 0xF030,
Close = 0xF060,
Restore = 0xF120,
}
public class SystemMenu
{
private IntPtr _menuHandle = IntPtr.Zero;
public IntPtr MenuHandle { get { return _menuHandle; } }
private readonly IntPtr _windowHandle;
public IntPtr WindowHandle { get { return _windowHandle; } }
public SystemMenu(IntPtr windowHandle)
{
if (windowHandle == IntPtr.Zero)
throw new InvalidOperationException("The handle must point to a real window. Create only after your window object has created a real window.");
_windowHandle = windowHandle;
IntPtr menuHandle = GetSystemMenu(windowHandle, 0);
if (menuHandle == IntPtr.Zero)
throw new InvalidOperationException("The specified window does not have a system menu.");
_menuHandle = menuHandle;
}
private SystemMenu(IntPtr windowHandle, IntPtr menuHandle)
{
_windowHandle = windowHandle;
_menuHandle = menuHandle;
}
public static SystemMenu FromHandle(IntPtr windowHandle)
{
if (windowHandle == IntPtr.Zero)
throw new InvalidOperationException("The handle must point to a real window. Call FromHandle only after your window object has created a real window.");
IntPtr menuHandle = GetSystemMenu(windowHandle, 0);
if (menuHandle == IntPtr.Zero)
return null;
return new SystemMenu(windowHandle, menuHandle);
}
public int Count
{
get
{
int count = GetMenuItemCount(MenuHandle);
if (count < 0)
throw new Win32Exception(Marshal.GetLastWin32Error());
return count;
}
}
private int GetItemPosition(SystemMenuCommand command)
{
int count = Count;
for (int position = 0; position < count; position++)
{
int id = GetMenuItemID(MenuHandle, position);
if ((SystemMenuCommand)id == command)
return position;
}
return -1;
}
public void InsertItem(int position, int id, string text)
{
if (String.IsNullOrEmpty(text))
throw new ArgumentNullException("text");
if (!IsValidMenuIdValue(id))
throw new ArgumentOutOfRangeException("id", "Valid range for menu id is [0 .. 0xF000]");
if (InsertMenu(MenuHandle, position, (Int32)(SystemMenuFlags.ByPosition | SystemMenuFlags.String), id, text) == 0)
throw new Win32Exception(Marshal.GetLastWin32Error());
}
public void InsertSeparator(int position)
{
if (InsertMenu(MenuHandle, position, (Int32)(SystemMenuFlags.ByPosition | SystemMenuFlags.Separator), 0, String.Empty) == 0)
throw new Win32Exception(Marshal.GetLastWin32Error());
}
public void InsertItemBefore(SystemMenuCommand command, int id, string text)
{
if (String.IsNullOrEmpty(text))
throw new ArgumentNullException("text");
if (!IsValidMenuIdValue(id))
throw new ArgumentOutOfRangeException("id", "Valid range for menu id is [0 .. 0xF000]");
if (InsertMenu(MenuHandle, (int)command, (Int32)(SystemMenuFlags.ByCommand | SystemMenuFlags.String), id, text) == 0)
throw new Win32Exception(Marshal.GetLastWin32Error());
}
public void InsertSeparatorBefore(SystemMenuCommand command)
{
if (InsertMenu(MenuHandle, (int)command, (Int32)(SystemMenuFlags.ByCommand | SystemMenuFlags.Separator), 0, String.Empty) == 0)
throw new Win32Exception(Marshal.GetLastWin32Error());
}
public void InsertItemAfter(SystemMenuCommand command, int id, string text)
{
if (String.IsNullOrEmpty(text))
throw new ArgumentNullException("text");
if (!IsValidMenuIdValue(id))
throw new ArgumentOutOfRangeException("id", "Valid range for menu id is [0 .. 0xF000]");
int position = GetItemPosition(command);
InsertItem(position + 1, id, text);
}
public void InsertSeparatorAfter(SystemMenuCommand command)
{
int position = GetItemPosition(command);
InsertSeparator(position + 1);
}
public void AppendSeparator()
{
if (AppendMenu(MenuHandle, (int)SystemMenuFlags.Separator, 0, String.Empty) == 0)
throw new Win32Exception(Marshal.GetLastWin32Error());
}
public void AppendItem(int id, string text)
{
if (String.IsNullOrEmpty(text))
throw new ArgumentNullException("text");
if (!IsValidMenuIdValue(id))
throw new ArgumentOutOfRangeException("id", "Valid range for menu id is [0 .. 0xF000]");
if (AppendMenu(MenuHandle, (int)SystemMenuFlags.String, id, text) == 0)
throw new Win32Exception(Marshal.GetLastWin32Error());
}
public void RemoveItem(int position)
{
if (RemoveMenu(MenuHandle, position, (int)SystemMenuFlags.ByPosition) == 0)
throw new Win32Exception(Marshal.GetLastWin32Error());
}
public void RemoveItem(SystemMenuCommand command)
{
if (RemoveMenu(MenuHandle, (int)command, (int)SystemMenuFlags.ByCommand) == 0)
throw new Win32Exception(Marshal.GetLastWin32Error());
}
public void Reset()
{
GetSystemMenu(WindowHandle, 1);
_menuHandle = GetSystemMenu(WindowHandle, 0);
}
public static bool IsValidMenuIdValue(int id)
{
return id > 0 && id < 0xF000;
}
#region p/Invoke
[DllImport("User32")]
extern static IntPtr GetSystemMenu(IntPtr hWnd, int bRevert);
[DllImport("User32", CharSet = CharSet.Auto, SetLastError = true)]
extern static int AppendMenu(IntPtr hMenu, int uFlags, int uIDNewItem, string lpNewItem);
[DllImport("User32", CharSet = CharSet.Auto, SetLastError = true)]
extern static int InsertMenu(IntPtr hMenu, int uPosition, int uFlags, int uIDNewItem, string lpNewItem);
[DllImport("User32", SetLastError = true)]
extern static int RemoveMenu(IntPtr hMenu, int uPosition, int uFlags);
[DllImport("User32", SetLastError = true)]
extern static int GetMenuItemCount(IntPtr hMenu);
[DllImport("User32")]
extern static int GetMenuItemID(IntPtr hMenu, int nPos);
#endregion
}
- 1. WPF에서 "도우미"창 만들기
- 2. PDO에서 긴 쿼리를 방지 할 수 있습니까?
- 3. Access에서 레코드 삭제를 방지 할 수 있습니까?
- 4. WPF에서 필렛 커브를 수행 할 수 있습니까?
- 5. WPF에서 글꼴 크기를 구성 할 수 있습니까?
- 6. WPF에서 스타일을 동적으로 전환 할 수 있습니까?
- 7. WPF에서 ToolBar.Header를 어떻게 사라지게 할 수 있습니까?
- 8. WPF에서 동적으로 행을 추가 할 수 있습니까?
- 9. WPF에서 컨트롤을 "클릭"할 수 있습니까?
- 10. WM_SysCommand 델파이의 창 이동 방지
- 11. 브라우저에서 창 팝업 경고 방지
- 12. WPF에서 Window의 너비를 어떻게 애니메이트 할 수 있습니까?
- 13. WPF에서 특정 시간의 팝업 창?
- 14. 호출 할 때 가비지 수집을 방지 할 수 있습니까?
- 15. WPF 창 최소화 방지 (Winkey + D, 대부분)
- 16. Vim에서 pythoncomplete를 사용할 때 분할 창 방지
- 17. WPF에서 창 경계 외부로 확장되는 격자를 가로 지르는 패닝 창
- 18. WPF에서 항상 맨 위의 동작이없는 창 소유자
- 19. 창 크기가 변경되면 WPF에서 메서드가 호출됩니까?
- 20. WPF에서 페이지에 창 모달을 만드는 방법은 무엇입니까?
- 21. CheckBoxList 컨트롤의 오버플로를 방지 할 수 없습니다.
- 22. Google App Engine에서 DoSing을 방지 할 수 있습니까?
- 23. md5를 사용하여 중복되는 콘텐츠를 방지 할 수 있습니까?
- 24. 브라우저에서 iPhone/iPad 방향이 변경되는 것을 방지 할 수 있습니까?
- 25. 인터넷상의 .net 코드 실행을 어떻게 제한/방지 할 수 있습니까?
- 26. SQL 데이터베이스 수준에서 일괄 업데이트를 방지 할 수 있습니까?
- 27. jQuery UI 탭 고정, 어떻게 방지 할 수 있습니까?
- 28. 종속성 삽입으로 순환 종속성을 방지 할 수 있습니까?
- 29. websphere 6의 보안 취약점을 어떻게 방지 할 수 있습니까?
- 30. EDMX를 저장할 때 T4 파일의 재생성을 방지 할 수 있습니까?
그래서 그것의 크기를 조정할 수있다? 그게 내가 수동으로 그것을 화면의 전체 크기로 끌고, 기본적으로 최대화 할 수 있다는 뜻이 아니겠습니까? 창을 최대화 할 수없는 이유는 무엇입니까? 귀하의 창문에 대해 무엇이 중요합니까? 전체 화면으로 늘릴 수는 있지만 단순히 버튼을 사용하지 않고 언제나 똑같이 사용했습니다. –
왜 사람들은 StackOverflow에서이 작업을 일관되게합니까? 질문에 답하기보다는 질문이 왜 필요한지 질문하기 시작합니다. 이것은 도움이되지 않습니다. 소프트웨어의 요구 사항으로 받아 들여 방법을 알고 있거나 혼자있는 경우 대답하십시오. 이 경우 고객은 수천 유로를 지불하기를 원하기 때문입니다. –