?? shell.java
字號:
if (parent != null) { if (OS.IsWin95) return bits; if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) { return bits; } } if ((style & SWT.ON_TOP) != 0) bits |= OS.WS_EX_TOPMOST; return bits;}TCHAR windowClass () { if (OS.IsSP) return DialogClass; return parent != null ? DialogClass : super.windowClass ();}int windowProc () { if (OS.IsSP) return DialogProc; return parent != null ? DialogProc : super.windowProc ();}int widgetStyle () { int bits = super.widgetStyle (); if (handle != 0) return bits | OS.WS_CHILD; bits &= ~OS.WS_CHILD; /* * Feature in WinCE. Calling CreateWindowEx () with WS_OVERLAPPED * and a parent window causes the new window to become a WS_CHILD of * the parent instead of a dialog child. The fix is to use WS_POPUP * for a window with a parent. * * Feature in WinCE PPC. A window without a parent with WS_POPUP * always shows on top of the Pocket PC 'Today Screen'. The fix * is to not set WS_POPUP for a window without a parent on WinCE * devices. * * NOTE: WS_POPUP causes CreateWindowEx () to ignore CW_USEDEFAULT * and causes the default window location and size to be zero. */ if (OS.IsWinCE) { if (OS.IsSP) return bits | OS.WS_POPUP; return parent == null ? bits : bits | OS.WS_POPUP; } /* * Use WS_OVERLAPPED for all windows, either dialog or top level * so that CreateWindowEx () will respect CW_USEDEFAULT and set * the default window location and size. * * NOTE: When a WS_OVERLAPPED window is created, Windows gives * the new window WS_CAPTION style bits. These two constants are * as follows: * * WS_OVERLAPPED = 0 * WS_CAPTION = WS_BORDER | WS_DLGFRAME * */ return bits | OS.WS_OVERLAPPED | OS.WS_CAPTION;}LRESULT WM_ACTIVATE (int wParam, int lParam) { if (OS.IsPPC) { /* * Note: this does not work when we get WM_ACTIVATE prior * to adding a listener. */ if (hooks (SWT.HardKeyDown) || hooks (SWT.HardKeyUp)) { int fActive = wParam & 0xFFFF; int hwnd = fActive != 0 ? handle : 0; for (int bVk=OS.VK_APP1; bVk<=OS.VK_APP6; bVk++) { OS.SHSetAppKeyWndAssoc ((byte) bVk, hwnd); } } /* Restore SIP state when window is activated */ if ((wParam & 0xFFFF) != 0) { OS.SHSipPreference (handle, psai.fSipUp == 0 ? OS.SIP_DOWN : OS.SIP_UP); } } /* * Bug in Windows XP. When a Shell is deactivated, the * IME composition window does not go away. This causes * repaint issues. The fix is to close the IME ourselves * when the Shell is deactivated. * * Note. When the Shell is reactivated, the text in the * composition window has been lost. */ if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) >= (5 << 16 | 1)) { if ((wParam & 0xFFFF) == 0 && OS.IsDBLocale && hIMC != 0) { OS.ImmSetOpenStatus (hIMC, false); } } LRESULT result = super.WM_ACTIVATE (wParam, lParam); if (parent != null) return LRESULT.ZERO; return result;}LRESULT WM_COMMAND (int wParam, int lParam) { if (OS.IsPPC) { /* * Note in WinCE PPC: Close the Shell when the "Done Button" has * been pressed. lParam is either 0 (PocketPC 2002) or the handle * to the Shell (PocketPC). */ int loWord = wParam & 0xFFFF; if (loWord == OS.IDOK && (lParam == 0 || lParam == handle)) { OS.PostMessage (handle, OS.WM_CLOSE, 0, 0); return LRESULT.ZERO; } } /* * Feature in Windows. On PPC, the menu is not actually an HMENU. * By observation, it is a tool bar that is configured to look like * a menu. Therefore, when the PPC menu sends WM_COMMAND messages, * lParam is not zero because the WM_COMMAND was not sent from a menu. * Sub menu item events originate from the menu bar. Top menu items * events originate from a tool bar. The fix is to detect the source * of the WM_COMMAND and set lParam to zero to pretend that the message * came from a real Windows menu, not a tool bar. */ if (OS.IsPPC || OS.IsSP) { if (menuBar != null) { int hwndCB = menuBar.hwndCB; if (lParam != 0 && hwndCB != 0) { if (lParam == hwndCB) { return super.WM_COMMAND (wParam, 0); } else { int hwndChild = OS.GetWindow (hwndCB, OS.GW_CHILD); if (lParam == hwndChild) return super.WM_COMMAND (wParam, 0); } } } } return super.WM_COMMAND (wParam, lParam);}LRESULT WM_DESTROY (int wParam, int lParam) { LRESULT result = super.WM_DESTROY (wParam, lParam); /* * When the shell is a WS_CHILD window of a non-SWT * window, the destroy code does not get called because * the non-SWT window does not call dispose (). Instead, * the destroy code is called here in WM_DESTROY. */ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); if ((bits & OS.WS_CHILD) != 0) { releaseChild (); releaseResources (); } return result;}LRESULT WM_ENTERIDLE (int wParam, int lParam) { LRESULT result = super.WM_ENTERIDLE (wParam, lParam); if (result != null) return result; if (display.runAsyncMessages ()) display.wakeThread (); return result;}LRESULT WM_MOUSEACTIVATE (int wParam, int lParam) { LRESULT result = super.WM_MOUSEACTIVATE (wParam, lParam); if (result != null) return result; /* * Check for WM_MOUSEACTIVATE when an MDI shell is active * and stop the normal shell activation but allow the mouse * down to be delivered. */ int hittest = (short) (lParam & 0xFFFF); switch (hittest) { case OS.HTERROR: case OS.HTTRANSPARENT: case OS.HTNOWHERE: break; default: { Control control = display.getFocusControl (); if (control != null) { Decorations decorations = control.menuShell (); if (decorations.getShell () == this && decorations != this) { display.ignoreRestoreFocus = true; display.lastHittest = hittest; display.lastHittestControl = null; if (hittest == OS.HTMENU || hittest == OS.HTSYSMENU) { display.lastHittestControl = control; return null; } if (OS.IsWin95 && hittest == OS.HTCAPTION) { display.lastHittestControl = control; } return new LRESULT (OS.MA_NOACTIVATE); } } } } if (hittest == OS.HTMENU) return null; /* * Get the current location of the cursor, * not the location of the cursor when the * WM_MOUSEACTIVATE was generated. This is * strictly incorrect but is necessary in * order to support Activate and Deactivate * events for embedded widgets that have * their own event loop. In that case, the * cursor location reported by GetMessagePos * is the one for our event loop, not the * embedded widget's event loop. */ POINT pt = new POINT (); if (!OS.GetCursorPos (pt)) { int pos = OS.GetMessagePos (); pt.x = (short) (pos & 0xFFFF); pt.y = (short) (pos >> 16); } int hwnd = OS.WindowFromPoint (pt); if (hwnd == 0) return null; Control control = display.findControl (hwnd); setActiveControl (control); /* * This code is intentionally commented. On some platforms, * shells that are created with SWT.NO_TRIM won't take focus * when the user clicks in the client area or on the border. * This behavior is usedful when emulating tool tip shells * Until this behavior is specified, this code will remain * commented. */// if ((style & SWT.NO_TRIM) != 0) {// if (hittest == OS.HTBORDER || hittest == OS.HTCLIENT) {// return new LRESULT (OS.MA_NOACTIVATE);// }// } return null;}LRESULT WM_NCHITTEST (int wParam, int lParam) { if (!OS.IsWindowEnabled (handle)) return null; if (!isEnabled () || !isActive ()) { if (!Display.TrimEnabled) return new LRESULT (OS.HTNOWHERE); int hittest = callWindowProc (OS.WM_NCHITTEST, wParam, lParam); if (hittest == OS.HTCLIENT || hittest == OS.HTMENU) hittest = OS.HTBORDER; return new LRESULT (hittest); } if (menuBar != null && !menuBar.getEnabled ()) { int hittest = callWindowProc (OS.WM_NCHITTEST, wParam, lParam); if (hittest == OS.HTMENU) hittest = OS.HTBORDER; return new LRESULT (hittest); } return null;}LRESULT WM_NCLBUTTONDOWN (int wParam, int lParam) { LRESULT result = super.WM_NCLBUTTONDOWN (wParam, lParam); if (result != null) return result; /* * When the normal activation was interruped in WM_MOUSEACTIVATE * because the active shell was an MDI shell, set the active window * to the top level shell but lock the active window and stop focus * changes. This allows the user to interact the top level shell * in the normal manner. */ if (!display.ignoreRestoreFocus) return result; Display display = this.display; int hwndActive = 0; boolean fixActive = OS.IsWin95 && display.lastHittest == OS.HTCAPTION; if (fixActive) hwndActive = OS.SetActiveWindow (handle); display.lockActiveWindow = true; int code = callWindowProc (OS.WM_NCLBUTTONDOWN, wParam, lParam); display.lockActiveWindow = false; if (fixActive) OS.SetActiveWindow (hwndActive); Control focusControl = display.lastHittestControl; if (focusControl != null && !focusControl.isDisposed ()) { focusControl.setFocus (); } display.lastHittestControl = null; display.ignoreRestoreFocus = false; return new LRESULT (code);}LRESULT WM_PALETTECHANGED (int wParam, int lParam) { if (wParam != handle) { int hPalette = display.hPalette; if (hPalette != 0) return selectPalette (hPalette); } return super.WM_PALETTECHANGED (wParam, lParam);}LRESULT WM_QUERYNEWPALETTE (int wParam, int lParam) { int hPalette = display.hPalette; if (hPalette != 0) return selectPalette (hPalette); return super.WM_QUERYNEWPALETTE (wParam, lParam);}LRESULT WM_SETCURSOR (int wParam, int lParam) { /* * Feature in Windows. When the shell is disabled * by a Windows standard dialog (like a MessageBox * or FileDialog), clicking in the shell does not * bring the shell or the dialog to the front. The * fix is to detect this case and bring the shell * forward. */ int msg = (short) (lParam >> 16); if (msg == OS.WM_LBUTTONDOWN) { if (!Display.TrimEnabled) { Shell modalShell = display.getModalShell (); if (modalShell != null && !isActive ()) { int hwndModal = modalShell.handle; if (OS.IsWindowEnabled (hwndModal)) { OS.SetActiveWindow (hwndModal); } } } if (!OS.IsWindowEnabled (handle)) { if (!OS.IsWinCE) { int hwndPopup = OS.GetLastActivePopup (handle); if (hwndPopup != 0 && hwndPopup != handle) { if (display.getControl (hwndPopup) == null) { if (OS.IsWindowEnabled (hwndPopup)) { OS.SetActiveWindow (hwndPopup); } } } } } } /* * When the shell that contains a cursor is disabled, * WM_SETCURSOR is called with HTERROR. Normally, * when a control is disabled, the parent will get * mouse and cursor events. In the case of a disabled * shell, there is no enabled parent. In order to * show the cursor when a shell is disabled, it is * necessary to override WM_SETCURSOR when called * with HTERROR to set the cursor but only when the * mouse is in the client area of the shell. */ int hitTest = (short) (lParam & 0xFFFF); if (hitTest == OS.HTERROR) { if (!getEnabled ()) { Control control = display.getControl (wParam); if (control == this && cursor != null) { POINT pt = new POINT (); if (OS.GetCursorPos (pt)) { OS.ScreenToClient (handle, pt); RECT rect = new RECT (); OS.GetClientRect (handle, rect); if (OS.PtInRect (rect, pt)) { OS.SetCursor (cursor.handle); switch (msg) { case OS.WM_LBUTTONDOWN: case OS.WM_RBUTTONDOWN: case OS.WM_MBUTTONDOWN: OS.MessageBeep (OS.MB_OK); } return LRESULT.ONE; } } } } } return super.WM_SETCURSOR (wParam, lParam);}LRESULT WM_SETTINGCHANGE (int wParam, int lParam) { LRESULT result = super.WM_SETTINGCHANGE (wParam, lParam); if (result != null) return result; if (OS.IsPPC) { if (wParam == OS.SPI_SETSIPINFO) { /* * The SIP is in a new state. Cache its new value. * Resize the Shell if it has the style SWT.RESIZE. * Note that SHHandleWMSettingChange resizes the * Shell and also updates the cached state. */ if ((style & SWT.RESIZE) != 0) { OS.SHHandleWMSettingChange (handle, wParam, lParam, psai); return LRESULT.ZERO; } else { SIPINFO pSipInfo = new SIPINFO (); pSipInfo.cbSize = SIPINFO.sizeof; OS.SipGetInfo (pSipInfo); psai.fSipUp = pSipInfo.fdwFlags & OS.SIPF_ON; } } } return result;}LRESULT WM_SHOWWINDOW (int wParam, int lParam) { LRESULT result = super.WM_SHOWWINDOW (wParam, lParam); if (result != null) return result; /* * Bug in Windows. If the shell is hidden while the parent * is iconic, Windows shows the shell when the parent is * deiconified. This does not happen if the shell is hidden * while the parent is not an icon. The fix is to track * visible state for the shell and refuse to show the shell * when the parent is shown. */ if (lParam == OS.SW_PARENTOPENING) { Control control = this; while (control != null) { Shell shell = control.getShell (); if (!shell.showWithParent) return LRESULT.ZERO; control = control.parent; } } return result;}}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -