LRESULT WindowImplBase::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lRes = 0; BOOL bHandled = TRUE; CPoint pt; switch (uMsg) { case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break; case WM_CLOSE: lRes = OnClose(uMsg, wParam, lParam, bHandled); break; case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break; #if defined(WIN32) && !defined(UNDER_CE) case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break; case WM_NCCALCSIZE: lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break; case WM_NCPAINT: lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break; case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break; case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break; case WM_MOUSEWHEEL: { pt.x = GET_X_LPARAM( lParam ); pt.y = GET_Y_LPARAM( lParam ); lRes = OnMouseWheel(uMsg,GET_KEYSTATE_WPARAM(wParam),GET_WHEEL_DELTA_WPARAM(wParam),pt,bHandled); break; } #endif case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break; case WM_CHAR: lRes = OnChar(uMsg, wParam, lParam, bHandled); break; case WM_SYSCOMMAND: lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); break; case WM_KEYDOWN: { lRes = OnKeyDown( uMsg,wParam, lParam&0xff, lParam>>16 ,bHandled); break; } case WM_KEYUP: { lRes = OnKeyUp(uMsg, wParam, lParam&0xff, lParam>>16,bHandled ); break; } case WM_SYSKEYDOWN: { lRes=OnSysKeyDown(uMsg,wParam,lParam&0xff,lParam>>16,bHandled); break; } case WM_SYSKEYUP: { lRes=OnSysKeyUp(uMsg,wParam,lParam&0xff,lParam>>16,bHandled); break; } case WM_KILLFOCUS: lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); break; case WM_SETFOCUS: lRes = OnSetFocus(uMsg, wParam, lParam, bHandled); break; case WM_LBUTTONUP: lRes = OnLButtonUp(uMsg, wParam, lParam, bHandled); break; case WM_LBUTTONDOWN: lRes = OnLButtonDown(uMsg, wParam, lParam, bHandled); break; case WM_RBUTTONDOWN: { pt.x = GET_X_LPARAM( lParam ); pt.y = GET_Y_LPARAM( lParam ); lRes = OnRButtonDown(uMsg,wParam,pt,bHandled); break; } case WM_RBUTTONUP: { pt.x = GET_X_LPARAM( lParam ); pt.y = GET_Y_LPARAM( lParam ); lRes = OnRButtonUp(uMsg,wParam,pt,bHandled); break; } case WM_MOUSEMOVE: { pt.x = GET_X_LPARAM( lParam ); pt.y = GET_Y_LPARAM( lParam ); lRes = OnMouseMove(uMsg, wParam, pt, bHandled); break; } case WM_MOUSEHOVER: { lRes = OnMouseHover(uMsg, wParam, lParam, bHandled); break; } #if(WINVER >= 0x0601) case WM_TOUCH: { UINT cInputs = LOWORD(wParam); HTOUCHINPUT hTouchInput=(HTOUCHINPUT)lParam; lRes = OnTouch(uMsg, cInputs, hTouchInput, bHandled); //If the application does not process the message, it must call DefWindowProc if (lRes==FALSE) { ::DefWindowProc(*this,uMsg,wParam,lParam); } break; } #endif #if(WINVER >= 0x0602) case WM_POINTERDOWN: { break; } #endif default: { bHandled = FALSE; break; } } if (bHandled) { return lRes; } lRes = HandleCustomMessage(uMsg, wParam, lParam, bHandled); if(bHandled) { return lRes; } if (m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes)) { return lRes; } return CWindowWnd::HandleMessage(uMsg, wParam, lParam); }
uint32 HeroChart::onMessage(uint32 message, uint32 wParam, uint32 lParam) { switch (message) { case WM_ERASEBKGND: { HDC hDC = (HDC) wParam; SetBkColor(hDC, 0x000000); RECT rc; GetClientRect(hWnd, &rc); ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL); } return TRUE; case WM_PAINT: { PAINTSTRUCT ps; HDC hDC = BeginPaint(hWnd, &ps); HDC hBitmapDC = CreateCompatibleDC(hDC); SetBkColor(hDC, 0x000000); SetBkMode(hDC, OPAQUE); for (int i = 0; i < numTags; i++) { SelectObject(hDC, textTags[i].hFont); SetTextColor(hDC, textTags[i].color); RECT rc = textTags[i].rc; rc.top -= scrollPos; rc.bottom -= scrollPos; DrawText(hDC, textTags[i].text, -1, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } ImageLibrary* ilib = getApp()->getImageLibrary(); SelectObject(hDC, counterFont); SetTextColor(hDC, 0xFFFFFF); for (int i = 0; i < numTaverns; i++) { if (i == curTavern) { RECT rc = taverns[i].rc; rc.top -= scrollPos + 3; rc.bottom -= scrollPos - 3; rc.left -= 3; rc.right += 3; SetBkColor(hDC, taverns[i].color); ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL); SetBkColor(hDC, 0x000000); rc = taverns[i].rc; rc.top -= scrollPos; rc.bottom -= scrollPos; ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL); } for (int h = 0; h < 12; h++) { Dota::Hero* hero = taverns[i].heroes[h]; if (hero) { int x = taverns[i].rc.left + (32 + 2) * (h % 4); int y = taverns[i].rc.top + (32 + 2) * (h / 4); HBITMAP hBitmap = ilib->getBitmap(String::format("big%s", hero->icon)); if (hBitmap) { SelectObject(hBitmapDC, hBitmap); BitBlt(hDC, x, y - scrollPos, 32, 32, hBitmapDC, 0, 0, SRCCOPY); RECT tipRc = {x, y - scrollPos, x + 32, y + 32 - scrollPos}; DrawText(hDC, String::format(" %d ", heroCounter[hero->point]), -1, &tipRc, DT_SINGLELINE | DT_RIGHT | DT_BOTTOM); } } } } DeleteDC(hBitmapDC); EndPaint(hWnd, &ps); } break; case WM_SIZE: { SCROLLINFO si; memset(&si, 0, sizeof si); si.cbSize = sizeof si; si.fMask = SIF_PAGE | SIF_RANGE | SIF_DISABLENOSCROLL; si.nPage = height(); si.nMin = 0; si.nMax = contentHeight; SetScrollInfo(hWnd, SB_VERT, &si, TRUE); } break; case WM_LBUTTONDOWN: { SetFocus(hWnd); int x = GET_X_LPARAM(lParam); int y = GET_Y_LPARAM(lParam) + scrollPos; for (int i = 0; i < numTaverns; i++) { if (x >= taverns[i].rc.left && y >= taverns[i].rc.top && x < taverns[i].rc.right && y < taverns[i].rc.bottom) { if (curTavern >= 0) { RECT rc = taverns[curTavern].rc; rc.left -= 3; rc.top -= scrollPos + 3; rc.right += 3; rc.bottom -= scrollPos - 3; curTavern = i; InvalidateRect(hWnd, &rc, TRUE); } curTavern = i; RECT rc = taverns[i].rc; rc.left -= 3; rc.top -= scrollPos + 3; rc.right += 3; rc.bottom -= scrollPos - 3; InvalidateRect(hWnd, &rc, TRUE); notify(WM_SETTAVERN, i, 0); int hx = (x - taverns[i].rc.left) / (32 + 2); int hy = (y - taverns[i].rc.top) / (32 + 2); int h = hx + hy * 4; if (h >= 0 && h < 12 && taverns[i].heroes[h]) notify(WM_SETHERO, taverns[i].heroes[h]->point, 0); break; } } } return 0; case WM_MOUSEWHEEL: doScroll(scrollPos - GET_WHEEL_DELTA_WPARAM(wParam) * 30 / WHEEL_DELTA); break; case WM_VSCROLL: { SCROLLINFO si; memset(&si, 0, sizeof si); si.cbSize = sizeof si; si.fMask = SIF_ALL; GetScrollInfo(hWnd, SB_VERT, &si); switch (LOWORD(wParam)) { case SB_TOP: si.nPos = si.nMin; break; case SB_BOTTOM: si.nPos = si.nMax; break; case SB_LINEUP: si.nPos--; break; case SB_LINEDOWN: si.nPos++; break; case SB_PAGEUP: si.nPos -= si.nPage; break; case SB_PAGEDOWN: si.nPos += si.nPage; break; case SB_THUMBTRACK: si.nPos = si.nTrackPos; break; } doScroll(si.nPos); } break; default: return M_UNHANDLED; } return 0; }
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hwndLifeForms; static HWND hwndSetBtn; static HWND hwndStartBtn; static HWND hwndStopBtn; static HWND hwndSpeed; static HWND hwndColor; static bool gameOn; static bool drawLifeForms; int iLifeFormIndex; int xMouse; int yMouse; char text[10]; PAINTSTRUCT ps; HPEN hPEN; RECT gameArea = {11, 11, 509, 509}; HDC hdc; switch(message) { case WM_CREATE: // Life form group box CreateWindowEx(0, "Button", "Life Form", WS_VISIBLE | WS_CHILD | BS_GROUPBOX, 520, 40, 170, 90, hwnd, 0, hInstance, NULL); // LIFEFORMS combobox hwndLifeForms = CreateWindow("ComboBox", "", CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE, 530, 65, 150, 25, hwnd, (HMENU)IDC_LIFEFORMS, hInstance, NULL); // SET button hwndSetBtn = CreateWindow("Button", "Set", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 530, 95, 150, 25, hwnd, (HMENU)IDB_SETBTN, hInstance, NULL); // Animation group box CreateWindowEx(0, "Button", "Animation", WS_VISIBLE | WS_CHILD | BS_GROUPBOX, 520, 160, 170, 150, hwnd, 0, hInstance, NULL); // START button hwndStartBtn = CreateWindow("Button", "Start", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 530, 185, 150, 25, hwnd, (HMENU)IDB_STARTBTN, hInstance, NULL); // STOP button hwndStopBtn = CreateWindow("Button", "Stop", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 530, 215, 150, 25, hwnd, (HMENU)IDB_STOPBTN, hInstance, NULL); // Color checkbox hwndColor = CreateWindowEx(0, "Button", "Color", WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX, 530, 245, 150, 20, hwnd, (HMENU)0, hInstance, NULL); // Speed title label CreateWindow("Static", "Speed:", WS_VISIBLE | WS_CHILD, 530, 280, 50, 20, hwnd, 0, hInstance, NULL); // Speed value label hwndSpeed = CreateWindow("Static", "10%", WS_VISIBLE | WS_CHILD | SS_RIGHT, 630, 280, 50, 20, hwnd, 0, hInstance, NULL); // About group box CreateWindowEx(0, "Button", "About", WS_VISIBLE | WS_CHILD | BS_GROUPBOX, 520, 340, 170, 170, hwnd, 0, hInstance, NULL); // About text label CreateWindow("Static", TEXT("\"Game Of Life\"\n\nWindows Programming\nLaboratory #4\n\n(c) Roman Roibu"), WS_VISIBLE | WS_CHILD | SS_CENTER, 530, 370, 150, 120, hwnd, 0, hInstance, NULL); // Add lifeforms to combo-box for(int i = 0; i < NUMLIFEFORMS; i++) { SendMessage(hwndLifeForms, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)lifeforms[i].szLabel); } // Set initial timer SetTimer(hwnd, ID_TIMER, (10000 / gameSpeed), NULL); // Set game booleans drawLifeForms = false; gameOn = false; // Disable Start and Stop buttons EnableWindow(hwndStartBtn, FALSE); EnableWindow(hwndStopBtn, FALSE); // Init Game settings game_of_life_initialize(); return 0; case WM_COMMAND: switch (LOWORD(wParam)) { case IDB_SETBTN: // Get selected life form index iLifeFormIndex = SendMessage(hwndLifeForms, CB_GETCURSEL, (WPARAM)0, (LPARAM)0); // If no item is selected, break imediately if(iLifeFormIndex == CB_ERR) break; // Set game map set_game_map(iLifeFormIndex); // Set user's drawing ability if(iLifeFormIndex == 5) drawLifeForms = true; else drawLifeForms = false; // Draw game map draw_game_map(hwnd, gameArea); // Pause the game, to wait for the start button gameOn = false; // Enable the start button, disable the stop button EnableWindow(hwndStartBtn, TRUE); EnableWindow(hwndStopBtn, FALSE); break; case IDB_STARTBTN: gameOn = true; EnableWindow(hwndStartBtn, FALSE); EnableWindow(hwndStopBtn, TRUE); break; case IDB_STOPBTN: gameOn = false; EnableWindow(hwndStopBtn, FALSE); EnableWindow(hwndStartBtn, TRUE); break; default: DefWindowProc(hwnd, WM_COMMAND, wParam, lParam); break; } return 0; case WM_LBUTTONDOWN: case WM_MOUSEMOVE: xMouse = GET_X_LPARAM(lParam); yMouse = GET_Y_LPARAM(lParam); if((xMouse > 10)&&(xMouse < 510)&& // If inside gameArea horizontally (yMouse > 10)&&(yMouse < 510)&& // And inside gameArea vertically ((message == WM_LBUTTONDOWN)|| // And left button is pressed (wParam == MK_LBUTTON))&& // Or left button is dragged (drawLifeForms)){ // And user is allowed to draw life forms int i = (yMouse - 10) / gamePixel; int j = (xMouse - 10) / gamePixel; if(!gameMap[i][j]) { gameMap[i][j] = 1; draw_game_pixel(hwnd, gameArea, i, j); } } return 0; case WM_MOUSEWHEEL: // Break if speed is MAX or MIN if(GET_WHEEL_DELTA_WPARAM(wParam) < 0) { // wheel rotated forward, away from user if(gameSpeed < 100) gameSpeed += 10; else return 0; } else { // wheel rotated backward, toward user if(gameSpeed > 10) gameSpeed -= 10; else return 0; } // Delete old timer, and create new timer KillTimer(hwnd, ID_TIMER); SetTimer(hwnd, ID_TIMER, (10000 / gameSpeed), NULL); // Update speed label sprintf(text, "%i", gameSpeed); strcat(text, "%"); SendMessage(hwndSpeed, WM_SETTEXT, (WPARAM)0, (LPARAM)text); return 0; case WM_TIMER: addColor = (Button_GetCheck(hwndColor) == BST_CHECKED); if((gameOn)&&(wParam == ID_TIMER)) { // Update game map if(update_game_map()) { // Draw game map, if changes to the map have been made draw_game_map(hwnd, gameArea); } else { // If map is static, stop the execution SendMessage(hwnd, WM_COMMAND, (WPARAM)IDB_STOPBTN, (LPARAM)0); } } break; case WM_PAINT: hdc = BeginPaint(hwnd, &ps); // Draw game area hPEN = CreatePen(PS_SOLID, 1, RGB(0,0,0)); SelectObject(hdc, hPEN); SelectObject(hdc, (HBRUSH)GetStockObject(WHITE_BRUSH)); Rectangle(hdc, 10, 10, 510, 510); DeleteObject(hPEN); EndPaint(hwnd, &ps); return 0; case WM_DESTROY: PostQuitMessage (0); return 0; default: return DefWindowProc (hwnd, message, wParam, lParam); } return 0; }
static LRESULT WINAPI submenuWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { const int itemheight = 12, lcol=12, rcol=12, mcol=10; switch (uMsg) { case WM_CREATE: m_trackingMenus.Add(hwnd); SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); if (m_trackingPar && !(m_trackingFlags&TPM_NONOTIFY)) SendMessage(m_trackingPar,WM_INITMENUPOPUP,(WPARAM)lParam,0); { HDC hdc = GetDC(hwnd); HMENU__ *menu = (HMENU__*)lParam; int ht = menu->items.GetSize()*itemheight, wid=100,wid2=0; int xpos=m_trackingPt.x; int ypos=m_trackingPt.y; int x; for (x=0; x < menu->items.GetSize(); x++) { MENUITEMINFO *inf = menu->items.Get(x); if (inf->fType == MFT_STRING && inf->dwTypeData) { RECT r={0,}; const char *pt2 = strstr(inf->dwTypeData,"\t"); DrawText(hdc,inf->dwTypeData,pt2 ? pt2-inf->dwTypeData : -1,&r,DT_CALCRECT|DT_SINGLELINE); if (r.right > wid) wid=r.right; if (pt2) { r.right=r.left; DrawText(hdc,pt2+1,-1,&r,DT_CALCRECT|DT_SINGLELINE); if (r.right > wid2) wid2=r.right; } } } wid+=lcol+rcol + (wid2?wid2+mcol:0); ReleaseDC(hwnd,hdc); RECT tr={xpos,ypos,xpos+wid,ypos+ht},vp; SWELL_GetViewPort(&vp,&tr,true); if (tr.bottom > vp.bottom) { tr.top += vp.bottom-tr.bottom; tr.bottom=vp.bottom; } if (tr.right > vp.right) { tr.left += vp.right-tr.right; tr.right=vp.right; } if (tr.left < vp.left) { tr.right += vp.left-tr.left; tr.left=vp.left; } if (tr.top < vp.top) { tr.bottom += vp.top-tr.top; tr.top=vp.top; } SetWindowPos(hwnd,NULL,tr.left,tr.top,tr.right-tr.left,tr.bottom-tr.top,SWP_NOZORDER); } SetWindowLong(hwnd,GWL_STYLE,GetWindowLong(hwnd,GWL_STYLE)&~WS_CAPTION); ShowWindow(hwnd,SW_SHOW); SetFocus(hwnd); SetTimer(hwnd,1,250,NULL); break; case WM_PAINT: { PAINTSTRUCT ps; if (BeginPaint(hwnd,&ps)) { RECT cr; GetClientRect(hwnd,&cr); HBRUSH br=CreateSolidBrush(GetSysColor(COLOR_3DFACE)); HPEN pen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DSHADOW)); HGDIOBJ oldbr = SelectObject(ps.hdc,br); HGDIOBJ oldpen = SelectObject(ps.hdc,pen); Rectangle(ps.hdc,cr.left,cr.top,cr.right-1,cr.bottom-1); SetBkMode(ps.hdc,TRANSPARENT); int cols[2]={ GetSysColor(COLOR_BTNTEXT),GetSysColor(COLOR_3DHILIGHT)}; HMENU__ *menu = (HMENU__*)GetWindowLongPtr(hwnd,GWLP_USERDATA); int x; for (x=0; x < menu->items.GetSize(); x++) { MENUITEMINFO *inf = menu->items.Get(x); RECT r={lcol,x*itemheight,cr.right,(x+1)*itemheight}; bool dis = !!(inf->fState & MF_GRAYED); SetTextColor(ps.hdc,cols[dis]); if (inf->fType == MFT_STRING && inf->dwTypeData) { const char *pt2 = strstr(inf->dwTypeData,"\t"); DrawText(ps.hdc,inf->dwTypeData,pt2 ? pt2-inf->dwTypeData : -1,&r,DT_VCENTER|DT_SINGLELINE); if (pt2) { RECT tr=r; tr.right-=rcol; DrawText(ps.hdc,pt2+1,-1,&tr,DT_VCENTER|DT_SINGLELINE|DT_RIGHT); } } else { MoveToEx(ps.hdc,r.left - lcol/2,(r.top+r.bottom)/2,NULL); LineTo(ps.hdc,r.right - rcol*3/2,(r.top+r.bottom)/2); } if (inf->hSubMenu) { RECT r2=r; r2.left = r2.right - rcol; DrawText(ps.hdc,">",-1,&r2,DT_VCENTER|DT_RIGHT|DT_SINGLELINE); } if (inf->fState&MF_CHECKED) { RECT r2=r; r2.left = 0; r2.right=lcol; DrawText(ps.hdc,"X",-1,&r2,DT_VCENTER|DT_CENTER|DT_SINGLELINE); } } SelectObject(ps.hdc,oldbr); SelectObject(ps.hdc,oldpen); DeleteObject(br); DeleteObject(pen); EndPaint(hwnd,&ps); } } break; case WM_TIMER: if (wParam==1) { HWND GetFocusIncludeMenus(); HWND h = GetFocusIncludeMenus(); if (h!=hwnd) { int a = h ? m_trackingMenus.Find(h) : -1; if (a<0 || a < m_trackingMenus.Find(hwnd)) DestroyWindow(hwnd); } } break; case WM_DESTROY: { int a = m_trackingMenus.Find(hwnd); m_trackingMenus.Delete(a); if (m_trackingMenus.Get(a)) DestroyWindow(m_trackingMenus.Get(a)); RemoveProp(hwnd,"SWELL_MenuOwner"); } break; case WM_LBUTTONUP: case WM_RBUTTONUP: { RECT r; GetClientRect(hwnd,&r); if (GET_X_LPARAM(lParam)>=r.left && GET_X_LPARAM(lParam)<r.right) { int which = GET_Y_LPARAM(lParam)/itemheight; HMENU__ *menu = (HMENU__*)GetWindowLongPtr(hwnd,GWLP_USERDATA); MENUITEMINFO *inf = menu->items.Get(which); if (inf) { if (inf->fState&MF_GRAYED){ } else if (inf->hSubMenu) { int a = m_trackingMenus.Find(hwnd); HWND next = m_trackingMenus.Get(a+1); if (next) DestroyWindow(next); m_trackingPt.x=r.right; m_trackingPt.y=r.top + which*itemheight; ClientToScreen(hwnd,&m_trackingPt); HWND hh; submenuWndProc(hh=new HWND__(NULL,0,NULL,"menu",false,submenuWndProc,NULL),WM_CREATE,0,(LPARAM)inf->hSubMenu); SetProp(hh,"SWELL_MenuOwner",GetProp(hh,"SWELL_MenuOwner")); } else if (inf->wID) m_trackingRet = inf->wID; } else DestroyWindow(hwnd); } else DestroyWindow(hwnd); } break; } return DefWindowProc(hwnd,uMsg,wParam,lParam); }
void OpenGLWindow::processEvent(UINT aMessage, WPARAM aWParam, LPARAM aLParam) { switch(aMessage) { case WM_CLOSE: PostQuitMessage(0); break; case WM_SIZE: resize(LOWORD(aLParam), HIWORD(aLParam)); break; case WM_KEYDOWN: InputManager::getInstance()->handleKeyDown(aWParam); break; case WM_KEYUP: //if(aWParam == VK_ESCAPE) //{ // std::string message = "Are you sure you want to exit "; // message.append(WINDOW_TITLE); // message.append("?"); // if(WINDOW_IS_FULLSCREEN == true || MessageBox(NULL, message.c_str(), "Exit", MB_YESNO | MB_ICONQUESTION) == IDYES) // { // exit(0); // } //} //else { InputManager::getInstance()->handleKeyUp(aWParam); } break; case WM_MOUSEMOVE: { // int positionX = GET_X_LPARAM(aLParam); int positionY = GET_Y_LPARAM(aLParam); // if(m_LastMouseX != -1 && m_LastMouseY != -1) { int differenceX = positionX - m_LastMouseX; int differenceY = positionY - m_LastMouseY; InputManager::getInstance()->handleMouseMovement(differenceX, differenceY, positionX, positionY); } // m_LastMouseX = positionX; m_LastMouseY = positionY; } break; case WM_LBUTTONDOWN: { int positionX = GET_X_LPARAM(aLParam); int positionY = GET_Y_LPARAM(aLParam); InputManager::getInstance()->handleMouseLeftClickDown(positionX, positionY); } break; case WM_LBUTTONUP: { int positionX = GET_X_LPARAM(aLParam); int positionY = GET_Y_LPARAM(aLParam); InputManager::getInstance()->handleMouseLeftClickUp(positionX, positionY); } break; case WM_RBUTTONDOWN: { int positionX = GET_X_LPARAM(aLParam); int positionY = GET_Y_LPARAM(aLParam); InputManager::getInstance()->handleMouseRightClickDown(positionX, positionY); } break; case WM_RBUTTONUP: { int positionX = GET_X_LPARAM(aLParam); int positionY = GET_Y_LPARAM(aLParam); InputManager::getInstance()->handleMouseRightClickUp(positionX, positionY); } break; } }
LRESULT kGUISystemWin::Event(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; int key; int newtick,deltatick; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: return DefWindowProc(hWnd, message, wParam, lParam); break; case WM_PAINT: // Get the Windows update region // while(kGUI::GetInDraw()==true || kGUI::GetInThread()==true); // kGUI::SetInDraw(true); GetUpdateRect(hWnd, &m_UpdateWinRect, FALSE); hdc = BeginPaint(hWnd, &ps); Draw(hWnd,m_UpdateWinRect.left,m_UpdateWinRect.right,m_UpdateWinRect.top,m_UpdateWinRect.bottom); EndPaint(hWnd, &ps); // kGUI::SetInDraw(false); break; case WM_TIMER: newtick=GetTickCount(); deltatick=newtick-m_lasttickcount; if(deltatick<0) deltatick=0; m_lasttickcount=newtick; #if DEBUGPRINT kGUI::Trace("Delta tick=%d\n",deltatick); #endif kGUI::Tick(deltatick); if(GetAsyncKeyState(VK_LSHIFT) || GetAsyncKeyState(VK_RSHIFT)) kGUI::SetKeyShift(true); else kGUI::SetKeyShift(false); if(GetAsyncKeyState(VK_CONTROL)) kGUI::SetKeyControl(true); else kGUI::SetKeyControl(false); if(kGUI::GetTempMouse()>=0) { int t=kGUI::GetTempMouse(); kGUI::SetTempMouse(t-1); if(!t) kGUI::SetMouseCursor(MOUSECURSOR_DEFAULT); } if(kGUI::GetMouseCursor()!=MOUSECURSOR_DEFAULT) /* if not default arrow */ kGUI::ChangeMouse(); kGUI::UpdateInput(); m_mousewheeldelta=0; // while(kGUI::GetInDraw()==true || kGUI::GetInThread()==true); // kGUI::SetInDraw(true); Draw(hWnd,0,0,0,0); // kGUI::SetInDraw(false); /* is the application shutting down? */ if(kGUI::IsAppClosed()==true) DestroyWindow(hWnd); else SetTimer(hWnd, 0, 1000 / FRAMES_PER_SECOND, NULL); break; case WM_DESTROY: /* sometimes this event get's called more than once, so allow only once! */ if(m_waskilled==false) { m_waskilled=true; AppClose(); kGUI::Close(); PostQuitMessage(0); WSACleanup(); } break; case WM_MOUSEWHEEL: //values are increments of 120 m_mousewheeldelta = GET_WHEEL_DELTA_WPARAM(wParam)/120; kGUI::SetMouse(m_mousex,m_mousey,m_mousewheeldelta,m_mouseleftbutton,m_mouserightbutton); break; case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_MOUSEMOVE: if(kGUI::GetMouseCursor()!=MOUSECURSOR_DEFAULT) /* if not default arrow */ kGUI::ChangeMouse(); m_mousex=GET_X_LPARAM(lParam); m_mousey=GET_Y_LPARAM(lParam); m_mouseleftbutton=(wParam&MK_LBUTTON)!=0; m_mouserightbutton=(wParam&MK_RBUTTON)!=0; /* this tells windows to keep updating me even if the mouse is moved off of */ /* my window area */ if(m_mouseleftbutton || m_mouserightbutton) SetCapture(hWnd); else ReleaseCapture(); kGUI::SetMouse(m_mousex,m_mousey,m_mousewheeldelta,m_mouseleftbutton,m_mouserightbutton); kGUI::Tick(0); kGUI::UpdateInput(); return DefWindowProc(hWnd, message, wParam, lParam); break; case WM_CHAR: key=(int)wParam; switch(key) { case 1: //'ctrl-a' key=GUIKEY_SELECTALL; break; case 3: //'ctrl-c' key=GUIKEY_COPY; break; case 6: //'ctrl-f' key=GUIKEY_FIND; break; // case 8: //'ctrl-h' // key=GUIKEY_REPLACE; // break; case 22: //'ctrl-v' key=GUIKEY_PASTE; break; case 24: //'ctrl-x' key=GUIKEY_CUT; break; case 26: //'ctrl-z' key=GUIKEY_UNDO; break; case 187: //'ctrl +' key=GUIKEY_CTRL_PLUS; break; case 189: //'ctrl -' key=GUIKEY_CTRL_MINUS; break; case VK_BACK: key=GUIKEY_BACKSPACE; break; case VK_RETURN: key=GUIKEY_RETURN; break; case VK_TAB: if(GetAsyncKeyState(VK_LSHIFT) || GetAsyncKeyState(VK_RSHIFT)) key=GUIKEY_SHIFTTAB; else key=GUIKEY_TAB; break; case VK_ESCAPE: key=GUIKEY_ESC; break; case VK_SHIFT: case VK_CONTROL: key=0; break; } if(key) kGUI::KeyPressed(key); break; case WM_KEYDOWN: key=ConvertKey((int)wParam,0); if(key) kGUI::KeyPressed(key); key=ConvertKey((int)wParam,(int)wParam); if(key) kGUI::SetKeyState(key,true); break; case WM_KEYUP: key=ConvertKey((int)wParam,(int)wParam); if(key) kGUI::SetKeyState(key,false); break; default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; }
LRESULT CALLBACK WndProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) { C_Window* win = (C_Window*)((void*)GetWindowLongPtr(wnd, GWLP_USERDATA)); //if(win!=0 && win->m_oldp != 0) //{ // win->m_oldp(wnd, msg, wParam, lParam); //} if(msg == WM_SIZE) { win->OnResize(); } else if(msg == WM_ACTIVATE) { if(LOWORD(wParam)) win->OnFocus(); if(!LOWORD(wParam)) win->OnLostFocus(); } else if(msg == WM_PAINT) { win->OnPaint(); } else if(msg == WM_CLOSE || msg == WM_DESTROY) { win->OnClose(); } else if(msg == WM_SHOWWINDOW) { win->OnVisible(); } else if(msg == WM_LBUTTONDOWN || msg == WM_RBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_XBUTTONDOWN) { unsigned int button = 0; switch(msg) { case WM_LBUTTONDOWN: button = KEY_LBUTTON; break; case WM_RBUTTONDOWN: button = KEY_RBUTTON; break; case WM_MBUTTONDOWN: button = KEY_MBUTTON; break; case WM_XBUTTONDOWN: if(HIWORD(wParam) == XBUTTON1) { button = KEY_XBUTTON1; } else if(HIWORD(wParam) == XBUTTON2) { button = KEY_XBUTTON2; } break; } win->MouseDown(button, LOWORD(wParam), PointI(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); } else if(msg == WM_LBUTTONUP || msg == WM_RBUTTONUP || msg == WM_MBUTTONUP || msg == WM_XBUTTONUP) { unsigned int button = 0; switch(msg) { case WM_LBUTTONUP: button = KEY_LBUTTON; break; case WM_RBUTTONUP: button = KEY_RBUTTON; break; case WM_MBUTTONUP: button = KEY_MBUTTON; break; case WM_XBUTTONUP: if(HIWORD(wParam) == XBUTTON1) { button = KEY_XBUTTON1; } else if(HIWORD(wParam) == XBUTTON2) { button = KEY_XBUTTON2; } break; } win->MouseUp(button, LOWORD(wParam), PointI(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); } else if(msg == WM_LBUTTONDBLCLK || msg == WM_RBUTTONDBLCLK || msg == WM_MBUTTONDBLCLK || msg == WM_XBUTTONDBLCLK) { unsigned int button = 0; switch(msg) { case WM_LBUTTONDBLCLK: button = KEY_LBUTTON; break; case WM_RBUTTONDBLCLK: button = KEY_RBUTTON; break; case WM_MBUTTONDBLCLK: button = KEY_MBUTTON; break; case WM_XBUTTONDBLCLK: if(HIWORD(wParam) == XBUTTON1) { button = KEY_XBUTTON1; } else if(HIWORD(wParam) == XBUTTON2) { button = KEY_XBUTTON2; } break; } win->MouseDblClick(button, LOWORD(wParam), PointI(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); } else if(msg == WM_MOUSEMOVE) { win->MouseMove(PointI(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); } else if(msg == WM_MOUSEWHEEL) { win->MouseWheel( short(HIWORD(wParam)) / WHEEL_DELTA, LOWORD(wParam), PointI(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); } else if(msg == WM_KEYDOWN) { win->KeyDown(wParam); if(isascii(wParam) && wParam != VK_RETURN && wParam != VK_DELETE && wParam != VK_CLEAR && wParam != VK_TAB) { win->KeyChar(static_cast<wchar_t>(wParam)); } } else if(msg == WM_KEYUP) { win->KeyUp(wParam); } else if(msg == WM_CHAR) { win->KeyChar(static_cast<wchar_t>(wParam)); } return DefWindowProc(wnd, msg, wParam, lParam); }
LRESULT CALLBACK GdiTableVis::WinProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { HDC hDC; PAINTSTRUCT Ps; HBRUSH tmpBrush; RECT rect = { 0 }; switch(Msg) { case WM_CREATE: break; case WM_ERASEBKGND: { GetClientRect(hWnd, &rect); hDC = (HDC)wParam; tmpBrush = CreateSolidBrush(COLORREF(RGB(0,0,0))); FillRect(hDC, &rect, tmpBrush); DeleteObject(tmpBrush); } break; case WM_PAINT: { GetClientRect(hWnd, &rect); hDC = BeginPaint(hWnd, &Ps); if(gdiObjectsX64.size() > 0) { for (std::vector<GDICELL_64>::iterator iter = gdiObjectsX64.begin(); iter != gdiObjectsX64.end(); ++iter) { DWORD index = (DWORD)(iter - gdiObjectsX64.begin()); tmpBrush = CreateSolidBrush(GetCellColor(LOBYTE(iter->wType))); // get a RECT from table index RectFromIndex(hWnd, index, (DWORD)gdiObjectsX64.size(), &rect, 1); FillRect(hDC, &rect, tmpBrush); DeleteObject(tmpBrush); } } EndPaint(hWnd, &Ps); } break; case WM_DESTROY: PostQuitMessage(int(lParam)); break; case WM_MOUSEHOVER: break; case WM_MOUSELEAVE: // The mouse pointer has left our window. Deactivate the tooltip. SendMessage(hWndToolTip, TTM_TRACKACTIVATE, (WPARAM)FALSE, (LPARAM)&_toolInfo); bTrackingMouse = FALSE; ShowWindow(hWndToolTip, SW_HIDE); break; case WM_MOUSEMOVE: { static int oldX, oldY; int newX, newY; if (!bTrackingMouse) { TrackMouse(); // Activate the tooltip. SendMessage(hWndToolTip, TTM_TRACKACTIVATE, (WPARAM)TRUE, (LPARAM)&_toolInfo); } newX = GET_X_LPARAM(lParam); newY = GET_Y_LPARAM(lParam); // greedy update for tooltip if ((newX != oldX) || (newY != oldY)) { DWORD index = CoordToIndex(hWnd, newX, newY, (DWORD)gdiObjectsX64.size()); if((index > gdiObjectsX64.size()-1) || (gdiObjectsX64.size() == 0)) { ShowWindow(hWndToolTip, SW_HIDE); break; } else { ShowWindow(hWndToolTip, SW_SHOW); oldX = newX; oldY = newY; WCHAR coords[0x100]; swprintf_s(coords, ARRAYSIZE(coords), L"%016I64X", gdiObjectsX64.at(index).pKernelAddress); _toolInfo.lpszText = coords; RECT _rect; GetGridRect(hWnd, (DWORD)gdiObjectsX64.size(), &_rect); _toolInfo.rect = _rect; SendMessage(hWndToolTip, TTM_SETTOOLINFO, 0, (LPARAM)&_toolInfo); POINT pt = { newX, newY }; ClientToScreen(hWnd, &pt); SendMessage(hWndToolTip, TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(pt.x + 10, pt.y - 20)); } } } break; case WM_LBUTTONDOWN: { POINT point; GetCursorPos(&point); ScreenToClient(hWnd, &point); DWORD index = 0; if(gdiObjectsX64.size() > 0) { index = CoordToIndex(hWnd, point.x, point.y, (DWORD)gdiObjectsX64.size()); if(index > (DWORD)gdiObjectsX64.size()-1) break; DumpBase(index); } } break; default: return DefWindowProc(hWnd, Msg, wParam, lParam); } return 0; }
LRESULT CTabPanelWin::ReBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, WNDPROC defaultProc) { int nOverTabHit = -1; switch (uMsg) { case WM_WINDOWPOSCHANGING: { LPWINDOWPOS pos = (LPWINDOWPOS)lParam; if (mn_TabHeight) { pos->cy = mn_TabHeight; return 0; } break; } case WM_WINDOWPOSCHANGED: { #ifdef _DEBUG LPWINDOWPOS pos = (LPWINDOWPOS)lParam; #endif break; } case WM_SETFOCUS: { gpConEmu->setFocus(); return 0; } case WM_SETCURSOR: { if (OnSetCursorRebar()) return TRUE; break; } case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_RBUTTONDBLCLK: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_MBUTTONDBLCLK: { if (gpSet->isTabs) { if (TabHitTest(true, &nOverTabHit) == HTCAPTION) { OnMouseRebar(uMsg, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); } else if (nOverTabHit >= 0) { POINT ptTab = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; if (uMsg != WM_MOUSEWHEEL || uMsg != WM_MOUSEHWHEEL) MapWindowPoints(mh_Rebar, mh_Tabbar, &ptTab, 1); OnMouseTabbar(uMsg, nOverTabHit, ptTab.x, ptTab.y); } } return 0; } // End of mouse messages } return CallWindowProc(defaultProc, hwnd, uMsg, wParam, lParam); }
LRESULT APIENTRY ListBoxWndProcWorker( PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam, DWORD fAnsi) { HWND hwnd = HWq(pwnd); PAINTSTRUCT ps; HDC hdc; LPRECT lprc; PLBIV plb; /* List Box Instance Variable */ INT iSel; /* Index of selected item */ DWORD dw; TL tlpwndParent; UINT wFlags; LPWSTR lpwsz = NULL; LRESULT lReturn = 0; static BOOL fInit = TRUE; CheckLock(pwnd); VALIDATECLASSANDSIZE(pwnd, FNID_LISTBOX); INITCONTROLLOOKASIDE(&ListboxLookaside, LBIV, spwnd, 4); /* * Get the plb for the given window now since we will use it a lot in * various handlers. This was stored using SetWindowLong(hwnd,0,plb) * when the listbox was first created (by INITCONTROLLOOKASIDE above) */ plb = ((PLBWND)pwnd)->pLBIV; /* * Handle ANSI translations of input parameters */ if (fAnsi) { switch (message) { case LB_ADDSTRING: case LB_ADDSTRINGUPPER: case LB_ADDSTRINGLOWER: case LB_FINDSTRING: case LB_FINDSTRINGEXACT: case LB_INSERTSTRING: case LB_INSERTSTRINGUPPER: case LB_INSERTSTRINGLOWER: case LB_SELECTSTRING: if (!plb->fHasStrings) { break; } // Fall through... case LB_ADDFILE: case LB_DIR: if (lParam) { if (!MBToWCS((LPSTR)lParam, -1, &lpwsz, -1, TRUE)) return LB_ERR; } break; default: break; } if (lpwsz) { lParam = (LPARAM)lpwsz; } } switch (message) { case LB_GETTOPINDEX: // Return index of top item displayed. return plb->iTop; case LB_SETTOPINDEX: if (wParam && ((INT)wParam < 0 || (INT)wParam >= plb->cMac)) { RIPERR0(ERROR_INVALID_INDEX, RIP_VERBOSE, ""); return LB_ERR; } if (plb->cMac) { xxxNewITop(plb, (INT)wParam); } break; case WM_STYLECHANGED: plb->fRtoLReading = (TestWF(pwnd, WEFRTLREADING) != 0); plb->fRightAlign = (TestWF(pwnd, WEFRIGHT) != 0); xxxCheckRedraw(plb, FALSE, 0); break; case WM_WINDOWPOSCHANGED: /* * If we are in the middle of creation, ignore this * message because it will generate a WM_SIZE message. * See xxxLBCreate(). */ if (!plb->fIgnoreSizeMsg) goto CallDWP; break; case WM_SIZE: /* * If we are in the middle of creation, ignore size * messages. See xxxLBCreate(). */ if (!plb->fIgnoreSizeMsg) xxxLBSize(plb, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break; case WM_ERASEBKGND: ThreadLock(plb->spwndParent, &tlpwndParent); FillWindow(HW(plb->spwndParent), hwnd, (HDC)wParam, (HBRUSH)CTLCOLOR_LISTBOX); ThreadUnlock(&tlpwndParent); return TRUE; case LB_RESETCONTENT: xxxLBResetContent(plb); break; case WM_TIMER: if (wParam == IDSYS_LBSEARCH) { plb->iTypeSearch = 0; NtUserKillTimer(hwnd, IDSYS_LBSEARCH); xxxInvertLBItem(plb, plb->iSel, TRUE); break; } message = WM_MOUSEMOVE; xxxTrackMouse(plb, message, plb->ptPrev); break; /* * Fall through */ case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: { POINT pt; POINTSTOPOINT(pt, lParam); xxxTrackMouse(plb, message, pt); } break; case WM_MBUTTONDOWN: EnterReaderModeHelper(hwnd); break; case WM_CAPTURECHANGED: // // Note that this message should be handled only on unexpected // capture changes currently. // UserAssert(TestWF(pwnd, WFWIN40COMPAT)); if (plb->fCaptured) xxxLBButtonUp(plb, LBUP_NOTIFY); break; case LBCB_STARTTRACK: // // Start tracking mouse moves in the listbox, setting capture // if (!plb->pcbox) break; plb->fCaptured = FALSE; if (wParam) { POINT pt; POINTSTOPOINT(pt, lParam); _ScreenToClient(pwnd, &pt); xxxTrackMouse(plb, WM_LBUTTONDOWN, pt); } else { NtUserSetCapture(hwnd); plb->fCaptured = TRUE; plb->iLastSelection = plb->iSel; } break; case LBCB_ENDTRACK: // Kill capture, tracking, etc. if (plb->fCaptured) xxxLBButtonUp(plb, LBUP_RELEASECAPTURE | (wParam ? LBUP_SELCHANGE : LBUP_RESETSELECTION)); break; case WM_PRINTCLIENT: xxxLBPaint(plb, (HDC) wParam, NULL); break; case WM_PAINT: if (wParam) { hdc = (HDC) wParam; lprc = NULL; } else { hdc = NtUserBeginPaint(hwnd, &ps); lprc = &(ps.rcPaint); } if (IsLBoxVisible(plb)) xxxLBPaint(plb, hdc, lprc); if (!wParam) NtUserEndPaint(hwnd, &ps); break; case WM_NCDESTROY: case WM_FINALDESTROY: xxxDestroyLBox(plb, pwnd); break; case WM_SETFOCUS: // DISABLED in Win 3.1 xxxUpdateWindow(pwnd); CaretCreate(plb); xxxLBSetCaret(plb, TRUE); xxxNotifyOwner(plb, LBN_SETFOCUS); if (FWINABLE()) { if (_IsWindowVisible(pwnd)) { LBEvent(plb, EVENT_OBJECT_FOCUS, plb->iSelBase); } } break; case WM_KILLFOCUS: /* * Reset the wheel delta count. */ gcWheelDelta = 0; xxxLBSetCaret(plb, FALSE); xxxCaretDestroy(plb); xxxNotifyOwner(plb, LBN_KILLFOCUS); if (plb->iTypeSearch) { plb->iTypeSearch = 0; NtUserKillTimer(hwnd, IDSYS_LBSEARCH); } if (plb->pszTypeSearch) { UserLocalFree(plb->pszTypeSearch); plb->pszTypeSearch = NULL; } break; case WM_MOUSEWHEEL: { int cDetants; int cPage; int cLines; RECT rc; int windowWidth; int cPos; /* * Don't handle zoom and datazoom. */ if (wParam & (MK_SHIFT | MK_CONTROL)) { goto CallDWP; } lReturn = 1; gcWheelDelta -= (short) HIWORD(wParam); cDetants = gcWheelDelta / WHEEL_DELTA; if ( cDetants != 0 && gpsi->ucWheelScrollLines > 0 && (pwnd->style & (WS_VSCROLL | WS_HSCROLL))) { gcWheelDelta = gcWheelDelta % WHEEL_DELTA; if (pwnd->style & WS_VSCROLL) { cPage = max(1, (plb->cItemFullMax - 1)); cLines = cDetants * (int) min((UINT) cPage, gpsi->ucWheelScrollLines); cPos = max(0, min(plb->iTop + cLines, plb->cMac - 1)); if (cPos != plb->iTop) { xxxLBoxCtlScroll(plb, SB_THUMBPOSITION, cPos); xxxLBoxCtlScroll(plb, SB_ENDSCROLL, 0); } } else if (plb->fMultiColumn) { cPage = max(1, plb->numberOfColumns); cLines = cDetants * (int) min((UINT) cPage, gpsi->ucWheelScrollLines); cPos = max( 0, min((plb->iTop / plb->itemsPerColumn) + cLines, plb->cMac - 1 - ((plb->cMac - 1) % plb->itemsPerColumn))); if (cPos != plb->iTop) { xxxLBoxCtlHScrollMultiColumn(plb, SB_THUMBPOSITION, cPos); xxxLBoxCtlHScrollMultiColumn(plb, SB_ENDSCROLL, 0); } } else { _GetClientRect(plb->spwnd, &rc); windowWidth = rc.right; cPage = max(plb->cxChar, (windowWidth / 3) * 2) / plb->cxChar; cLines = cDetants * (int) min((UINT) cPage, gpsi->ucWheelScrollLines); cPos = max( 0, min(plb->xOrigin + (cLines * plb->cxChar), plb->maxWidth)); if (cPos != plb->xOrigin) { xxxLBoxCtlHScroll(plb, SB_THUMBPOSITION, cPos); xxxLBoxCtlHScroll(plb, SB_ENDSCROLL, 0); } } } } break; case WM_VSCROLL: xxxLBoxCtlScroll(plb, LOWORD(wParam), HIWORD(wParam)); break; case WM_HSCROLL: xxxLBoxCtlHScroll(plb, LOWORD(wParam), HIWORD(wParam)); break; case WM_GETDLGCODE: return DLGC_WANTARROWS | DLGC_WANTCHARS; case WM_CREATE: return xxxLBCreate(plb, pwnd, (LPCREATESTRUCT) lParam); case WM_SETREDRAW: /* * If wParam is nonzero, the redraw flag is set * If wParam is zero, the flag is cleared */ xxxLBSetRedraw(plb, (wParam != 0)); break; case WM_ENABLE: xxxLBInvalidateRect(plb, NULL, !plb->OwnerDraw); break; case WM_SETFONT: xxxLBSetFont(plb, (HANDLE)wParam, LOWORD(lParam)); break; case WM_GETFONT: return (LRESULT)plb->hFont; case WM_DRAGSELECT: case WM_DRAGLOOP: case WM_DRAGMOVE: case WM_DROPFILES: ThreadLock(plb->spwndParent, &tlpwndParent); lReturn = SendMessage(HW(plb->spwndParent), message, wParam, lParam); ThreadUnlock(&tlpwndParent); return lReturn; case WM_QUERYDROPOBJECT: case WM_DROPOBJECT: /* * fix up control data, then pass message to parent */ LBDropObjectHandler(plb, (PDROPSTRUCT)lParam); ThreadLock(plb->spwndParent, &tlpwndParent); lReturn = SendMessage(HW(plb->spwndParent), message, wParam, lParam); ThreadUnlock(&tlpwndParent); return lReturn; case LB_GETITEMRECT: return LBGetItemRect(plb, (INT)wParam, (LPRECT)lParam); case LB_GETITEMDATA: return LBGetItemData(plb, (INT)wParam); // wParam = item index case LB_SETITEMDATA: /* * wParam is item index */ return LBSetItemData(plb, (INT)wParam, lParam); case LB_ADDSTRINGUPPER: wFlags = UPPERCASE | LBI_ADD; goto CallInsertItem; case LB_ADDSTRINGLOWER: wFlags = LOWERCASE | LBI_ADD; goto CallInsertItem; case LB_ADDSTRING: wFlags = LBI_ADD; goto CallInsertItem; case LB_INSERTSTRINGUPPER: wFlags = UPPERCASE; goto CallInsertItem; case LB_INSERTSTRINGLOWER: wFlags = LOWERCASE; goto CallInsertItem; case LB_INSERTSTRING: wFlags = 0; CallInsertItem: lReturn = ((LRESULT) xxxLBInsertItem(plb, (LPWSTR) lParam, (int) wParam, wFlags)); break; case LB_INITSTORAGE: return xxxLBInitStorage(plb, fAnsi, (INT)wParam, (INT)lParam); case LB_DELETESTRING: return xxxLBoxCtlDelete(plb, (INT)wParam); case LB_DIR: /* * wParam - Dos attribute value. * lParam - Points to a file specification string */ lReturn = xxxLbDir(plb, (INT)wParam, (LPWSTR)lParam); break; case LB_ADDFILE: lReturn = xxxLbInsertFile(plb, (LPWSTR)lParam); break; case LB_SETSEL: return xxxLBSetSel(plb, (wParam != 0), (INT)lParam); case LB_SETCURSEL: /* * If window obscured, update so invert will work correctly */ // DISABLED in Win 3.1 xxxUpdateWindow(pwnd); return xxxLBSetCurSel(plb, (INT)wParam); case LB_GETSEL: if (wParam >= (UINT) plb->cMac) return((LRESULT) LB_ERR); return IsSelected(plb, (INT)wParam, SELONLY); case LB_GETCURSEL: if (plb->wMultiple == SINGLESEL) { return plb->iSel; } return plb->iSelBase; case LB_SELITEMRANGE: if (plb->wMultiple == SINGLESEL) { /* * Can't select a range if only single selections are enabled */ RIPERR0(ERROR_INVALID_INDEX, RIP_VERBOSE,"Invalid index passed to LB_SELITEMRANGE"); return LB_ERR; } xxxLBSelRange(plb, LOWORD(lParam), HIWORD(lParam), (wParam != 0)); break; case LB_SELITEMRANGEEX: if (plb->wMultiple == SINGLESEL) { /* * Can't select a range if only single selections are enabled */ RIPERR0(ERROR_INVALID_LB_MESSAGE, RIP_VERBOSE,"LB_SELITEMRANGEEX:Can't select a range if only single selections are enabled"); return LB_ERR; } else { BOOL fHighlight = ((DWORD)lParam > (DWORD)wParam); if (fHighlight == FALSE) { ULONG_PTR temp = lParam; lParam = wParam; wParam = temp; } xxxLBSelRange(plb, (INT)wParam, (INT)lParam, fHighlight); } break; case LB_GETTEXTLEN: if (lParam != 0) { RIPMSG1(RIP_WARNING, "LB_GETTEXTLEN with lParam = %lx\n", lParam); } lReturn = LBGetText(plb, TRUE, fAnsi, (INT)wParam, NULL); break; case LB_GETTEXT: lReturn = LBGetText(plb, FALSE, fAnsi, (INT)wParam, (LPWSTR)lParam); break; case LB_GETCOUNT: // Lotus Approach calls CallWndProc(ListWndProc, LB_GETCOUNT,...) // on a window that doesn't have a plb yet. So, we need to make // this check. Bug #6675 - 11/7/94 -- if(plb) return((LRESULT) plb->cMac); else return(0); case LB_SETCOUNT: return xxxLBSetCount(plb, (INT)wParam); case LB_SELECTSTRING: case LB_FINDSTRING: iSel = xxxFindString(plb, (LPWSTR)lParam, (INT)wParam, PREFIX, TRUE); if (message == LB_FINDSTRING || iSel == LB_ERR) { lReturn = iSel; } else { lReturn = xxxLBSetCurSel(plb, iSel); } break; case LB_GETLOCALE: return plb->dwLocaleId; case LB_SETLOCALE: /* * Validate locale */ wParam = ConvertDefaultLocale((LCID)wParam); if (!IsValidLocale((LCID)wParam, LCID_INSTALLED)) return LB_ERR; dw = plb->dwLocaleId; plb->dwLocaleId = (DWORD)wParam; return dw; case WM_KEYDOWN: /* * IanJa: Use LOWORD() to get low 16-bits of wParam - this should * work for Win16 & Win32. The value obtained is the virtual key */ xxxLBoxCtlKeyInput(plb, message, LOWORD(wParam)); break; case WM_CHAR: xxxLBoxCtlCharInput(plb, LOWORD(wParam), fAnsi); break; case LB_GETSELITEMS: case LB_GETSELCOUNT: /* * IanJa/Win32 should this be LPWORD now? */ return LBoxGetSelItems(plb, (message == LB_GETSELCOUNT), (INT)wParam, (LPINT)lParam); case LB_SETTABSTOPS: /* * IanJa/Win32: Tabs given by array of INT for backwards compatability */ return LBSetTabStops(plb, (INT)wParam, (LPINT)lParam); case LB_GETHORIZONTALEXTENT: /* * Return the max width of the listbox used for horizontal scrolling */ return plb->maxWidth; case LB_SETHORIZONTALEXTENT: /* * Set the max width of the listbox used for horizontal scrolling */ if (plb->maxWidth != (INT)wParam) { plb->maxWidth = (INT)wParam; /* * When horizontal extent is set, Show/hide the scroll bars. * NOTE: LBShowHideScrollBars() takes care if Redraw is OFF. * Fix for Bug #2477 -- 01/14/91 -- SANKAR -- */ xxxLBShowHideScrollBars(plb); //Try to show or hide scroll bars if (plb->fHorzBar && plb->fRightAlign && !(plb->fMultiColumn || plb->OwnerDraw)) { /* * origin to right */ xxxLBoxCtlHScroll(plb, SB_BOTTOM, 0); } } break; /* originally returned register ax (message) ! */ case LB_SETCOLUMNWIDTH: /* * Set the width of a column in a multicolumn listbox */ plb->cxColumn = (INT)wParam; LBCalcItemRowsAndColumns(plb); if (IsLBoxVisible(plb)) NtUserInvalidateRect(hwnd, NULL, TRUE); xxxLBShowHideScrollBars(plb); break; case LB_SETANCHORINDEX: if ((INT)wParam >= plb->cMac) { RIPERR0(ERROR_INVALID_INDEX, RIP_VERBOSE,"Invalid index passed to LB_SETANCHORINDEX"); return LB_ERR; } plb->iMouseDown = (INT)wParam; plb->iLastMouseMove = (INT)wParam; xxxInsureVisible(plb, (int) wParam, (BOOL)(lParam != 0)); break; case LB_GETANCHORINDEX: return plb->iMouseDown; case LB_SETCARETINDEX: if ( (plb->iSel == -1) || ((plb->wMultiple != SINGLESEL) && (plb->cMac > (INT)wParam))) { /* * Set's the iSelBase to the wParam * if lParam, then don't scroll if partially visible * else scroll into view if not fully visible */ xxxInsureVisible(plb, (INT)wParam, (BOOL)LOWORD(lParam)); xxxSetISelBase(plb, (INT)wParam); break; } else { if ((INT)wParam >= plb->cMac) { RIPERR0(ERROR_INVALID_INDEX, RIP_VERBOSE,"Invalid index passed to LB_SETCARETINDEX"); } return LB_ERR; } break; case LB_GETCARETINDEX: return plb->iSelBase; case LB_SETITEMHEIGHT: case LB_GETITEMHEIGHT: return LBGetSetItemHeightHandler(plb, message, (INT)wParam, LOWORD(lParam)); break; case LB_FINDSTRINGEXACT: lReturn = xxxFindString(plb, (LPWSTR)lParam, (INT)wParam, EQ, TRUE); break; case LB_ITEMFROMPOINT: { POINT pt; BOOL bOutside; DWORD dwItem; POINTSTOPOINT(pt, lParam); bOutside = ISelFromPt(plb, pt, &dwItem); UserAssert(bOutside == 1 || bOutside == 0); return (LRESULT)MAKELONG(dwItem, bOutside); } case LBCB_CARETON: /* * Internal message for combo box support */ CaretCreate(plb); // Set up the caret in the proper location for drop downs. plb->iSelBase = plb->iSel; xxxLBSetCaret(plb, TRUE); if (FWINABLE()) { if (_IsWindowVisible(pwnd)) { LBEvent(plb, EVENT_OBJECT_FOCUS, plb->iSelBase); } } return(plb->iSel); case LBCB_CARETOFF: /* * Internal message for combo box support */ xxxLBSetCaret(plb, FALSE); xxxCaretDestroy(plb); break; case WM_NCCREATE: if ((pwnd->style & LBS_MULTICOLUMN) && (pwnd->style & WS_VSCROLL)) { DWORD mask = WS_VSCROLL; DWORD flags = 0; if (!TestWF(pwnd, WFWIN40COMPAT)) { mask |= WS_HSCROLL; flags = WS_HSCROLL; } NtUserAlterWindowStyle(hwnd, mask, flags); } goto CallDWP; default: CallDWP: return DefWindowProcWorker(pwnd, message, wParam, lParam, fAnsi); } /* * Handle translation of ANSI output data and free buffer */ if (lpwsz) { UserLocalFree(lpwsz); } return lReturn; }
static LRESULT CALLBACK MonthCalWndProc(IN HWND hwnd, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam) { PMONTHCALWND infoPtr; LRESULT Ret = 0; infoPtr = (PMONTHCALWND)GetWindowLongPtrW(hwnd, 0); if (infoPtr == NULL && uMsg != WM_CREATE) { goto HandleDefaultMessage; } switch (uMsg) { #if MONTHCAL_CTRLBG != MONTHCAL_DISABLED_CTRLBG case WM_ERASEBKGND: Ret = !infoPtr->Enabled; break; #endif case WM_PAINT: case WM_PRINTCLIENT: { if (infoPtr->CellSize.cx != 0 && infoPtr->CellSize.cy != 0) { PAINTSTRUCT ps; HDC hDC; if (wParam != 0) { if (!GetUpdateRect(hwnd, &ps.rcPaint, TRUE)) { break; } hDC = (HDC)wParam; } else { hDC = BeginPaint(hwnd, &ps); if (hDC == NULL) { break; } } MonthCalPaint(infoPtr, hDC, &ps.rcPaint); if (wParam == 0) { EndPaint(hwnd, &ps); } } break; } case WM_LBUTTONDBLCLK: case WM_LBUTTONDOWN: { WORD SelDay; SelDay = MonthCalPtToDay(infoPtr, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); if (SelDay != 0 && SelDay != infoPtr->Day) { MonthCalSetDate(infoPtr, SelDay, infoPtr->Month, infoPtr->Year); } /* Fall through */ } case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: { if (!infoPtr->HasFocus) { SetFocus(hwnd); } break; } case WM_KEYDOWN: { WORD NewDay = 0; switch (wParam) { case VK_UP: { if (infoPtr->Day > 7) { NewDay = infoPtr->Day - 7; } break; } case VK_DOWN: { if (infoPtr->Day + 7 <= MonthCalMonthLength(infoPtr->Month, infoPtr->Year)) { NewDay = infoPtr->Day + 7; } break; } case VK_LEFT: { if (infoPtr->Day > 1) { NewDay = infoPtr->Day - 1; } break; } case VK_RIGHT: { if (infoPtr->Day < MonthCalMonthLength(infoPtr->Month, infoPtr->Year)) { NewDay = infoPtr->Day + 1; } break; } } /* Update the selection */ if (NewDay != 0) { MonthCalSetDate(infoPtr, NewDay, infoPtr->Month, infoPtr->Year); } goto HandleDefaultMessage; } case WM_GETDLGCODE: { INT virtKey; virtKey = (lParam != 0 ? (INT)((LPMSG)lParam)->wParam : 0); switch (virtKey) { case VK_TAB: { /* Change the UI status */ SendMessageW(GetAncestor(hwnd, GA_PARENT), WM_CHANGEUISTATE, MAKEWPARAM(UIS_INITIALIZE, 0), 0); break; } } Ret |= DLGC_WANTARROWS; break; } case WM_SETFOCUS: { infoPtr->HasFocus = TRUE; MonthCalRepaintDay(infoPtr, infoPtr->Day); break; } case WM_KILLFOCUS: { infoPtr->HasFocus = FALSE; MonthCalRepaintDay(infoPtr, infoPtr->Day); break; } case WM_UPDATEUISTATE: { DWORD OldUIState; Ret = DefWindowProcW(hwnd, uMsg, wParam, lParam); OldUIState = infoPtr->UIState; switch (LOWORD(wParam)) { case UIS_SET: infoPtr->UIState |= HIWORD(wParam); break; case UIS_CLEAR: infoPtr->UIState &= ~HIWORD(wParam); break; } if (infoPtr->UIState != OldUIState) { MonthCalRepaintDay(infoPtr, infoPtr->Day); } break; } case MCCM_SETDATE: { WORD Day, Month, Year, DaysCount; Day = LOWORD(wParam); Month = HIWORD(wParam); Year = LOWORD(lParam); if (Day == (WORD)-1) Day = infoPtr->Day; if (Month == (WORD)-1) Month = infoPtr->Month; if (Year == (WORD)-1) Year = infoPtr->Year; DaysCount = MonthCalMonthLength(Month, Year); if (Day > DaysCount) Day = DaysCount; if (MonthCalValidDate(Day, Month, Year)) { if (Day != infoPtr->Day || Month != infoPtr->Month || Year != infoPtr->Year) { Ret = MonthCalSetDate(infoPtr, Day, Month, Year); } } break; } case MCCM_GETDATE: { LPSYSTEMTIME lpSystemTime = (LPSYSTEMTIME)wParam; lpSystemTime->wYear = infoPtr->Year; lpSystemTime->wMonth = infoPtr->Month; lpSystemTime->wDay = infoPtr->Day; Ret = TRUE; break; } case MCCM_RESET: { MonthCalSetLocalTime(infoPtr, NULL); Ret = TRUE; break; } case MCCM_CHANGED: { Ret = infoPtr->Changed; break; } case WM_TIMER: { switch (wParam) { case ID_DAYTIMER: { /* Kill the timer */ KillTimer(hwnd, ID_DAYTIMER); infoPtr->DayTimerSet = FALSE; if (!infoPtr->Changed) { /* Update the system time and setup the new day timer */ MonthCalSetLocalTime(infoPtr, NULL); /* Update the control */ MonthCalUpdate(infoPtr); } break; } } break; } case WM_SETFONT: { Ret = (LRESULT)MonthCalChangeFont(infoPtr, (HFONT)wParam, (BOOL)LOWORD(lParam)); break; } case WM_SIZE: { infoPtr->ClientSize.cx = LOWORD(lParam); infoPtr->ClientSize.cy = HIWORD(lParam); infoPtr->CellSize.cx = infoPtr->ClientSize.cx / 7; infoPtr->CellSize.cy = infoPtr->ClientSize.cy / 7; /* Repaint the control */ InvalidateRect(hwnd, NULL, TRUE); break; } case WM_GETFONT: { Ret = (LRESULT)infoPtr->hFont; break; } case WM_ENABLE: { infoPtr->Enabled = ((BOOL)wParam != FALSE); MonthCalReload(infoPtr); break; } case WM_STYLECHANGED: { if (wParam == GWL_STYLE) { unsigned int OldEnabled = infoPtr->Enabled; infoPtr->Enabled = !(((LPSTYLESTRUCT)lParam)->styleNew & WS_DISABLED); if (OldEnabled != infoPtr->Enabled) { MonthCalReload(infoPtr); } } break; } case WM_CREATE: { infoPtr = (MONTHCALWND*) HeapAlloc(GetProcessHeap(), 0, sizeof(MONTHCALWND)); if (infoPtr == NULL) { Ret = (LRESULT)-1; break; } SetWindowLongPtrW(hwnd, 0, (LONG_PTR)infoPtr); ZeroMemory(infoPtr, sizeof(MONTHCALWND)); infoPtr->hSelf = hwnd; infoPtr->hNotify = ((LPCREATESTRUCTW)lParam)->hwndParent; infoPtr->Enabled = !(((LPCREATESTRUCTW)lParam)->style & WS_DISABLED); MonthCalSetLocalTime(infoPtr, NULL); MonthCalReload(infoPtr); break; } case WM_DESTROY: { HeapFree(GetProcessHeap(), 0, infoPtr); SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)NULL); break; } default: { HandleDefaultMessage: Ret = DefWindowProcW(hwnd, uMsg, wParam, lParam); break; } } return Ret; }
bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, LRESULT *result) { #ifdef Q_COMPILER_CLASS_ENUM enum : quint64 { signatureMask = 0xffffff00, miWpSignature = 0xff515700 }; #else static const quint64 signatureMask = 0xffffff00; static const quint64 miWpSignature = 0xff515700; #endif // !Q_COMPILER_CLASS_ENUM if (et == QtWindows::MouseWheelEvent) return translateMouseWheelEvent(window, hwnd, msg, result); #ifndef Q_OS_WINCE // Check for events synthesized from touch. Lower byte is touch index, 0 means pen. const quint64 extraInfo = GetMessageExtraInfo(); const bool fromTouch = (extraInfo & signatureMask) == miWpSignature && (extraInfo & 0xff); if (fromTouch) return false; #endif // !Q_OS_WINCE const QPoint winEventPosition(GET_X_LPARAM(msg.lParam), GET_Y_LPARAM(msg.lParam)); if (et & QtWindows::NonClientEventFlag) { const QPoint globalPosition = winEventPosition; const QPoint clientPosition = QWindowsGeometryHint::mapFromGlobal(hwnd, globalPosition); const Qt::MouseButtons buttons = QWindowsMouseHandler::queryMouseButtons(); QWindowSystemInterface::handleFrameStrutMouseEvent(window, clientPosition, globalPosition, buttons, QWindowsKeyMapper::queryKeyboardModifiers()); return false; // Allow further event processing (dragging of windows). } *result = 0; if (msg.message == WM_MOUSELEAVE) { if (QWindowsContext::verboseEvents) qDebug() << "WM_MOUSELEAVE for " << window << " previous window under mouse = " << m_windowUnderMouse << " tracked window =" << m_trackedWindow; // When moving out of a window, WM_MOUSEMOVE within the moved-to window is received first, // so if m_trackedWindow is not the window here, it means the cursor has left the // application. if (window == m_trackedWindow) { QWindow *leaveTarget = m_windowUnderMouse ? m_windowUnderMouse : m_trackedWindow; if (QWindowsContext::verboseEvents) qDebug() << "Generating leave event for " << leaveTarget; QWindowSystemInterface::handleLeaveEvent(leaveTarget); m_trackedWindow = 0; m_windowUnderMouse = 0; } return true; } QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window->handle()); const Qt::MouseButtons buttons = keyStateToMouseButtons((int)msg.wParam); // If the window was recently resized via mouse doubleclick on the frame or title bar, // we don't get WM_LBUTTONDOWN or WM_LBUTTONDBLCLK for the second click, // but we will get at least one WM_MOUSEMOVE with left button down and the WM_LBUTTONUP, // which will result undesired mouse press and release events. // To avoid those, we ignore any events with left button down if we didn't // get the original WM_LBUTTONDOWN/WM_LBUTTONDBLCLK. if (msg.message == WM_LBUTTONDOWN || msg.message == WM_LBUTTONDBLCLK) { m_leftButtonDown = true; } else { const bool actualLeftDown = buttons & Qt::LeftButton; if (!m_leftButtonDown && actualLeftDown) { // Autocapture the mouse for current window to and ignore further events until release. // Capture is necessary so we don't get WM_MOUSELEAVEs to confuse matters. // This autocapture is released normally when button is released. if (!platformWindow->hasMouseCapture()) { QWindowsWindow::baseWindowOf(window)->applyCursor(); platformWindow->setMouseGrabEnabled(true); platformWindow->setFlag(QWindowsWindow::AutoMouseCapture); if (QWindowsContext::verboseEvents) qDebug() << "Automatic mouse capture for missing buttondown event" << window; } m_previousCaptureWindow = window; return true; } else if (m_leftButtonDown && !actualLeftDown) { m_leftButtonDown = false; } } const QPoint globalPosition = QWindowsGeometryHint::mapToGlobal(hwnd, winEventPosition); // In this context, neither an invisible nor a transparent window (transparent regarding mouse // events, "click-through") can be considered as the window under mouse. QWindow *currentWindowUnderMouse = platformWindow->hasMouseCapture() ? QWindowsScreen::windowAt(globalPosition, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT) : window; compressMouseMove(&msg); // Qt expects the platform plugin to capture the mouse on // any button press until release. if (!platformWindow->hasMouseCapture() && (msg.message == WM_LBUTTONDOWN || msg.message == WM_MBUTTONDOWN || msg.message == WM_RBUTTONDOWN || msg.message == WM_XBUTTONDOWN || msg.message == WM_LBUTTONDBLCLK || msg.message == WM_MBUTTONDBLCLK || msg.message == WM_RBUTTONDBLCLK || msg.message == WM_XBUTTONDBLCLK)) { platformWindow->setMouseGrabEnabled(true); platformWindow->setFlag(QWindowsWindow::AutoMouseCapture); if (QWindowsContext::verboseEvents) qDebug() << "Automatic mouse capture " << window; // Implement "Click to focus" for native child windows (unless it is a native widget window). if (!window->isTopLevel() && !window->inherits("QWidgetWindow") && QGuiApplication::focusWindow() != window) window->requestActivate(); } else if (platformWindow->hasMouseCapture() && platformWindow->testFlag(QWindowsWindow::AutoMouseCapture) && (msg.message == WM_LBUTTONUP || msg.message == WM_MBUTTONUP || msg.message == WM_RBUTTONUP || msg.message == WM_XBUTTONUP) && !buttons) { platformWindow->setMouseGrabEnabled(false); if (QWindowsContext::verboseEvents) qDebug() << "Releasing automatic mouse capture " << window; } const bool hasCapture = platformWindow->hasMouseCapture(); const bool currentNotCapturing = hasCapture && currentWindowUnderMouse != window; #ifndef Q_OS_WINCE // Enter new window: track to generate leave event. // If there is an active capture, only track if the current window is capturing, // so we don't get extra leave when cursor leaves the application. if (window != m_trackedWindow && !currentNotCapturing) { TRACKMOUSEEVENT tme; tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_LEAVE; tme.hwndTrack = hwnd; tme.dwHoverTime = HOVER_DEFAULT; // if (!TrackMouseEvent(&tme)) qWarning("TrackMouseEvent failed."); m_trackedWindow = window; } #endif // !Q_OS_WINCE // No enter or leave events are sent as long as there is an autocapturing window. if (!hasCapture || !platformWindow->testFlag(QWindowsWindow::AutoMouseCapture)) { // Leave is needed if: // 1) There is no capture and we move from a window to another window. // Note: Leaving the application entirely is handled in WM_MOUSELEAVE case. // 2) There is capture and we move out of the capturing window. // 3) There is a new capture and we were over another window. if ((m_windowUnderMouse && m_windowUnderMouse != currentWindowUnderMouse && (!hasCapture || window == m_windowUnderMouse)) || (hasCapture && m_previousCaptureWindow != window && m_windowUnderMouse && m_windowUnderMouse != window)) { if (QWindowsContext::verboseEvents) qDebug() << "Synthetic leave for " << m_windowUnderMouse; QWindowSystemInterface::handleLeaveEvent(m_windowUnderMouse); if (currentNotCapturing) { // Clear tracking if capturing and current window is not the capturing window // to avoid leave when mouse actually leaves the application. m_trackedWindow = 0; // We are not officially in any window, but we need to set some cursor to clear // whatever cursor the left window had, so apply the cursor of the capture window. QWindowsWindow::baseWindowOf(window)->applyCursor(); } } // Enter is needed if: // 1) There is no capture and we move to a new window. // 2) There is capture and we move into the capturing window. // 3) The capture just ended and we are over non-capturing window. if ((currentWindowUnderMouse && m_windowUnderMouse != currentWindowUnderMouse && (!hasCapture || currentWindowUnderMouse == window)) || (m_previousCaptureWindow && window != m_previousCaptureWindow && currentWindowUnderMouse && currentWindowUnderMouse != m_previousCaptureWindow)) { if (QWindowsContext::verboseEvents) qDebug() << "Entering " << currentWindowUnderMouse; QWindowsWindow::baseWindowOf(currentWindowUnderMouse)->applyCursor(); QWindowSystemInterface::handleEnterEvent(currentWindowUnderMouse, currentWindowUnderMouse->mapFromGlobal(globalPosition), globalPosition); } // We need to track m_windowUnderMouse separately from m_trackedWindow, as // Windows mouse tracking will not trigger WM_MOUSELEAVE for leaving window when // mouse capture is set. m_windowUnderMouse = currentWindowUnderMouse; } QWindowSystemInterface::handleMouseEvent(window, winEventPosition, globalPosition, buttons, QWindowsKeyMapper::queryKeyboardModifiers()); m_previousCaptureWindow = hasCapture ? window : 0; return true; }
WXLRESULT wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { if ( nMsg == WM_NCHITTEST ) { // This code breaks some other processing such as enter/leave tracking // so it's off by default. static int s_useHTClient = -1; if (s_useHTClient == -1) s_useHTClient = wxSystemOptions::GetOptionInt(wxT("msw.staticbox.htclient")); if (s_useHTClient == 1) { int xPos = GET_X_LPARAM(lParam); int yPos = GET_Y_LPARAM(lParam); ScreenToClient(&xPos, &yPos); // Make sure you can drag by the top of the groupbox, but let // other (enclosed) controls get mouse events also if ( yPos < 10 ) return (long)HTCLIENT; } } if ( nMsg == WM_PRINTCLIENT ) { // we have to process WM_PRINTCLIENT ourselves as otherwise child // windows' background (eg buttons in radio box) would never be drawn // unless we have a parent with non default background // so check first if we have one if ( !HandlePrintClient((WXHDC)wParam) ) { // no, we don't, erase the background ourselves // (don't use our own) - see PaintBackground for explanation wxBrush brush(GetParent()->GetBackgroundColour()); wxFillRect(GetHwnd(), (HDC)wParam, GetHbrushOf(brush)); } return 0; } if ( nMsg == WM_UPDATEUISTATE ) { // DefWindowProc() redraws just the static box text when it gets this // message and it does it using the standard (blue in standard theme) // colour and not our own label colour that we use in PaintForeground() // resulting in the label mysteriously changing the colour when e.g. // "Alt" is pressed anywhere in the window, see #12497. // // To avoid this we simply refresh the window forcing our own code // redrawing the label in the correct colour to be called. This is // inefficient but there doesn't seem to be anything else we can do. // // Notice that the problem is XP-specific and doesn't arise under later // systems. if ( m_hasFgCol && wxGetWinVersion() == wxWinVersion_XP ) Refresh(); } return wxControl::MSWWindowProc(nMsg, wParam, lParam); }
LRESULT CALLBACK DisplayProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { // Only apply a factor > 1 in windowed mode. int factor = !IsZoomed(GetHWND()) && !g_Config.bFullScreen && IsWindowSmall() ? 2 : 1; static bool firstErase = true; switch (message) { case WM_ACTIVATE: if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) { g_activeWindow = WINDOW_MAINWINDOW; } break; case WM_SIZE: break; case WM_SETFOCUS: break; case WM_ERASEBKGND: if (firstErase) { firstErase = false; // Paint black on first erase while OpenGL stuff is loading return DefWindowProc(hWnd, message, wParam, lParam); } // Then never erase, let the OpenGL drawing take care of everything. return 1; // Poor man's touch - mouse input. We send the data both as an input_state pointer, // and as asynchronous touch events for minimal latency. case WM_LBUTTONDOWN: if (!touchHandler.hasTouch() || (GetMessageExtraInfo() & MOUSEEVENTF_MASK_PLUS_PENTOUCH) != MOUSEEVENTF_FROMTOUCH_NOPEN) { // Hack: Take the opportunity to show the cursor. mouseButtonDown = true; { lock_guard guard(input_state.lock); input_state.mouse_valid = true; input_state.pointer_down[0] = true; input_state.pointer_x[0] = GET_X_LPARAM(lParam) * factor; input_state.pointer_y[0] = GET_Y_LPARAM(lParam) * factor; } TouchInput touch; touch.id = 0; touch.flags = TOUCH_DOWN; touch.x = input_state.pointer_x[0]; touch.y = input_state.pointer_y[0]; NativeTouch(touch); SetCapture(hWnd); // Simulate doubleclick, doesn't work with RawInput enabled static double lastMouseDown; double now = real_time_now(); if ((now - lastMouseDown) < 0.001 * GetDoubleClickTime()) { if (!g_Config.bShowTouchControls && GetUIState() == UISTATE_INGAME && g_Config.bFullscreenOnDoubleclick) { SendToggleFullscreen(!g_Config.bFullScreen); } lastMouseDown = 0.0; } else { lastMouseDown = real_time_now(); } } break; case WM_MOUSEMOVE: if (!touchHandler.hasTouch() || (GetMessageExtraInfo() & MOUSEEVENTF_MASK_PLUS_PENTOUCH) != MOUSEEVENTF_FROMTOUCH_NOPEN) { // Hack: Take the opportunity to show the cursor. mouseButtonDown = (wParam & MK_LBUTTON) != 0; int cursorX = GET_X_LPARAM(lParam); int cursorY = GET_Y_LPARAM(lParam); if (abs(cursorX - prevCursorX) > 1 || abs(cursorY - prevCursorY) > 1) { hideCursor = false; SetTimer(hwndMain, TIMER_CURSORMOVEUPDATE, CURSORUPDATE_MOVE_TIMESPAN_MS, 0); } prevCursorX = cursorX; prevCursorY = cursorY; { lock_guard guard(input_state.lock); input_state.pointer_x[0] = GET_X_LPARAM(lParam) * factor; input_state.pointer_y[0] = GET_Y_LPARAM(lParam) * factor; } if (wParam & MK_LBUTTON) { TouchInput touch; touch.id = 0; touch.flags = TOUCH_MOVE; touch.x = input_state.pointer_x[0]; touch.y = input_state.pointer_y[0]; NativeTouch(touch); } } break; case WM_LBUTTONUP: if (!touchHandler.hasTouch() || (GetMessageExtraInfo() & MOUSEEVENTF_MASK_PLUS_PENTOUCH) != MOUSEEVENTF_FROMTOUCH_NOPEN) { // Hack: Take the opportunity to hide the cursor. mouseButtonDown = false; { lock_guard guard(input_state.lock); input_state.pointer_down[0] = false; input_state.pointer_x[0] = GET_X_LPARAM(lParam) * factor; input_state.pointer_y[0] = GET_Y_LPARAM(lParam) * factor; } TouchInput touch; touch.id = 0; touch.flags = TOUCH_UP; touch.x = input_state.pointer_x[0]; touch.y = input_state.pointer_y[0]; NativeTouch(touch); ReleaseCapture(); } break; case WM_TOUCH: { touchHandler.handleTouchEvent(hWnd, message, wParam, lParam); return 0; } default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lParam) { struct dinput_input *di = (struct dinput_input *)dinput; settings_t *settings = config_get_ptr(); /* WM_POINTERDOWN : Arrives for each new touch event * with a new ID - add to list. * WM_POINTERUP : Arrives once the pointer is no * longer down - remove from list. * WM_POINTERUPDATE : arrives for both pressed and * hovering pointers - ignore hovering */ switch (message) { case WM_MOUSEMOVE: di->window_pos_x = GET_X_LPARAM(lParam); di->window_pos_y = GET_Y_LPARAM(lParam); break; case WM_POINTERDOWN: { struct pointer_status *new_pointer = (struct pointer_status *)malloc(sizeof(struct pointer_status)); if (!new_pointer) { RARCH_ERR("dinput_handle_message: pointer allocation in WM_POINTERDOWN failed.\n"); return false; } new_pointer->pointer_id = GET_POINTERID_WPARAM(wParam); dinput_pointer_store_pos(new_pointer, lParam); dinput_add_pointer(di, new_pointer); return true; } case WM_POINTERUP: { int pointer_id = GET_POINTERID_WPARAM(wParam); dinput_delete_pointer(di, pointer_id); return true; } case WM_POINTERUPDATE: { int pointer_id = GET_POINTERID_WPARAM(wParam); struct pointer_status *pointer = dinput_find_pointer(di, pointer_id); if (pointer) dinput_pointer_store_pos(pointer, lParam); return true; } case WM_DEVICECHANGE: { if (di->joypad) di->joypad->destroy(); di->joypad = input_joypad_init_driver(settings->input.joypad_driver, di); break; } case WM_MOUSEWHEEL: { if (((short) HIWORD(wParam))/120 > 0) di->mouse_wu = true; if (((short) HIWORD(wParam))/120 < 0) di->mouse_wd = true; } break; case WM_MOUSEHWHEEL: { if (((short) HIWORD(wParam))/120 > 0) di->mouse_hwu = true; if (((short) HIWORD(wParam))/120 < 0) di->mouse_hwd = true; } break; } return false; }
/** * @param hwnd - window handle. * @param uMsg - message identifier. * @param wParam - first message parameter. * @param lParam - second message parameter. */ LRESULT CALLBACK CHyperLink::HyperLinkWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { int x, y, nCtrlID; POINT point; HCURSOR hCursor; COLORREF rgbNewColor; PAINTSTRUCT ps; HWND hwndParent, hwndCtrl; LRESULT lResult; DWORD dwResult; HDC hdc; CHyperLink* _this = (CHyperLink*)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch(uMsg) { case WM_NCHITTEST: return HTCLIENT; case WM_SETCURSOR: hCursor = g_pResManager->m_hArrowCursor; if (g_pResManager->m_hHandCursor) { dwResult = GetMessagePos(); point.x = GET_X_LPARAM(dwResult); point.y = GET_Y_LPARAM(dwResult); ScreenToClient(hwnd, &point); if (_this->HitTest(point)) hCursor = g_pResManager->m_hHandCursor; } if (hCursor) { SetCursor(hCursor); return TRUE; } return FALSE; case WM_LBUTTONDOWN: if (GetCapture() != hwnd) { x = GET_X_LPARAM(lParam); y = GET_Y_LPARAM(lParam); if (_this->HitTest(x, y)) { _this->m_rgbCurrentColor = m_rgbRedColor; SetCapture(hwnd); if (GetFocus() == hwnd) InvalidateRect(hwnd, NULL, FALSE); else SetFocus(hwnd); } } return 0; case WM_MOUSEMOVE: if (GetCapture() == hwnd) { x = GET_X_LPARAM(lParam); y = GET_Y_LPARAM(lParam); rgbNewColor = _this->HitTest(x, y) ? m_rgbRedColor : m_rgbBlueColor; if (_this->m_rgbCurrentColor != rgbNewColor) { _this->m_rgbCurrentColor = rgbNewColor; InvalidateRect(hwnd, NULL, FALSE); } } return 0; case WM_LBUTTONUP: if (GetCapture() == hwnd) { ReleaseCapture(); x = GET_X_LPARAM(lParam); y = GET_Y_LPARAM(lParam); if (_this->HitTest(x, y)) _this->DoAction(); } return 0; case WM_SETFOCUS: hwndParent = GetParent(hwnd); if (hwndParent) { nCtrlID = GetDlgCtrlID(hwnd); if (_this->m_nPrevDefButtonID < 0) { lResult = SendMessage(hwndParent, DM_GETDEFID, 0, 0); _this->m_nPrevDefButtonID = HIWORD(lResult) == DC_HASDEFID && LOWORD(lResult) != nCtrlID ? LOWORD(lResult) : -1; } SendMessage(hwndParent, DM_SETDEFID, nCtrlID, 0); if (_this->m_nPrevDefButtonID > 0) { // Sending a DM_SETDEFID message to change the default button will not always // remove the default state border from the first push button. In these cases, // the application should send a BM_SETSTYLE message to change the first push // button border style. hwndCtrl = GetDlgItem(hwndParent, _this->m_nPrevDefButtonID); if (SendMessage(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON) SendMessage(hwndCtrl, BM_SETSTYLE, BS_PUSHBUTTON, TRUE); } } InvalidateRect(hwnd, NULL, FALSE); return 0; case WM_KILLFOCUS: hwndParent = GetParent(hwnd); if (hwndParent && wParam && IsChild(hwndParent, (HWND)wParam)) { if (! (SendMessage((HWND)wParam, WM_GETDLGCODE, 0, 0) & (DLGC_DEFPUSHBUTTON | DLGC_UNDEFPUSHBUTTON))) { if (_this->m_nPrevDefButtonID > 0) { nCtrlID = _this->m_nPrevDefButtonID; _this->m_nPrevDefButtonID = -1; } else nCtrlID = IDOK; hwndCtrl = GetDlgItem(hwndParent, nCtrlID); if (hwndCtrl && IsWindowEnabled(hwndCtrl)) SendMessage(hwndParent, DM_SETDEFID, nCtrlID, 0); } else { _this->m_nPrevDefButtonID = -1; nCtrlID = GetDlgCtrlID((HWND)wParam); SendMessage(hwndParent, DM_SETDEFID, nCtrlID, 0); } } InvalidateRect(hwnd, NULL, FALSE); return 0; case WM_CAPTURECHANGED: _this->m_rgbCurrentColor = m_rgbBlueColor; InvalidateRect(hwnd, NULL, FALSE); return 0; case WM_ERASEBKGND: return TRUE; case WM_PAINT: hdc = (HDC)wParam; if (! hdc) { hdc = BeginPaint(hwnd, &ps); if (hdc) { _this->DrawHyperLink(hdc); EndPaint(hwnd, &ps); } } else _this->DrawHyperLink(hdc); return 0; case WM_PRINTCLIENT: hdc = (HDC)wParam; _this->DrawHyperLink(hdc); return 0; case WM_KEYDOWN: switch (wParam) { case VK_RETURN: _this->DoAction(); break; case VK_TAB: hwndParent = GetParent(hwnd); if (hwndParent) { BOOL bPrevCtrl = GetKeyState(VK_SHIFT) < 0; FORWARD_WM_NEXTDLGCTL(hwndParent, bPrevCtrl, FALSE, PostMessage); // ToDo: Fix This Define } break; case VK_LEFT: case VK_UP: hwndParent = GetParent(hwnd); if (hwndParent) FORWARD_WM_NEXTDLGCTL(hwndParent, TRUE, FALSE, PostMessage); break; case VK_RIGHT: case VK_DOWN: hwndParent = GetParent(hwnd); if (hwndParent) FORWARD_WM_NEXTDLGCTL(hwndParent, FALSE, FALSE, PostMessage); break; case VK_ESCAPE: hwndParent = GetParent(hwnd); if (hwndParent) { HWND hwndCtl = GetDlgItem(hwndParent, IDCANCEL); if (! hwndCtl || IsWindowEnabled(hwndCtl)) FORWARD_WM_COMMAND(hwndParent, IDCANCEL, hwndCtl, BN_CLICKED, PostMessage); } break; } return 0; case WM_GETDLGCODE: return ((GetFocus() == hwnd ? DLGC_DEFPUSHBUTTON : DLGC_UNDEFPUSHBUTTON) | DLGC_WANTALLKEYS); case BM_SETSTYLE: return 0; default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } }
static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { HWND hwndList = GetDlgItem(hwnd, IDC_AVATARLIST); switch(uMsg) { case WM_INITDIALOG: { AvatarDialogData *data = (struct AvatarDialogData*) lParam; SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)createDefaultOverlayedIcon(TRUE)); SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)createDefaultOverlayedIcon(FALSE)); if (db_get_b(NULL, MODULE_NAME, "LogToHistory", AVH_DEF_LOGTOHISTORY)) FillAvatarListFromDB(hwndList, data->hContact); else if (opts.log_store_as_hash) FillAvatarListFromFolder(hwndList, data->hContact); else FillAvatarListFromFiles(hwndList, data->hContact); TCHAR *displayName = pcli->pfnGetContactDisplayName(data->hContact, 0); if (displayName) { TCHAR title[MAX_PATH]; mir_sntprintf(title, _countof(title), TranslateT("Avatar History for %s"), displayName); SetWindowText(hwnd, title); } SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data->hContact); UpdateAvatarPic(hwnd); CheckDlgButton(hwnd, IDC_LOGUSER, (UINT)db_get_b(data->hContact, MODULE_NAME, "LogToDisk", BST_INDETERMINATE)); CheckDlgButton(hwnd, IDC_POPUPUSER, (UINT)db_get_b(data->hContact, MODULE_NAME, "AvatarPopups", BST_INDETERMINATE)); CheckDlgButton(hwnd, IDC_HISTORYUSER, (UINT)db_get_b(data->hContact, MODULE_NAME, "LogToHistory", BST_INDETERMINATE)); ShowWindow(GetDlgItem(hwnd, IDC_OPENFOLDER), opts.log_per_contact_folders ? SW_SHOW : SW_HIDE); Utils_RestoreWindowPositionNoSize(hwnd,NULL,MODULE_NAME,"AvatarHistoryDialog"); WindowList_Add(hAvatarWindowsList,hwnd,data->hContact); TranslateDialogDefault(hwnd); EnableDisableControls(hwnd); free(data); data = NULL; } break; case WM_CLOSE: CleanupAvatarPic(hwnd); EndDialog(hwnd, 0); return TRUE; case WM_DESTROY: Utils_SaveWindowPosition(hwnd,NULL,MODULE_NAME,"AvatarHistoryDialog"); WindowList_Remove(hAvatarWindowsList,hwnd); DestroyIcon((HICON)SendMessage(hwnd, WM_SETICON, ICON_BIG, 0)); DestroyIcon((HICON)SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0)); { int count = SendMessage(hwndList, LB_GETCOUNT, 0, 0); for(int i = 0; i < count; i++) delete (ListEntry*)SendMessage(hwndList, LB_GETITEMDATA, i, 0); } break; case WM_CONTEXTMENU: { HWND pic = GetDlgItem(hwnd, IDC_AVATAR); int pos; if ((HANDLE)wParam == hwndList) { POINT p = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; ScreenToClient(hwndList, &p); pos = SendMessage(hwndList, LB_ITEMFROMPOINT, 0, MAKELONG(p.x, p.y)); if (HIWORD(pos)) break; pos = LOWORD(pos); int count = SendMessage(hwndList, LB_GETCOUNT, 0, 0); if (pos >= count) break; SendMessage(hwndList, LB_SETCURSEL, pos, 0); EnableDisableControls(hwnd); } else if ((HANDLE) wParam == pic) { pos = SendMessage(hwndList, LB_GETCURSEL, 0, 0); if (pos == LB_ERR) break; } else break; HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)); HMENU submenu = GetSubMenu(menu, 0); TranslateMenu(submenu); if (!UpdateAvatarPic(hwnd)) { RemoveMenu(submenu, 2, MF_BYPOSITION); RemoveMenu(submenu, 0, MF_BYPOSITION); } POINT p; p.x = LOWORD(lParam); p.y = HIWORD(lParam); int ret = TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, p.x, p.y, 0, hwndList, NULL); DestroyMenu(menu); ListEntry *le = (ListEntry*) SendMessage(hwndList, LB_GETITEMDATA, pos, 0); MCONTACT hContact = (MCONTACT) GetWindowLongPtr(hwnd, GWLP_USERDATA); switch(ret) { case ID_AVATARLISTPOPUP_SAVEAS: ShowSaveDialog(hwnd, le->filename, hContact); break; case ID_AVATARLISTPOPUP_DELETE: { BOOL blDelete; if (le->hDbEvent) blDelete = MessageBox(hwnd, TranslateT("Are you sure you wish to delete this history entry?\nOnly the entry in history will be deleted, bitmap file will be kept!"), TranslateT("Delete avatar log?"), MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SETFOREGROUND|MB_TOPMOST) == IDYES; else blDelete = MessageBox(hwnd, TranslateT("Are you sure you wish to delete this avatar shortcut?\nOnly shortcut will be deleted, bitmap file will be kept!"), TranslateT("Delete avatar log?"), MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SETFOREGROUND|MB_TOPMOST) == IDYES; if (blDelete) { if (le->hDbEvent) db_event_delete(hContact, le->hDbEvent); else DeleteFile(le->filelink); delete le; SendMessage(hwndList, LB_DELETESTRING, pos, 0); int count = SendMessage(hwndList, LB_GETCOUNT, 0, 0); if (count > 0) { if (pos >= count) pos = count -1; SendMessage(hwndList, LB_SETCURSEL, pos, 0); } UpdateAvatarPic(hwnd); EnableDisableControls(hwnd); } } break; case ID_AVATARLISTPOPUP_DELETE_BOTH: BOOL blDelete; if (le->hDbEvent) blDelete = MessageBox(hwnd, TranslateT("Are you sure you wish to delete this archived avatar?\nThis will delete the history entry and the bitmap file.\nWARNING:This can affect more than one entry in history!"), TranslateT("Delete avatar?"), MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SETFOREGROUND|MB_TOPMOST) == IDYES; else blDelete = MessageBox(hwnd, TranslateT("Are you sure you wish to delete this archived avatar?\nThis will delete the shortcut and the bitmap file.\nWARNING:This can affect more than one shortcut!"), TranslateT("Delete avatar?"), MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SETFOREGROUND|MB_TOPMOST) == IDYES; if (blDelete) { DeleteFile(le->filename); if (le->hDbEvent) db_event_delete(hContact, le->hDbEvent); else DeleteFile(le->filelink); delete le; SendMessage(hwndList, LB_DELETESTRING, pos, 0); int count = SendMessage(hwndList, LB_GETCOUNT, 0, 0); if (count > 0) { if (pos >= count) pos = count -1; SendMessage(hwndList, LB_SETCURSEL, pos, 0); } UpdateAvatarPic(hwnd); EnableDisableControls(hwnd); } } } break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: if (HIWORD(wParam) == BN_CLICKED) { MCONTACT hContact = (MCONTACT) GetWindowLongPtr(hwnd, GWLP_USERDATA); db_set_b(hContact, MODULE_NAME, "AvatarPopups", (BYTE) IsDlgButtonChecked(hwnd, IDC_POPUPUSER)); db_set_b(hContact, MODULE_NAME, "LogToDisk", (BYTE) IsDlgButtonChecked(hwnd, IDC_LOGUSER)); db_set_b(hContact, MODULE_NAME, "LogToHistory", (BYTE) IsDlgButtonChecked(hwnd, IDC_HISTORYUSER)); CleanupAvatarPic(hwnd); EndDialog(hwnd, 0); return TRUE; } break; case IDC_AVATARLIST: if (HIWORD(wParam) == LBN_SELCHANGE) { UpdateAvatarPic(hwnd); EnableDisableControls(hwnd); return TRUE; } break; case IDC_OPENFOLDER: if (HIWORD(wParam) == BN_CLICKED && opts.log_per_contact_folders) { TCHAR avfolder[MAX_PATH]; MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); GetContactFolder(avfolder, hContact); ShellExecute(NULL, db_get_b(NULL, MODULE_NAME, "OpenFolderMethod", 0) ? _T("explore") : _T("open"), avfolder, NULL, NULL, SW_SHOWNORMAL); return TRUE; } break; case IDC_NEXT: if (HIWORD(wParam) == BN_CLICKED) { SendMessage(hwndList, LB_SETCURSEL, SendMessage(hwndList, LB_GETCURSEL, 0, 0) +1, 0); UpdateAvatarPic(hwnd); EnableDisableControls(hwnd); return TRUE; } break; case IDC_BACK: if (HIWORD(wParam) == BN_CLICKED) { int cursel = SendMessage(hwndList, LB_GETCURSEL, 0, 0); if (cursel == LB_ERR) SendMessage(hwndList, LB_SETCURSEL, SendMessage(hwndList, LB_GETCOUNT, 0, 0) -1, 0); else SendMessage(hwndList, LB_SETCURSEL, cursel -1, 0); UpdateAvatarPic(hwnd); EnableDisableControls(hwnd); return TRUE; } } break; } return FALSE; }
//--------------------------------------------------------------------- // // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_PAINT: ValidateRect(hWnd, NULL); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; case WM_MOUSEMOVE: if (g_flashPlayer) g_flashPlayer->SetMousePos(GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam)); return 0; case WM_LBUTTONDOWN: if (g_flashPlayer) g_flashPlayer->SetMouseButtonState(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), IFlashDXPlayer::eMouse1, true); return 0; case WM_LBUTTONUP: if (g_flashPlayer) g_flashPlayer->SetMouseButtonState(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), IFlashDXPlayer::eMouse1, false); return 0; case WM_KEYDOWN: if (g_flashPlayer) g_flashPlayer->SendKey(true, wParam, lParam); return 0; case WM_KEYUP: if (g_flashPlayer) g_flashPlayer->SendKey(false, wParam, lParam); return 0; case WM_CHAR: if (g_flashPlayer) g_flashPlayer->SendChar(wParam, lParam); return 0; case WM_SIZE: if (g_flashPlayer) { SAFE_RELEASE(g_textureGUI); g_params.BackBufferWidth = GET_X_LPARAM(lParam); g_params.BackBufferHeight = GET_Y_LPARAM(lParam); g_device->Reset(&g_params); RecreateTargets(g_params.BackBufferWidth, g_params.BackBufferHeight); } return 0; case WM_SETCURSOR: if (g_flashPlayer) { static bool restoreCursor = true; if (LOWORD(lParam) != HTCLIENT) restoreCursor = true; if (restoreCursor) { restoreCursor = false; break; // DefWindowProc will set the cursor } return 1; } break; default: break; } return DefWindowProc(hWnd, message, wParam, lParam); }
CPoint::CPoint(LPARAM lParam) { x = GET_X_LPARAM(lParam); y = GET_Y_LPARAM(lParam); }