void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) { Q_Q(QDockWidget); int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q); QRect geo = q->geometry(); QRect titleRect = q->frameGeometry(); #ifdef Q_WS_MAC if ((features & QDockWidget::DockWidgetVerticalTitleBar)) { titleRect.setTop(geo.top()); titleRect.setBottom(geo.bottom()); titleRect.setRight(geo.left() - 1); } else #endif { titleRect.setLeft(geo.left()); titleRect.setRight(geo.right()); titleRect.setBottom(geo.top() - 1); titleRect.adjust(0, fw, 0, 0); } switch (event->type()) { case QEvent::NonClientAreaMouseButtonPress: if (!titleRect.contains(event->globalPos())) break; if (state != 0) break; if (qobject_cast<QMainWindow*>(parent) == 0) break; if (isAnimating()) break; initDrag(event->pos(), true); if (state == 0) break; #ifdef Q_WS_WIN // On Windows, NCA mouse events don't contain modifier info state->ctrlDrag = GetKeyState(VK_CONTROL) & 0x8000; #else state->ctrlDrag = event->modifiers() & Qt::ControlModifier; #endif startDrag(); break; case QEvent::NonClientAreaMouseMove: if (state == 0 || !state->dragging) break; #ifndef Q_OS_MAC if (state->nca) { endDrag(); } #endif break; case QEvent::NonClientAreaMouseButtonRelease: #ifdef Q_OS_MAC if (state) endDrag(); #endif break; case QEvent::NonClientAreaMouseButtonDblClick: _q_toggleTopLevel(); break; default: break; } }
//-------------------------------------------------------------------------- // 功能:响应键盘按键操作 //-------------------------------------------------------------------------- int KWndEdit::OnKeyDown(int nKeyCode, int nModifiers) { int nRet = 1; switch(nKeyCode) { case VK_DELETE: if (m_nCaretPos < m_nTextLen) { int nNextPos = TSplitString(m_pText + m_nCaretPos, 1, false); m_nTextLen -= nNextPos; memmove(m_pText + m_nCaretPos, m_pText + m_nCaretPos + nNextPos, m_nTextLen - m_nCaretPos + 1); UpdateData(); } break; case VK_LEFT: if (m_nCaretPos) { m_nCaretPos = TSplitString(m_pText, m_nCaretPos - 1, true); FmtForShow(); } break; case VK_RIGHT: if (m_nCaretPos < m_nTextLen) { m_nCaretPos += TSplitString(m_pText + m_nCaretPos, 1, false); FmtForShow(); } break; case VK_HOME: m_nCaretPos = 0; FmtForShow(); break; case VK_END: m_nCaretPos = m_nTextLen; FmtForShow(); break; case VK_UP: if (MULTI_LINE && m_nCaretLineIndex) { int nCharPerLine = (m_Width * 2) / m_nFontSize; int nLineHead = 0, nLineEnd = 0; for (nRet = 0; nRet < m_nCaretLineIndex; nRet++) { nLineHead = nLineEnd; nLineEnd = nLineHead + SplitStringLine(&m_pText[nLineHead], 1, nCharPerLine); } m_nCaretPos = nLineHead + TSplitString(&m_pText[nLineHead], (m_nCaretPos - nLineEnd), false); if (m_nCaretPos >= nLineEnd && nLineEnd) { m_nCaretPos = nLineEnd; if(m_pText[nLineEnd - 1] == KTC_ENTER) m_nCaretPos--; } FmtForShow(); } else if (m_pParentWnd) nRet = m_pParentWnd->WndProc(WND_N_EDIT_SPECIAL_KEY_DOWN, (unsigned int)(KWndWindow*)this, VK_UP); break; case VK_DOWN: if (MULTI_LINE) { int nCharPerLine = (m_Width * 2) / m_nFontSize; int nLineHead = 0, nLineEnd = 0; for (nRet = 0; nRet <= m_nCaretLineIndex; nRet++) { nLineHead = nLineEnd; nLineEnd = nLineHead + SplitStringLine(&m_pText[nLineHead], 1, nCharPerLine); } m_nCaretPos = nLineEnd + TSplitString(&m_pText[nLineEnd], (m_nCaretPos - nLineHead), false); nLineHead = nLineEnd; nLineEnd = nLineHead + SplitStringLine(&m_pText[nLineHead], 1, nCharPerLine); if (m_nCaretPos >= nLineEnd && nLineEnd) { m_nCaretPos = nLineEnd; if(m_pText[nLineEnd - 1] == KTC_ENTER) m_nCaretPos--; } FmtForShow(); } else if (m_pParentWnd) nRet = m_pParentWnd->WndProc(WND_N_EDIT_SPECIAL_KEY_DOWN, (unsigned int)(KWndWindow*)this, VK_DOWN); break; case VK_TAB: case VK_PRIOR: case VK_NEXT: case VK_ESCAPE: if (m_pParentWnd) nRet = m_pParentWnd->WndProc(WND_N_EDIT_SPECIAL_KEY_DOWN, (unsigned int)(KWndWindow*)this, nKeyCode); break; case VK_RETURN: if (m_pParentWnd) { if ((m_Flag & WNDEDIT_ES_MULTI_LINE) == 0) nRet = m_pParentWnd->WndProc(WND_N_EDIT_SPECIAL_KEY_DOWN, (unsigned int)(KWndWindow*)this, VK_RETURN); else if ((GetKeyState(VK_CONTROL) & 0x8000) == 0 && (GetKeyState(VK_SHIFT) & 0x8000) == 0) nRet = m_pParentWnd->WndProc(WND_N_EDIT_SPECIAL_KEY_DOWN, (unsigned int)(KWndWindow*)this, VK_RETURN); else if (InsertChar(0x0a, 0)) { UpdateData(); nRet = 1; } } break; case 'V': //粘帖 if ((GetKeyState(VK_CONTROL) & 0x8000) && Paste()) nRet = 1; break; case 'C': //复制 if ((GetKeyState(VK_CONTROL) & 0x8000) && Copy()) nRet = 1; break; default: if ((nKeyCode < '0' || nKeyCode > '9') && (nKeyCode < 'A' || nKeyCode > 'Z') && (nKeyCode < VK_NUMPAD0 || nKeyCode > VK_DIVIDE)) { nRet = 0; } } return nRet; }
long CALLBACK EXPORT ConsoleFunc(HWND hwnd,unsigned message,WPARAM wParam, LPARAM lParam) { CONSOLE *con; PAINTSTRUCT ps; RECT rect; switch (message) { case WM_CHAR: if ((con=Hwnd2Console(hwnd))!=NULL) { /* store in a key queue */ if ((con->keyq_end+1)%KEYQUEUE_SIZE==con->keyq_start) { MessageBeep(MB_OK); break; } /* if */ con->keyqueue[con->keyq_end]=(short)wParam; con->keyq_end=(con->keyq_end+1)%KEYQUEUE_SIZE; } /* if */ break; case WM_CREATE: /* The "hwnd" member of the CONSOLE structure has not yet been set, which * means that Hwnd2Console() cannot work on the real "hwnd". There should * at every instant be only one CONSOLE structure with a NULL handle, * however. */ if ((con=Hwnd2Console(NULL))!=NULL) { con->hwnd=hwnd; SetConsoleFont(con,con->cheight); GetWindowRect(hwnd, &rect); SetRect(&rect,rect.left,rect.top, rect.left+con->cwidth*con->columns, rect.top+con->cheight*con->winlines); AdjustWindowRect(&rect,GetWindowLong(hwnd,GWL_STYLE),FALSE); if (con->winlines<con->lines) rect.right+=GetSystemMetrics(SM_CXVSCROLL); ClampToScreen(&rect); SetWindowPos(hwnd,NULL,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,0); } /* if */ break; case WM_DESTROY: if ((con=Hwnd2Console(hwnd))!=NULL) DoDeleteConsole(con); /* if there are no consoles left, abort the program */ if (consoleroot.next==NULL) { #if defined __WIN32__ || defined _WIN32 || defined WIN32 ExitProcess(0); #else exit(0); #endif } /* if */ break; case WM_GETMINMAXINFO: if ((con=Hwnd2Console(hwnd))!=NULL) { MINMAXINFO FAR *lpmmi=(MINMAXINFO FAR*)lParam; int rx,ry,hsize,vsize; GetClientRect(hwnd,&rect); rx= (rect.right < con->columns*con->cwidth) ? con->columns*con->cwidth-rect.right : 0; ry= (rect.bottom < con->lines*con->cheight) ? con->lines*con->cheight-rect.bottom : 0; hsize= (ry>0) ? GetSystemMetrics(SM_CXVSCROLL) : 0; vsize= (rx>0) ? GetSystemMetrics(SM_CYHSCROLL) : 0; SetRect(&rect,0,0,con->cwidth*con->columns+hsize,con->cheight*con->lines+vsize); AdjustWindowRect(&rect,GetWindowLong(hwnd,GWL_STYLE),FALSE); lpmmi->ptMaxTrackSize.x=rect.right-rect.left; lpmmi->ptMaxTrackSize.y=rect.bottom-rect.top; lpmmi->ptMaxSize=lpmmi->ptMaxTrackSize; } /* if */ break; case WM_SYSKEYDOWN: case WM_KEYDOWN: if ((con=Hwnd2Console(hwnd))!=NULL) { TCHAR str[20]; int i; str[0]=__T('\0'); switch (LOWORD(wParam)) { case VK_F1: case VK_F2: case VK_F3: case VK_F4: case VK_F5: case VK_F6: case VK_F7: case VK_F8: case VK_F9: case VK_F10: case VK_F11: case VK_F12: if (LOWORD(wParam)<=VK_F5) _stprintf(str,__T("\033[%d~\n"),LOWORD(wParam)-VK_F1+11); else if (LOWORD(wParam)==VK_F10) _stprintf(str,__T("\033[%d~\n"),LOWORD(wParam)-VK_F6+17); else _stprintf(str,__T("\033[%d~\n"),LOWORD(wParam)-VK_F11+23); break; case VK_ADD: case VK_SUBTRACT: /* check Ctrl key */ if ((GetKeyState(VK_CONTROL) & 0x8000)!=0) { POINT pt; int newheight=con->cheight; int oldheight=newheight; int incr= (LOWORD(wParam)==VK_SUBTRACT) ? -1 : 1; do { newheight+=incr; /* make a new font, re-create a caret and redraw everything */ SetConsoleFont(con,newheight); } while (newheight>5 && (oldheight==con->cheight || con->hfont==NULL)); if (con->hfont==NULL) /* reset to original on failure */ SetConsoleFont(con,oldheight); GetClientRect(hwnd,&rect); DestroyCaret(); CreateCaret(hwnd,NULL,con->cwidth,2); RefreshCaretPos(con); /* redraw the window */ InvalidateRect(hwnd,NULL,TRUE); /* resize the window */ SetRect(&rect,0,0,con->cwidth*con->columns,con->cheight*con->winlines); AdjustWindowRect(&rect,GetWindowLong(hwnd,GWL_STYLE),FALSE); pt.x=pt.y=0; ClientToScreen(hwnd,&pt); OffsetRect(&rect,pt.x,pt.y); ClampToScreen(&rect); SetWindowPos(hwnd,NULL,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top, SWP_NOZORDER); } /* if */ break; case VK_UP: _tcscpy(str,__T("\033[A")); break; case VK_DOWN: _tcscpy(str,__T("\033[B")); break; case VK_RIGHT: _tcscpy(str,__T("\033[C")); break; case VK_LEFT: _tcscpy(str,__T("\033[D")); break; case VK_HOME: _tcscpy(str,__T("\033[1~")); break; case VK_END: _tcscpy(str,__T("\033[4~")); break; case VK_INSERT: _tcscpy(str,__T("\033[2~")); break; case VK_DELETE: _tcscpy(str,__T("\033[3~")); break; case VK_PRIOR: /* PageUp */ _tcscpy(str,__T("\033[5~")); break; case VK_NEXT: /* PageDown */ _tcscpy(str,__T("\033[6~")); break; default: return DefWindowProc(hwnd,message,wParam,lParam); } /* switch */ for (i=0; str[i]!=__T('\0'); i++) { if ((con->keyq_end+1)%KEYQUEUE_SIZE!=con->keyq_start) { con->keyqueue[con->keyq_end]=(short)str[i]; con->keyq_end=(con->keyq_end+1)%KEYQUEUE_SIZE; } /* if */ } /* for */ } /* if */ break; case WM_KILLFOCUS: HideCaret(hwnd); DestroyCaret(); break; case WM_SETFOCUS: if ((con=Hwnd2Console(hwnd))!=NULL) { CreateCaret(hwnd,NULL,con->cwidth,2); RefreshCaretPos(con); ShowCaret(hwnd); } /* if */ break; case WM_LBUTTONDOWN: SetFocus(hwnd); break; case WM_PAINT: HideCaret(hwnd); BeginPaint(hwnd, &ps); if ((con=Hwnd2Console(hwnd))!=NULL && con->buffer!=NULL) { TCHAR *string; string=malloc(con->columns*sizeof(TCHAR)); if (string!=NULL) { int l,c,bpos,start; TCHAR attr; HFONT hfontOrg; int scrollx=GetScrollPos(hwnd,SB_HORZ); int scrolly=GetScrollPos(hwnd,SB_VERT); GetClientRect(hwnd,&rect); hfontOrg=SelectObject(ps.hdc,con->hfont); SetBkMode(ps.hdc,OPAQUE); for (l=0; l<con->lines; l++) { bpos=l*con->columns*2; c=0; while (c<con->columns) { /* find stretches with the same attribute */ attr=con->buffer[bpos+1]; start=c; while (c<con->columns && con->buffer[bpos+1]==attr) { assert(c-start>=0); assert(c-start<con->columns); string[c-start]=con->buffer[bpos]; c++; bpos+=2; } /* if */ SetTextAttribute(ps.hdc,attr); TextOut(ps.hdc,start*con->cwidth-scrollx,l*con->cheight-scrolly,string,c-start); } /* while */ } /* for */ SelectObject(ps.hdc,hfontOrg); free(string); } /* if */ } /* if */ EndPaint(hwnd, &ps); ShowCaret(hwnd); break; case WM_SIZE: if ((con=Hwnd2Console(hwnd))!=NULL) { int rx,ry; /* add/remove/recalculate scroll bars */ GetClientRect(hwnd,&rect); rx= (rect.right < con->columns*con->cwidth) ? con->columns*con->cwidth-rect.right : 0; ry= (rect.bottom < con->lines*con->cheight) ? con->lines*con->cheight-rect.bottom : 0; /* adjust scrolling position, if necessary */ if (GetScrollPos(hwnd,SB_HORZ)>=rx) { SetScrollPos(hwnd,SB_HORZ,rx,FALSE); InvalidateRect(hwnd,NULL,FALSE); } /* if */ if (GetScrollPos(hwnd,SB_VERT)>=ry) { SetScrollPos(hwnd,SB_VERT,ry,FALSE); InvalidateRect(hwnd,NULL,FALSE); } /* if */ SetScrollRange(hwnd,SB_HORZ,0,rx,TRUE); SetScrollRange(hwnd,SB_VERT,0,ry,TRUE); } /* if */ break; case WM_HSCROLL: if ((con=Hwnd2Console(hwnd))!=NULL) { int scrollx=GetScrollPos(hwnd,SB_HORZ); int oldpos=scrollx; int min,max; GetScrollRange(hwnd,SB_HORZ,&min,&max); switch (LOWORD(wParam)) { case SB_TOP: scrollx=min; break; case SB_BOTTOM: scrollx=max; break; case SB_LINELEFT: scrollx=(scrollx>min) ? scrollx-1 : min; break; case SB_LINERIGHT: scrollx=(scrollx<max) ? scrollx+1 : max; break; case SB_PAGELEFT: scrollx=(scrollx>min) ? scrollx-50 : min; break; case SB_PAGERIGHT: scrollx=(scrollx<max) ? scrollx+50 : max; break; case SB_THUMBTRACK: scrollx=(int)HIWORD(wParam); break; } /* switch */ if (oldpos!=scrollx) { SetScrollPos(hwnd,SB_HORZ,scrollx,TRUE); InvalidateRect(hwnd,NULL,FALSE); RefreshCaretPos(con); } /* if */ } /* if */ break; case WM_VSCROLL: if ((con=Hwnd2Console(hwnd))!=NULL) { int scrolly=GetScrollPos(hwnd,SB_VERT); int oldpos=scrolly; int min,max; GetScrollRange(hwnd,SB_VERT,&min,&max); switch (LOWORD(wParam)) { case SB_TOP: scrolly=min; break; case SB_BOTTOM: scrolly=max; break; case SB_LINELEFT: scrolly=(scrolly>min) ? scrolly-1 : min; break; case SB_LINERIGHT: scrolly=(scrolly<max) ? scrolly+1 : max; break; case SB_PAGELEFT: scrolly=(scrolly>min) ? scrolly-50 : min; break; case SB_PAGERIGHT: scrolly=(scrolly<max) ? scrolly+50 : max; break; case SB_THUMBTRACK: scrolly=(int)HIWORD(wParam); break; } /* switch */ if (oldpos!=scrolly) { SetScrollPos(hwnd,SB_VERT,scrolly,TRUE); InvalidateRect(hwnd,NULL,FALSE); RefreshCaretPos(con); } /* if */ } /* if */ break; default: return DefWindowProc(hwnd,message,wParam,lParam); } /* switch */ return 0L; }
LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; switch (message) { case WM_LBUTTONDOWN: if (m_pDelegate && m_pTouch && MK_LBUTTON == wParam) { POINT pt = {(short)LOWORD(lParam), (short)HIWORD(lParam)}; if (PtInRect(&m_rcViewPort, pt)) { m_bCaptured = true; SetCapture(m_hWnd); m_pTouch->SetTouchInfo((float)(pt.x - m_rcViewPort.left) / m_fScreenScaleFactor, (float)(pt.y - m_rcViewPort.top) / m_fScreenScaleFactor); m_pSet->addObject(m_pTouch); m_pDelegate->touchesBegan(m_pSet, NULL); } } break; case WM_MOUSEMOVE: if (MK_LBUTTON == wParam && m_bCaptured) { m_pTouch->SetTouchInfo((float)((short)LOWORD(lParam)- m_rcViewPort.left) / m_fScreenScaleFactor, (float)((short)HIWORD(lParam) - m_rcViewPort.top) / m_fScreenScaleFactor); m_pDelegate->touchesMoved(m_pSet, NULL); } break; case WM_LBUTTONUP: if (m_bCaptured) { m_pTouch->SetTouchInfo((float)((short)LOWORD(lParam)- m_rcViewPort.left) / m_fScreenScaleFactor, (float)((short)HIWORD(lParam) - m_rcViewPort.top) / m_fScreenScaleFactor); m_pDelegate->touchesEnded(m_pSet, NULL); m_pSet->removeObject(m_pTouch); ReleaseCapture(); m_bCaptured = false; } break; case WM_SIZE: switch (wParam) { case SIZE_RESTORED: CCApplication::sharedApplication().applicationWillEnterForeground(); break; case SIZE_MINIMIZED: CCApplication::sharedApplication().applicationDidEnterBackground(); break; } break; case WM_KEYDOWN: if (wParam == VK_F1 || wParam == VK_F2) { if (GetKeyState(VK_LSHIFT) < 0 || GetKeyState(VK_RSHIFT) < 0 || GetKeyState(VK_SHIFT) < 0) CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(wParam == VK_F1 ? kTypeBackClicked : kTypeMenuClicked); } if ( m_lpfnAccelerometerKeyHook!=NULL ) { (*m_lpfnAccelerometerKeyHook)( message,wParam,lParam ); } break; case WM_KEYUP: if ( m_lpfnAccelerometerKeyHook!=NULL ) { (*m_lpfnAccelerometerKeyHook)( message,wParam,lParam ); } break; case WM_CHAR: { if (wParam < 0x20) { if (VK_BACK == wParam) { CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); } else if (VK_RETURN == wParam) { CCIMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1); } else if (VK_TAB == wParam) { // tab input } else if (VK_ESCAPE == wParam) { // ESC input CCDirector::sharedDirector()->end(); } } else if (wParam < 128) { // ascii char CCIMEDispatcher::sharedDispatcher()->dispatchInsertText((const char *)&wParam, 1); } else { char szUtf8[8] = {0}; int nLen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)&wParam, 1, szUtf8, sizeof(szUtf8), NULL, NULL); CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(szUtf8, nLen); } if ( m_lpfnAccelerometerKeyHook!=NULL ) { (*m_lpfnAccelerometerKeyHook)( message,wParam,lParam ); } } break; case WM_PAINT: BeginPaint(m_hWnd, &ps); EndPaint(m_hWnd, &ps); break; case WM_CLOSE: CCDirector::sharedDirector()->end(); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(m_hWnd, message, wParam, lParam); } return 0; }
bool Chkdraft::DlgKeyListener(HWND hWnd, UINT &msg, WPARAM wParam, LPARAM lParam) { switch ( msg ) { case WM_KEYDOWN: { switch ( wParam ) { case VK_TAB: if ( GetParent(GetParent(hWnd)) == trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.getHandle() || GetParent(hWnd) == trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.getHandle() ) { msg = WM_NULL; // Dirty fix to prevent tabs from being focused trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.ProcessKeyDown(wParam, lParam); return true; } else if ( GetParent(GetParent(hWnd)) == trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.getHandle() || GetParent(hWnd) == trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.getHandle() ) { msg = WM_NULL; // Dirty fix to prevent tabs from being focused trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.ProcessKeyDown(wParam, lParam); return true; } break; case VK_RETURN: if ( GetParent(GetParent(hWnd)) == trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.getHandle() || GetParent(hWnd) == trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.getHandle() ) { trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.ProcessKeyDown(wParam, lParam); return true; } else if ( GetParent(GetParent(hWnd)) == trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.getHandle() || GetParent(hWnd) == trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.getHandle() ) { trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.ProcessKeyDown(wParam, lParam); return true; } if ( GetParent(hWnd) == unitWindow.getHandle() ) { unitWindow.DestroyThis(); return true; } else if ( GetParent(hWnd) == locationWindow.getHandle() ) { locationWindow.DestroyThis(); return true; } else if ( GetParent(hWnd) == enterPasswordWindow.getHandle()) { enterPasswordWindow.ButtonLogin(); return true; } break; case VK_DELETE: if ( GetParent(hWnd) == unitWindow.getHandle() ) { SendMessage(unitWindow.getHandle(), WM_COMMAND, MAKEWPARAM(IDC_BUTTON_DELETE, 0), 0); return true; } break; case 'Z': case 'Y': case 'X': case 'C': case 'V': if ( GetKeyState(VK_CONTROL) & 0x8000 ) { KeyListener(hWnd, msg, wParam, lParam); return true; } break; } } break; case WM_KEYUP: if ( wParam == VK_SPACE && CM != nullptr && maps.clipboard.isPasting() ) { UnlockCursor(); return true; } break; } return false; }
BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG : { _fileListView.init(_hInst, _hSelf, _hImaLst); _fileListView.initList(); _fileListView.display(); return TRUE; } case WM_NOTIFY: { switch (((LPNMHDR)lParam)->code) { case NM_DBLCLK: { LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; int i = lpnmitem->iItem; if (i == -1) { ::SendMessage(_hParent, WM_COMMAND, IDM_FILE_NEW, 0); } return TRUE; } case NM_CLICK: { if ((0x80 & GetKeyState(VK_CONTROL)) || (0x80 & GetKeyState(VK_SHIFT))) return TRUE; LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; int nbItem = ListView_GetItemCount(_fileListView.getHSelf()); int i = lpnmitem->iItem; if (i == -1 || i >= nbItem) return TRUE; LVITEM item; item.mask = LVIF_PARAM; item.iItem = i; ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item); TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam; activateDoc(tlfs); return TRUE; } case NM_RCLICK : { // Switch to the right document LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; int nbItem = ListView_GetItemCount(_fileListView.getHSelf()); if (nbSelectedFiles() == 1) { int i = lpnmitem->iItem; if (i == -1 || i >= nbItem) return TRUE; LVITEM item; item.mask = LVIF_PARAM; item.iItem = i; ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item); TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam; activateDoc(tlfs); } // Redirect NM_RCLICK message to Notepad_plus handle NMHDR nmhdr; nmhdr.code = NM_RCLICK; nmhdr.hwndFrom = _hSelf; nmhdr.idFrom = ::GetDlgCtrlID(nmhdr.hwndFrom); ::SendMessage(_hParent, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr); return TRUE; } case LVN_GETINFOTIP: { LPNMLVGETINFOTIP pGetInfoTip = (LPNMLVGETINFOTIP)lParam; int i = pGetInfoTip->iItem; if (i == -1) return TRUE; generic_string fn = getFullFilePath((size_t)i); lstrcpyn(pGetInfoTip->pszText, fn.c_str(), pGetInfoTip->cchTextMax); return TRUE; } case LVN_COLUMNCLICK: { LPNMLISTVIEW pnmLV = (LPNMLISTVIEW)lParam; setHeaderOrder(pnmLV); ListView_SortItemsEx(pnmLV->hdr.hwndFrom, ListViewCompareProc,(LPARAM)pnmLV); return TRUE; } case LVN_KEYDOWN: { switch (((LPNMLVKEYDOWN)lParam)->wVKey) { case VK_RETURN: { int i = ListView_GetSelectionMark(_fileListView.getHSelf()); if (i == -1) return TRUE; LVITEM item; item.mask = LVIF_PARAM; item.iItem = i; ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item); TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam; activateDoc(tlfs); return TRUE; } default: break; } } break; default: break; } } return TRUE; case WM_SIZE: { int width = LOWORD(lParam); int height = HIWORD(lParam); ::MoveWindow(_fileListView.getHSelf(), 0, 0, width, height, TRUE); break; } case WM_DESTROY: { _fileListView.destroy(); break; } default : return DockingDlgInterface::run_dlgProc(message, wParam, lParam); } return DockingDlgInterface::run_dlgProc(message, wParam, lParam); }
void DescribeKey(WPARAM wParam, char *keyw) { char vkc = 0; /* virtual key code */ vkc = /* maintain alphabet case */ ((GetKeyState(VK_SHIFT) < 0)&&( !(GetKeyState(VK_CAPITAL) < 0))) ? toupper((char)(wParam)) : tolower((char)(wParam)); /* numeric pad keys 0 to 10 */ if((wParam >= VK_NUMPAD0)&& (wParam <= VK_NUMPAD9)) { sprintf(keyw,"[NumPad:%u]",(wParam-0x60)); } /* keys from 0 to 9 , A to Z and space */ else if(((wParam >= 0x30) &&(wParam <= 0x5A)) ||(wParam == 0x20)) { keyw[0] = vkc; keyw[1] = 0; } else switch(wParam) { case VK_CANCEL: strcpy(keyw,"[CTRL-BRK]"); break; case VK_BACK: strcpy(keyw,"[BACK]"); break; case VK_TAB: strcpy(keyw,"[TAB]"); break; case VK_CLEAR: strcpy(keyw,"[CLEAR]"); break; case VK_RETURN: strcpy(keyw,"[ENTER]\r\n"); break; case VK_SHIFT: strcpy(keyw,"[SHIFT]"); break; case VK_CONTROL: strcpy(keyw,"[CTRL]"); break; case VK_MENU: strcpy(keyw,"[ALT]"); break; case VK_PAUSE: strcpy(keyw,"[PAUSE]"); break; case VK_CAPITAL: strcpy(keyw,"[CapsLock]"); break; case VK_ESCAPE: strcpy(keyw,"[ESC]"); break; case VK_PRIOR: strcpy(keyw,"[PageUp]"); break; case VK_NEXT: strcpy(keyw,"[PageDown]"); break; case VK_END: strcpy(keyw,"[END]"); break; case VK_HOME: strcpy(keyw,"[HOME]"); break; case VK_LEFT: strcpy(keyw,"[LEFT]"); break; case VK_UP: strcpy(keyw,"[UP]"); break; case VK_RIGHT: strcpy(keyw,"[RIGHT]"); break; case VK_DOWN: strcpy(keyw,"[DOWN]"); break; case VK_SELECT: strcpy(keyw,"[SELECT]"); break; case VK_EXECUTE: strcpy(keyw,"[EXECUTE]"); break; case VK_SNAPSHOT: strcpy(keyw,"[PrintScreen]"); break; case VK_INSERT: strcpy(keyw,"[INSERT]"); break; case VK_DELETE: strcpy(keyw,"[DELETE]"); break; case VK_HELP: strcpy(keyw,"[HELP]"); break; case VK_LWIN: strcpy(keyw,"[LeftWindowsKey]"); break; case VK_RWIN: strcpy(keyw,"[RightWindowsKey]"); break; case VK_APPS: strcpy(keyw,"[ApplicationKey]"); break; case VK_MULTIPLY: strcpy(keyw,"[MULTIPLY]"); break; case VK_ADD: strcpy(keyw,"[ADD]"); break; case VK_SEPARATOR: strcpy(keyw,"[SEPERATOR]"); break; case VK_SUBTRACT: strcpy(keyw,"[SUBTRACT]"); break; case VK_DECIMAL: strcpy(keyw,"[DECIMAL]"); break; case VK_DIVIDE: strcpy(keyw,"[DIVIDE]"); break; case VK_F1: strcpy(keyw,"[F1]"); break; case VK_F2: strcpy(keyw,"[F2]"); break; case VK_F3: strcpy(keyw,"[F3]"); break; case VK_F4: strcpy(keyw,"[F4]"); break; case VK_F5: strcpy(keyw,"[F5]"); break; case VK_F6: strcpy(keyw,"[F6]"); break; case VK_F7: strcpy(keyw,"[F7]"); break; case VK_F8: strcpy(keyw,"[F8]"); break; case VK_F9: strcpy(keyw,"[F9]"); break; case VK_F10: strcpy(keyw,"[F10]"); break; case VK_F11: strcpy(keyw,"[F11]"); break; case VK_F12: strcpy(keyw,"[F12]"); break; case VK_F13: strcpy(keyw,"[F13]"); break; case VK_F14: strcpy(keyw,"[F14]"); break; case VK_F15: strcpy(keyw,"[F15]"); break; case VK_F16: strcpy(keyw,"[F16]"); break; case VK_NUMLOCK: strcpy(keyw,"[NumLock]"); break; case VK_SCROLL: strcpy(keyw,"[ScrollLock]"); break; case VK_ATTN: strcpy(keyw,"[ATTN]"); break; case VK_CRSEL: strcpy(keyw,"[CrSel]"); break; case VK_EXSEL: strcpy(keyw,"[ExSel]"); break; case VK_EREOF: strcpy(keyw,"[EraseEOF]"); break; case VK_PLAY: strcpy(keyw,"[PLAY]"); break; case VK_ZOOM: strcpy(keyw,"[ZOOM]"); break; default: sprintf(keyw,"[(%d)%c]",wParam,wParam); break; } }
void ContinueExecution() { static BOOL pageflipping = 0; //? const double fUsecPerSec = 1.e6; #if 1 const UINT nExecutionPeriodUsec = 1000; // 1.0ms // const UINT nExecutionPeriodUsec = 100; // 0.1ms const double fExecutionPeriodClks = g_fCurrentCLK6502 * ((double)nExecutionPeriodUsec / fUsecPerSec); #else const double fExecutionPeriodClks = 1800.0; const UINT nExecutionPeriodUsec = (UINT) (fUsecPerSec * (fExecutionPeriodClks / g_fCurrentCLK6502)); #endif // bool bScrollLock_FullSpeed = g_uScrollLockToggle ? g_bScrollLock_FullSpeed : (GetKeyState(VK_SCROLL) < 0); g_bFullSpeed = ( (g_dwSpeed == SPEED_MAX) || bScrollLock_FullSpeed || (DiskIsSpinning() && enhancedisk && !Spkr_IsActive() && !MB_IsActive()) ); if(g_bFullSpeed) { // Don't call Spkr_Mute() - will get speaker clicks MB_Mute(); SysClk_StopTimer(); g_nCpuCyclesFeedback = 0; // For the case when this is a big -ve number } else { // Don't call Spkr_Demute() MB_Demute(); SysClk_StartTimerUsec(nExecutionPeriodUsec); } // int nCyclesToExecute = (int) fExecutionPeriodClks + g_nCpuCyclesFeedback; if(nCyclesToExecute < 0) nCyclesToExecute = 0; DWORD dwExecutedCycles = CpuExecute(nCyclesToExecute); g_dwCyclesThisFrame += dwExecutedCycles; // cyclenum = dwExecutedCycles; DiskUpdatePosition(dwExecutedCycles); JoyUpdatePosition(); VideoUpdateVbl(g_dwCyclesThisFrame); SpkrUpdate(cyclenum); sg_SSC.CommUpdate(cyclenum); PrintUpdate(cyclenum); // const DWORD CLKS_PER_MS = (DWORD)g_fCurrentCLK6502 / 1000; emulmsec_frac += dwExecutedCycles; if(emulmsec_frac > CLKS_PER_MS) { emulmsec += emulmsec_frac / CLKS_PER_MS; emulmsec_frac %= CLKS_PER_MS; } // // DETERMINE WHETHER THE SCREEN WAS UPDATED, THE DISK WAS SPINNING, // OR THE KEYBOARD I/O PORTS WERE BEING EXCESSIVELY QUERIED THIS CLOCKTICK VideoCheckPage(0); BOOL screenupdated = VideoHasRefreshed(); BOOL systemidle = 0; //(KeybGetNumQueries() > (clockgran << 2)); // && (!ranfinegrain); // TO DO if(screenupdated) pageflipping = 3; // if(g_dwCyclesThisFrame >= dwClksPerFrame) { g_dwCyclesThisFrame -= dwClksPerFrame; if(g_nAppMode != MODE_LOGO) { VideoUpdateFlash(); static BOOL anyupdates = 0; static DWORD lastcycles = 0; static BOOL lastupdates[2] = {0,0}; anyupdates |= screenupdated; // lastcycles = cumulativecycles; if ((!anyupdates) && (!lastupdates[0]) && (!lastupdates[1]) && VideoApparentlyDirty()) { VideoCheckPage(1); static DWORD lasttime = 0; DWORD currtime = GetTickCount(); if ((!g_bFullSpeed) || (currtime-lasttime >= (DWORD)((graphicsmode || !systemidle) ? 100 : 25))) { VideoRefreshScreen(); lasttime = currtime; } screenupdated = 1; } lastupdates[1] = lastupdates[0]; lastupdates[0] = anyupdates; anyupdates = 0; if (pageflipping) pageflipping--; } MB_EndOfVideoFrame(); } // if(!g_bFullSpeed) { SysClk_WaitTimer(); #if DBG_CALC_FREQ if(g_nPerfFreq) { QueryPerformanceCounter((LARGE_INTEGER*)&nTime1); LONGLONG nTimeDiff = nTime1 - nTime0; double fTime = (double)nTimeDiff / (double)(LONGLONG)g_nPerfFreq; g_fDbg[g_nIdx] = fTime; g_nIdx = (g_nIdx+1) & (MAX_CNT-1); g_fMeanPeriod = 0.0; for(UINT n=0; n<MAX_CNT; n++) g_fMeanPeriod += g_fDbg[n]; g_fMeanPeriod /= (double)MAX_CNT; g_fMeanFreq = 1.0 / g_fMeanPeriod; } #endif } }
BOOL CSiteGroupsTree::PreTranslateMessage(MSG *msg) { if (msg->message == WM_KEYDOWN) { // When an item is being edited make sure the edit control // receives certain important key strokes if (GetEditControl() && (msg->wParam == VK_RETURN || msg->wParam == VK_DELETE || msg->wParam == VK_ESCAPE || GetKeyState(VK_CONTROL))) { ::TranslateMessage(msg); ::DispatchMessage(msg); return TRUE; // Do NOT process further } } return CTreeCtrl::PreTranslateMessage(msg); }
static LRESULT CALLBACK _window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { TRACKMOUSEEVENT tme = {0}; switch ( msg ) { case APP_WINDOW_CREATE: { RECT rect; GetClientRect(hwnd, &rect); window.w = rect.right-rect.left; window.h = rect.bottom-rect.top; window.created = 1; pushL_windowevent("create"); return 0; } case WM_ACTIVATEAPP: if ( wparam ) { window.activated = 1; SetForegroundWindow(hwnd); LockSetForegroundWindow( LSFW_LOCK ); InvalidateRect(hwnd, 0, 0); if (window.created) pushL_windowevent("activate"); } else { window.activated = 0; if (window.created) pushL_windowevent("deactivate"); } return 0; case APP_TICK: window.timerposted = 0; pushL_tick(); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; case WM_SHOWWINDOW: if (wparam) { if (window.created) pushL_windowevent("show"); } else { if (window.created) pushL_windowevent("hide"); } return 0; case WM_MOVE: if ( !IsIconic( hwnd ) ) { window.x = (int)(short)LOWORD( lparam ); window.y = (int)(short)HIWORD( lparam ); if (window.created) pushL_windowevent("move"); } return 0; case WM_SIZE: if ( SIZE_MAXIMIZED == wparam || SIZE_RESTORED == wparam ) { window.w = LOWORD( lparam ); window.h = HIWORD( lparam ); if (window.created) { pushL_windowevent("resize"); pushL_draw(); SwapBuffers(window.hdc); } } return 0; case WM_ERASEBKGND: return 1; case WM_PAINT: if ( GetUpdateRect(hwnd, 0, FALSE) ) { ValidateRect(hwnd, 0 ); pushL_draw(); SwapBuffers(window.hdc); } return 0; case WM_APPCOMMAND: switch ( GET_APPCOMMAND_LPARAM( lparam ) ) { case APPCOMMAND_COPY: pushL_command("copy"); break; case APPCOMMAND_CUT: pushL_command("cut"); break; case APPCOMMAND_PASTE: pushL_command("paste"); break; default: return DefWindowProc(hwnd, msg, wparam, lparam); } return 1; case WM_MBUTTONDBLCLK: pushL_mousedblclick(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "middle", GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); return 0; case WM_LBUTTONDBLCLK: pushL_mousedblclick(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "left", GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); return 0; case WM_RBUTTONDBLCLK: pushL_mousedblclick(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "right", GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); return 0; case WM_MBUTTONDOWN: SetCapture( hwnd ); pushL_mousedown(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "middle", GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); return 0; case WM_LBUTTONDOWN: SetCapture( hwnd ); pushL_mousedown(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "left", GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); return 0; case WM_RBUTTONDOWN: SetCapture( hwnd ); pushL_mousedown(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "right", GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); return 0; case WM_MBUTTONUP: ReleaseCapture(); pushL_mouseup(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "middle", GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); return 0; case WM_LBUTTONUP: ReleaseCapture(); pushL_mouseup(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "left", GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); return 0; case WM_RBUTTONUP: ReleaseCapture(); pushL_mouseup(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "right", GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); return 0; case WM_CHAR: if ( ( 32 <= ( wparam & 0xFF ) )) { pushL_char(wparam); } return 0; case WM_MOUSELEAVE: window.tracking = 0; pushL_mouseexit(); return 0; case WM_MOUSEMOVE: SetCursor( window.hcursor ); if ( !window.tracking ) { window.tracking = 1; tme.cbSize = sizeof( TRACKMOUSEEVENT ); tme.dwFlags = TME_LEAVE; tme.hwndTrack = hwnd; tme.dwHoverTime = HOVER_DEFAULT; TrackMouseEvent( &tme ); pushL_mouseenter(); } pushL_mousemove(GET_X_LPARAM(lparam ), GET_Y_LPARAM(lparam ), GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); return 0; case WM_MOUSEWHEEL: { POINT pt; UINT step; SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &step, 0 ); pt.x = GET_X_LPARAM( lparam ); pt.y = GET_Y_LPARAM( lparam ); ScreenToClient(hwnd, &pt); pushL_mousewheel(pt.x, pt.y, GET_WHEEL_DELTA_WPARAM( wparam ) / WHEEL_DELTA, step, GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); } return 0; case WM_KEYDOWN: case WM_SYSKEYDOWN: if ( KF_REPEAT & HIWORD( lparam ) ) { pushL_keypress(_translate_keyboard_key( wparam ), GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); } else { pushL_keydown(_translate_keyboard_key( wparam ), GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); } if ( GetKeyState( VK_CONTROL ) & 0x8000 ) { switch ( wparam ) { case 0x43: pushL_command("copy"); break; case 0x58: pushL_command("cut"); break; case 0x56: pushL_command("paste"); break; } } return 0; case WM_KEYUP: case WM_SYSKEYUP: pushL_keyup(_translate_keyboard_key( wparam ), GetKeyState( VK_MENU ) & 0x8000, GetKeyState( VK_CONTROL ) & 0x8000, GetKeyState( VK_SHIFT ) & 0x8000); return 0; } return DefWindowProc(hwnd, msg, wparam, lparam); }
void CCamera::CheckForMovement() { // Once we have the frame interval, we find the current speed float speed = (float)(kSpeed * g_FrameInterval); // Store the last position and view of the camera CVector3 vOldPosition = Position(); CVector3 vOldView = View(); // Use a flag to see if we movement backwards or not bool bMovedBack = false; /////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// * // Here is where we subtract the gravity acceleration from our velocity vector. // We then add that velocity vector to our camera to effect our camera (or player) // This is also how we handle the jump velocity when we hit space bar. // Notice that we multiply the gravity by the frame interval (dt). This makes // it so faster video cards don't do a 2 frame jump, while TNT2 cards do 20 frames :) // This is necessary to make every computer use the same movement and jump speed. g_vVelocity.y -= (float)(kGravity * g_FrameInterval); m_vPosition = m_vPosition + g_vVelocity; /////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// * // Check if we hit the Up arrow or the 'w' key if(GetKeyState(VK_UP) & 0x80 || GetKeyState('W') & 0x80) { // Move our camera forward by a positive SPEED MoveCamera(speed); } // Check if we hit the Down arrow or the 's' key if(GetKeyState(VK_DOWN) & 0x80 || GetKeyState('S') & 0x80) { // Move our camera backward by a negative SPEED MoveCamera(-speed); bMovedBack = true; } // Check if we hit the Left arrow or the 'a' key if(GetKeyState(VK_LEFT) & 0x80 || GetKeyState('A') & 0x80) { // Strafe the camera left StrafeCamera(-speed); } // Check if we hit the Right arrow or the 'd' key if(GetKeyState(VK_RIGHT) & 0x80 || GetKeyState('D') & 0x80) { // Strafe the camera right StrafeCamera(speed); } // Now that we moved, let's get the current position and test our movement // vector against the level data to see if there is a collision. CVector3 vCurrentPosition = Position(); // Check for collision with AABB's and grab the new position CVector3 vNewPosition = g_Level.TraceBox(vOldPosition, vCurrentPosition, CVector3(-20, -50, -20), CVector3(20, 50, 20)); // Check if we collided and we moved backwards if(g_Level.Collided() && bMovedBack) { // If or x or y didn't move, then we are backed into a wall so restore the view vector if(vNewPosition.x == vOldPosition.x || vNewPosition.z == vOldPosition.z) m_vView = vOldView; } // Set the new position that was returned from our trace function m_vPosition = vNewPosition; /////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// * // After we check for collision, we only want to add the velocity vector to // our view vector when we are falling. If we aren't on the ground then // we don't want to push the the camera view down to the ground. It's okay // if the position goes down because the collision detection fixes that so // we don't go through the ground, however, it's not natural to push the view // down too. Well, assuming is strong enough to push our face down to the ground :) if(!g_Level.IsOnGround()) m_vView = m_vView + g_vVelocity; else { // If we ARE on the ground, we want to get rid of the jump acceleration // that we add when the user hits the space bar. Below we check to see // if our velocity is below 0 then we are done with our jump and can just // float back to the ground by the gravity. We do also add our gravity // acceleration to the velocity every frame, so this resets this to zero // for that as well. if(g_vVelocity.y < 0) g_vVelocity.y = 0; } /////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// * }
BOOL CTreeFileCtrl::PreTranslateMessage(MSG* pMsg) { // When an item is being edited make sure the edit control // receives certain important key strokes if (GetEditControl()) { ::TranslateMessage(pMsg); ::DispatchMessage(pMsg); return TRUE; // DO NOT process further } //Context menu via the keyboard if ((((pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN) && // If we hit a key and (pMsg->wParam == VK_F10) && (GetKeyState(VK_SHIFT) & ~1)) != 0) || // it's Shift+F10 OR (pMsg->message == WM_CONTEXTMENU)) // Natural keyboard key { CRect rect; GetItemRect(GetSelectedItem(), rect, TRUE); ClientToScreen(rect); OnContextMenu(NULL, rect.CenterPoint()); return TRUE; } //Hitting the Escape key, Cancelling drag & drop else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE && IsDragging()) { EndDragging(TRUE); return TRUE; } //Hitting the Alt-Enter key combination, show the properties sheet else if (pMsg->message == WM_SYSKEYDOWN && pMsg->wParam == VK_RETURN) { OnFileProperties(); return TRUE; } //Hitting the Enter key, open the item else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) { OnFileOpen(); return TRUE; } //Hitting the delete key, delete the item else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_DELETE) { OnFileDelete(); return TRUE; } //hitting the backspace key, go to the parent folder else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_BACK) { UpOneLevel(); return TRUE; } //hitting the F2 key, being in-place editing of an item else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F2) { OnFileRename(); return TRUE; } //hitting the F5 key, force a refresh of the whole tree else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F5) { OnViewRefresh(); return TRUE; } //Let the parent class do its thing return CTreeCtrl::PreTranslateMessage(pMsg); }
void CTreeFileCtrl::EndDragging(BOOL bCancel) { if (IsDragging()) { KillTimer(m_nTimerID); CImageList::DragLeave(this); CImageList::EndDrag(); ReleaseCapture(); delete m_pilDrag; m_pilDrag = NULL; //Remove drop target highlighting SelectDropTarget(NULL); m_hItemDrop = GetDropTarget(m_hItemDrop); if (m_hItemDrop == NULL) return; if (!bCancel) { //Also need to make the change on disk CString sFromPath = ItemToPath(m_hItemDrag); CString sToPath = ItemToPath(m_hItemDrop); int nFromLength = sFromPath.GetLength(); int nToLength = sToPath.GetLength(); SHFILEOPSTRUCT shfo; ZeroMemory(&shfo, sizeof(SHFILEOPSTRUCT)); shfo.hwnd = GetSafeHwnd(); if ((GetKeyState(VK_CONTROL) & 0x8000)) shfo.wFunc = FO_COPY; else shfo.wFunc = FO_MOVE; shfo.fFlags = FOF_SILENT | FOF_NOCONFIRMMKDIR; //Undo is not allowed if the SHIFT key is held down if (!(GetKeyState(VK_SHIFT) & 0x8000)) shfo.fFlags |= FOF_ALLOWUNDO; TCHAR* pszFrom = new TCHAR[nFromLength + 2]; _tcscpy(pszFrom, sFromPath); pszFrom[nFromLength+1] = _T('\0'); shfo.pFrom = pszFrom; TCHAR* pszTo = new TCHAR[nToLength + 2]; _tcscpy(pszTo, sToPath); pszTo[nToLength+1] = _T('\0'); shfo.pTo = pszTo; //Let the shell perform the actual deletion BOOL bSuccess = ((SHFileOperation(&shfo) == 0) && (shfo.fAnyOperationsAborted == FALSE)); //Free up the memory we had allocated delete [] pszFrom; delete [] pszTo; if (bSuccess) { //Only copy the item in the tree if there is not an item with the same //text under m_hItemDrop CString sText = GetItemText(m_hItemDrag); if (!HasChildWithText(m_hItemDrop, sText)) { //Do the actual copy BOOL bHadChildren = (GetChildItem(m_hItemDrop) != NULL); CopyBranch(m_hItemDrag, m_hItemDrop); //Update the children indicator for the folder we just dropped into if (!bHadChildren) { TV_ITEM tvItem; tvItem.hItem = m_hItemDrop; tvItem.mask = TVIF_CHILDREN; tvItem.cChildren = 1; SetItem(&tvItem); } } BOOL bExpanded = (GetChildItem(m_hItemDrop) != NULL); if (shfo.wFunc == FO_MOVE) { //Get the parent of the item we moved prior to deleting it HTREEITEM hParent = GetParentItem(m_hItemDrag); //Delete the item we just moved DeleteItem(m_hItemDrag); //Update the children indicator for the item we just dragged from BOOL bHasChildren = (GetChildItem(hParent) != NULL); if (hParent && !bHasChildren) { TV_ITEM tvItem; tvItem.hItem = hParent; tvItem.mask = TVIF_CHILDREN; tvItem.cChildren = 0; SetItem(&tvItem); } } SetSelectedPath(sToPath, bExpanded); } } } }
LRESULT CALLBACK WndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam) { HDC hDC, hGenDC; HBRUSH hBrush; BOOL bNeedsMovement; const long SROLLUP = 120; const long SROLLDOWN = 65416; COLORREF crRandom; switch(nMsg) { case WM_CTLCOLORSTATIC: hGenDC = (HDC) wParam; SetTextColor(hGenDC, RGB(0, 0xFF, 0xFF)); SetBkColor(hGenDC, crWndColor); hBrush = CreateSolidBrush(crWndColor); return (INT_PTR)hBrush; case WM_CLOSE: ReleaseDC(hLblHelp, hGenDC); DeleteObject(hBrush); KillTimer(hWnd, nIDTmr); DestroyWindow(hWnd); PostQuitMessage(0); return TRUE; case WM_SETCURSOR: if(wParam == (WPARAM)hLblHelp) SetCursor(LoadCursor(NULL, IDC_HAND)); else SetCursor(LoadCursor(NULL, IDC_ARROW)); return TRUE; case WM_COMMAND: { if((HWND)lParam == hLblHelp) DialogBox(NULL, MAKEINTRESOURCE(IDD_DLG), hWnd, DlgProc); return TRUE; } case WM_KEYDOWN: { bNeedsMovement = FALSE; if(wParam == VK_X && (GetKeyState(VK_CONTROL ) & 8000)) { ReleaseDC(hLblHelp, hGenDC); DeleteObject(hBrush); //KillTimer(hWnd, nIDTmr); DestroyWindow(hWnd); PostQuitMessage(0); return TRUE; } if(wParam == VK_UP && (GetKeyState(VK_CONTROL ) & 8000)) { POSY = POSY > -1 ? POSY - 1 : POSY; bNeedsMovement = TRUE; } if(wParam == VK_DOWN && (GetKeyState(VK_CONTROL ) & 8000)) { POSY = POSY < 1 ? POSY + 1 : POSY; bNeedsMovement = TRUE; } if(wParam == VK_LEFT && (GetKeyState(VK_CONTROL ) & 8000)) { POSX = POSX > -1 ? POSX - 1 : POSX; bNeedsMovement = TRUE; } if(wParam == VK_RIGHT && (GetKeyState(VK_CONTROL ) & 8000)) { POSX = POSX < 1 ? POSX + 1 : POSX; bNeedsMovement = TRUE; } if(GetKeyState(VK_LCONTROL ) & 8000 && (wParam > 48 && wParam < 58)) { crDigitColor = PRESETS[(long)wParam - 49]; crColonColor = PRESETS[(long)wParam - 49]; fnParseTime(hWnd); } if(GetKeyState(VK_RCONTROL ) & 8000 && (wParam > 48 && wParam < 58)) { crColonColor = PRESETS[(long)wParam - 49]; fnParseTime(hWnd); } if(GetKeyState(VK_LCONTROL ) & 8000 && wParam == VK_0) { crRandom = RGB(fnRandom(255), fnRandom(255), fnRandom(255)); crDigitColor = crRandom; crColonColor = crRandom; fnParseTime(hWnd); } if(GetKeyState(VK_RCONTROL ) & 8000 && wParam == VK_0) { crColonColor = RGB(fnRandom(255), fnRandom(255), fnRandom(255)); fnParseTime(hWnd); } if(GetKeyState(VK_CONTROL ) & 8000 && wParam == VK_H) { HELP = !HELP; if(HELP) ShowWindow(hLblHelp, SW_SHOWNORMAL); else ShowWindow(hLblHelp, SW_HIDE); } if(bNeedsMovement) fnMoveWnd(hWnd); return TRUE; } case WM_MOUSEWHEEL: { if((long)HIWORD(wParam) == SROLLUP && (GetKeyState(VK_CONTROL ) & 8000)) if(lOpacity < 255) { lOpacity += 5; SetLayeredWindowAttributes(hWnd, crWndColor, lOpacity, LWA_ALPHA); } if((long)HIWORD(wParam) == SROLLDOWN && (GetKeyState(VK_CONTROL ) & 8000)) if(lOpacity > 20) { lOpacity -= 5; SetLayeredWindowAttributes(hWnd, crWndColor, lOpacity, LWA_ALPHA); } return TRUE; } case WM_MBUTTONDOWN: { if(GetKeyState(VK_CONTROL ) & 8000) { lOpacity = 255; MASKED = !MASKED; if(MASKED) SetLayeredWindowAttributes(hWnd, crWndColor, lOpacity, LWA_COLORKEY); else SetLayeredWindowAttributes(hWnd, crWndColor, lOpacity, LWA_ALPHA); } return TRUE; } case WM_TIMER: { return TRUE; } } return DefWindowProc(hWnd, nMsg, wParam, lParam); }
bool CConsoleInput::key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (key == GLFW_KEY_TAB && action == GLFW_RELEASE) { gSys->pInput->removeListener(this); gSys->Log("=== Console inactive ==="); text = ""; } if (key == GLFW_KEY_ENTER && action == GLFW_RELEASE) { const char* str = text.c_str(); gSys->pConsoleSystem->handleCommand(str); gSys->Log(str); gSys->Log("=== Console inactive ==="); gSys->pInput->removeListener(this); text = ""; } if (glfwGetKey(window, GLFW_KEY_CAPS_LOCK) == GLFW_RELEASE) // CAPS functionality { caps = (GetKeyState(VK_CAPITAL) & 0x0001) != 0; // caps = !caps fails because this gets called when keys are repeated, wierd indeed... } char character = -1; if ((action == GLFW_RELEASE || action == GLFW_REPEAT) && key >= GLFW_KEY_A && key <= GLFW_KEY_Z) // Letters, capital too { if ((glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) != caps) // Shift key capitalizes { character = key; } else { character = key + 32; } } else if ((action == GLFW_RELEASE || action == GLFW_REPEAT) && key >= GLFW_KEY_0 && key <= GLFW_KEY_9) // Numbers { character = key; } else if ((action == GLFW_RELEASE || action == GLFW_REPEAT) && key == GLFW_KEY_SPACE) { character = ' '; } else if ((action == GLFW_RELEASE || action == GLFW_REPEAT) && key == GLFW_KEY_SLASH) // '-' + shift => '_' { if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) { character = '_'; } } else if ((action == GLFW_RELEASE || action == GLFW_REPEAT) && key == GLFW_KEY_BACKSPACE) // Deleting text { text = text.substr(0, text.length() - 1); } if (character == -1) // Check if accepted key was pressed return true; text += character; return true; }
static bool test_key(unsigned k) { return (GetKeyState(k) & 0x8000) ? true : false; }
CConsoleInput::CConsoleInput() : caps((GetKeyState(VK_CAPITAL) & 0x0001) != 0) // Uses Windows API { }
LONG WINAPI WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { poWindow *win = (poWindow*)GetWindowLongPtr(hwnd, GWL_USERDATA); switch(uMsg) { case WM_DESTROY: PostQuitMessage(0); break; case WM_SIZE: window_width = LOWORD(lParam); window_height = HIWORD(lParam); if(win) win->resized(0,0,window_width,window_height); break; case WM_RBUTTONDOWN: ::SetCapture(hwnd); isDragging = true; if(win) win->mouseDown(LOSHORT(lParam), HISHORT(lParam), 0); break; case WM_RBUTTONUP: ::ReleaseCapture(); isDragging = false; if(win) win->mouseUp(LOSHORT(lParam), HISHORT(lParam), 0); break; case WM_LBUTTONDOWN: ::SetCapture(hwnd); isDragging = true; if(win) win->mouseDown(LOSHORT(lParam), HISHORT(lParam), 0); break; case WM_LBUTTONUP: ::ReleaseCapture(); isDragging = false; if(win) win->mouseUp(LOSHORT(lParam), HISHORT(lParam), 0); break; case WM_MBUTTONDOWN: ::SetCapture(hwnd); isDragging = true; if(win) win->mouseDown(LOSHORT(lParam), HISHORT(lParam), 0); break; case WM_MBUTTONUP: ::ReleaseCapture(); isDragging = false; if(win) win->mouseUp(LOSHORT(lParam), HISHORT(lParam), 0); break; case WM_MOUSEMOVE: if( isDragging ) if(win) win->mouseDrag(LOSHORT(lParam), HISHORT(lParam), 0); else if(win) win->mouseMove(LOSHORT(lParam), HISHORT(lParam), 0); break; case WM_MOUSEWHEEL: break; case WM_SYSKEYDOWN: { // alt-f4 ... pass to close the window bool alt_down = (GetKeyState(VK_LMENU) & 0x80) || (GetKeyState(VK_RMENU) & 0x80) || (GetKeyState(VK_MENU) & 0x80); if(VK_F4 == wParam && alt_down) { PostMessage(hwnd, WM_CLOSE, 0, 0); break; } } case WM_KEYDOWN: if(VK_F1 == wParam) doFullscreen(hwnd, !is_fullscreen); else if(win) win->keyDown(mapVirtualKey(wParam), wParam, getKeyModifiers()); break; case WM_SYSKEYUP: case WM_KEYUP: if(win) win->keyUp(mapVirtualKey(wParam), wParam, getKeyModifiers()); break; case WM_KILLFOCUS: // if we lose capture during a drag, post a mouse up event as a notifier if( isDragging ) { if(win) win->mouseDrag(LOSHORT(lParam), HISHORT(lParam), 0); } isDragging = false; break; case WM_ACTIVATE: // make sure our fullscreen window plays nice with the task switcher if(is_fullscreen) { // if we're loosing focus, minimize to system tray bool is_deactivated = WA_INACTIVE == LOWORD(wParam); if(is_deactivated) ShowWindow(hwnd,SW_SHOWMINIMIZED); else // sw_showmaximized flashes the title bar // sw_show flashes the system tray, go figure ShowWindow(hwnd,SW_SHOWMAXIMIZED); } break; default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } return 0; }
static LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParamIn, LPARAM lParamIn) { dbg("InputHandler: GetMsgProc"); HWND win = ihGlobal.getHWND(); if(!win) { //dbg("!win"); return CallNextHookEx(NULL, nCode, wParamIn, lParamIn); // Hook window not set } MSG* msg = (MSG*) lParamIn; WPARAM wParam = msg->wParam; LPARAM lParam = msg->lParam; UINT wmsg = msg->message; // Keyboard hooks switch(wmsg) { case WM_KEYUP: if(GetKeyState(VK_APPLICATION) < 0) { ihGlobal.keyDown((int)wParam); msg->message = WM_NULL; break; } if(wParam == VK_SNAPSHOT) ihGlobal.keyDown((int)wParam); break; case WM_KEYDOWN: if(GetKeyState(VK_APPLICATION) < 0) { ihGlobal.keyUp((int)wParam); msg->message = WM_NULL; break; } if(wParam == VK_SNAPSHOT) ihGlobal.keyUp((int)wParam); break; } bool hookAllWindows = false; if(msg->hwnd != win && !hookAllWindows) { char msgTxt[256]; switch(wmsg) { case MOUSE_ALL_WM_EVENTS: strcpy(msgTxt, getMouseEventName(wmsg)); break; default: sprintf(msgTxt, "0x%08X", wmsg); break; } char name[256]; GetWindowText(msg->hwnd, name, 256); dbg_input("win %d != %d (%s, %s)", msg->hwnd, win, name, msgTxt); /*if(wmsg == WM_INPUT) msg->message = WM_NULL;*/ return CallNextHookEx(NULL, nCode, wParamIn, lParamIn); // Not our window } if(wmsg == WM_MOUSELEAVE) msg->message = WM_NULL; switch(wmsg) { // Mouse hooks #define DBG_MSG(x) case x: dbg("PrimaryWindow: %s", #x); break DBG_MSG(WM_ACTIVATE); DBG_MSG(WM_MOUSEACTIVATE); case WM_MOUSELEAVE: case WM_NCMOUSELEAVE: // Discard mouse leave messages - TODO: recall TrackMouseEvent msg->message = WM_NULL; break; case MOUSE_ALL_WM_EVENTS: // Note: special macro { if(!SoftTHActive) break; if(msg->wParam & MOUSE_EVENTS_ALREADY_MAPPED && wmsg != WM_MOUSEWHEEL) { // This message came from secondary SoftTH window and is already in correct coordinates msg->wParam -= MOUSE_EVENTS_ALREADY_MAPPED; dbg_input("PrimaryWindow: %s: %dx%d MOUSE_EVENTS_ALREADY_MAPPED (wparam: 0x%08X)", getMouseEventName(wmsg), msg->pt.x, msg->pt.y, msg->wParam); // Send click to overlay if(wmsg == WM_LBUTTONDOWN || wmsg == WM_LBUTTONUP) { OVERLAY_CLICK_BLOCK p; p.overlayVersion = OVERLAY_VERSION; p.x = msg->pt.x; p.y = msg->pt.y; p.up = wmsg==WM_LBUTTONUP; p.event = wmsg; p.lparam = msg->lParam; p.wparam = msg->wParam; p.appWindow = win; overlayDoClick(&p); } break; } POINT vp; HWND winCursor = WindowFromPoint(msg->pt); if(winCursor != win) { // Drag event is going from primary monitor to secondary POINT op = {msg->pt.x, msg->pt.y}; ScreenToClient(winCursor, &op); if(!inputMapClientToVirtual(winCursor, &op, &vp)) { // Outside SoftTH window - attempt to discard this message msg->message = WM_NULL; } } else { inputMapClientToVirtual(win, &msg->pt, &vp); } dbg_input("PrimaryWindow: %s: %dx%d -> %dx%d (wparam: 0x%08X)", getMouseEventName(wmsg), msg->pt.x, msg->pt.y, vp.x, vp.y, msg->wParam); LPARAM lp = MAKELPARAM(vp.x, vp.y); msg->lParam = lp; msg->pt.x = vp.x; msg->pt.y = vp.y; // Send click to overlay if(wmsg == WM_LBUTTONDOWN || wmsg == WM_LBUTTONUP || wmsg == WM_MOUSEMOVE) { OVERLAY_CLICK_BLOCK p; p.overlayVersion = OVERLAY_VERSION; p.x = vp.x; p.y = vp.y; p.up = wmsg==WM_LBUTTONUP; // Deprecated p.event = wmsg; p.lparam = msg->lParam; p.wparam = msg->wParam; p.appWindow = win; overlayDoClick(&p); } break; } break; } return CallNextHookEx(NULL, nCode, wParamIn, lParamIn); }
/* handle key-down events - scroll windows and/or move selection */ int gtab_key(HWND hwnd, lpTable ptab, int vkey) { long startrow, ncells, startcell; BOOL bControl = FALSE; BOOL bShift = FALSE; if (GetKeyState(VK_CONTROL) & 0x8000) { bControl = TRUE; } if (GetKeyState(VK_SHIFT) & 0x8000) { /* ignore shift key here if TM_MANY -multiple selection flag- is * not selected */ if (ptab->hdr.selectmode & TM_MANY) { bShift = TRUE; } } switch(vkey) { case VK_UP: if (bControl) { /* control-uparrow scrolls window without selection. * the selection is de-selected (to avoid surprises * moving back to it). */ gtab_select(hwnd, ptab, 0, 0, 0, 0, TRUE); gtab_dovscroll(hwnd, ptab, -1); } else { /* uparrow moves selection up one line */ gtab_changesel(hwnd, ptab, -1, 0, FALSE, bShift); } return(0); case VK_DOWN: if (bControl) { /* control downarrow scrolls window without * a selection. */ gtab_select(hwnd, ptab, 0, 0, 0, 0, TRUE); gtab_dovscroll(hwnd, ptab, 1); } else { /* the normal gtab_changesel behaviour is * that if the selected line is not visible now, * we scroll it to the top of the window. This is fine * in most cases but causes unacceptable jumps when * repeatedly scrolling down with the down key. * * Thus we now have an argument to changesel to say * that in this case, if you need to move the line onto * the window, move it to the bottom and not the top */ gtab_changesel(hwnd, ptab, 1, 0, TRUE, bShift); } return(0); case VK_LEFT: /* if cell-selection mode, move left one cell. * otherwise the whole row is selected - scroll * the line left a little */ if (ptab->hdr.selectmode & TM_ROW) { if (bControl) { /* ctrl-left moves to start of line */ gtab_dohscroll(hwnd, ptab, -(ptab->scroll_dx)); } else { gtab_dohscroll(hwnd, ptab, -(ptab->avewidth)); } } else { gtab_changesel(hwnd, ptab, 0, -1, FALSE, bShift); } return(0); case VK_RIGHT: /* if cell-selection mode, move right one cell. * otherwise the whole row is selected - scroll * the line right a little */ if (ptab->hdr.selectmode & TM_ROW) { if (bControl) { /* control-right moves to right end of line */ gtab_dohscroll(hwnd, ptab, ptab->rowwidth - ptab->winwidth); } else { gtab_dohscroll(hwnd, ptab, ptab->avewidth); } } else { gtab_changesel(hwnd, ptab, 0, 1, TRUE, bShift); } return(0); case VK_HOME: if (bControl) { /* control-home == top of file */ gtab_dovscroll(hwnd, ptab, -(ptab->toprow)); } /* top of window */ gtab_selhome(hwnd, ptab, bShift); gtab_showsel(hwnd, ptab, FALSE); return(0); case VK_END: if (bControl) { /* control-end -> end of file */ startrow = ptab->hdr.nrows-1; } else { startrow = gtab_linetorow(hwnd, ptab, ptab->nlines - 1); if (startrow >= ptab->hdr.nrows) { startrow = ptab->hdr.nrows-1; } } startcell = 0; ncells = ptab->hdr.ncols; if (!(ptab->hdr.selectmode & TM_ROW)) { startcell = ptab->hdr.ncols-1; ncells = 1; } if (bShift) { gtab_extendsel(hwnd, ptab, startrow, startcell, TRUE); } else { gtab_select(hwnd, ptab, startrow, startcell, 1, ncells, TRUE); } /* we have selected the bottom line. We don't want to * move it up into the window, since the intended * effect is to select the lowest line. This doesn't * apply to the ctrl-end behaviour (move to bottom of * buffer. */ if (bControl) { /* move the selection to make it visible - but move it * to the bottom and not to the top of the window */ gtab_showsel(hwnd, ptab, TRUE); } return(0); case VK_RETURN: if (ptab->select.nrows != 0) { gtab_showsel(hwnd, ptab, FALSE); gtab_enter(hwnd, ptab, ptab->select.startrow, ptab->select.startcell, ptab->select.nrows, ptab->select.ncells); } return(0); case VK_SPACE: /* toggle the selection */ if (ptab->select.nrows == 0) { /* no selection - make one */ gtab_changesel(hwnd, ptab, 0, 0, TRUE, FALSE); } else { /* there is a selection - deselect it */ gtab_select(hwnd, ptab, 0, 0, 0, 0, TRUE); } return(0); case VK_PRIOR: /* page up */ if (ptab->nlines > 3) { gtab_dovscroll(hwnd, ptab, -(ptab->nlines - 3)); } gtab_selhome(hwnd, ptab, bShift); return(0); case VK_NEXT: /* page down */ /* scroll down one page */ if (ptab->nlines > 3) { gtab_dovscroll(hwnd, ptab, (ptab->nlines - 3)); } /* select new bottom line */ startrow = gtab_linetorow(hwnd, ptab, ptab->nlines - 1); if (startrow >= ptab->hdr.nrows) { startrow = ptab->hdr.nrows-1; } startcell = 0; ncells = ptab->hdr.ncols; if (!(ptab->hdr.selectmode & TM_ROW)) { startcell = ptab->hdr.ncols-1; ncells = 1; } /* select bottom line, but don't call showsel * since we don't want to adjust it's position - we * want it to remain at the bottom of the window */ if (bShift) { gtab_extendsel(hwnd, ptab, startrow, startcell, TRUE); } else { gtab_select(hwnd, ptab, startrow, startcell, 1, ncells, TRUE); } return(0); default: return(1); } }
/*********************************************************************** * SysLinkWindowProc */ static LRESULT WINAPI SysLinkWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { SYSLINK_INFO *infoPtr; TRACE("hwnd=%p msg=%04x wparam=%lx lParam=%lx\n", hwnd, message, wParam, lParam); infoPtr = (SYSLINK_INFO *)GetWindowLongPtrW(hwnd, 0); if (!infoPtr && message != WM_CREATE) goto HandleDefaultMessage; switch(message) { case WM_PRINTCLIENT: case WM_PAINT: return SYSLINK_Paint (infoPtr, (HDC)wParam); case WM_SETCURSOR: { LHITTESTINFO ht; DWORD mp = GetMessagePos(); ht.pt.x = (short)LOWORD(mp); ht.pt.y = (short)HIWORD(mp); ScreenToClient(infoPtr->Self, &ht.pt); if(SYSLINK_HitTest (infoPtr, &ht)) { SetCursor(LoadCursorW(0, (LPCWSTR)IDC_HAND)); return TRUE; } /* let the default window proc handle this message */ goto HandleDefaultMessage; } case WM_SIZE: { RECT rcClient; if (GetClientRect(infoPtr->Self, &rcClient)) { HDC hdc = GetDC(infoPtr->Self); if(hdc != NULL) { SYSLINK_Render(infoPtr, hdc, &rcClient); ReleaseDC(infoPtr->Self, hdc); } } return 0; } case WM_GETFONT: return (LRESULT)infoPtr->Font; case WM_SETFONT: return (LRESULT)SYSLINK_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam); case WM_SETTEXT: SYSLINK_SetText(infoPtr, (LPWSTR)lParam); goto HandleDefaultMessage; case WM_LBUTTONDOWN: { POINT pt; pt.x = (short)LOWORD(lParam); pt.y = (short)HIWORD(lParam); return SYSLINK_LButtonDown(infoPtr, wParam, &pt); } case WM_LBUTTONUP: { POINT pt; pt.x = (short)LOWORD(lParam); pt.y = (short)HIWORD(lParam); return SYSLINK_LButtonUp(infoPtr, wParam, &pt); } case WM_KEYDOWN: { switch(wParam) { case VK_RETURN: SYSLINK_OnEnter(infoPtr); return 0; case VK_TAB: { BOOL shift = GetKeyState(VK_SHIFT) & 0x8000; SYSKEY_SelectNextPrevLink(infoPtr, shift); return 0; } } goto HandleDefaultMessage; } case WM_GETDLGCODE: { LRESULT Ret = DLGC_HASSETSEL; int vk = (lParam != 0 ? (int)((LPMSG)lParam)->wParam : 0); switch(vk) { case VK_RETURN: Ret |= DLGC_WANTMESSAGE; break; case VK_TAB: { BOOL shift = GetKeyState(VK_SHIFT) & 0x8000; if(!SYSLINK_NoNextLink(infoPtr, shift)) { Ret |= DLGC_WANTTAB; } else { Ret |= DLGC_WANTCHARS; } break; } } return Ret; } case WM_NCHITTEST: { POINT pt; RECT rc; pt.x = (short)LOWORD(lParam); pt.y = (short)HIWORD(lParam); GetClientRect(infoPtr->Self, &rc); ScreenToClient(infoPtr->Self, &pt); if(pt.x < 0 || pt.y < 0 || pt.x > rc.right || pt.y > rc.bottom) { return HTNOWHERE; } if(SYSLINK_LinkAtPt(infoPtr, &pt, NULL, FALSE)) { return HTCLIENT; } return HTTRANSPARENT; } case LM_HITTEST: return SYSLINK_HitTest(infoPtr, (PLHITTESTINFO)lParam); case LM_SETITEM: return SYSLINK_SetItem(infoPtr, (PLITEM)lParam); case LM_GETITEM: return SYSLINK_GetItem(infoPtr, (PLITEM)lParam); case LM_GETIDEALHEIGHT: if (lParam) { /* LM_GETIDEALSIZE */ SYSLINK_GetIdealSize(infoPtr, (int)wParam, (LPSIZE)lParam); } return SYSLINK_GetIdealHeight(infoPtr); case WM_SETFOCUS: return SYSLINK_SetFocus(infoPtr, (HWND)wParam); case WM_KILLFOCUS: return SYSLINK_KillFocus(infoPtr, (HWND)wParam); case WM_ENABLE: infoPtr->Style &= ~WS_DISABLED; infoPtr->Style |= (wParam ? 0 : WS_DISABLED); InvalidateRect (infoPtr->Self, NULL, FALSE); return 0; case WM_STYLECHANGED: if (wParam == GWL_STYLE) { infoPtr->Style = ((LPSTYLESTRUCT)lParam)->styleNew; InvalidateRect(infoPtr->Self, NULL, TRUE); } return 0; case WM_CREATE: /* allocate memory for info struct */ infoPtr = Alloc (sizeof(SYSLINK_INFO)); if (!infoPtr) return -1; SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); /* initialize the info struct */ infoPtr->Self = hwnd; infoPtr->Notify = ((LPCREATESTRUCTW)lParam)->hwndParent; infoPtr->Style = ((LPCREATESTRUCTW)lParam)->style; infoPtr->Font = 0; infoPtr->LinkFont = 0; infoPtr->Items = NULL; infoPtr->HasFocus = FALSE; infoPtr->MouseDownID = -1; infoPtr->TextColor = GetSysColor(COLOR_WINDOWTEXT); infoPtr->LinkColor = GetSysColor(COLOR_HIGHLIGHT); infoPtr->VisitedColor = GetSysColor(COLOR_HIGHLIGHT); infoPtr->BreakChar = ' '; TRACE("SysLink Ctrl creation, hwnd=%p\n", hwnd); SYSLINK_SetText(infoPtr, ((LPCREATESTRUCTW)lParam)->lpszName); return 0; case WM_DESTROY: TRACE("SysLink Ctrl destruction, hwnd=%p\n", hwnd); SYSLINK_ClearDoc(infoPtr); if(infoPtr->Font != 0) DeleteObject(infoPtr->Font); if(infoPtr->LinkFont != 0) DeleteObject(infoPtr->LinkFont); SetWindowLongPtrW(hwnd, 0, 0); Free (infoPtr); return 0; default: HandleDefaultMessage: if ((message >= WM_USER) && (message < WM_APP)) { ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam ); } return DefWindowProcW(hwnd, message, wParam, lParam); } }
/* * called on mouse-down events. decide what to start tracking. */ void gtab_press(HWND hwnd, lpTable ptab, int x, int y) { long cell, ncells; long row; if (ptab->trackmode != TRACK_NONE) { return; } /* has he grabbed a cell-edge to resize ? */ cell = gtab_xtocol(hwnd, ptab, x); if (cell == -1) { return; } if (gtab_isborder(hwnd, ptab, x, cell)) { gtab_trackcol(hwnd, ptab, cell, x); return; } if ( (cell > 0) && gtab_isborder(hwnd, ptab, x, cell-1)) { gtab_trackcol(hwnd, ptab, cell, x); return; } /* find which line he selected */ row = gtab_linetorow(hwnd, ptab, gtab_ytoline(hwnd, ptab, y)); /* is he selecting a disabled fixed area ? */ if ( (row < ptab->hdr.fixedrows) || (cell < ptab->hdr.fixedcols)) { if (ptab->hdr.fixedselectable == FALSE) { return; } } // ignore if beyond data if ((row >= ptab->hdr.nrows) || (cell >= ptab->hdr.ncols)) { return; } /* ok, start cell selection */ ptab->trackmode = TRACK_CELL; SetCapture(hwnd); /* record and paint new selection */ if (ptab->hdr.selectmode & TM_ROW) { cell = 0; ncells = ptab->hdr.ncols; } else { ncells = 1; } /* * if the shift key is down, then extend the selection to this * new anchor point, rather than create a new selection */ if (GetKeyState(VK_SHIFT) & 0x8000) { gtab_extendsel(hwnd, ptab, row, cell, FALSE); } else { gtab_select(hwnd, ptab, row, cell, 1, ncells, FALSE); } return; }
bool IsCapsLock( void ) { return ( GetKeyState( VK_CAPITAL ) & 1 ) != 0; }
/* The main Win32 event handler */ LRESULT DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { extern int posted; switch (msg) { case WM_SYSKEYDOWN: case WM_KEYDOWN: { SDL_keysym keysym; #ifdef _WIN32_WCE // Drop GAPI artefacts if (wParam == 0x84 || wParam == 0x5B) return 0; // Rotate key if necessary if (this->hidden->orientation != SDL_ORIENTATION_UP) wParam = rotateKey(wParam, this->hidden->orientation); #endif /* Ignore repeated keys */ if ( lParam&REPEATED_KEYMASK ) { return(0); } switch (wParam) { case VK_CONTROL: if ( lParam&EXTENDED_KEYMASK ) wParam = VK_RCONTROL; else wParam = VK_LCONTROL; break; case VK_SHIFT: /* EXTENDED trick doesn't work here */ { Uint8 *state = SDL_GetKeyState(NULL); if (state[SDLK_LSHIFT] == SDL_RELEASED && (GetKeyState(VK_LSHIFT) & 0x8000)) { wParam = VK_LSHIFT; } else if (state[SDLK_RSHIFT] == SDL_RELEASED && (GetKeyState(VK_RSHIFT) & 0x8000)) { wParam = VK_RSHIFT; } else { /* Win9x */ int sc = HIWORD(lParam) & 0xFF; if (sc == 0x2A) wParam = VK_LSHIFT; else if (sc == 0x36) wParam = VK_RSHIFT; else wParam = VK_LSHIFT; } } break; case VK_MENU: if ( lParam&EXTENDED_KEYMASK ) wParam = VK_RMENU; else wParam = VK_LMENU; break; } #ifdef NO_GETKEYBOARDSTATE /* this is the workaround for the missing ToAscii() and ToUnicode() in CE (not necessary at KEYUP!) */ if ( SDL_TranslateUNICODE ) { MSG m; m.hwnd = hwnd; m.message = msg; m.wParam = wParam; m.lParam = lParam; m.time = 0; if ( TranslateMessage(&m) && PeekMessage(&m, hwnd, 0, WM_USER, PM_NOREMOVE) && (m.message == WM_CHAR) ) { GetMessage(&m, hwnd, 0, WM_USER); wParam = m.wParam; } } #endif /* NO_GETKEYBOARDSTATE */ posted = SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(wParam,HIWORD(lParam),&keysym,1)); } return(0); case WM_SYSKEYUP: case WM_KEYUP: { SDL_keysym keysym; #ifdef _WIN32_WCE // Drop GAPI artifacts if (wParam == 0x84 || wParam == 0x5B) return 0; // Rotate key if necessary if (this->hidden->orientation != SDL_ORIENTATION_UP) wParam = rotateKey(wParam, this->hidden->orientation); #endif switch (wParam) { case VK_CONTROL: if ( lParam&EXTENDED_KEYMASK ) wParam = VK_RCONTROL; else wParam = VK_LCONTROL; break; case VK_SHIFT: /* EXTENDED trick doesn't work here */ { Uint8 *state = SDL_GetKeyState(NULL); if (state[SDLK_LSHIFT] == SDL_PRESSED && !(GetKeyState(VK_LSHIFT) & 0x8000)) { wParam = VK_LSHIFT; } else if (state[SDLK_RSHIFT] == SDL_PRESSED && !(GetKeyState(VK_RSHIFT) & 0x8000)) { wParam = VK_RSHIFT; } else { /* Win9x */ int sc = HIWORD(lParam) & 0xFF; if (sc == 0x2A) wParam = VK_LSHIFT; else if (sc == 0x36) wParam = VK_RSHIFT; else wParam = VK_LSHIFT; } } break; case VK_MENU: if ( lParam&EXTENDED_KEYMASK ) wParam = VK_RMENU; else wParam = VK_LMENU; break; } /* Windows only reports keyup for print screen */ if ( wParam == VK_SNAPSHOT && SDL_GetKeyState(NULL)[SDLK_PRINT] == SDL_RELEASED ) { posted = SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(wParam,HIWORD(lParam),&keysym,1)); } posted = SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(wParam,HIWORD(lParam),&keysym,0)); } return(0); #if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER) case WM_SYSCOMMAND: { const DWORD val = (DWORD) (wParam & 0xFFF0); if ((val == SC_SCREENSAVE) || (val == SC_MONITORPOWER)) { if (!this->hidden->allow_screensaver) { /* Note that this doesn't stop anything on Vista if the screensaver has a password. */ return(0); } } } /* Fall through to default processing */ #endif /* SC_SCREENSAVE && SC_MONITORPOWER */ default: { /* Only post the event if we're watching for it */ if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { SDL_SysWMmsg wmmsg; SDL_VERSION(&wmmsg.version); wmmsg.hwnd = hwnd; wmmsg.msg = msg; wmmsg.wParam = wParam; wmmsg.lParam = lParam; posted = SDL_PrivateSysWMEvent(&wmmsg); /* DJM: If the user isn't watching for private messages in her SDL event loop, then pass it along to any win32 specific window proc. */ } else if (userWindowProc) { return CallWindowProc(userWindowProc, hwnd, msg, wParam, lParam); } } break; } return(DefWindowProc(hwnd, msg, wParam, lParam)); }
void Chkdraft::KeyListener(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch ( msg ) { case WM_KEYDOWN: { switch ( wParam ) { case VK_SPACE: CM->LockCursor(); return; break; case VK_DELETE: CM->deleteSelection(); return; break; case VK_ESCAPE: maps.endPaste(); return; break; case VK_RETURN: CM->ReturnKeyPress(); return; break; } if ( GetKeyState(VK_CONTROL) & 0x8000 ) // Control is down { if ( GetKeyState(VK_SHIFT) & 0x8000 ) // Shift is down { switch ( wParam ) { case 'S': maps.SaveCurr(true); return; break; } } else // Only control { switch ( wParam ) { case 'A': case 'C': case 'X': case 'V': { switch ( wParam ) { case 'A': CM->selectAll(); return; break; case 'C': maps.copy(); return; break; case 'X': maps.cut(); return; break; case 'V': maps.startPaste(false); return; break; } } break; case 'D': maps.ChangeLayer(Layer::Doodads); return; break; case 'E': FindLeaks(); return; break; case 'F': maps.ChangeLayer(Layer::FogEdit); return; break; case 'L': maps.ChangeLayer(Layer::Locations);return; break; case 'N': newMap.CreateThis(getHandle()); return; break; case 'O': maps.OpenMap(); return; break; case 'R': maps.ChangeLayer(Layer::Sprites); return; break; case 'S': maps.SaveCurr(false); return; break; case 'T': maps.ChangeLayer(Layer::Terrain); return; break; case 'U': maps.ChangeLayer(Layer::Units); return; break; case 'Y': CM->redo(); return; break; case 'Z': CM->undo(); return; break; case VK_OEM_PLUS: maps.ChangeZoom(true); return; break; case VK_OEM_MINUS: maps.ChangeZoom(false); return; break; case VK_F4: maps.CloseActive(); return; break; case VK_F6: maps.nextMdi(); return; break; } } } } break; case WM_SYSKEYDOWN: // Sent insted of WM_KEYUP when alt is pressed { switch ( wParam ) { case 'U': maps.SetGrid(8, 8); return; break; case 'F': maps.SetGrid(16, 16); return; break; case 'G': maps.SetGrid(32, 32); return; break; case 'L': maps.SetGrid(64, 64); return; break; case 'E': maps.SetGrid(128, 128); return; break; } } break; case WM_KEYUP: { switch ( wParam ) { case VK_SPACE: if ( !maps.clipboard.isPasting() ) UnlockCursor(); return; break; } } break; } if ( CM && editFocused == false && GetActiveWindow() == getHandle() ) { Layer layer = CM->getLayer(); if ( layer == Layer::Units || layer == Layer::FogEdit || layer == Layer::Sprites ) { u8 newPlayer; switch ( wParam ) { case '1': newPlayer = 0 ; break; case '2': newPlayer = 1 ; break; case '3': newPlayer = 2 ; break; case '4': newPlayer = 3 ; break; case '5': newPlayer = 4 ; break; case '6': newPlayer = 5 ; break; case '7': newPlayer = 6 ; break; case '8': newPlayer = 7 ; break; case '9': newPlayer = 8 ; break; case '0': newPlayer = 9 ; break; case '-': newPlayer = 10; break; case '=': newPlayer = 11; break; default: return; break; } mainToolbar.playerBox.SetSel(newPlayer); maps.ChangePlayer(newPlayer); } } }
void RKADrawBoxes() { for (unsigned short CardBoard = POSOFFSET; CardBoard < POSOFFSET + SSTLEN; CardBoard += SPRITESIZE) { if (!(CheatRead<unsigned short>(0xFF0000 | CardBoard))) continue; short Xpos = CheatRead<short>(0xFF0000 | CardBoard + XPo); // too many many lines which were this way already when we discovered short Ypos = CheatRead<short>(0xFF0000 | CardBoard + YPo); // that Ram_68k is little endian to begin with unsigned short Height2 = CheatRead<short>(0xFF0000 | CardBoard + Ho); unsigned short Width2 = CheatRead<short>(0xFF0000 | CardBoard + Wo); if (CheatRead<unsigned short>(0xFF0000 | CardBoard) == 0x09) { Height2 = 0x20; Width2 = 0x10; } else if ((CheatRead<unsigned short>(0xFF0000 | CardBoard) == 0x33) || (CheatRead<unsigned short>(0xFF0000 | CardBoard) == 0x64) || (CheatRead<unsigned short>(0xFF0000 | CardBoard) == 0x66) || (CheatRead<unsigned short>(0xFF0000 | CardBoard) == 0x68)) { Height2 = 0x10; Width2 = 0x8; } // Xpos += 8; // Ypos -= CheatRead<short>(0xFF0000 | CardBoard + YVo); // Xpos -= CheatRead<short>(0xFF0000 | CardBoard + XVo); if (!GetKeyState(VK_SCROLL)) { Xpos -= CamX; Ypos -= CamY; } // Height2 /= 2; // Ypos -= Height2; // Height2 = min(Height2,0xFE); // Width2 = min(Width2,0xFE); DrawBoxCWH(Xpos - Width2,Ypos - Height2,Width2 * 2, Height2, -1, -1, -1,-1,1); /* for (unsigned char JXQ = 0; JXQ <= Width2; JXQ++) { int x1 = Xpos - JXQ, x2 = Xpos + JXQ; int y1 = Ypos - Height2, y2 = Ypos + Height2; while (x1 < 8) x1 += 320; while (x1 > 327) x1 -= 320; while (x2 < 8) x2 += 320; while (x2 > 327) x2 -= 320; while (y1 < 0) y1 += 224; while (y1 > 223) y1 -= 224; while (y2 < 0) y2 += 224; while (y2 > 223) y2 -= 224; MD_Screen32[max(8,min(327,x1)) + (336 * max(0,min(223,y1)))] = 0xFFFFFF; MD_Screen[max(8,min(327,x1)) + (336 * max(0,min(223,y1)))] = 0xFFFF; MD_Screen32[max(8,min(327,x1)) + (336 * max(0,min(223,y2)))] = 0xFFFFFF; MD_Screen[max(8,min(327,x1)) + (336 * max(0,min(223,y2)))] = 0xFFFF; MD_Screen32[max(8,min(327,x2)) + (336 * max(0,min(223,y1)))] = 0xFFFFFF; MD_Screen[max(8,min(327,x2)) + (336 * max(0,min(223,y1)))] = 0xFFFF; MD_Screen32[max(8,min(327,x2)) + (336 * max(0,min(223,y2)))] = 0xFFFFFF; MD_Screen[max(8,min(327,x2)) + (336 * max(0,min(223,y2)))] = 0xFFFF; } for (unsigned char JXQ = 0; JXQ <= Height2; JXQ++) { int x1 = Xpos - Width2, x2 = Xpos + Width2; int y1 = Ypos - JXQ, y2 = Ypos + JXQ; while (x1 < 8) x1 += 320; while (x1 > 327) x1 -= 320; while (x2 < 8) x2 += 320; while (x2 > 327) x2 -= 320; while (y1 < 0) y1 += 224; while (y1 > 223) y1 -= 224; while (y2 < 0) y2 += 224; while (y2 > 223) y2 -= 224; MD_Screen32[max(8,min(327,x1)) + (336 * max(0,min(223,y1)))] = 0xFFFFFF; MD_Screen[max(8,min(327,x1)) + (336 * max(0,min(223,y1)))] = 0xFFFF; MD_Screen32[max(8,min(327,x1)) + (336 * max(0,min(223,y2)))] = 0xFFFFFF; MD_Screen[max(8,min(327,x1)) + (336 * max(0,min(223,y2)))] = 0xFFFF; MD_Screen32[max(8,min(327,x2)) + (336 * max(0,min(223,y1)))] = 0xFFFFFF; MD_Screen[max(8,min(327,x2)) + (336 * max(0,min(223,y1)))] = 0xFFFF; MD_Screen32[max(8,min(327,x2)) + (336 * max(0,min(223,y2)))] = 0xFFFFFF; MD_Screen[max(8,min(327,x2)) + (336 * max(0,min(223,y2)))] = 0xFFFF; }*/ // Ypos += Height2; DrawBoxMWH(Xpos,Ypos,2,2,0x00FF00,0x07E0,0); DrawBoxMWH(Xpos,Ypos,1,1,0x00FF00,0x07E0,0); DrawLine(Xpos-1,Ypos,Xpos+1,Ypos,0,0,0); DrawLine(Xpos,Ypos-1,Xpos,Ypos+1,0,0,0); /* for (char jxq = 0; jxq <=2; jxq++) { for (char Jxq = 0; Jxq <=2; Jxq++) { MD_Screen32[max(8,min(327,(Xpos - jxq))) + 336 * max(0,min(223,(Ypos - Jxq)))] =0x00FF00; MD_Screen32[max(8,min(327,(Xpos + jxq))) + 336 * max(0,min(223,(Ypos - Jxq)))] =0x00FF00; MD_Screen32[max(8,min(327,(Xpos - jxq))) + 336 * max(0,min(223,(Ypos + Jxq)))] =0x00FF00; MD_Screen32[max(8,min(327,(Xpos + jxq))) + 336 * max(0,min(223,(Ypos + Jxq)))] =0x00FF00; MD_Screen[max(8,min(327,(Xpos - jxq))) + 336 * max(0,min(223,(Ypos - Jxq)))] =0x07E0; MD_Screen[max(8,min(327,(Xpos + jxq))) + 336 * max(0,min(223,(Ypos - Jxq)))] =0x07E0; MD_Screen[max(8,min(327,(Xpos - jxq))) + 336 * max(0,min(223,(Ypos + Jxq)))] =0x07E0; MD_Screen[max(8,min(327,(Xpos + jxq))) + 336 * max(0,min(223,(Ypos + Jxq)))] =0x07E0; } } MD_Screen32[max(8,min(327,(Xpos))) + 336 * max(0,min(223,(Ypos)))] = 0; MD_Screen32[max(8,min(327,(Xpos - 1))) + 336 * max(0,min(223,(Ypos)))] = 0; MD_Screen32[max(8,min(327,(Xpos + 1))) + 336 * max(0,min(223,(Ypos)))] = 0; MD_Screen32[max(8,min(327,(Xpos))) + 336 * max(0,min(223,(Ypos - 1)))] = 0; MD_Screen32[max(8,min(327,(Xpos))) + 336 * max(0,min(223,(Ypos + 1)))] = 0; MD_Screen32[max(8,min(327,(Xpos))) + 336 * max(0,min(223,(Ypos - 1)))] = 0; MD_Screen[max(8,min(327,(Xpos))) + 336 * max(0,min(223,(Ypos)))] = 0; MD_Screen[max(8,min(327,(Xpos - 1))) + 336 * max(0,min(223,(Ypos)))] = 0; MD_Screen[max(8,min(327,(Xpos + 1))) + 336 * max(0,min(223,(Ypos)))] = 0; MD_Screen[max(8,min(327,(Xpos))) + 336 * max(0,min(223,(Ypos - 1)))] = 0; MD_Screen[max(8,min(327,(Xpos))) + 336 * max(0,min(223,(Ypos + 1)))] = 0; MD_Screen[max(8,min(327,(Xpos))) + 336 * max(0,min(223,(Ypos - 1)))] = 0;*/ int HP = (int) CheatRead<short>(0xFF0000 | CardBoard + 0x40); if (HP + 1 == 0x8000) HP = 0; sprintf(Str_Tmp,"%d", HP); if (HP) { PutText(Str_Tmp,Xpos,Ypos - (Height2 >> 1),0,0,319,223,WHITE,BLUE); /* short xpos = Xpos - 8 - ((5 * (strlen(Str_Tmp) - 1))/2); xpos = min(max(xpos,1),318 - 4 * strlen(Str_Tmp)); short ypos = min(max(Ypos - Height2 - 3,1),217); const static int xOffset [] = {-1,-1,-1,0,1,1,1,0}; const static int yOffset [] = {-1,0,1,1,1,0,-1,-1}; for(int i = 0 ; i < 8 ; i++) Print_Text(Str_Tmp,strlen(Str_Tmp),xpos + xOffset[i],ypos + yOffset[i],0); Print_Text(Str_Tmp,strlen(Str_Tmp),xpos,ypos,2);*/ } if ((CheatRead<short>(0xFF0000 | CardBoard) == 0x01) || (CheatRead<unsigned short>(0xFF0000 | CardBoard) == 0x09)) { bool attack = false; bool EU = (CPU_Mode || (!Game_Mode)); if ((CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x04) || (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x17) || (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x13) || (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x18) || (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x20) || (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x21) || (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x06) || (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x07) || (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x08) || (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x09) || (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x0A) || (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x0B)) { attack = true; unsigned int Blah = *(unsigned short *) &(Rom_Data[0xFAB6 + (EU * 0xC0) + (CheatRead<short>(0xFF0000 | CardBoard + 0x60) & 7) * 4]); if (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x06) Blah = 0xFB34 + (EU * 0xC0); else if (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x07) Blah = 0xFB3C + (EU * 0xC0); else if ((CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x08) || (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x0B)) Blah = 0xFB44 + (EU * 0xC0); else if (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x09) Blah = 0xFB4C + (EU * 0xC0); else if (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x0A) Blah = 0xFB54 + (EU * 0xC0); Width2 = * (short *) &(Rom_Data[Blah + 4]); Width2 >>= 1; Height2 = * (short *) &(Rom_Data[Blah + 6]); Width2 = min(0xFE,Width2); Height2 = min(0xFE,Height2); if (CheatRead<short>(0xFF0000 | CardBoard + 2) == 0x18) { Ypos -= Height2; Ypos -= * (short *) &(Rom_Data[Blah + 2]); } else { Ypos += Height2; Ypos += * (short *) &(Rom_Data[Blah + 2]); } if (CheatRead<short>(0xFF0000 | CardBoard + 0x1A)) { Xpos -= * (short *) &(Rom_Data[Blah]); Xpos -= Width2; } else { Xpos += * (short *) &(Rom_Data[Blah]); Xpos += Width2; } } else if (CheatRead<unsigned short>(0xFF0000 | CardBoard) == 0x09)
static int winListEditProc(Ihandle* ih, HWND cbedit, UINT msg, WPARAM wp, LPARAM lp, LRESULT *result) { int ret = 0; if (msg==WM_KEYDOWN) /* process K_ANY before text callbacks */ { ret = iupwinBaseProc(ih, msg, wp, lp, result); if (ret) { iupAttribSetStr(ih, "_IUPWIN_IGNORE_CHAR", "1"); *result = 0; return 1; } else iupAttribSetStr(ih, "_IUPWIN_IGNORE_CHAR", NULL); } switch (msg) { case WM_CHAR: { if (iupAttribGet(ih, "_IUPWIN_IGNORE_CHAR")) { iupAttribSetStr(ih, "_IUPWIN_IGNORE_CHAR", NULL); *result = 0; return 1; } if ((char)wp == '\b') { if (!winListCallEditCb(ih, cbedit, NULL, 0, -1)) ret = 1; } else if ((char)wp == '\n' || (char)wp == '\r') { ret = 1; } else if (!(GetKeyState(VK_CONTROL) & 0x8000 || GetKeyState(VK_MENU) & 0x8000 || GetKeyState(VK_LWIN) & 0x8000 || GetKeyState(VK_RWIN) & 0x8000)) { char insert_value[2]; insert_value[0] = (char)wp; insert_value[1] = 0; if (!winListCallEditCb(ih, cbedit, insert_value, wp, 1)) ret = 1; } PostMessage(cbedit, WM_CARET, 0, 0L); if (wp==VK_TAB) /* the keys have the same definitions as the chars */ ret = 1; /* abort default processing to avoid beep */ break; } case WM_KEYDOWN: { if (wp == VK_DELETE) /* Del does not generates a WM_CHAR */ { if (!winListCallEditCb(ih, cbedit, NULL, 0, 1)) ret = 1; } else if (wp == 'A' && GetKeyState(VK_CONTROL) & 0x8000) /* Ctrl+A = Select All */ { SendMessage(cbedit, EM_SETSEL, (WPARAM)0, (LPARAM)-1); } PostMessage(cbedit, WM_CARET, 0, 0L); break; } case WM_CLEAR: { if (!winListCallEditCb(ih, cbedit, NULL, 0, 1)) ret = 1; PostMessage(cbedit, WM_CARET, 0, 0L); break; } case WM_CUT: { if (!winListCallEditCb(ih, cbedit, NULL, 0, 1)) ret = 1; PostMessage(cbedit, WM_CARET, 0, 0L); break; } case WM_PASTE: { if (IupGetCallback(ih, "EDIT_CB") || ih->data->mask) /* test before to avoid alocate clipboard text memory */ { char* insert_value = iupwinGetClipboardText(ih); if (insert_value) { if (!winListCallEditCb(ih, cbedit, insert_value, 0, 1)) ret = 1; free(insert_value); } } PostMessage(cbedit, WM_CARET, 0, 0L); break; } case WM_UNDO: { IFnis cb = (IFnis)IupGetCallback(ih, "EDIT_CB"); if (cb) { char* value; WNDPROC oldProc = (WNDPROC)IupGetCallback(ih, "_IUPWIN_EDITOLDPROC_CB"); CallWindowProc(oldProc, cbedit, WM_UNDO, 0, 0); value = winListGetValueAttrib(ih); cb(ih, 0, (char*)value); ret = 1; } PostMessage(cbedit, WM_CARET, 0, 0L); break; } case WM_KEYUP: case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONUP: case WM_RBUTTONUP: case WM_LBUTTONUP: PostMessage(cbedit, WM_CARET, 0, 0L); break; case WM_CARET: winListCallCaretCb(ih, cbedit); break; } if (ret) /* if abort processing, then the result is 0 */ { *result = 0; return 1; } else { if (msg==WM_KEYDOWN) return 0; else return iupwinBaseProc(ih, msg, wp, lp, result); } }
void CCamera::CheckForMovement() { // Once we have the frame interval, we find the current speed float speed = (float)(kSpeed * g_FrameInterval); // Before we move our camera we want to store the old position. We then use // this data to test collision detection. CVector3 vOldPosition = Position(); /////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// * // Store the old view vector to restore it if we collided backwards CVector3 vOldView = View(); // Use a flag to see if we movement backwards or not bool bMovedBack = false; /////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// * // Check if we hit the Up arrow or the 'w' key if(GetKeyState(VK_UP) & 0x80 || GetKeyState('W') & 0x80) { // Move our camera forward by a positive SPEED MoveCamera(speed); } // Check if we hit the Down arrow or the 's' key if(GetKeyState(VK_DOWN) & 0x80 || GetKeyState('S') & 0x80) { // Move our camera backward by a negative SPEED MoveCamera(-speed); bMovedBack = true; } // Check if we hit the Left arrow or the 'a' key if(GetKeyState(VK_LEFT) & 0x80 || GetKeyState('A') & 0x80) { // Strafe the camera left StrafeCamera(-speed); } // Check if we hit the Right arrow or the 'd' key if(GetKeyState(VK_RIGHT) & 0x80 || GetKeyState('D') & 0x80) { // Strafe the camera right StrafeCamera(speed); } // Now that we moved, let's get the current position and test our movement // vector against the level data to see if there is a collision. CVector3 vCurrentPosition = Position(); // We will not use sphere collision from now on, but AABB collision (box) // CVector3 vNewPosition = g_Level.TraceSphere(vOldPosition, vCurrentPosition, 25.0f); /////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// * // We are now using AABB collision now, so we no longer use sphere checks. // Below we pass into the TraceBox() function some generic Min and Max values // for our bounding box. We then get the new position if we collided CVector3 vNewPosition = g_Level.TraceBox(vOldPosition, vCurrentPosition, CVector3(-20, -50, -20), CVector3(20, 50, 20)); // We add some code below to make it so when we back into a wall, our view vector // doesn't keep going backwards, since we aren't moving backwards. If we don't // do this check, it will turn our camera around and look like a glitch. Not desired! // Check if we collided and we moved backwards if(g_Level.Collided() && bMovedBack) { // If or x or y didn't move, then we are backed into a wall so restore the view vector if(vNewPosition.x == vOldPosition.x || vNewPosition.z == vOldPosition.z) m_vView = vOldView; } /////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// * // Set the new position that was returned from our trace function m_vPosition = vNewPosition; }
// Initialize the modifier mask to the current modifiers. static void initialize_modifiers() { current_modifiers = 0x0000; // NOTE We are checking the high order bit, so it will be < 0 for a singed short. if (GetKeyState(VK_LSHIFT) < 0) { set_modifier_mask(MASK_SHIFT_L); } if (GetKeyState(VK_RSHIFT) < 0) { set_modifier_mask(MASK_SHIFT_R); } if (GetKeyState(VK_LCONTROL) < 0) { set_modifier_mask(MASK_CTRL_L); } if (GetKeyState(VK_RCONTROL) < 0) { set_modifier_mask(MASK_CTRL_R); } if (GetKeyState(VK_LMENU) < 0) { set_modifier_mask(MASK_ALT_L); } if (GetKeyState(VK_RMENU) < 0) { set_modifier_mask(MASK_ALT_R); } if (GetKeyState(VK_LWIN) < 0) { set_modifier_mask(MASK_META_L); } if (GetKeyState(VK_RWIN) < 0) { set_modifier_mask(MASK_META_R); } if (GetKeyState(VK_LBUTTON) < 0) { set_modifier_mask(MASK_BUTTON1); } if (GetKeyState(VK_RBUTTON) < 0) { set_modifier_mask(MASK_BUTTON2); } if (GetKeyState(VK_MBUTTON) < 0) { set_modifier_mask(MASK_BUTTON3); } if (GetKeyState(VK_XBUTTON1) < 0) { set_modifier_mask(MASK_BUTTON4); } if (GetKeyState(VK_XBUTTON2) < 0) { set_modifier_mask(MASK_BUTTON5); } if (GetKeyState(VK_NUMLOCK) < 0) { set_modifier_mask(MASK_NUM_LOCK); } if (GetKeyState(VK_CAPITAL) < 0) { set_modifier_mask(MASK_CAPS_LOCK); } if (GetKeyState(VK_SCROLL) < 0) { set_modifier_mask(MASK_SCROLL_LOCK); } }
bool isPressed(int key) { return (GetKeyState(getSystemKey(key)) & 0x8000) != 0; }