개정판 d2b05ce7
issue #763 Maximized 상태일 때 작업표시줄이 안보이는 현상
KCOM/MainWindow.xaml.cs | ||
---|---|---|
18 | 18 |
using System.Windows.Shapes; |
19 | 19 |
using System.Xml; |
20 | 20 |
using Telerik.Windows.Controls; |
21 |
using WinInterop = System.Windows.Interop; |
|
21 | 22 |
|
22 | 23 |
namespace KCOM |
23 | 24 |
{ |
... | ... | |
33 | 34 |
this.Loaded += MainWindow_Loaded; |
34 | 35 |
this.KeyDown += new KeyEventHandler(KeyEventDownAction); |
35 | 36 |
this.KeyUp += new KeyEventHandler(KeyEventUpAction); |
37 |
this.SourceInitialized += new EventHandler(win_SourceInitialized); |
|
36 | 38 |
} |
37 | 39 |
|
38 | 40 |
public static BitmapImage CursorChange() |
... | ... | |
76 | 78 |
this.Left = (screenWidth / 2) - (windowWidth / 2); |
77 | 79 |
this.Top = (screenHeight / 2) - (windowHeight / 2); |
78 | 80 |
|
79 |
|
|
80 | 81 |
ViewerDataModel.Instance.SystemMain = this; |
81 | 82 |
|
82 | 83 |
if (!App.ParameterMode) |
... | ... | |
176 | 177 |
{ |
177 | 178 |
restoreIfMove = true; |
178 | 179 |
} |
179 |
|
|
180 | 180 |
this.DragMove(); |
181 | 181 |
} |
182 | 182 |
} |
... | ... | |
192 | 192 |
{ |
193 | 193 |
if (Mouse.LeftButton == MouseButtonState.Pressed) |
194 | 194 |
{ |
195 |
//this.WindowState = WindowState.Normal; |
|
196 |
|
|
197 | 195 |
restoreIfMove = false; |
198 | 196 |
|
199 | 197 |
double percentHorizontal = e.GetPosition(this).X / ActualWidth; |
... | ... | |
208 | 206 |
Left = lMousePosition.X - targetHorizontal; |
209 | 207 |
Top = lMousePosition.Y - targetVertical; |
210 | 208 |
|
211 |
|
|
212 | 209 |
WindowState = WindowState.Normal; |
213 | 210 |
|
214 | 211 |
this.DragMove(); |
... | ... | |
338 | 335 |
dzTopMenu.SaveEvent(null, null); |
339 | 336 |
} |
340 | 337 |
} |
338 |
|
|
339 |
void win_SourceInitialized(object sender, EventArgs e) |
|
340 |
{ |
|
341 |
System.IntPtr handle = (new WinInterop.WindowInteropHelper(this)).Handle; |
|
342 |
WinInterop.HwndSource.FromHwnd(handle).AddHook(new WinInterop.HwndSourceHook(WindowProc)); |
|
343 |
} |
|
344 |
|
|
345 |
private static System.IntPtr WindowProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) |
|
346 |
{ |
|
347 |
switch (msg) |
|
348 |
{ |
|
349 |
case 0x0024: |
|
350 |
WmGetMinMaxInfo(hwnd, lParam); |
|
351 |
handled = true; |
|
352 |
break; |
|
353 |
} |
|
354 |
|
|
355 |
return (System.IntPtr)0; |
|
356 |
} |
|
357 |
|
|
358 |
private static void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam) |
|
359 |
{ |
|
360 |
MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO)); |
|
361 |
int MONITOR_DEFAULTTONEAREST = 0x00000002; |
|
362 |
System.IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); |
|
363 |
|
|
364 |
if (monitor != System.IntPtr.Zero) |
|
365 |
{ |
|
366 |
MONITORINFO monitorInfo = new MONITORINFO(); |
|
367 |
GetMonitorInfo(monitor, monitorInfo); |
|
368 |
RECT rcWorkArea = monitorInfo.rcWork; |
|
369 |
RECT rcMonitorArea = monitorInfo.rcMonitor; |
|
370 |
mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left); |
|
371 |
mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top); |
|
372 |
mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left); |
|
373 |
mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top); |
|
374 |
} |
|
375 |
Marshal.StructureToPtr(mmi, lParam, true); |
|
376 |
} |
|
377 |
|
|
378 |
[StructLayout(LayoutKind.Sequential)] |
|
379 |
public struct POINT2 |
|
380 |
{ |
|
381 |
public int x; |
|
382 |
public int y; |
|
383 |
public POINT2(int x, int y) |
|
384 |
{ |
|
385 |
this.x = x; |
|
386 |
this.y = y; |
|
387 |
} |
|
388 |
} |
|
389 |
|
|
390 |
[StructLayout(LayoutKind.Sequential)] |
|
391 |
public struct MINMAXINFO |
|
392 |
{ |
|
393 |
public POINT2 ptReserved; |
|
394 |
public POINT2 ptMaxSize; |
|
395 |
public POINT2 ptMaxPosition; |
|
396 |
public POINT2 ptMinTrackSize; |
|
397 |
public POINT2 ptMaxTrackSize; |
|
398 |
}; |
|
399 |
|
|
400 |
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] |
|
401 |
public class MONITORINFO |
|
402 |
{ |
|
403 |
public int cbSize = Marshal.SizeOf(typeof(MONITORINFO)); |
|
404 |
public RECT rcMonitor = new RECT(); |
|
405 |
public RECT rcWork = new RECT(); |
|
406 |
public int dwFlags = 0; |
|
407 |
} |
|
408 |
|
|
409 |
[StructLayout(LayoutKind.Sequential, Pack = 0)] |
|
410 |
public struct RECT |
|
411 |
{ |
|
412 |
public int left; |
|
413 |
public int top; |
|
414 |
public int right; |
|
415 |
public int bottom; |
|
416 |
|
|
417 |
public static readonly RECT Empty = new RECT(); |
|
418 |
|
|
419 |
public int Width |
|
420 |
{ |
|
421 |
get { return Math.Abs(right - left); } // Abs needed for BIDI OS |
|
422 |
} |
|
423 |
|
|
424 |
public int Height |
|
425 |
{ |
|
426 |
get { return bottom - top; } |
|
427 |
} |
|
428 |
|
|
429 |
public RECT(int left, int top, int right, int bottom) |
|
430 |
{ |
|
431 |
this.left = left; |
|
432 |
this.top = top; |
|
433 |
this.right = right; |
|
434 |
this.bottom = bottom; |
|
435 |
} |
|
436 |
|
|
437 |
public RECT(RECT rcSrc) |
|
438 |
{ |
|
439 |
this.left = rcSrc.left; |
|
440 |
this.top = rcSrc.top; |
|
441 |
this.right = rcSrc.right; |
|
442 |
this.bottom = rcSrc.bottom; |
|
443 |
} |
|
444 |
|
|
445 |
public bool IsEmpty |
|
446 |
{ |
|
447 |
get |
|
448 |
{ |
|
449 |
// BUGBUG : On Bidi OS (hebrew arabic) left > right |
|
450 |
return left >= right || top >= bottom; |
|
451 |
} |
|
452 |
} |
|
453 |
|
|
454 |
public override bool Equals(object obj) |
|
455 |
{ |
|
456 |
if (!(obj is Rect)) { return false; } |
|
457 |
return (this == (RECT)obj); |
|
458 |
} |
|
459 |
|
|
460 |
public override int GetHashCode() |
|
461 |
{ |
|
462 |
return left.GetHashCode() + top.GetHashCode() + right.GetHashCode() + bottom.GetHashCode(); |
|
463 |
} |
|
464 |
|
|
465 |
public static bool operator ==(RECT rect1, RECT rect2) |
|
466 |
{ |
|
467 |
return (rect1.left == rect2.left && rect1.top == rect2.top && rect1.right == rect2.right && rect1.bottom == rect2.bottom); |
|
468 |
} |
|
469 |
|
|
470 |
public static bool operator !=(RECT rect1, RECT rect2) |
|
471 |
{ |
|
472 |
return !(rect1 == rect2); |
|
473 |
} |
|
474 |
} |
|
475 |
|
|
476 |
[DllImport("user32")] |
|
477 |
internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi); |
|
478 |
|
|
479 |
[DllImport("User32")] |
|
480 |
internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags); |
|
341 | 481 |
} |
342 | 482 |
} |
483 |
|
내보내기 Unified diff