分类:.NET技术2011-08-18 08:58 1727人阅读评论(1) 收藏举报
[csharp]view plaincopy
1.[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
2.publicstaticexternint GetWindowLong(IntPtr hwnd, int nIndex);
3. [DllImport("user32.dll", EntryPoint = "SetWindowLong")]
4.publicstaticexternint SetWindowLong(IntPtr hMenu, int nIndex, int dwNewLong);
5. [DllImport("user32.dll")]
6.privatestaticexternint SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
[csharp]view plaincopy
1.privatevoid DisableMaxmizebox(bool isDisable)
2. {
3.int GWL_STYLE = -16;
4.int WS_MAXIMIZEBOX = 0x00010000;
5.int WS_MINIMIZEBOX = 0x00020000;
6.int SWP_NOSIZE = 0x0001;
7.int SWP_NOMOVE = 0x0002;
8.int SWP_FRAMECHANGED = 0x0020;
9. IntPtr handle = new WindowInteropHelper(this).Handle;
10.int nStyle = GetWindowLong(handle, GWL_STYLE);
11.if (isDisable)
12. {
13. nStyle &= ~(WS_MAXIMIZEBOX);
14. nStyle &= ~(WS_MINIMIZEBOX);
15. }
16.else
17. {
18. nStyle |= WS_MAXIMIZEBOX;
19. nStyle |= WS_MINIMIZEBOX;
20. }
21. SetWindowLong(handle, GWL_STYLE, nStyle);
22. SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED);
23. }
24.
25.privatevoid Window_Loaded(object sender, RoutedEventArgs e)
26. {
27. DisableMaxmizebox(true);
28. }
转载于:https://blog.51cto.com/3446502/1228115