/*********************************************************************** * ColorDlgProc32 [internal] * */ static INT_PTR CALLBACK ColorDlgProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { int res; LPCCPRIV lpp = GetPropW( hDlg, szColourDialogProp ); if (message != WM_INITDIALOG) { if (!lpp) return FALSE; res = 0; if (CC_HookCallChk(lpp->lpcc)) res = CallWindowProcA( (WNDPROC)lpp->lpcc->lpfnHook, hDlg, message, wParam, lParam); if ( res ) return res; } /* FIXME: SetRGB message if (message && message == msetrgb) return HandleSetRGB(hDlg, lParam); */ switch (message) { case WM_INITDIALOG: return CC_WMInitDialog(hDlg, wParam, lParam); case WM_NCDESTROY: DeleteDC(lpp->hdcMem); DeleteObject(lpp->hbmMem); HeapFree(GetProcessHeap(), 0, lpp); RemovePropW( hDlg, szColourDialogProp ); break; case WM_COMMAND: if (CC_WMCommand( hDlg, wParam, lParam, HIWORD(wParam), (HWND) lParam)) return TRUE; break; case WM_PAINT: if (CC_WMPaint(hDlg)) return TRUE; break; case WM_LBUTTONDBLCLK: if (CC_MouseCheckResultWindow(hDlg, lParam)) return TRUE; break; case WM_MOUSEMOVE: if (CC_WMMouseMove(hDlg, lParam)) return TRUE; break; case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/ if (CC_WMLButtonUp(hDlg)) return TRUE; break; case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/ if (CC_WMLButtonDown(hDlg, lParam)) return TRUE; break; } return FALSE ; }
/*********************************************************************** * COMCTL32_SubclassProc (internal) * * Window procedure for all subclassed windows. * Saves the current subclassing stack position to support nested messages */ static LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { LPSUBCLASS_INFO stack; LPSUBCLASSPROCS proc; LRESULT ret; TRACE ("(%p, 0x%08x, 0x%08lx, 0x%08lx)\n", hWnd, uMsg, wParam, lParam); stack = GetPropW (hWnd, COMCTL32_wSubclass); if (!stack) { ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd); return 0; } /* Save our old stackpos to properly handle nested messages */ proc = stack->stackpos; stack->stackpos = stack->SubclassProcs; stack->running++; ret = DefSubclassProc(hWnd, uMsg, wParam, lParam); stack->running--; stack->stackpos = proc; if (!stack->SubclassProcs && !stack->running) { TRACE("Last Subclass removed, cleaning up\n"); /* clean up our heap and reset the original window procedure */ if (IsWindowUnicode (hWnd)) SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc); else SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc); Free (stack); RemovePropW( hWnd, COMCTL32_wSubclass ); } return ret; }
static LRESULT HostWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { WNDPROC fnOldProc; fnOldProc = (WNDPROC)GetPropW(hwnd, WNDPROP_SCCTRLW); if (!fnOldProc) return DefWindowProcW(hwnd, uMsg, wParam, lParam); switch (uMsg) { case WM_NCDESTROY: // detach RemovePropW(hwnd, WNDPROP_SCCTRLW); CallWindowProcW(fnOldProc, hwnd, uMsg, wParam, lParam); SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)fnOldProc); return 0; case WM_ERASEBKGND: if (wParam) { RECT rc; if (GetClientRect(hwnd, &rc)) { SetBkColor((HDC)wParam, ml_color(WADLG_WNDBG)); ExtTextOutW((HDC)wParam, 0, 0, ETO_OPAQUE, &rc, L"", 0, 0); } } return 1; case WM_SETFOCUS: if (htmlControl) { htmlControl->setFocus(TRUE); return 0; } break; } return CallWindowProcW(fnOldProc, hwnd, uMsg, wParam, lParam); }
void CWebWindow::_destroyWindow() { //KillTimer(m_hwnd, 100); RemovePropW(m_hwnd, L"wkeWebWindow"); DestroyWindow(m_hwnd); m_hwnd = NULL; }
static void _clearSuggestions(HWND hwnd){ int count = SendDlgItemMessageW(hwnd, IDC_LST_MISPRINTS, LB_GETCOUNT, 0, 0); for(int i = 0; i < count; i++){ PSUGGESTION ps = (PSUGGESTION)SendDlgItemMessageW(hwnd, IDC_LST_MISPRINTS, LB_GETITEMDATA, i, 0); _freeSuggestions(&ps); } RemovePropW(hwnd, EDIT_PROP); }
/************************************************************************** * IAutoComplete_Destructor */ CAutoComplete::~CAutoComplete() { TRACE(" destroying IAutoComplete(%p)\n", this); HeapFree(GetProcessHeap(), 0, quickComplete); HeapFree(GetProcessHeap(), 0, txtbackup); RemovePropW(hwndEdit, autocomplete_propertyW); SetWindowLongPtrW(hwndEdit, GWLP_WNDPROC, (LONG_PTR)wpOrigEditProc); if (hwndListBox) DestroyWindow(hwndListBox); }
/* * @implemented */ HANDLE WINAPI RemovePropA(HWND hWnd, LPCSTR lpString) { PWSTR lpWString; UNICODE_STRING UString; HANDLE Ret; if (HIWORD(lpString)) { RtlCreateUnicodeStringFromAsciiz(&UString, (LPSTR)lpString); lpWString = UString.Buffer; if (lpWString == NULL) { return(FALSE); } Ret = RemovePropW(hWnd, lpWString); RtlFreeUnicodeString(&UString); } else { Ret = RemovePropW(hWnd, (LPCWSTR)lpString); } return(Ret); }
BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uID) { LPSUBCLASS_INFO stack; LPSUBCLASSPROCS prevproc = NULL; LPSUBCLASSPROCS proc; BOOL ret = FALSE; TRACE ("(%p, %p, %lx)\n", hWnd, pfnSubclass, uID); /* Find the Subclass to remove */ stack = GetPropW (hWnd, COMCTL32_wSubclass); if (!stack) return FALSE; proc = stack->SubclassProcs; while (proc) { if ((proc->id == uID) && (proc->subproc == pfnSubclass)) { if (!prevproc) stack->SubclassProcs = proc->next; else prevproc->next = proc->next; if (stack->stackpos == proc) stack->stackpos = stack->stackpos->next; Free (proc); ret = TRUE; break; } prevproc = proc; proc = proc->next; } if (!stack->SubclassProcs && !stack->running) { TRACE("Last Subclass removed, cleaning up\n"); /* clean up our heap and reset the original window procedure */ if (IsWindowUnicode (hWnd)) SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc); else SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc); Free (stack); RemovePropW( hWnd, COMCTL32_wSubclass ); } return ret; }
/*********************************************************************** * UXTHEME_SetWindowProperty * * I'm using atoms as there may be large numbers of duplicated strings * and they do the work of keeping memory down as a cause of that quite nicely */ static HRESULT UXTHEME_SetWindowProperty(HWND hwnd, ATOM aProp, LPCWSTR pszValue) { ATOM oldValue = (ATOM)(size_t)RemovePropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp)); if(oldValue) DeleteAtom(oldValue); if(pszValue) { ATOM atValue = AddAtomW(pszValue); if(!atValue || !SetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp), (LPWSTR)MAKEINTATOM(atValue))) { HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); if(atValue) DeleteAtom(atValue); return hr; } } return S_OK; }
static HRESULT IOCS_Detach( IOCS *This ) /* remove subclassing */ { if ( This->hWnd ) { SetWindowLongPtrW( This->hWnd, GWLP_WNDPROC, (ULONG_PTR) This->OrigWndProc ); RemovePropW( This->hWnd, wine_atl_iocsW); This->hWnd = NULL; } if ( This->control ) { IOleObject *control = This->control; This->control = NULL; IOleObject_Close( control, OLECLOSE_NOSAVE ); IOleObject_SetClientSite( control, NULL ); IOleObject_Release( control ); } return S_OK; }
void _glfwPlatformDestroyWindow(_GLFWwindow* window) { if (window->monitor) releaseMonitor(window); if (window->context.destroy) window->context.destroy(window); if (_glfw.win32.disabledCursorWindow == window) _glfw.win32.disabledCursorWindow = NULL; if (window->win32.handle) { RemovePropW(window->win32.handle, L"GLFW"); DestroyWindow(window->win32.handle); window->win32.handle = NULL; } if (window->win32.bigIcon) DestroyIcon(window->win32.bigIcon); if (window->win32.smallIcon) DestroyIcon(window->win32.smallIcon); }
/*********************************************************************** * UPDOWN_SetBuddy * * Sets bud as a new Buddy. * Then, it should subclass the buddy * If window has the UDS_ARROWKEYS, it subcalsses the buddy window to * process the UP/DOWN arrow keys. * If window has the UDS_ALIGNLEFT or UDS_ALIGNRIGHT style * the size/pos of the buddy and the control are adjusted accordingly. */ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud) { static const WCHAR editW[] = { 'E', 'd', 'i', 't', 0 }; static const WCHAR listboxW[] = { 'L', 'i', 's', 't', 'b', 'o', 'x', 0 }; RECT budRect; /* new coord for the buddy */ int x, width; /* new x position and width for the up-down */ WNDPROC baseWndProc; WCHAR buddyClass[40]; HWND ret; TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud); ret = infoPtr->Buddy; /* there is already a body assigned */ if (infoPtr->Buddy) RemovePropW(infoPtr->Buddy, BUDDY_UPDOWN_HWND); if(!IsWindow(bud)) bud = 0; /* Store buddy window handle */ infoPtr->Buddy = bud; if(bud) { /* keep upDown ctrl hwnd in a buddy property */ SetPropW( bud, BUDDY_UPDOWN_HWND, infoPtr->Self); /* Store buddy window class type */ infoPtr->BuddyType = BUDDY_TYPE_UNKNOWN; if (GetClassNameW(bud, buddyClass, COUNT_OF(buddyClass))) { if (lstrcmpiW(buddyClass, editW) == 0) infoPtr->BuddyType = BUDDY_TYPE_EDIT; else if (lstrcmpiW(buddyClass, listboxW) == 0) infoPtr->BuddyType = BUDDY_TYPE_LISTBOX; } if(infoPtr->dwStyle & UDS_ARROWKEYS){ /* Note that I don't clear the BUDDY_SUPERCLASS_WNDPROC property when we reset the upDown ctrl buddy to another buddy because it is not good to break the window proc chain. */ if (!GetPropW(bud, BUDDY_SUPERCLASS_WNDPROC)) { baseWndProc = (WNDPROC)SetWindowLongPtrW(bud, GWLP_WNDPROC, (LPARAM)UPDOWN_Buddy_SubclassProc); SetPropW(bud, BUDDY_SUPERCLASS_WNDPROC, (HANDLE)baseWndProc); } } /* Get the rect of the buddy relative to its parent */ GetWindowRect(infoPtr->Buddy, &budRect); MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy), (POINT *)(&budRect.left), 2); /* now do the positioning */ if (infoPtr->dwStyle & UDS_ALIGNLEFT) { x = budRect.left; budRect.left += DEFAULT_WIDTH + DEFAULT_XSEP; } else if (infoPtr->dwStyle & UDS_ALIGNRIGHT) { budRect.right -= DEFAULT_WIDTH + DEFAULT_XSEP; x = budRect.right+DEFAULT_XSEP; } else { /* nothing to do */ return ret; } /* first adjust the buddy to accommodate the up/down */ SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top, budRect.right - budRect.left, budRect.bottom - budRect.top, SWP_NOACTIVATE|SWP_NOZORDER); /* now position the up/down */ /* Since the UDS_ALIGN* flags were used, */ /* we will pick the position and size of the window. */ width = DEFAULT_WIDTH; /* * If the updown has a buddy border, it has to overlap with the buddy * to look as if it is integrated with the buddy control. * We nudge the control or change its size to overlap. */ if (UPDOWN_HasBuddyBorder(infoPtr)) { if(infoPtr->dwStyle & UDS_ALIGNLEFT) width += DEFAULT_BUDDYBORDER; else x -= DEFAULT_BUDDYBORDER; } SetWindowPos(infoPtr->Self, 0, x, budRect.top - DEFAULT_ADDTOP, width, budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER); } else { RECT rect; GetWindowRect(infoPtr->Self, &rect); MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Self), (POINT *)&rect, 2); SetWindowPos(infoPtr->Self, 0, rect.left, rect.top, DEFAULT_WIDTH, rect.bottom - rect.top, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER); } return ret; }
BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIDSubclass, DWORD_PTR dwRef) { LPSUBCLASS_INFO stack; LPSUBCLASSPROCS proc; TRACE ("(%p, %p, %lx, %lx)\n", hWnd, pfnSubclass, uIDSubclass, dwRef); /* Since the window procedure that we set here has two additional arguments, * we can't simply set it as the new window procedure of the window. So we * set our own window procedure and then calculate the other two arguments * from there. */ /* See if we have been called for this window */ stack = GetPropW (hWnd, COMCTL32_wSubclass); if (!stack) { /* allocate stack */ stack = Alloc (sizeof(SUBCLASS_INFO)); if (!stack) { ERR ("Failed to allocate our Subclassing stack\n"); return FALSE; } SetPropW (hWnd, COMCTL32_wSubclass, stack); /* set window procedure to our own and save the current one */ if (IsWindowUnicode (hWnd)) stack->origproc = (WNDPROC)SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)COMCTL32_SubclassProc); else stack->origproc = (WNDPROC)SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)COMCTL32_SubclassProc); } else { /* Check to see if we have called this function with the same uIDSubClass * and pfnSubclass */ proc = stack->SubclassProcs; while (proc) { if ((proc->id == uIDSubclass) && (proc->subproc == pfnSubclass)) { proc->ref = dwRef; return TRUE; } proc = proc->next; } } proc = Alloc(sizeof(SUBCLASSPROCS)); if (!proc) { ERR ("Failed to allocate subclass entry in stack\n"); if (IsWindowUnicode (hWnd)) SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc); else SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc); Free (stack); RemovePropW( hWnd, COMCTL32_wSubclass ); return FALSE; } proc->subproc = pfnSubclass; proc->ref = dwRef; proc->id = uIDSubclass; proc->next = stack->SubclassProcs; stack->SubclassProcs = proc; return TRUE; }
LRESULT CWebWindow::_windowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_CREATE: { DragAcceptFiles(hwnd, TRUE); //SetTimer(hwnd, 100, 20, NULL); } return 0; case WM_CLOSE: if (m_windowClosingCallback) { if (!m_windowClosingCallback(this, m_windowClosingCallbackParam)) return 0; } ShowWindow(hwnd, SW_HIDE); DestroyWindow(hwnd); return 0; case WM_DESTROY: { //KillTimer(hwnd, 100); RemovePropW(hwnd, L"wkeWebWindow"); m_hwnd = NULL; if (m_windowDestroyCallback) m_windowDestroyCallback(this, m_windowDestroyCallbackParam); wkeDestroyWebView(this); } return 0; //case WM_TIMER: // { // wkeRepaintIfNeeded(this); // } // return 0; case WM_PAINT: { PAINTSTRUCT ps = { 0 }; HDC hdc = BeginPaint(hwnd, &ps); _paintDC(hdc, (HDC)wkeGetViewDC(this)); EndPaint(hwnd, &ps); } return 0; case WM_ERASEBKGND: return TRUE; case WM_SIZE: { RECT rc = { 0 }; GetClientRect(hwnd, &rc); int width = rc.right - rc.left; int height = rc.bottom - rc.top; CWebView::resize(width, height); wkeRepaintIfNeeded(this); } return 0; case WM_DROPFILES: { wchar_t szFile[MAX_PATH + 8] = {0}; wcscpy(szFile, L"file:///"); HDROP hDrop = reinterpret_cast<HDROP>(wParam); UINT uFilesCount = DragQueryFileW(hDrop, 0xFFFFFFFF, szFile, MAX_PATH); if (uFilesCount != 0) { UINT uRet = DragQueryFileW(hDrop, 0, (wchar_t*)szFile + 8, MAX_PATH); if ( uRet != 0) { wkeLoadURLW(this, szFile); SetWindowTextW(hwnd, szFile); } } DragFinish(hDrop); } return 0; //case WM_NCHITTEST: // if (IsWindow(m_hwnd) && flagsOff(GetWindowLong(m_hwnd, GWL_STYLE), WS_CAPTION)) // { // IWebkitObserverPtr observer = m_observer.lock(); // if (!observer) // break; // QPoint cursor(LOWORD(lParam), HIWORD(lParam)); // ScreenToClient(m_hwnd, &cursor); // QRect clientRect; // QSize clientSize; // GetClientRect(hwnd, &clientRect); // clientSize.cx = clientRect.width(); // clientSize.cy = clientRect.height(); // EWebkitHitTest hit = observer->onHitTest(QWebkitView(thisView), clientSize, cursor); // switch (hit) // { // case eWebkitHitLeftTop: return HTTOPLEFT; // case eWebkitHitLeft: return HTLEFT; // case eWebkitHitLeftBottom: return HTBOTTOMLEFT; // case eWebkitHitRightTop: return HTTOPRIGHT; // case eWebkitHitRight: return HTRIGHT; // case eWebkitHitRightBottom: return HTBOTTOMRIGHT; // case eWebkitHitTop: return HTTOP; // case eWebkitHitBottom: return HTBOTTOM; // case eWebkitHitCaption: return HTCAPTION; // case eWebkitHitClient: return HTCLIENT; // case eWebkitHitNone: return HTCLIENT; // } // } // break; //case WM_SETCURSOR: // if (IsWindow(m_hwnd) && flagsOff(GetWindowLong(m_hwnd, GWL_STYLE), WS_CAPTION)) // { // WORD hit = LOWORD(lParam); // switch (hit) // { // case HTCAPTION: // case HTSYSMENU: // case HTMENU: // case HTCLIENT: // SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW))); // return TRUE; // case HTTOP: // case HTBOTTOM: // SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS))); // return TRUE; // case HTLEFT: // case HTRIGHT: // SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZEWE))); // return TRUE; // case HTTOPLEFT: // case HTBOTTOMRIGHT: // SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENWSE))); // return TRUE; // case HTTOPRIGHT: // case HTBOTTOMLEFT: // SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENESW))); // return TRUE; // default: // SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW))); // return TRUE; // } // } // break; //case WM_NCLBUTTONDOWN: // if (IsWindow(m_hwnd) && flagsOff(GetWindowLong(m_hwnd, GWL_STYLE), WS_CAPTION)) // { // int hit = wParam; // switch (hit) // { // case HTTOP: SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_TOP, lParam); return 0; // case HTBOTTOM: SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_BOTTOM, lParam); return 0; // case HTLEFT: SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_LEFT, lParam); return 0; // case HTRIGHT: SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_RIGHT, lParam); return 0; // case HTTOPLEFT: SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_TOPLEFT, lParam); return 0; // case HTTOPRIGHT: SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_TOPRIGHT, lParam); return 0; // case HTBOTTOMLEFT: SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_BOTTOMLEFT, lParam); return 0; // case HTBOTTOMRIGHT: SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_SIZE|WMSZ_BOTTOMRIGHT, lParam); return 0; // case HTCAPTION: SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_MOVE|4, lParam); return 0; // } // } // break; //case WM_NCLBUTTONDBLCLK: // if (IsWindow(m_hwnd) && flagsOff(GetWindowLong(m_hwnd, GWL_STYLE), WS_CAPTION)) // { // int hit = wParam; // if (hit == HTCAPTION) // { // if (IsZoomed(m_hwnd)) // SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_RESTORE, lParam); // else // SendMessageW(m_hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, lParam); // return 0; // } // } // break; case WM_KEYDOWN: { unsigned int virtualKeyCode = wParam; unsigned int flags = 0; if (HIWORD(lParam) & KF_REPEAT) flags |= WKE_REPEAT; if (HIWORD(lParam) & KF_EXTENDED) flags |= WKE_EXTENDED; if (wkeFireKeyDownEvent(this, virtualKeyCode, flags, false)) return 0; } break; case WM_KEYUP: { unsigned int virtualKeyCode = wParam; unsigned int flags = 0; if (HIWORD(lParam) & KF_REPEAT) flags |= WKE_REPEAT; if (HIWORD(lParam) & KF_EXTENDED) flags |= WKE_EXTENDED; if (wkeFireKeyUpEvent(this, virtualKeyCode, flags, false)) return 0; } break; case WM_CHAR: { unsigned int charCode = wParam; unsigned int flags = 0; if (HIWORD(lParam) & KF_REPEAT) flags |= WKE_REPEAT; if (HIWORD(lParam) & KF_EXTENDED) flags |= WKE_EXTENDED; if (wkeFireKeyPressEvent(this, charCode, flags, false)) return 0; } break; case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: case WM_MOUSEMOVE: { if (message == WM_LBUTTONDOWN || message == WM_MBUTTONDOWN || message == WM_RBUTTONDOWN) { SetFocus(hwnd); SetCapture(hwnd); } else if (message == WM_LBUTTONUP || message == WM_MBUTTONUP || message == WM_RBUTTONUP) { ReleaseCapture(); } int x = LOWORD(lParam); int y = HIWORD(lParam); unsigned int flags = 0; if (wParam & MK_CONTROL) flags |= WKE_CONTROL; if (wParam & MK_SHIFT) flags |= WKE_SHIFT; if (wParam & MK_LBUTTON) flags |= WKE_LBUTTON; if (wParam & MK_MBUTTON) flags |= WKE_MBUTTON; if (wParam & MK_RBUTTON) flags |= WKE_RBUTTON; if (wkeFireMouseEvent(this, message, x, y, flags)) return 0; } break; case WM_CONTEXTMENU: { POINT pt; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); if (pt.x != -1 && pt.y != -1) ScreenToClient(hwnd, &pt); unsigned int flags = 0; if (wParam & MK_CONTROL) flags |= WKE_CONTROL; if (wParam & MK_SHIFT) flags |= WKE_SHIFT; if (wParam & MK_LBUTTON) flags |= WKE_LBUTTON; if (wParam & MK_MBUTTON) flags |= WKE_MBUTTON; if (wParam & MK_RBUTTON) flags |= WKE_RBUTTON; if (wkeFireContextMenuEvent(this, pt.x, pt.y, flags)) return 0; } break; case WM_MOUSEWHEEL: { POINT pt; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); ScreenToClient(hwnd, &pt); int delta = GET_WHEEL_DELTA_WPARAM(wParam); unsigned int flags = 0; if (wParam & MK_CONTROL) flags |= WKE_CONTROL; if (wParam & MK_SHIFT) flags |= WKE_SHIFT; if (wParam & MK_LBUTTON) flags |= WKE_LBUTTON; if (wParam & MK_MBUTTON) flags |= WKE_MBUTTON; if (wParam & MK_RBUTTON) flags |= WKE_RBUTTON; if (wkeFireMouseWheelEvent(this, pt.x, pt.y, delta, flags)) return 0; } break; case WM_SETFOCUS: wkeSetFocus(this); return 0; case WM_KILLFOCUS: wkeKillFocus(this); return 0; case WM_IME_STARTCOMPOSITION: { wkeRect caret = wkeGetCaretRect(this); CANDIDATEFORM form; form.dwIndex = 0; form.dwStyle = CFS_EXCLUDE; form.ptCurrentPos.x = caret.x; form.ptCurrentPos.y = caret.y + caret.h; form.rcArea.top = caret.y; form.rcArea.bottom = caret.y + caret.h; form.rcArea.left = caret.x; form.rcArea.right = caret.x + caret.w; COMPOSITIONFORM compForm; compForm.ptCurrentPos = form.ptCurrentPos; compForm.rcArea = form.rcArea; compForm.dwStyle = CFS_POINT; HIMC hIMC = ImmGetContext(hwnd); ImmSetCandidateWindow(hIMC, &form); ImmSetCompositionWindow(hIMC, &compForm); ImmReleaseContext(hwnd, hIMC); } return 0; } return DefWindowProcW(hwnd, message, wParam, lParam); }
static INT_PTR CALLBACK ps_dlg_proc(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp) { /* native uses prop name "Structure", but we're not compatible with that so we'll prepend "Wine_". */ static const WCHAR prop_name[] = {'W','i','n','e','_','S','t','r','u','c','t','u','r','e',0}; ps_struct_t *ps_struct; TRACE("(%p, %04x, %08lx, %08lx)\n", hdlg, msg, wp, lp); ps_struct = GetPropW(hdlg, prop_name); if(msg != WM_INITDIALOG) { if(!ps_struct) return 0; if(ps_struct->ps->lpfnHook) { INT_PTR ret = ps_struct->ps->lpfnHook(hdlg, msg, wp, lp); if(ret) return ret; } } switch(msg) { case WM_INITDIALOG: { ps_struct = HeapAlloc(GetProcessHeap(), 0, sizeof(*ps_struct)); ps_struct->ps = (OLEUIPASTESPECIALW*)lp; ps_struct->type_name = NULL; ps_struct->source_name = NULL; ps_struct->link_type_name = NULL; ps_struct->link_source_name = NULL; ps_struct->app_name = NULL; ps_struct->flags = ps_struct->ps->dwFlags; SetPropW(hdlg, prop_name, ps_struct); if(!(ps_struct->ps->dwFlags & PSF_SHOWHELP)) { ShowWindow(GetDlgItem(hdlg, IDC_OLEUIHELP), SW_HIDE); EnableWindow(GetDlgItem(hdlg, IDC_OLEUIHELP), 0); } if(ps_struct->ps->lpszCaption) SetWindowTextW(hdlg, ps_struct->ps->lpszCaption); get_descriptors(hdlg, ps_struct); init_lists(hdlg, ps_struct); update_src_text(hdlg, ps_struct); selection_change(hdlg, ps_struct); SetFocus(GetDlgItem(hdlg, IDC_PS_DISPLAYLIST)); if(ps_struct->ps->lpfnHook) ps_struct->ps->lpfnHook(hdlg, msg, 0, 0); return FALSE; /* use new focus */ } case WM_COMMAND: switch(LOWORD(wp)) { case IDC_PS_DISPLAYLIST: switch(HIWORD(wp)) { case LBN_SELCHANGE: selection_change(hdlg, ps_struct); return FALSE; default: return FALSE; } case IDC_PS_PASTE: case IDC_PS_PASTELINK: switch(HIWORD(wp)) { case BN_CLICKED: mode_change(hdlg, ps_struct, LOWORD(wp)); return FALSE; default: return FALSE; } case IDC_OLEUIHELP: switch(HIWORD(wp)) { case BN_CLICKED: post_help_msg(hdlg, ps_struct); return FALSE; default: return FALSE; } case IDOK: case IDCANCEL: switch(HIWORD(wp)) { case BN_CLICKED: send_end_dialog_msg(hdlg, ps_struct, LOWORD(wp)); return FALSE; default: return FALSE; } } return FALSE; default: if(msg == oleui_msg_enddialog) { if(wp == IDOK) update_structure(hdlg, ps_struct); EndDialog(hdlg, wp); /* native does its cleanup in WM_DESTROY */ RemovePropW(hdlg, prop_name); free_structure(ps_struct); return TRUE; } return FALSE; } }
/*********************************************************************** * UpDownWndProc */ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); static const WCHAR themeClass[] = {'S','p','i','n',0}; HTHEME theme; TRACE("hwnd=%p msg=%04x wparam=%08lx lparam=%08lx\n", hwnd, message, wParam, lParam); if (!infoPtr && (message != WM_CREATE)) return DefWindowProcW (hwnd, message, wParam, lParam); switch(message) { case WM_CREATE: infoPtr = Alloc (sizeof(UPDOWN_INFO)); SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); /* initialize the info struct */ infoPtr->Self = hwnd; infoPtr->Notify = ((LPCREATESTRUCTW)lParam)->hwndParent; infoPtr->dwStyle = ((LPCREATESTRUCTW)lParam)->style; infoPtr->AccelCount = 0; infoPtr->AccelVect = 0; infoPtr->AccelIndex = -1; infoPtr->CurVal = 0; infoPtr->MinVal = 100; infoPtr->MaxVal = 0; infoPtr->Base = 10; /* Default to base 10 */ infoPtr->Buddy = 0; /* No buddy window yet */ infoPtr->Flags = 0; /* And no flags */ SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle & ~WS_BORDER); /* Do we pick the buddy win ourselves? */ if (infoPtr->dwStyle & UDS_AUTOBUDDY) UPDOWN_SetBuddy (infoPtr, GetWindow (hwnd, GW_HWNDPREV)); OpenThemeData (hwnd, themeClass); TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd); break; case WM_DESTROY: Free (infoPtr->AccelVect); if(infoPtr->Buddy) RemovePropW(infoPtr->Buddy, BUDDY_UPDOWN_HWND); Free (infoPtr); SetWindowLongPtrW (hwnd, 0, 0); theme = GetWindowTheme (hwnd); CloseThemeData (theme); TRACE("UpDown Ctrl destruction, hwnd=%p\n", hwnd); break; case WM_ENABLE: if (wParam) { infoPtr->dwStyle &= ~WS_DISABLED; } else { infoPtr->dwStyle |= WS_DISABLED; UPDOWN_CancelMode (infoPtr); } InvalidateRect (infoPtr->Self, NULL, FALSE); break; case WM_STYLECHANGED: if (wParam == GWL_STYLE) { infoPtr->dwStyle = ((LPSTYLESTRUCT)lParam)->styleNew; InvalidateRect (infoPtr->Self, NULL, FALSE); } break; case WM_THEMECHANGED: theme = GetWindowTheme (hwnd); CloseThemeData (theme); OpenThemeData (hwnd, themeClass); InvalidateRect (hwnd, NULL, FALSE); break; case WM_TIMER: /* is this the auto-press timer? */ if(wParam == TIMER_AUTOPRESS) { KillTimer(hwnd, TIMER_AUTOPRESS); infoPtr->Flags &= ~(FLAG_PRESSED | FLAG_ARROW); InvalidateRect(infoPtr->Self, NULL, FALSE); } /* if initial timer, kill it and start the repeat timer */ if(wParam == TIMER_AUTOREPEAT) { int temp; KillTimer(hwnd, TIMER_AUTOREPEAT); /* if no accel info given, used default timer */ if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0) { infoPtr->AccelIndex = -1; temp = REPEAT_DELAY; } else { infoPtr->AccelIndex = 0; /* otherwise, use it */ temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1; } SetTimer(hwnd, TIMER_ACCEL, temp, 0); } /* now, if the mouse is above us, do the thing...*/ if(infoPtr->Flags & FLAG_MOUSEIN) { int temp; temp = infoPtr->AccelIndex == -1 ? 1 : infoPtr->AccelVect[infoPtr->AccelIndex].nInc; UPDOWN_DoAction(infoPtr, temp, infoPtr->Flags & FLAG_ARROW); if(infoPtr->AccelIndex != -1 && infoPtr->AccelIndex < infoPtr->AccelCount-1) { KillTimer(hwnd, TIMER_ACCEL); infoPtr->AccelIndex++; /* move to the next accel info */ temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1; /* make sure we have at least 1ms intervals */ SetTimer(hwnd, TIMER_ACCEL, temp, 0); } } break; case WM_CANCELMODE: return UPDOWN_CancelMode (infoPtr); case WM_LBUTTONUP: if (GetCapture() != infoPtr->Self) break; if ( (infoPtr->Flags & FLAG_MOUSEIN) && (infoPtr->Flags & FLAG_ARROW) ) { SendMessageW( infoPtr->Notify, (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL, MAKELONG(SB_ENDSCROLL, infoPtr->CurVal), (LPARAM)hwnd); if (UPDOWN_IsBuddyEdit(infoPtr)) SendMessageW(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1)); } UPDOWN_CancelMode(infoPtr); break; case WM_LBUTTONDOWN: case WM_MOUSEMOVE: case WM_MOUSELEAVE: if(UPDOWN_IsEnabled(infoPtr)) UPDOWN_HandleMouseEvent (infoPtr, message, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); break; case WM_MOUSEWHEEL: UPDOWN_MouseWheel(infoPtr, wParam); break; case WM_KEYDOWN: if((infoPtr->dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr)) return UPDOWN_KeyPressed(infoPtr, (int)wParam); break; case WM_PRINTCLIENT: case WM_PAINT: return UPDOWN_Paint (infoPtr, (HDC)wParam); case UDM_GETACCEL: if (wParam==0 && lParam==0) return infoPtr->AccelCount; if (wParam && lParam) { int temp = min(infoPtr->AccelCount, wParam); memcpy((void *)lParam, infoPtr->AccelVect, temp*sizeof(UDACCEL)); return temp; } return 0; case UDM_SETACCEL: { unsigned temp; TRACE("UDM_SETACCEL\n"); if(infoPtr->AccelVect) { Free (infoPtr->AccelVect); infoPtr->AccelCount = 0; infoPtr->AccelVect = 0; } if(wParam==0) return TRUE; infoPtr->AccelVect = Alloc (wParam*sizeof(UDACCEL)); if(infoPtr->AccelVect == 0) return FALSE; memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL)); infoPtr->AccelCount = wParam; for (temp = 0; temp < wParam; temp++) TRACE("%d: nSec %u nInc %u\n", temp, infoPtr->AccelVect[temp].nSec, infoPtr->AccelVect[temp].nInc); return TRUE; } case UDM_GETBASE: return infoPtr->Base; case UDM_SETBASE: TRACE("UpDown Ctrl new base(%ld), hwnd=%p\n", wParam, hwnd); if (wParam==10 || wParam==16) { WPARAM temp = infoPtr->Base; infoPtr->Base = wParam; return temp; } break; case UDM_GETBUDDY: return (LRESULT)infoPtr->Buddy; case UDM_SETBUDDY: return (LRESULT)UPDOWN_SetBuddy (infoPtr, (HWND)wParam); case UDM_GETPOS: { int temp = UPDOWN_GetBuddyInt (infoPtr); return MAKELONG(infoPtr->CurVal, temp ? 0 : 1); } case UDM_SETPOS: { int temp = (short)LOWORD(lParam); TRACE("UpDown Ctrl new value(%d), hwnd=%p\n", temp, hwnd); if(!UPDOWN_InBounds(infoPtr, temp)) { if(temp < infoPtr->MinVal) temp = infoPtr->MinVal; if(temp > infoPtr->MaxVal) temp = infoPtr->MaxVal; } wParam = infoPtr->CurVal; infoPtr->CurVal = temp; UPDOWN_SetBuddyInt (infoPtr); return wParam; /* return prev value */ } case UDM_GETRANGE: return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal); case UDM_SETRANGE: /* we must have: */ infoPtr->MaxVal = (short)(lParam); /* UD_MINVAL <= Max <= UD_MAXVAL */ infoPtr->MinVal = (short)HIWORD(lParam); /* UD_MINVAL <= Min <= UD_MAXVAL */ /* |Max-Min| <= UD_MAXVAL */ TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n", infoPtr->MinVal, infoPtr->MaxVal, hwnd); break; case UDM_GETRANGE32: if (wParam) *(LPINT)wParam = infoPtr->MinVal; if (lParam) *(LPINT)lParam = infoPtr->MaxVal; break; case UDM_SETRANGE32: infoPtr->MinVal = (INT)wParam; infoPtr->MaxVal = (INT)lParam; if (infoPtr->MaxVal <= infoPtr->MinVal) infoPtr->MaxVal = infoPtr->MinVal + 1; TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n", infoPtr->MinVal, infoPtr->MaxVal, hwnd); break; case UDM_GETPOS32: if ((LPBOOL)lParam != NULL) *((LPBOOL)lParam) = TRUE; return infoPtr->CurVal; case UDM_SETPOS32: { int temp; if(!UPDOWN_InBounds(infoPtr, (int)lParam)) { if((int)lParam < infoPtr->MinVal) lParam = infoPtr->MinVal; if((int)lParam > infoPtr->MaxVal) lParam = infoPtr->MaxVal; } temp = infoPtr->CurVal; /* save prev value */ infoPtr->CurVal = (int)lParam; /* set the new value */ UPDOWN_SetBuddyInt (infoPtr); return temp; /* return prev value */ } case UDM_GETUNICODEFORMAT: /* we lie a bit here, we're always using Unicode internally */ return infoPtr->UnicodeFormat; case UDM_SETUNICODEFORMAT: { /* do we really need to honour this flag? */ int temp = infoPtr->UnicodeFormat; infoPtr->UnicodeFormat = (BOOL)wParam; return temp; } default: if ((message >= WM_USER) && (message < WM_APP) && !COMCTL32_IsReflectedMessage(message)) ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam); return DefWindowProcW (hwnd, message, wParam, lParam); } return 0; }
/* Window procedure for autocompletion */ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { IAutoCompleteImpl *This = GetPropW(hwnd, autocomplete_propertyW); LPOLESTR strs; HRESULT hr; WCHAR hwndText[255]; WCHAR *hwndQCText; RECT r; BOOL control, filled, displayall = FALSE; int cpt, height, sel; if (!This->enabled) return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); switch (uMsg) { case CB_SHOWDROPDOWN: ShowWindow(This->hwndListBox, SW_HIDE); break; case WM_KILLFOCUS: if ((This->options & ACO_AUTOSUGGEST) && ((HWND)wParam != This->hwndListBox)) { ShowWindow(This->hwndListBox, SW_HIDE); } return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); case WM_KEYUP: GetWindowTextW( hwnd, hwndText, 255); switch(wParam) { case VK_RETURN: /* If quickComplete is set and control is pressed, replace the string */ control = GetKeyState(VK_CONTROL) & 0x8000; if (control && This->quickComplete) { hwndQCText = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(This->quickComplete)+lstrlenW(hwndText))*sizeof(WCHAR)); sel = sprintfW(hwndQCText, This->quickComplete, hwndText); SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)hwndQCText); SendMessageW(hwnd, EM_SETSEL, 0, sel); HeapFree(GetProcessHeap(), 0, hwndQCText); } ShowWindow(This->hwndListBox, SW_HIDE); return 0; case VK_LEFT: case VK_RIGHT: return 0; case VK_UP: case VK_DOWN: /* Two cases here : - if the listbox is not visible, displays it with all the entries if the style ACO_UPDOWNKEYDROPSLIST is present but does not select anything. - if the listbox is visible, change the selection */ if ( (This->options & (ACO_AUTOSUGGEST | ACO_UPDOWNKEYDROPSLIST)) && (!IsWindowVisible(This->hwndListBox) && (! *hwndText)) ) { /* We must display all the entries */ displayall = TRUE; } else { if (IsWindowVisible(This->hwndListBox)) { int count; count = SendMessageW(This->hwndListBox, LB_GETCOUNT, 0, 0); /* Change the selection */ sel = SendMessageW(This->hwndListBox, LB_GETCURSEL, 0, 0); if (wParam == VK_UP) sel = ((sel-1)<0)?count-1:sel-1; else sel = ((sel+1)>= count)?-1:sel+1; SendMessageW(This->hwndListBox, LB_SETCURSEL, sel, 0); if (sel != -1) { WCHAR *msg; int len; len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0); msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR)); SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg); SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg); SendMessageW(hwnd, EM_SETSEL, lstrlenW(msg), lstrlenW(msg)); HeapFree(GetProcessHeap(), 0, msg); } else { SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)This->txtbackup); SendMessageW(hwnd, EM_SETSEL, lstrlenW(This->txtbackup), lstrlenW(This->txtbackup)); } } return 0; } break; case VK_BACK: case VK_DELETE: if ((! *hwndText) && (This->options & ACO_AUTOSUGGEST)) { ShowWindow(This->hwndListBox, SW_HIDE); return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); } if (This->options & ACO_AUTOAPPEND) { DWORD b; SendMessageW(hwnd, EM_GETSEL, (WPARAM)&b, 0); if (b>1) { hwndText[b-1] = '\0'; } else { hwndText[0] = '\0'; SetWindowTextW(hwnd, hwndText); } } break; default: ; } SendMessageW(This->hwndListBox, LB_RESETCONTENT, 0, 0); HeapFree(GetProcessHeap(), 0, This->txtbackup); This->txtbackup = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(hwndText)+1)*sizeof(WCHAR)); lstrcpyW(This->txtbackup, hwndText); /* Returns if there is no text to search and we doesn't want to display all the entries */ if ((!displayall) && (! *hwndText) ) break; IEnumString_Reset(This->enumstr); filled = FALSE; for(cpt = 0;;) { ULONG fetched; hr = IEnumString_Next(This->enumstr, 1, &strs, &fetched); if (hr != S_OK) break; if (strstrW(strs, hwndText) == strs) { if (!filled && (This->options & ACO_AUTOAPPEND)) { SetWindowTextW(hwnd, strs); SendMessageW(hwnd, EM_SETSEL, lstrlenW(hwndText), lstrlenW(strs)); if (!(This->options & ACO_AUTOSUGGEST)) break; } if (This->options & ACO_AUTOSUGGEST) { SendMessageW(This->hwndListBox, LB_ADDSTRING, 0, (LPARAM)strs); cpt++; } filled = TRUE; } } if (This->options & ACO_AUTOSUGGEST) { if (filled) { height = SendMessageW(This->hwndListBox, LB_GETITEMHEIGHT, 0, 0); SendMessageW(This->hwndListBox, LB_CARETOFF, 0, 0); GetWindowRect(hwnd, &r); SetParent(This->hwndListBox, HWND_DESKTOP); /* It seems that Windows XP displays 7 lines at most and otherwise displays a vertical scroll bar */ SetWindowPos(This->hwndListBox, HWND_TOP, r.left, r.bottom + 1, r.right - r.left, min(height * 7, height*(cpt+1)), SWP_SHOWWINDOW ); } else { ShowWindow(This->hwndListBox, SW_HIDE); } } break; case WM_DESTROY: { WNDPROC proc = This->wpOrigEditProc; RemovePropW(hwnd, autocomplete_propertyW); SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)proc); This->hwndEdit = NULL; if (This->hwndListBox) DestroyWindow(This->hwndListBox); IAutoComplete2_Release((IAutoComplete2 *)This); return CallWindowProcW(proc, hwnd, uMsg, wParam, lParam); } default: return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); } return 0; }
static BOOL CALLBACK PropEnumProcW(HWND hwnd, LPCWSTR lpszString, HANDLE hData){ if((DWORD)(VOID *)hData != 0xffffffff){ RemovePropW(hwnd, lpszString); } return TRUE; }