//鼠标消息 VOID CSkinSplitter::OnMouseMove(UINT nFlags, CPoint Point) { __super::OnMouseMove(nFlags,Point); if (m_bMouseDown==true) { //获取位置 CRect rcWindow; GetWindowRect(&rcWindow); //效验位置 CPoint PointParent=Point; MapWindowPoints(GetParent(),&PointParent,1); //控件位置 CSize SizeControl; SizeControl.SetSize(rcWindow.Width(),rcWindow.Height()); //设置光标 if (m_SplitterType==SplitterType_Hor) { if ((PointParent.y>(m_nMaxDragPos-SizeControl.cy/2))||(PointParent.y<(m_nMinDragPos+SizeControl.cy/2))) { //设置光标 SetCursor(LoadCursor(NULL,IDC_NO)); //设置位置 PointParent.y=__min(m_nMaxDragPos-SizeControl.cy/2,PointParent.y); PointParent.y=__max(m_nMinDragPos+SizeControl.cy/2,PointParent.y); } else SetCursor(LoadCursor(NULL,IDC_SIZENS)); } else { if ((PointParent.x>(m_nMaxDragPos-SizeControl.cx/2))||(PointParent.x<(m_nMinDragPos+SizeControl.cx/2))) { //设置光标 SetCursor(LoadCursor(NULL,IDC_NO)); //设置位置 PointParent.x=__min(m_nMaxDragPos-SizeControl.cx/2,PointParent.x); PointParent.x=__max(m_nMinDragPos+SizeControl.cx/2,PointParent.x); } else SetCursor(LoadCursor(NULL,IDC_SIZEWE)); } //转换位置 CPoint PointScreen=PointParent; GetParent()->ClientToScreen(&PointScreen); //计算区域 CRect rcCurrentDraw=m_rcDrawLine; if (m_SplitterType==SplitterType_Hor) { rcCurrentDraw.top=PointScreen.y-SizeControl.cy/2; rcCurrentDraw.bottom=rcCurrentDraw.top+SizeControl.cy; } else { rcCurrentDraw.left=PointScreen.x-SizeControl.cx/2; rcCurrentDraw.right=rcCurrentDraw.left+SizeControl.cx; } //绘画线条 if (rcCurrentDraw!=m_rcDrawLine) { //设置 DC CDC * pDC=CDC::FromHandle(::GetDC(NULL)); pDC->SelectObject(CDC::GetHalftoneBrush()); //绘画拆分 pDC->PatBlt(m_rcDrawLine.left,m_rcDrawLine.top,m_rcDrawLine.Width(),m_rcDrawLine.Height(),PATINVERT); pDC->PatBlt(rcCurrentDraw.left,rcCurrentDraw.top,rcCurrentDraw.Width(),rcCurrentDraw.Height(),PATINVERT); //释放资源 ::ReleaseDC(NULL,pDC->m_hDC); //设置变量 m_rcDrawLine=rcCurrentDraw; } } return; }
bool CGUIListContainer::OnAction(const CAction &action) { switch (action.GetID()) { case ACTION_PAGE_UP: { if (GetOffset() == 0) { // already on the first page, so move to the first item SetCursor(0); } else { // scroll up to the previous page Scroll( -m_itemsPerPage); } return true; } break; case ACTION_PAGE_DOWN: { if (GetOffset() == (int)m_items.size() - m_itemsPerPage || (int)m_items.size() < m_itemsPerPage) { // already at the last page, so move to the last item. SetCursor(m_items.size() - GetOffset() - 1); } else { // scroll down to the next page Scroll(m_itemsPerPage); } return true; } break; // smooth scrolling (for analog controls) case ACTION_SCROLL_UP: { m_analogScrollCount += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_analogScrollCount > 0.4) { handled = true; m_analogScrollCount -= 0.4f; if (GetOffset() > 0 && GetCursor() <= m_itemsPerPage / 2) { Scroll(-1); } else if (GetCursor() > 0) { SetCursor(GetCursor() - 1); } } return handled; } break; case ACTION_SCROLL_DOWN: { m_analogScrollCount += action.GetAmount() * action.GetAmount(); bool handled = false; while (m_analogScrollCount > 0.4) { handled = true; m_analogScrollCount -= 0.4f; if (GetOffset() + m_itemsPerPage < (int)m_items.size() && GetCursor() >= m_itemsPerPage / 2) { Scroll(1); } else if (GetCursor() < m_itemsPerPage - 1 && GetOffset() + GetCursor() < (int)m_items.size() - 1) { SetCursor(GetCursor() + 1); } } return handled; } break; } return CGUIBaseContainer::OnAction(action); }
BOOL CALLBACK PGrid_OnLButtonDown(HELE hEle,UINT flags,POINT *pPt) { propertyGrid_ *pObj=(propertyGrid_*)hEle; if(pPt->x<pObj->spacePoint && pPt->x>(pObj->spacePoint-5)) { pObj->bDown=TRUE; XEle_SetCapture(hEle); SetCursor(LoadCursor(NULL,IDC_SIZEWE)); return FALSE; } RECT rcView; XSView_GetViewRect(hEle,&rcView); if(FALSE==PtInRect(&rcView,*pPt)) return FALSE; POINT pt=*pPt; pt.y-=XSView_GetVViewPos(hEle); int left=XSView_GetSpacingLeft(hEle)-XSView_GetHViewPos(hEle); PGridNode_ *pNode=pObj->pItemList; while(pNode) { if(1==pNode->type) //组 { PGridGroup_ *pGroup=(PGridGroup_*)pNode->pItem; RECT rcBtn={left+pObj->indentBtn,pGroup->posy+pObj->itemHeight/2-5, left+pObj->indentBtn+9,pGroup->posy+(pObj->itemHeight/2)+4}; if(PtInRect(&rcBtn,pt)) { if(pGroup->bExpand) { pGroup->bExpand=FALSE; }else { pGroup->bExpand=TRUE; } if(-1!=pObj->selId) { int oldSel=pObj->selId; PGrid_HideEle(hEle); // PGrid_CheckValueChange(hEle,PGrid_GetItem(hEle,oldSel)); pObj->selId=-1; Ele_SendEvent(hEle,XE_PGRID_SELCHANGE,oldSel,pObj->selId); } PGrid_Adjust(hEle); XEle_RedrawEle(hEle); return FALSE; }else { if(pGroup->bExpand) { //子项 PGridItem_ *pItem=pGroup->pItemList; while(pItem) { if(PGrid_LButtonDownItem(hEle,pItem,&pt)) return FALSE; pItem=pItem->pNext; } } } }else //项 { if(PGrid_LButtonDownItem(hEle,(PGridItem_*)pNode->pItem,&pt)) return FALSE; } pNode=pNode->pNext; } //点击在空白处 if(-1!=pObj->selId) { int oldSel=pObj->selId; PGrid_HideEle(hEle); // PGrid_CheckValueChange(hEle,PGrid_GetItem(hEle,oldSel)); pObj->selId=-1; Ele_SendEvent(hEle,XE_PGRID_SELCHANGE,oldSel,pObj->selId); } XEle_RedrawEle(hEle); return FALSE; }
INT_PTR TlevelsPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: SelectObject(hdcGradient, oldHDCgradient); DeleteDC(hdcGradient); DeleteBitmap(bmpGradient); DeleteFont(fontGradient); SendMessage(GetDlgItem(m_hwnd, IDC_LBX_LEVELS_CURVES), WM_SETFONT, NULL, FALSE); DeleteFont(fontCurier); break; case WM_DRAWITEM: switch (wParam) { case IDC_BMP_HISTOGRAM: { LPDRAWITEMSTRUCT dis = LPDRAWITEMSTRUCT(lParam); int full = cfgGet(IDFF_levelsFullY); StretchDIBits(dis->hDC, 0, 0, dis->rcItem.right, dis->rcItem.bottom, full ? 0 : 16, 0, full ? 256 : 234 - 16 + 1, 64, histogramBits, (BITMAPINFO*)&histogramBmp, DIB_RGB_COLORS, SRCCOPY); wIn->draw(dis); return TRUE; } case IDC_BMP_LEVELS_IN: { LPDRAWITEMSTRUCT dis = LPDRAWITEMSTRUCT(lParam); StretchBlt(dis->hDC, 0, 0, dis->rcItem.right, 10, hdcGradient, 0, 0, 256, 1, SRCCOPY); RECT r = dis->rcItem; r.top = 10; FillRect(dis->hDC, &r, GetSysColorBrush(COLOR_BTNFACE)); if (filter && getCheck(IDC_CHB_LEVELS_INPUT_AUTO)) { int min, max; filter->getInAuto(&min, &max); drawTriangle(dis, min, true); drawTriangle(dis, max, true); } drawTriangle(dis, cfgGet(IDFF_levelsInMin)); drawTriangle(dis, cfgGet(IDFF_levelsInMax)); return TRUE; } case IDC_BMP_LEVELS_OUT: { LPDRAWITEMSTRUCT dis = LPDRAWITEMSTRUCT(lParam); StretchBlt(dis->hDC, 0, 0, dis->rcItem.right, 10, hdcGradient, 0, 0, 256, 1, SRCCOPY); RECT r = dis->rcItem; r.top = 10; FillRect(dis->hDC, &r, GetSysColorBrush(COLOR_BTNFACE)); drawTriangle(dis, cfgGet(IDFF_levelsOutMin)); drawTriangle(dis, cfgGet(IDFF_levelsOutMax)); return TRUE; } case IDC_BMP_LEVELS_CURVES: { LPDRAWITEMSTRUCT dis = LPDRAWITEMSTRUCT(lParam); StretchDIBits(dis->hDC, 0, 0, dis->rcItem.right, dis->rcItem.bottom, 0, 0, 256, 256, histogramBits, (BITMAPINFO*)&curvesBmp, DIB_RGB_COLORS, SRCCOPY); wCurves->draw(dis); return TRUE; } } break; case WM_SETCURSOR: if (HWND(wParam) == hcurves) { if (wCurves->setCursor()) { SetCursor(LoadCursor(NULL, IDC_SIZEALL)); setDlgResult(TRUE); } return TRUE; } break; } return TconfPageDecVideo::msgProc(uMsg, wParam, lParam); }
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { static HRGN hRgnClip ; static int cxClient, cyClient ; double fAngle, fRadius ; HCURSOR hCursor ; HDC hdc ; HRGN hRgnTemp[6] ; // HRGN just like RECT is a self-defined area. int i ; PAINTSTRUCT ps ; switch (iMsg) { // The task of WM_SIZE case is used to create a self-defined region as valid client area. case WM_SIZE: cxClient = LOWORD (lParam) ; cyClient = HIWORD (lParam) ; hCursor = SetCursor (LoadCursor (NULL, IDC_WAIT)) ; ShowCursor (TRUE) ; if (hRgnClip) DeleteObject (hRgnClip) ; // delete old region before create a new one. // The apis below are used to create RGN just like RECT // other apis including CreateRoundRectRgn & CreatePolygonRgn etc.. // These apis will create region and be ready to be selected, after that the valid client area // will be changed to the region created instead of tranditional rect area. hRgnTemp[0] = CreateEllipticRgn (0, cyClient / 3, cxClient / 2, 2 * cyClient / 3) ; hRgnTemp[1] = CreateEllipticRgn (cxClient / 2, cyClient / 3, cxClient, 2 * cyClient / 3) ; hRgnTemp[2] = CreateEllipticRgn (cxClient / 3, 0, 2 * cxClient / 3, cyClient / 2) ; hRgnTemp[3] = CreateEllipticRgn (cxClient / 3, cyClient / 2, 2 * cxClient / 3, cyClient) ; hRgnTemp[4] = CreateRectRgn (0, 0, 1, 1) ; hRgnTemp[5] = CreateRectRgn (0, 0, 1, 1) ; hRgnClip = CreateRectRgn (0, 0, 1, 1) ; // combie region from the second and the third regions to the first region with the fourth style. // and the first region should be initialized with a small region. // RGN_AND: inter sect // RGN_OR: srcRgn1 || srcRgn2 // RGN_XOR: !RGN_AND // RGN_DIFF: the part belong to srcRgn1 but not belong to srcRgn2 // RGN_COPY: srcRgn1 and ignore srcRgn2 totally. // Return value: NULLREGION; SIMPLEREGION; COMPLEXREGION; ERROR CombineRgn (hRgnTemp[4], hRgnTemp[0], hRgnTemp[1], RGN_OR) ; CombineRgn (hRgnTemp[5], hRgnTemp[2], hRgnTemp[3], RGN_OR) ; CombineRgn (hRgnClip, hRgnTemp[4], hRgnTemp[5], RGN_XOR) ; for (i = 0 ; i < 6 ; i++) DeleteObject (hRgnTemp[i]) ; SetCursor (hCursor) ; ShowCursor (FALSE) ; return 0 ; case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; // draw on region api // FillRgn, FrameRgn, InvertRgn, PaintRgn like FillRect, FrameRect ... etc. HBRUSH hBrush = CreateSolidBrush(RGB(255, 0, 0)); FillRgn(hdc, hRgnClip, hBrush); DeleteObject(hBrush); // set the center position as the origin. SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ; // select self-defined region as valid client area. // so the painting will only happen in self-defined region. SelectClipRgn (hdc, hRgnClip) ; // equals to SelectObject(hdc, hRgnClip); // Use InvalidateRgn and ValidRgn instead of InvalidRect and ValidRect. fRadius = _hypot (cxClient / 2.0, cyClient / 2.0) ; for (fAngle = 0.0 ; fAngle < TWO_PI ; fAngle += TWO_PI / 360) { MoveToEx (hdc, 0, 0, NULL) ; LineTo (hdc, (int) ( fRadius * cos (fAngle) + 0.5), (int) (-fRadius * sin (fAngle) + 0.5)) ; } EndPaint (hwnd, &ps) ; return 0 ; case WM_DESTROY: DeleteObject (hRgnClip) ; // destroy region PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, iMsg, wParam, lParam) ; }
LRESULT CALLBACK winproc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: PostQuitMessage(0); break; case WM_CREATE: break; #ifdef OO_FULLSCREEN case WM_SETCURSOR: { SetCursor(NULL); } break; #endif case WM_PAINT: { //PAINTSTRUCT PtStr; //windata.desthDC = BeginPaint(hWnd,&PtStr); //render(&windata); //EndPaint(hWnd,&PtStr); } break; case WM_ACTIVATE: if( wParam==WA_INACTIVE ) { windata.activeWindow = oofalse; } else { windata.activeWindow = ootrue; } break; case WM_ERASEBKGND: return (LRESULT)1; // this is needed to reduce flickering case WM_SYSKEYDOWN: case WM_SYSKEYUP: case WM_KEYDOWN: case WM_KEYUP: { unsigned int keyCode = (unsigned int)wParam; oobool keyIsDown = ((lParam & (1 << 31)) == 0); oobool keyWasDown = ((lParam & (1 << 30)) != 0); if( keyCode==VK_ESCAPE && keyIsDown ) { windata.running = oofalse; } if( keyIsDown!=keyWasDown ) { if( keyCode>=0 && keyCode<OOGameInput_Keys_Max ) { windata.gameinput.keyboard[keyCode] = keyIsDown; } } } break; default: return DefWindowProc (hWnd, uMsg, wParam, lParam); break; } return 0; }
/* ================ rvGEWorkspace::HandleMouseMove Handles the moving of the mouse for dragging and cursor updating ================ */ int rvGEWorkspace::HandleMouseMove ( WPARAM wParam, LPARAM lParam ) { idVec2 cursor; cursor.Set ( (short)LOWORD(lParam), (short)HIWORD(lParam) ); // Convert the window point to the workspace before updating the // cursor with the position WindowToWorkspace ( cursor ); // Scrolling the window around if ( mDragScroll ) { Scroll ( SB_HORZ, mDragPoint.x - cursor.x ); Scroll ( SB_VERT, mDragPoint.y - cursor.y ); SetCursor ( mHandCursor ); mDragPoint = cursor; return 0; } // If not dragging then just update the cursor and return if ( mDragType == rvGESelectionMgr::HT_NONE ) { UpdateCursor ( cursor.x, cursor.y ); return 0; } // Dont allow a drag move start until the button has been down for 100 ms or so if ( mDragType == rvGESelectionMgr::HT_MOVE && Sys_Milliseconds() - mDragTime <= 50 ) { return 0; } // Handle grid snapping if ( gApp.GetOptions().GetGridSnap ( ) ) { cursor.x = (float)(((int)cursor.x + gApp.GetOptions().GetGridWidth()/2) / gApp.GetOptions().GetGridWidth() * gApp.GetOptions().GetGridWidth()); cursor.y = (float)(((int)cursor.y + gApp.GetOptions().GetGridWidth()/2) / gApp.GetOptions().GetGridWidth() * gApp.GetOptions().GetGridWidth()); } // If the cursor hasnt moved then there is nothing to update with the drag if ( (int) cursor.x == (int) mDragPoint.x && (int) cursor.y == (int) mDragPoint.y ) { return 0; } switch ( mDragType ) { case rvGESelectionMgr::HT_MOVE: AddModifierMove ( "Move", cursor.x - mDragPoint.x, cursor.y - mDragPoint.y, mApplication->GetOptions().GetGridSnap ( ) ); break; case rvGESelectionMgr::HT_SIZE_BOTTOM: AddModifierSize ( "Size", 0, 0, 0, cursor.y - mDragPoint.y, mApplication->GetOptions().GetGridSnap ( ) ); break; case rvGESelectionMgr::HT_SIZE_TOP: AddModifierSize ( "Size", 0, cursor.y - mDragPoint.y, 0, 0, mApplication->GetOptions().GetGridSnap ( ) ); break; case rvGESelectionMgr::HT_SIZE_RIGHT: AddModifierSize ( "Size", 0, 0, cursor.x - mDragPoint.x, 0, mApplication->GetOptions().GetGridSnap ( ) ); break; case rvGESelectionMgr::HT_SIZE_LEFT: AddModifierSize ( "Size", cursor.x - mDragPoint.x, 0, 0, 0, mApplication->GetOptions().GetGridSnap ( ) ); break; case rvGESelectionMgr::HT_SIZE_TOPLEFT: AddModifierSize ( "Size", cursor.x - mDragPoint.x, cursor.y - mDragPoint.y, 0, 0, mApplication->GetOptions().GetGridSnap ( ) ); break; case rvGESelectionMgr::HT_SIZE_TOPRIGHT: AddModifierSize ( "Size", 0, cursor.y - mDragPoint.y, cursor.x - mDragPoint.x, 0, mApplication->GetOptions().GetGridSnap ( ) ); break; case rvGESelectionMgr::HT_SIZE_BOTTOMLEFT: AddModifierSize ( "Size", cursor.x - mDragPoint.x, 0, 0, cursor.y - mDragPoint.y, mApplication->GetOptions().GetGridSnap ( ) ); break; case rvGESelectionMgr::HT_SIZE_BOTTOMRIGHT: AddModifierSize ( "Size", 0, 0, cursor.x - mDragPoint.x, cursor.y - mDragPoint.y, mApplication->GetOptions().GetGridSnap ( ) ); break; } UpdateCursor ( mDragType ); // If the x coordinate has changed then update it if ( (int)cursor.x != (int)mDragPoint.x && mDragX ) { mDragPoint.x = cursor.x; } // If the y coordinate has changed then update it if ( (int)cursor.y != (int)mDragPoint.y && mDragY ) { mDragPoint.y = cursor.y; } return 0; }
static LRESULT CALLBACK GROUP_GroupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { PROGGROUP* group; INT iItem; LVITEMW lvItem; POINT pt; group = (PROGGROUP*)GetWindowLongPtrW(hWnd, 0); switch (uMsg) { case WM_NCCREATE: { LPCREATESTRUCTW pcs = (LPCREATESTRUCTW)lParam; LPMDICREATESTRUCTW pMDIcs = (LPMDICREATESTRUCTW)pcs->lpCreateParams; group = (PROGGROUP*)pMDIcs->lParam; SetWindowLongPtrW(hWnd, 0, (LONG_PTR)group); if (group->bIsCommonGroup) { DefMDIChildProcW(hWnd, WM_SETICON, ICON_BIG, (LPARAM)CopyImage(Globals.hCommonGroupIcon, IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_COPYFROMRESOURCE)); DefMDIChildProcW(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)CopyImage(Globals.hCommonGroupIcon, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_COPYFROMRESOURCE)); } else { DefMDIChildProcW(hWnd, WM_SETICON, ICON_BIG, (LPARAM)CopyImage(Globals.hPersonalGroupIcon, IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_COPYFROMRESOURCE)); DefMDIChildProcW(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)CopyImage(Globals.hPersonalGroupIcon, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_COPYFROMRESOURCE)); } break; } case WM_NCDESTROY: SetWindowLongPtrW(hWnd, 0, 0); break; case WM_CREATE: { DWORD dwStyle; RECT rect; GetClientRect(hWnd, &rect); group->hListView = CreateWindowW(WC_LISTVIEW, NULL, WS_CHILD | WS_VISIBLE | WS_OVERLAPPED, 0, 0, rect.right - rect.left, rect.bottom - rect.top, hWnd, NULL, Globals.hInstance, NULL); dwStyle = (GetWindowLongPtrW(group->hListView, GWL_STYLE) | LVS_SHOWSELALWAYS) & ~LVS_AUTOARRANGE; SetWindowLongPtrW(group->hListView, GWL_STYLE, dwStyle); dwStyle = SendMessageA(group->hListView, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) | LVS_EX_BORDERSELECT; SendMessageA(group->hListView, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_SNAPTOGRID, dwStyle); InitUxTheme(); SetWindowTheme(group->hListView, L"Explorer", NULL); group->hListLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), ILC_COLOR24 | ILC_MASK, 1, 1); SendMessageA(group->hListView, LVM_SETIMAGELIST, 0, (LPARAM)group->hListLarge); SendMessageA(group->hListView, LVM_SETICONSPACING, 0, MAKELPARAM(80, 64)); break; } case WM_DESTROY: { SendMessageA(group->hListView, LVM_SETIMAGELIST, 0, 0); ImageList_Destroy(group->hListLarge); DestroyWindow(group->hListView); break; } case WM_SIZE: { RECT rect; rect.left = 0; rect.top = 0; rect.right = LOWORD(lParam); rect.bottom = HIWORD(lParam); AdjustWindowRectEx(&rect, GetWindowLongPtrW(group->hListView, GWL_STYLE), FALSE, GetWindowLongPtrW(group->hListView, GWL_EXSTYLE)); MoveWindow(group->hListView, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); break; } case WM_CLOSE: SendMessageW(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); break; case WM_SYSCOMMAND: if (wParam == SC_CLOSE) wParam = SC_MINIMIZE; break; case WM_CHILDACTIVATE: case WM_NCLBUTTONDOWN: Globals.hActiveGroup = (PROGGROUP*)GetWindowLongPtrW(hWnd, 0); Globals.hActiveGroup->hActiveProgram = NULL; break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case NM_CLICK: { iItem = ((LPNMITEMACTIVATE)lParam)->iItem; if (iItem == -1) { group->hActiveProgram = NULL; break; } lvItem.mask = LVIF_PARAM; lvItem.iItem = iItem; SendMessageW(group->hListView, LVM_GETITEMW, 0, (LPARAM)&lvItem); group->hActiveProgram = (PROGRAM*)lvItem.lParam; break; } case NM_DBLCLK: { iItem = ((LPNMITEMACTIVATE)lParam)->iItem; if (iItem == -1) break; lvItem.mask = LVIF_PARAM; lvItem.iItem = iItem; SendMessageW(group->hListView, LVM_GETITEMW, 0, (LPARAM)&lvItem); /* ... or use group->hActiveProgram */ PROGRAM_ExecuteProgram((PROGRAM*)lvItem.lParam); break; } case LVN_BEGINDRAG: { POINT ptMin; BOOL bFirst = TRUE; for (iItem = SendMessageA(group->hListView, LVM_GETNEXTITEM, -1, LVNI_SELECTED); iItem != -1; iItem = SendMessageA(group->hListView, LVM_GETNEXTITEM, iItem, LVNI_SELECTED)) { if (bFirst) { group->hDragImageList = (HIMAGELIST)SendMessageA(group->hListView, LVM_CREATEDRAGIMAGE, iItem, (LPARAM)&pt); ptMin = pt; bFirst = FALSE; } else { HIMAGELIST hOneImageList, hTempImageList; hOneImageList = (HIMAGELIST)SendMessageA(group->hListView, LVM_CREATEDRAGIMAGE, iItem, (LPARAM)&pt); hTempImageList = ImageList_Merge(group->hDragImageList, 0, hOneImageList, 0, pt.x - ptMin.x, pt.y - ptMin.y); ImageList_Destroy(group->hDragImageList); ImageList_Destroy(hOneImageList); group->hDragImageList = hTempImageList; ptMin.x = min(ptMin.x, pt.x); ptMin.y = min(ptMin.y, pt.y); } } // pt = ((LPNMLISTVIEW)lParam)->ptAction; pt.x = ((LPNMLISTVIEW)lParam)->ptAction.x; pt.y = ((LPNMLISTVIEW)lParam)->ptAction.y; group->ptStart = pt; pt.x -= ptMin.x; pt.y -= ptMin.y; ImageList_BeginDrag(group->hDragImageList, 0, pt.x, pt.y); MapWindowPoints(group->hListView, Globals.hMDIWnd, &pt, 1); ImageList_DragEnter(Globals.hMDIWnd, pt.x, pt.y); group->bDragging = TRUE; group->hOldCursor = GetCursor(); SetCapture(group->hWnd); break; } } break; case WM_MOUSEMOVE: if (group->bDragging) { pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); MapWindowPoints(group->hWnd, Globals.hMDIWnd, &pt, 1); ImageList_DragMove(pt.x, pt.y); } break; case WM_LBUTTONUP: if (group->bDragging) { // LVHITTESTINFO lvhti; POINT ptHit; group->bDragging = FALSE; ImageList_DragLeave(Globals.hMDIWnd); ImageList_EndDrag(); ImageList_Destroy(group->hDragImageList); ReleaseCapture(); SetCursor(group->hOldCursor); ptHit.x = GET_X_LPARAM(lParam); ptHit.y = GET_Y_LPARAM(lParam); MapWindowPoints(group->hWnd, group->hListView, &ptHit, 1); for (iItem = SendMessageA(group->hListView, LVM_GETNEXTITEM, -1, LVNI_SELECTED); iItem != -1; iItem = SendMessageA(group->hListView, LVM_GETNEXTITEM, iItem, LVNI_SELECTED)) { SendMessageA(group->hListView, LVM_GETITEMPOSITION, iItem, (LPARAM)&pt); pt.x += ptHit.x - group->ptStart.x; pt.y += ptHit.y - group->ptStart.y; SendMessageA(group->hListView, LVM_SETITEMPOSITION, iItem, MAKELPARAM(pt.x, pt.y)); } } break; } return DefMDIChildProcW(hWnd, uMsg, wParam, lParam); }
void MyFrame::OnComputeLinearModes(wxCommandEvent& event) { char numLinearModesStringC[256]; int numSuggestedModes = uiState.numComputedLinearModes; if (uiState.firstModalComputation) { // increase the number of suggested modes based on the number of constrained vertices if (precomputationState.fixedVertices.size() == 2) { numSuggestedModes += 1; } else if (precomputationState.fixedVertices.size() == 1) { numSuggestedModes += 3; } else if (precomputationState.fixedVertices.size() == 0) { numSuggestedModes += 6; } } sprintf(numLinearModesStringC, "%d", numSuggestedModes); wxDialog * dlg = new wxDialog(this, -1, _T("Select number of modes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("dialogBox") ); wxBoxSizer * dlgSizer = new wxBoxSizer(wxVERTICAL); wxStaticText * numModesText = new wxStaticText(dlg, -1, _T("Number of modes: "), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER, _T( "staticText")); wxTextCtrl * numModesControl = new wxTextCtrl(dlg, -1, wxString(numLinearModesStringC, wxConvUTF8), wxDefaultPosition, wxSize(100,-1)); wxBoxSizer * numModesSizer = new wxBoxSizer(wxHORIZONTAL); numModesSizer->Add(numModesText, 0, wxCENTER); numModesSizer->Add(numModesControl, 0, wxCENTER); dlgSizer->Add(numModesSizer, 0, wxALL | wxCENTER, 8); dlgSizer->Add(dlg->CreateButtonSizer(wxOK | wxCANCEL), 0, wxLEFT | wxRIGHT | wxBOTTOM | wxCENTER, 8); dlg->SetSizer(dlgSizer); dlgSizer->SetSizeHints(dlg); if (dlg->ShowModal() != wxID_OK) { delete(dlg); return; } wxString valueString = numModesControl->GetValue(); delete(dlg); long value; bool goodInput = valueString.ToLong(&value); if (goodInput) { if ((value <= 0) || (value > 16384)) goodInput = false; } if (goodInput) { int oldNumModes = uiState.numComputedLinearModes; uiState.numComputedLinearModes = value; double * newFrequencies = NULL; double * newLinearModes = NULL; int newr; SetCursor(*wxHOURGLASS_CURSOR); LinearModesWorker( uiState.numComputedLinearModes, &newr, &newFrequencies, &newLinearModes ); SetCursor(*wxSTANDARD_CURSOR); if (newr != uiState.numComputedLinearModes) { uiState.numComputedLinearModes = oldNumModes; this->errMsg( _T("Linear mode computation failed"), _T("Linear mode computation failed.") ); free(newFrequencies); free(newLinearModes); return; } else { precomputationState.linearModesAvailable = true; uiState.firstModalComputation = false; UpdateMenus(); delete(precomputationState.linearModalMatrix); precomputationState.rLin = uiState.numComputedLinearModes; precomputationState.linearModalMatrix = new ModalMatrix( precomputationState.simulationMesh->getNumVertices(), precomputationState.rLin, newLinearModes); free(newLinearModes); free(precomputationState.frequencies); precomputationState.frequencies = newFrequencies; precomputationState.frequenciesAvailable = true; precomputationState.linearModesAvailable = true; uiState.eraseRangeHi = precomputationState.rLin; // set the rigid modes based on the number of constrained vertices if (precomputationState.fixedVertices.size() >= 3) { precomputationState.numRigidModes = 0; } else if (precomputationState.fixedVertices.size() == 2) { precomputationState.numRigidModes = 1; } else if (precomputationState.fixedVertices.size() == 1) { precomputationState.numRigidModes = 3; } else { precomputationState.numRigidModes = 6; } uiState.numComputedNonLinearModes = 2 * (precomputationState.rLin - precomputationState.numRigidModes); modeSelectionControl->SetValue(1); SelectView(UIState::VIEW_LINEAR_MODES); SetAutoRenderingMagnitude(precomputationState.linearModalMatrix); UpdateMenus(); myGLCanvas->UpdateLinearModesRenderData(); Refresh(); } } else { this->errMsg( _T("Invalid number of linear modes"), _T("Invalid number of linear modes: ") + valueString ); } }
void MyFrame::OnLoadLinearModes(wxCommandEvent& event) { wxFileDialog *dlg = new wxFileDialog(this, _T("Load linear modes"), uiState.currentWorkingDirectory, _T(""), _T("Modal Matrix Files(*.Ulin)|*.Ulin|Modal Matrix Files(*.U)|*.U|All files(*.*)|*.*"), wxFD_OPEN /*| wxHIDE_READONLY*/, wxDefaultPosition); if ( dlg->ShowModal() == wxID_OK ) { wxString linearModesFilename( dlg->GetPath()); SaveCurrentWorkingDirectory(linearModesFilename); if( !linearModesFilename.empty() ) { int newr; double * newLinearModes = NULL; int n1; SetCursor(*wxHOURGLASS_CURSOR); const char * filename = linearModesFilename.mb_str(); int code = ReadMatrixFromDisk((char*)filename, &n1, &newr, &newLinearModes); SetCursor(*wxSTANDARD_CURSOR); if (code != 0) { this->errMsg( _T("Loading error"), _T("Unable to load linear modes from ") + linearModesFilename ); dlg->Destroy(); return; } if (n1 != 3 * precomputationState.simulationMesh->getNumVertices()) { this->errMsg( _T("Loading error"), _T("The number of vertices in ") + linearModesFilename + _T(" does not match the simulation mesh.")); free(newLinearModes); dlg->Destroy(); return; } if (precomputationState.frequenciesAvailable) { // check that the number of modes is consistent with the existing number of frequencies if (newr != precomputationState.rLin) { wxMessageDialog * confirmationDialog = new wxMessageDialog (this, _T("Warning: number of existing frequencies does not match the number of modes. Delete existing frequencies?"), _T("Mismatch in the number of frequencies"), wxYES_NO | wxICON_EXCLAMATION); if (confirmationDialog->ShowModal() != wxID_YES) { free(newLinearModes); delete(confirmationDialog); dlg->Destroy(); return; } else { delete(confirmationDialog); free(precomputationState.frequencies); precomputationState.frequenciesAvailable = false; } } } // success delete(precomputationState.linearModalMatrix); precomputationState.rLin = newr; precomputationState.linearModalMatrix = new ModalMatrix( precomputationState.simulationMesh->getNumVertices(), precomputationState.rLin, newLinearModes); free(newLinearModes); precomputationState.linearModesAvailable = true; uiState.numComputedNonLinearModes = 2 * (precomputationState.rLin - precomputationState.numRigidModes); uiState.eraseRangeHi = precomputationState.rLin; modeSelectionControl->SetValue(1); SelectView(UIState::VIEW_LINEAR_MODES); SetAutoRenderingMagnitude(precomputationState.linearModalMatrix); UpdateMenus(); myGLCanvas->UpdateLinearModesRenderData(); Refresh(); } } dlg->Destroy(); }
//WinMain -- Main Window int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { MSG msg; msg.message = WM_CREATE; WNDCLASS wc; wc.style = CS_HREDRAW|CS_VREDRAW; wc.lpfnWndProc = WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(GetModuleHandle(NULL), IDI_APPLICATION); wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = "chockngt"; RegisterClass (&wc); // Create the window //mainWnd = CreateWindow (szAppName,szAppName,WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,CW_USEDEFAULT,CW_USEDEFAULT,1024,600,0,0,hInstance,0); mainWnd = CreateWindow("chockngt","chockngt",WS_POPUP|WS_VISIBLE|WS_MAXIMIZE,0,0,0,0,0,0,hInstance,0); glInit(); ShowWindow(mainWnd,SW_SHOW); UpdateWindow(mainWnd); // Initialize Swarm positions and stuff initSwarm(); long startTime = timeGetTime(); long lastTime = 0; // start music playback BASS_Init(-1,44100,0,mainWnd,NULL); mp3Str=BASS_StreamCreateFile(FALSE,"GT_muc.mp3",0,0,0); BASS_ChannelPlay(mp3Str, TRUE); BASS_Start(); float fCurTime; GetAsyncKeyState(VK_ESCAPE); do { SetCursor(FALSE); while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { if (!IsDialogMessage(mainWnd, &msg)) { TranslateMessage (&msg); DispatchMessage (&msg); } } if (msg.message == WM_QUIT) break; // early exit on quit // update timer long curTime = timeGetTime() - startTime; fCurTime = (float)curTime * 0.001f; long deltaTime = curTime - lastTime; float fDeltaTime = (float) deltaTime * 0.001f; lastTime = curTime; // render wglMakeCurrent(mainDC, mainRC); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDisable(GL_DEPTH_TEST); // draw background //drawQuad(-1.0f, 1.0f, -1.0f, 1.0f, 0.4f, 1.0f, 1.0f); glEnable(GL_DEPTH_TEST); // Distance to the center object // TODO: Hitchcock-effect by means of gluPerspective! float cameraDist = 20.0f; float cameraComeTime = 150.0f; if (fCurTime > cameraComeTime) { cameraDist = 3.0f + 17.0f / (1.0f + 0.1f * ((fCurTime - cameraComeTime) * (fCurTime - cameraComeTime))); } // set up matrices glMatrixMode(GL_PROJECTION); glLoadIdentity(); // TODO aspect //gluPerspective(25.0, 1.8, 0.1, 100.0); gluPerspective(500.0f / cameraDist, 1.8, 0.1, 100.0); //gluPerspective(25.0, 1.8, 1.1, 100.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //gluLookAt(0.0, 0.0, -cameraDist, // 0.0, 0.0, 0.0, // 0.0, 1.0, 0.0); gluLookAt(1., 0.5, -cameraDist, 1., 0.5, 0.0, 0.0, 1.0, 0.0); // lighting: float ambient[4] = {0.3f, 0.23f, 0.2f, 1.0f}; //float diffuse[4] = {1.8f, 1.7f, 0.8f, 1.0f}; float diffuse[4] = {0.9f, 0.85f, 0.4f, 1.0f}; float diffuse2[4] = {0.45f, 0.475f, 0.2f, 1.0f}; //float diffuse2[4] = {0.0f, 0.0f, 0.0f, 1.0f}; float specular[4] = {1.0f, 1.0f, 1.0f, 1.0f}; float lightDir[4] = {0.7f, 0.0f, 0.7f, 0.0f}; float allOnes[4] = {1.0f, 1.0f, 1.0f, 1.0f}; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, specular); glLightfv(GL_LIGHT0, GL_POSITION, lightDir); //glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, allOnes); //glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, allOnes); //glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, allOnes); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); float metaAmount = 1.0f; int signedDistanceID = 1; // sphere if (fCurTime > 61.0f) signedDistanceID = 2; // metaballs //signedDistanceID = 0; // nothing int pathID = 0; // 8 moveTo points if (fCurTime > 80.0f) { pathID = 1; // 4 lines signedDistanceID = 0; // Nothing if (fCurTime > 130.0f) { pathID = 0; // 4 move to points signedDistanceID = 2; // metaballs } } // In reversed field if (fCurTime > 170.0f) { pathID = 0; signedDistanceID = 2; if (fCurTime > 190.0f) { pathID = 1; signedDistanceID = 0; } if (fCurTime > 210.0f) { pathID = 1; signedDistanceID = 2; } if (fCurTime > 217.0f) { pathID = 0; signedDistanceID = 1; } } // generate destiations float overshoot = 0.0f; if (fCurTime > 19.f) { float relTime = fCurTime - 19.f; overshoot = 2.0f * sin(relTime*0.17f) * (-cos(relTime * 0.75f) + 1.0f); } if (fCurTime > 200.0f) { float relTime = (fCurTime - 200.0f); overshoot /= relTime * relTime + 1.0f; } updateSwarmDestinations(pathID, fDeltaTime, overshoot); // update direction of the Triangles updateSwarmWithSignedDistance(signedDistanceID, fDeltaTime, metaAmount); // move all triangles moveSwarm(fDeltaTime); // Set how many triangles to render for each path int numTrisRender1 = (curTime - 11300) / 8; int numTrisRender2 = (curTime - 3300) / 2; numTrisRender1 = numTrisRender1 > NUM_TRIANGLES ? NUM_TRIANGLES : numTrisRender1; numTrisRender1 = numTrisRender1 < 0 ? 0 : numTrisRender1; numTrisRender2 = numTrisRender2 > NUM_TRIANGLES ? NUM_TRIANGLES : numTrisRender2; numTrisRender2 = numTrisRender2 < 0 ? 0 : numTrisRender2; float triBrightness = fCurTime / 30.0f + 0.2f; if (triBrightness > 1.0f) triBrightness = 1.0f; // render tris glBegin(GL_TRIANGLES); for (int i = 0; i < numTrisRender1; i++) { //glNormal3f(0.3f, 0.5f, 0.2f); float right[3]; right[0] = tris.direction[i][1] * tris.normal[i][2] - tris.direction[i][2] * tris.normal[i][1]; right[1] = tris.direction[i][2] * tris.normal[i][0] - tris.direction[i][0] * tris.normal[i][2]; right[2] = tris.direction[i][0] * tris.normal[i][1] - tris.direction[i][1] * tris.normal[i][0]; glNormal3fv(tris.normal[i]); glVertex3f(tris.position[i][0] + 0.2f * tris.direction[i][0], tris.position[i][1] + 0.2f * tris.direction[i][1], tris.position[i][2] + 0.2f * tris.direction[i][2]); glVertex3f(tris.position[i][0] + 0.2f * right[0], tris.position[i][1] + 0.2f * right[1], tris.position[i][2] + 0.2f * right[2]); glVertex3f(tris.position[i][0] - 0.2f * right[0], tris.position[i][1] - 0.2f * right[0], tris.position[i][2] - 0.2f * right[0]); } glEnd(); glDepthMask(FALSE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE); glDisable(GL_LIGHTING); float beating = 1.0f - 0.25f * fabsf((float)sin(fCurTime*4.652f)); glBegin(GL_TRIANGLES); for (int i = 0; i < numTrisRender2; i++) { const float colorA[3] = {0.3f, 0.5f, 1.0f}; const float colorB[3] = {1.0f, 0.8f, 0.3f}; const float colorC[3] = {2.0f, 0.4f, 0.1f}; float color[3]; float colorT = fCurTime * 0.01f; if (colorT > 1.0f) colorT = 1.0f; for (int c = 0; c < 3; c++) { color[c] = colorA[c] * (1.0f - colorT) + colorT * colorB[c]; } if (fCurTime > 100.0f) { colorT = (fCurTime - 100.0f) * 0.1f - ((i*i*17)%63) * 0.1f; if (colorT < 0.0f) colorT = 0.0f; if (colorT > 1.0f) colorT = 1.0f; for (int c = 0; c < 3; c++) { color[c] = colorB[c] * (1.0f - colorT) + colorT * colorC[c]; } } // Some color noise for (int c = 0; c < 3; c++) { float n = ((((i*i+13)*(c*c+7)+(i*(c+1))) % 100) - 50) * 0.0025f; color[c] += n; } //glNormal3f(0.3f, 0.5f, 0.2f); glColor4f(color[0], color[1], color[2], beating * 0.1f * triBrightness); float right[3]; right[0] = tris.direction[i][1] * tris.normal[i][2] - tris.direction[i][2] * tris.normal[i][1]; right[1] = tris.direction[i][2] * tris.normal[i][0] - tris.direction[i][0] * tris.normal[i][2]; right[2] = tris.direction[i][0] * tris.normal[i][1] - tris.direction[i][1] * tris.normal[i][0]; glNormal3fv(tris.normal[i]); glVertex3f(tris.position[i][0] + 0.6f * tris.direction[i][0], tris.position[i][1] + 0.6f * tris.direction[i][1], tris.position[i][2] + 0.6f * tris.direction[i][2] - 0.1f); glVertex3f(tris.position[i][0] + 0.6f * right[0] - 0.2f * tris.direction[i][0], tris.position[i][1] + 0.6f * right[1] - 0.2f * tris.direction[i][1], tris.position[i][2] + 0.6f * right[2] - 0.2f * tris.direction[i][2] - 0.001f); glVertex3f(tris.position[i][0] - 0.6f * right[0] - 0.2f * tris.direction[i][0], tris.position[i][1] - 0.6f * right[0] - 0.2f * tris.direction[i][1], tris.position[i][2] - 0.6f * right[0] - 0.2f * tris.direction[i][2] - 0.001f); } glEnd(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_DEPTH_TEST); glBegin(GL_TRIANGLES); if (fCurTime > 219.0f) { float alpha = (fCurTime - 219.0f) * 0.5f; alpha = alpha > 1.0f ? 1.0f : alpha; glColor4f(0.0f, 0.0f, 0.0f, alpha); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glVertex3f(-180.0f, 180.0f, 1.0f); glVertex3f(180.0f, 0.0f, 1.0f); glVertex3f(-180.0f, -180.0f, 1.0f); } glEnd(); glDepthMask(TRUE); // draw credits if (fCurTime > 221.0f) { float alpha = (fCurTime - 221.0f) * 1.0f; alpha = alpha > 1.0f ? 1.0f : alpha; drawQuad(-1.3f, 0.7f, -0.1f, 0.4f, 0.0f, 0.175f, alpha); drawQuad(-0.7f, 1.3f, -0.5f, 0.0f, 0.175f, 0.35f, alpha); } glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); //glColor3ub(200, 100, 50); //glEnable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // swap buffers wglSwapLayerBuffers(mainDC, WGL_SWAP_MAIN_PLANE); //Sleep(5); } while (msg.message != WM_QUIT && fCurTime < 230.0f && !GetAsyncKeyState(VK_ESCAPE)); // music uninit BASS_ChannelStop(mp3Str); BASS_StreamFree(mp3Str); BASS_Free(); glUnInit(); return msg.wParam; }
void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) { int localrealbutt = 0, localbutt = 0; BASE_SCREEN* screen = GetScreen(); if( !screen ) return; /* Adjust value to filter mouse displacement before consider the drag * mouse is really a drag command, not just a movement while click */ #define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5 if( event.Leaving() ) m_canStartBlock = -1; if( !IsMouseCaptured() ) // No mouse capture in progress. m_requestAutoPan = false; if( GetParent()->IsActive() ) SetFocus(); else return; if( !event.IsButton() && !event.Moving() && !event.Dragging() ) return; if( event.RightDown() ) { OnRightClick( event ); return; } if( m_ignoreMouseEvents ) return; if( event.LeftIsDown() ) localrealbutt |= GR_M_LEFT_DOWN; if( event.MiddleIsDown() ) localrealbutt |= GR_M_MIDDLE_DOWN; if( event.LeftDown() ) localbutt = GR_M_LEFT_DOWN; if( event.ButtonDClick( 1 ) ) localbutt = GR_M_LEFT_DOWN | GR_M_DCLICK; if( event.MiddleDown() ) localbutt = GR_M_MIDDLE_DOWN; localrealbutt |= localbutt; // compensation default wxGTK INSTALL_UNBUFFERED_DC( DC, this ); DC.SetBackground( *wxBLACK_BRUSH ); // Compute the cursor position in drawing (logical) units. GetParent()->SetMousePosition( event.GetLogicalPosition( DC ) ); int kbstat = 0; if( event.ShiftDown() ) kbstat |= GR_KB_SHIFT; if( event.ControlDown() ) kbstat |= GR_KB_CTRL; if( event.AltDown() ) kbstat |= GR_KB_ALT; // Calling Double Click and Click functions : if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) ) { GetParent()->OnLeftDClick( &DC, GetParent()->RefPos( true ) ); // inhibit a response to the mouse left button release, // because we have a double click, and we do not want a new // OnLeftClick command at end of this Double Click m_ignoreNextLeftButtonRelease = true; } else if( event.LeftUp() ) { // A block command is in progress: a left up is the end of block // or this is the end of a double click, already seen // Note also m_ignoreNextLeftButtonRelease can be set by // the call to OnLeftClick(), so do not change it after calling OnLeftClick bool ignoreEvt = m_ignoreNextLeftButtonRelease; m_ignoreNextLeftButtonRelease = false; if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK && !ignoreEvt ) GetParent()->OnLeftClick( &DC, GetParent()->RefPos( true ) ); } else if( !event.LeftIsDown() ) { /* be sure there is a response to a left button release command * even when a LeftUp event is not seen. This happens when a * double click opens a dialog box, and the release mouse button * is made when the dialog box is opened. */ m_ignoreNextLeftButtonRelease = false; } if( event.ButtonDown( wxMOUSE_BTN_MIDDLE ) && m_enableMiddleButtonPan ) { if( m_panScrollbarLimits ) { int ppux, ppuy; GetScrollPixelsPerUnit( &ppux, &ppuy ); GetViewStart( &m_PanStartCenter.x, &m_PanStartCenter.y ); m_PanStartCenter.x *= ppux; m_PanStartCenter.y *= ppuy; } else m_PanStartCenter = GetParent()->GetScrollCenterPosition(); m_PanStartEventPosition = event.GetPosition(); INSTALL_UNBUFFERED_DC( dc, this ); CrossHairOff( &dc ); } if( event.ButtonUp( wxMOUSE_BTN_MIDDLE ) && m_enableMiddleButtonPan ) { INSTALL_UNBUFFERED_DC( dc, this ); CrossHairOn( &dc ); } if( event.MiddleIsDown() && m_enableMiddleButtonPan ) { wxPoint currentPosition = event.GetPosition(); if( m_panScrollbarLimits ) { int x, y; int tmpX, tmpY; int ppux, ppuy; int maxX, maxY; int vsizeX, vsizeY; int csizeX, csizeY; GetViewStart( &tmpX, &tmpY ); GetScrollPixelsPerUnit( &ppux, &ppuy ); GetVirtualSize( &vsizeX, &vsizeY ); GetClientSize( &csizeX, &csizeY ); maxX = vsizeX - csizeX; maxY = vsizeY - csizeY; x = m_PanStartCenter.x + m_PanStartEventPosition.x - currentPosition.x; y = m_PanStartCenter.y + m_PanStartEventPosition.y - currentPosition.y; bool shouldMoveCursor = false; if( x < 0 ) { currentPosition.x += x; x = 0; shouldMoveCursor = true; } if( y < 0 ) { currentPosition.y += y; y = 0; shouldMoveCursor = true; } if( x > maxX ) { currentPosition.x += ( x - maxX ); x = maxX; shouldMoveCursor = true; } if( y > maxY ) { currentPosition.y += ( y - maxY ); y = maxY; shouldMoveCursor = true; } if ( shouldMoveCursor ) WarpPointer( currentPosition.x, currentPosition.y ); Scroll( x/ppux, y/ppuy ); double scale = GetParent()->GetScreen()->GetScalingFactor(); wxPoint center = GetParent()->GetScrollCenterPosition(); center.x += KiROUND( (double) ( x - tmpX ) / scale ) / ppux; center.y += KiROUND( (double) ( y - tmpY ) / scale ) / ppuy; GetParent()->SetScrollCenterPosition( center ); Refresh(); Update(); } else { double scale = GetParent()->GetScreen()->GetScalingFactor(); int x = m_PanStartCenter.x + KiROUND( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale ); int y = m_PanStartCenter.y + KiROUND( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale ); GetParent()->RedrawScreen( wxPoint( x, y ), false ); } } if( event.ButtonUp( wxMOUSE_BTN_MIDDLE ) && !m_enableMiddleButtonPan && (screen->m_BlockLocate.GetState() == STATE_NO_BLOCK) ) { // The middle button has been released, with no block command: // We use it for a zoom center at cursor position command wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER ); cmd.SetEventObject( this ); GetEventHandler()->ProcessEvent( cmd ); } // Calling the general function on mouse changes (and pseudo key commands) GetParent()->GeneralControl( &DC, event.GetLogicalPosition( DC ), 0 ); /*******************************/ /* Control of block commands : */ /*******************************/ // Command block can't start if mouse is dragging a new panel static EDA_DRAW_PANEL* lastPanel; if( lastPanel != this ) { m_minDragEventCount = 0; m_canStartBlock = -1; } /* A new command block can start after a release buttons * and if the drag is enough * This is to avoid a false start block when a dialog box is dismissed, * or when changing panels in hierarchy navigation * or when clicking while and moving mouse */ if( !event.LeftIsDown() && !event.MiddleIsDown() ) { m_minDragEventCount = 0; m_canStartBlock = 0; /* Remember the last cursor position when a drag mouse starts * this is the last position ** before ** clicking a button * this is useful to start a block command from the point where the * mouse was clicked first * (a filter creates a delay for the real block command start, and * we must remember this point) */ m_CursorStartPos = GetParent()->GetCrossHairPosition(); } if( m_enableBlockCommands && !(localbutt & GR_M_DCLICK) ) { if( !screen->IsBlockActive() ) { screen->m_BlockLocate.SetOrigin( m_CursorStartPos ); } if( event.LeftDown() || ( !m_enableMiddleButtonPan && event.MiddleDown() ) ) { if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE ) { m_requestAutoPan = false; GetParent()->HandleBlockPlace( &DC ); m_ignoreNextLeftButtonRelease = true; } } else if( ( m_canStartBlock >= 0 ) && ( event.LeftIsDown() || ( !m_enableMiddleButtonPan && event.MiddleIsDown() ) ) && !IsMouseCaptured() ) { // Mouse is dragging: if no block in progress, start a block command. if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK ) { // Start a block command int cmd_type = kbstat; if( !m_enableMiddleButtonPan && event.MiddleIsDown() ) cmd_type |= MOUSE_MIDDLE; // A block command is started if the drag is enough. A small // drag is ignored (it is certainly a little mouse move when // clicking) not really a drag mouse if( m_minDragEventCount < MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND ) m_minDragEventCount++; else { if( !GetParent()->HandleBlockBegin( &DC, cmd_type, m_CursorStartPos ) ) { // should not occur: error GetParent()->DisplayToolMsg( wxT( "EDA_DRAW_PANEL::OnMouseEvent() Block Error" ) ); } else { m_requestAutoPan = true; SetCursor( wxCURSOR_SIZING ); } } } } if( event.ButtonUp( wxMOUSE_BTN_LEFT ) || ( !m_enableMiddleButtonPan && event.ButtonUp( wxMOUSE_BTN_MIDDLE ) ) ) { /* Release the mouse button: end of block. * The command can finish (DELETE) or have a next command (MOVE, * COPY). However the block command is canceled if the block * size is small because a block command filtering is already * made, this case happens, but only when the on grid cursor has * not moved. */ #define BLOCK_MINSIZE_LIMIT 1 bool BlockIsSmall = ( std::abs( screen->m_BlockLocate.GetWidth() ) < BLOCK_MINSIZE_LIMIT ) && ( std::abs( screen->m_BlockLocate.GetHeight() ) < BLOCK_MINSIZE_LIMIT ); if( (screen->m_BlockLocate.GetState() != STATE_NO_BLOCK) && BlockIsSmall ) { if( m_endMouseCaptureCallback ) { m_endMouseCaptureCallback( this, &DC ); m_requestAutoPan = false; } SetCursor( (wxStockCursor) m_currentCursor ); } else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END ) { m_requestAutoPan = false; GetParent()->HandleBlockEnd( &DC ); SetCursor( (wxStockCursor) m_currentCursor ); if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE ) { m_requestAutoPan = true; SetCursor( wxCURSOR_HAND ); } } } } // End of block command on a double click // To avoid an unwanted block move command if the mouse is moved while double clicking if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) ) { if( !screen->IsBlockActive() && IsMouseCaptured() ) { m_endMouseCaptureCallback( this, &DC ); } } #if 0 wxString msg_debug; msg_debug.Printf( " block state %d, cmd %d", screen->m_BlockLocate.GetState(), screen->m_BlockLocate.GetCommand() ); GetParent()->PrintMsg( msg_debug ); #endif lastPanel = this; }
/* =============== idEditField::SetBuffer =============== */ void idEditField::SetBuffer( const char *buf ) { Clear(); idStr::Copynz( buffer, buf, sizeof( buffer ) ); SetCursor( strlen( buffer ) ); }
/* =============== idEditField::AutoComplete =============== */ void idEditField::AutoComplete( void ) { char completionArgString[MAX_EDIT_LINE]; idCmdArgs args; if( !autoComplete.valid ) { args.TokenizeString( buffer, false ); idStr::Copynz( autoComplete.completionString, args.Argv( 0 ), sizeof( autoComplete.completionString ) ); idStr::Copynz( completionArgString, args.Args(), sizeof( completionArgString ) ); autoComplete.matchCount = 0; autoComplete.matchIndex = 0; autoComplete.currentMatch[0] = 0; if( strlen( autoComplete.completionString ) == 0 ) { return; } globalAutoComplete = autoComplete; cmdSystem->CommandCompletion( FindMatches ); cvarSystem->CommandCompletion( FindMatches ); autoComplete = globalAutoComplete; if( autoComplete.matchCount == 0 ) { return; // no matches } // when there's only one match or there's an argument if( autoComplete.matchCount == 1 || completionArgString[0] != '\0' ) { /// try completing arguments idStr::Append( autoComplete.completionString, sizeof( autoComplete.completionString ), " " ); idStr::Append( autoComplete.completionString, sizeof( autoComplete.completionString ), completionArgString ); autoComplete.matchCount = 0; globalAutoComplete = autoComplete; cmdSystem->ArgCompletion( autoComplete.completionString, FindMatches ); cvarSystem->ArgCompletion( autoComplete.completionString, FindMatches ); autoComplete = globalAutoComplete; idStr::snPrintf( buffer, sizeof( buffer ), "%s", autoComplete.currentMatch ); if( autoComplete.matchCount == 0 ) { // no argument matches idStr::Append( buffer, sizeof( buffer ), " " ); idStr::Append( buffer, sizeof( buffer ), completionArgString ); SetCursor( strlen( buffer ) ); return; } } else { // multiple matches, complete to shortest idStr::snPrintf( buffer, sizeof( buffer ), "%s", autoComplete.currentMatch ); if( strlen( completionArgString ) ) { idStr::Append( buffer, sizeof( buffer ), " " ); idStr::Append( buffer, sizeof( buffer ), completionArgString ); } } autoComplete.length = strlen( buffer ); autoComplete.valid = ( autoComplete.matchCount != 1 ); SetCursor( autoComplete.length ); common->Printf( "]%s\n", buffer ); // run through again, printing matches globalAutoComplete = autoComplete; cmdSystem->CommandCompletion( PrintMatches ); cmdSystem->ArgCompletion( autoComplete.completionString, PrintMatches ); cvarSystem->CommandCompletion( PrintCvarMatches ); cvarSystem->ArgCompletion( autoComplete.completionString, PrintMatches ); } else if( autoComplete.matchCount != 1 ) { // get the next match and show instead autoComplete.matchIndex++; if( autoComplete.matchIndex == autoComplete.matchCount ) { autoComplete.matchIndex = 0; } autoComplete.findMatchIndex = 0; globalAutoComplete = autoComplete; cmdSystem->CommandCompletion( FindIndexMatch ); cmdSystem->ArgCompletion( autoComplete.completionString, FindIndexMatch ); cvarSystem->CommandCompletion( FindIndexMatch ); cvarSystem->ArgCompletion( autoComplete.completionString, FindIndexMatch ); autoComplete = globalAutoComplete; // and print it idStr::snPrintf( buffer, sizeof( buffer ), autoComplete.currentMatch ); if( autoComplete.length > ( int ) strlen( buffer ) ) { autoComplete.length = strlen( buffer ); } SetCursor( autoComplete.length ); } }
static BOOL CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { page *m_this_page=g_this_page; HWND hwLicense; static int ignoreWMCommand; if (uMsg == WM_INITDIALOG) { TCHAR *l = (TCHAR *)GetNSISStringNP(GetNSISTab(this_page->parms[1])); int lt = *l; EDITSTREAM es = { (DWORD)(++l), 0, StreamLicense }; int selected = (this_page->flags & PF_LICENSE_SELECTED) | !(this_page->flags & PF_LICENSE_FORCE_SELECTION); SetUITextFromLang(IDC_LICENSEAGREE,this_page->parms[2]); SetUITextFromLang(IDC_LICENSEDISAGREE,this_page->parms[3]); CheckDlgButton(hwndDlg,IDC_LICENSEAGREE+!selected,BST_CHECKED); EnableNext(selected); hwLicense=GetUIItem(IDC_EDIT1); SetActiveCtl(hwLicense); SendMessage(hwLicense,EM_AUTOURLDETECT,TRUE,0); #define lbg g_header->license_bg SendMessage(hwLicense,EM_SETBKGNDCOLOR,0,lbg>=0?lbg:GetSysColor(-lbg)); #undef lbg SendMessage(hwLicense,EM_SETEVENTMASK,0,ENM_LINK|ENM_KEYEVENTS); //XGE 8th September 2002 Or'd in ENM_KEYEVENTS dwRead=0; SendMessage(hwLicense,EM_EXLIMITTEXT,0,mystrlen(l)); SendMessage(hwLicense,EM_STREAMIN,lt,(LPARAM)&es); ignoreWMCommand = 0; return FALSE; } if (uMsg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && !ignoreWMCommand) { if (m_this_page->flags & PF_LICENSE_FORCE_SELECTION) { int is = SendMessage(GetUIItem(IDC_LICENSEAGREE), BM_GETCHECK, 0, 0) & BST_CHECKED; m_this_page->flags &= ~PF_LICENSE_SELECTED; m_this_page->flags |= is; EnableNext(is); SetNextDef(); } } if (uMsg == WM_NOTIFY) { hwLicense=GetUIItem(IDC_EDIT1); #define nmhdr ((NMHDR *)lParam) #define enlink ((ENLINK *)lParam) #define msgfilter ((MSGFILTER *)lParam) if (nmhdr->code==EN_LINK) { if (enlink->msg==WM_LBUTTONDOWN) { TEXTRANGE tr = { { enlink->chrg.cpMin, enlink->chrg.cpMax, }, ps_tmpbuf }; if (tr.chrg.cpMax-tr.chrg.cpMin < sizeof(ps_tmpbuf)) { SendMessage(hwLicense,EM_GETTEXTRANGE,0,(LPARAM)&tr); SetCursor(LoadCursor(0, IDC_WAIT)); ShellExecute(hwndDlg,_T("open"),tr.lpstrText,NULL,NULL,SW_SHOWNORMAL); SetCursor(LoadCursor(0, IDC_ARROW)); } } } //Ximon Eighteen 8th September 2002 Capture return key presses in the rich //edit control now that the control gets the focus rather than the default //push button. When the user presses return ask the outer dialog to move //the installer onto the next page. MSDN docs say return non-zero if the //rich edit control should NOT process this message, hence the return 1. // //This is required because the RichEdit control is eating all the key hits. //It does try to release some and convert VK_ESCAPE to WM_CLOSE, VK_ENTER //to a push on the default button and VM_TAB to WM_NEXTDLGCTL. But sadly it //it sends all of these messages to its parent instead of just letting the //dialog manager handle them. Instead of properly handling WM_GETDLGCODE, //it mimics the dialog manager. if (nmhdr->code==EN_MSGFILTER) { if (msgfilter->msg==WM_KEYDOWN) { if (msgfilter->wParam==VK_RETURN) { SendMessage(g_hwnd, WM_COMMAND, IDOK, 0); } if (msgfilter->wParam==VK_ESCAPE) { SendMessage(g_hwnd, WM_CLOSE, 0, 0); } return 1; } } #undef nmhdr #undef enlink #undef msgfilter } if (uMsg == WM_NOTIFY_INIGO_MONTOYA) { ignoreWMCommand++; } return HandleStaticBkColor(); }
HRESULT APPLICATION::Init(HINSTANCE hInstance, int width, int height, bool windowed) { debug.Print("Application initiated"); //Create Window Class WNDCLASS wc; memset(&wc, 0, sizeof(WNDCLASS)); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)::DefWindowProc; wc.hInstance = hInstance; wc.lpszClassName = "D3DWND"; //Register Class and Create new Window RegisterClass(&wc); m_mainWindow = CreateWindow("D3DWND", "Example 4.1: Heightmaps from Images", WS_EX_TOPMOST, 0, 0, width, height, 0, 0, hInstance, 0); SetCursor(NULL); ShowWindow(m_mainWindow, SW_SHOW); UpdateWindow(m_mainWindow); //Create IDirect3D9 Interface IDirect3D9* d3d9 = Direct3DCreate9(D3D_SDK_VERSION); if(d3d9 == NULL) { debug.Print("Direct3DCreate9() - FAILED"); return E_FAIL; } //Check that the Device supports what we need from it D3DCAPS9 caps; d3d9->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps); //Hardware Vertex Processing or not? int vp = 0; if(caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) vp = D3DCREATE_HARDWARE_VERTEXPROCESSING; else vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING; //Check vertex & pixelshader versions if(caps.VertexShaderVersion < D3DVS_VERSION(2, 0) || caps.PixelShaderVersion < D3DPS_VERSION(2, 0)) { debug.Print("Warning - Your graphic card does not support vertex and pixelshaders version 2.0"); } //Set D3DPRESENT_PARAMETERS D3DPRESENT_PARAMETERS d3dpp; d3dpp.BackBufferWidth = width; d3dpp.BackBufferHeight = height; d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; d3dpp.BackBufferCount = 1; d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; d3dpp.MultiSampleQuality = 0; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.hDeviceWindow = m_mainWindow; d3dpp.Windowed = windowed; d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; d3dpp.Flags = 0; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; //Create the IDirect3DDevice9 if(FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_mainWindow, vp, &d3dpp, &m_pDevice))) { debug.Print("Failed to create IDirect3DDevice9"); return E_FAIL; } //Release IDirect3D9 interface d3d9->Release(); D3DXCreateFont(m_pDevice, 18, 0, 0, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &m_pFont); return S_OK; }
////////////////////////////////////// // Handles WM_TIMER messages ////////////////////////////////////// void Main_Timer(HWND hwnd, UINT id) { if(Mstart == TRUE) { SaveLevels(); SetCursor(LoadCursor(NULL, IDC_WAIT)); for(int i = 0; i < MAXLEVEL; i++) { leveltemp[i] = (LPLEVELARRAY)malloc(sizeof(LEVELARRAY)); } SetCursor(LoadCursor(NULL, IDC_ARROW)); FILE *fp; char S2[MAXARRAY] = GAMEDIR; strcat(S2, LEVELSFILE); fp = fopen(S2, "r"); for(i = 0; i < CL; i++) { fread(&(leveltemp[i]->midi), sizeof(MIDIFILE), 1, fp); fread(&(leveltemp[i]->waveNum), sizeof(UINT), 1, fp); fread(&(leveltemp[i]->bitmapNum), sizeof(UINT), 1, fp); fread(&(leveltemp[i]->spriteNum), sizeof(UINT), 1, fp); fread(&(leveltemp[i]->zoneNum), sizeof(UINT), 1, fp); fread(&(leveltemp[i]->lWaveA), sizeof(UINT), leveltemp[i]->waveNum, fp); fread(&(leveltemp[i]->lBitmapA), sizeof(BITMAPARRAY), leveltemp[i]->bitmapNum, fp); fread(&(leveltemp[i]->lSpriteA), sizeof(SPRITEARRAY), leveltemp[i]->spriteNum, fp); fread(&(leveltemp[i]->lZoneA), sizeof(ZONEARRAY), leveltemp[i]->zoneNum, fp); } fclose(fp); Mstart = FALSE; } else if(mouseswitch) { int m = 10; int x = 10; RECT r; char S[MAXARRAY]; HDC PaintDC = GetDC(hwnd); GetWindowRect(hwnd, &r); FillRect(PaintDC, &r, (HBRUSH)GetStockObject(BLACK_BRUSH)); sprintf(S, "LevelNum = %u", n); TextOut(PaintDC, x, m, S, strlen(S)); m += 30; sprintf(S, "level.midi.file = %s", leveltemp[n]->midi.file); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.midi.sec = %u", leveltemp[n]->midi.sec); TextOut(PaintDC, x, m, S, strlen(S)); m += 30; sprintf(S, "level.waveNum = %u", leveltemp[n]->waveNum); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.bitmapNum = %u", leveltemp[n]->bitmapNum); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.spriteNum = %u", leveltemp[n]->spriteNum); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.zoneNum = %u", leveltemp[n]->zoneNum); TextOut(PaintDC, x, m, S, strlen(S)); m += 30; ////////////////////////////////////////////////////////////////// sprintf(S, "WaveNum = %u", w); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lWaveA = %d", leveltemp[n]->lWaveA[w]); TextOut(PaintDC, x, m, S, strlen(S)); m += 30; ////////////////////////////////////////////////////////////////// x = 400; m = 10; sprintf(S, "BitmapNum = %u", b); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lBitmapA.zNum = %u", leveltemp[n]->lBitmapA[b].zNum); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; if(leveltemp[n]->lZoneA[leveltemp[n]->lBitmapA[b].zNum].x1 < 65500) { sprintf(S, "level.lBitmapA.zoneName = %s", leveltemp[n]->lZoneA[leveltemp[n]->lBitmapA[b].zNum].zoneName); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; } sprintf(S, "level.lBitmapA.x1 = %u", leveltemp[n]->lZoneA[leveltemp[n]->lBitmapA[b].zNum].x1); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lBitmapA.y1 = %u", leveltemp[n]->lZoneA[leveltemp[n]->lBitmapA[b].zNum].y1); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lBitmapA.x2 = %u", leveltemp[n]->lZoneA[leveltemp[n]->lBitmapA[b].zNum].x2); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lBitmapA.y2 = %u", leveltemp[n]->lZoneA[leveltemp[n]->lBitmapA[b].zNum].y2); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lBitmapA.w = %u", leveltemp[n]->lZoneA[leveltemp[n]->lBitmapA[b].zNum].w); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lBitmapA.h = %u", leveltemp[n]->lZoneA[leveltemp[n]->lBitmapA[b].zNum].h); TextOut(PaintDC, x, m, S, strlen(S)); m += 30; ////////////////////////////////////////////////////////////////// sprintf(S, "SpriteNum = %u", l); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lSpriteA.zNum = %u", leveltemp[n]->lSpriteA[l].zNum); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; if(leveltemp[n]->lZoneA[leveltemp[n]->lSpriteA[l].zNum].x1 < 65500) { sprintf(S, "level.lSpriteA.zoneName = %s", leveltemp[n]->lZoneA[leveltemp[n]->lSpriteA[l].zNum].zoneName); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; } sprintf(S, "level.lSpriteA.x1 = %u", leveltemp[n]->lZoneA[leveltemp[n]->lSpriteA[l].zNum].x1); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lSpriteA.y1 = %u", leveltemp[n]->lZoneA[leveltemp[n]->lSpriteA[l].zNum].y1); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lSpriteA.x2 = %u", leveltemp[n]->lZoneA[leveltemp[n]->lSpriteA[l].zNum].x2); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lSpriteA.y2 = %u", leveltemp[n]->lZoneA[leveltemp[n]->lSpriteA[l].zNum].y2); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lSpriteA.w = %u", leveltemp[n]->lZoneA[leveltemp[n]->lSpriteA[l].zNum].w); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lSpriteA.h = %u", leveltemp[n]->lZoneA[leveltemp[n]->lSpriteA[l].zNum].h); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lSpriteA.zOrder = %u", leveltemp[n]->lSpriteA[l].zOrder); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lSpriteA.cel = %u", leveltemp[n]->lSpriteA[l].cel); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lSpriteA.xDelta = %u", leveltemp[n]->lSpriteA[l].xDelta); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lSpriteA.yDelta = %u", leveltemp[n]->lSpriteA[l].yDelta); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lSpriteA.xHotspot = %u", leveltemp[n]->lSpriteA[l].xHotspot); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lSpriteA.yHotspot = %u", leveltemp[n]->lSpriteA[l].yHotspot); TextOut(PaintDC, x, m, S, strlen(S)); m += 30; ////////////////////////////////////////////////////////////////// sprintf(S, "ZoneNum = %u", k); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; if(leveltemp[n]->lZoneA[k].x1 < 65500) { sprintf(S, "level.lZoneA.zoneName = %s", leveltemp[n]->lZoneA[k].zoneName); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; } sprintf(S, "level.lZoneA.x1 = %u", leveltemp[n]->lZoneA[k].x1); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lZoneA.y1 = %u", leveltemp[n]->lZoneA[k].y1); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lZoneA.x2 = %u", leveltemp[n]->lZoneA[k].x2); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lZoneA.y2 = %u", leveltemp[n]->lZoneA[k].y2); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lZoneA.w = %u", leveltemp[n]->lZoneA[k].w); TextOut(PaintDC, x, m, S, strlen(S)); m += 20; sprintf(S, "level.lZoneA.h = %u", leveltemp[n]->lZoneA[k].h); TextOut(PaintDC, x, m, S, strlen(S)); m += 30; ReleaseDC(hwnd, PaintDC); mouseswitch = FALSE; } SetTimer(hwnd, IDT_MAIN, 10, NULL); }
virtual void OnLeftUp(wxMouseEvent& /*event*/) { SetCursor(m_handOpenCursor); m_handToolActive = false; }
/// <summary> /// Save Mesh to disk. /// </summary> /// <param name="mesh">The mesh to save.</param> /// <returns>indicates success or failure</returns> HRESULT CKinectFusionExplorer::SaveMeshFile(INuiFusionColorMesh* pMesh, KinectFusionMeshTypes saveMeshType) { HRESULT hr = S_OK; if (nullptr == pMesh) { return E_INVALIDARG; } CComPtr<IFileSaveDialog> pSaveDlg; // Create the file save dialog object. hr = pSaveDlg.CoCreateInstance(__uuidof(FileSaveDialog)); if (FAILED(hr)) { return hr; } // Set the dialog title hr = pSaveDlg->SetTitle(L"Save Kinect Fusion Mesh"); if (SUCCEEDED(hr)) { // Set the button text hr = pSaveDlg->SetOkButtonLabel (L"Save"); if (SUCCEEDED(hr)) { // Set a default filename if (Stl == saveMeshType) { hr = pSaveDlg->SetFileName(L"MeshedReconstruction.stl"); } else if (Obj == saveMeshType) { hr = pSaveDlg->SetFileName(L"MeshedReconstruction.obj"); } else if (Ply == saveMeshType) { hr = pSaveDlg->SetFileName(L"MeshedReconstruction.ply"); } if (SUCCEEDED(hr)) { // Set the file type extension if (Stl == saveMeshType) { hr = pSaveDlg->SetDefaultExtension(L"stl"); } else if (Obj == saveMeshType) { hr = pSaveDlg->SetDefaultExtension(L"obj"); } else if (Ply == saveMeshType) { hr = pSaveDlg->SetDefaultExtension(L"ply"); } if (SUCCEEDED(hr)) { // Set the file type filters if (Stl == saveMeshType) { COMDLG_FILTERSPEC allPossibleFileTypes[] = { { L"Stl mesh files", L"*.stl" }, { L"All files", L"*.*" } }; hr = pSaveDlg->SetFileTypes( ARRAYSIZE(allPossibleFileTypes), allPossibleFileTypes); } else if (Obj == saveMeshType) { COMDLG_FILTERSPEC allPossibleFileTypes[] = { { L"Obj mesh files", L"*.obj" }, { L"All files", L"*.*" } }; hr = pSaveDlg->SetFileTypes( ARRAYSIZE(allPossibleFileTypes), allPossibleFileTypes ); } else if (Ply == saveMeshType) { COMDLG_FILTERSPEC allPossibleFileTypes[] = { { L"Ply mesh files", L"*.ply" }, { L"All files", L"*.*" } }; hr = pSaveDlg->SetFileTypes( ARRAYSIZE(allPossibleFileTypes), allPossibleFileTypes ); } if (SUCCEEDED(hr)) { // Show the file selection box hr = pSaveDlg->Show(m_hWnd); // Save the mesh to the chosen file. if (SUCCEEDED(hr)) { CComPtr<IShellItem> pItem; hr = pSaveDlg->GetResult(&pItem); if (SUCCEEDED(hr)) { LPOLESTR pwsz = nullptr; hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pwsz); if (SUCCEEDED(hr)) { SetStatusMessage(L"Saving mesh file, please wait..."); SetCursor(LoadCursor(nullptr, MAKEINTRESOURCE(IDC_WAIT))); if (Stl == saveMeshType) { hr = WriteBinarySTLMeshFile(pMesh, pwsz); } else if (Obj == saveMeshType) { hr = WriteAsciiObjMeshFile(pMesh, pwsz); } else if (Ply == saveMeshType) { hr = WriteAsciiPlyMeshFile(pMesh, pwsz, true, m_bColorCaptured); } CoTaskMemFree(pwsz); } } } } } } } } return hr; }
void GainCanvas::OnMouseEnterWindow(wxMouseEvent& event) { InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event); SetCursor(wxCURSOR_CROSS); // Refresh(); }
// Window callback function (handles window events) // static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { _GLFWwindow* window = (_GLFWwindow*) GetWindowLongPtrW(hWnd, 0); switch (uMsg) { case WM_NCCREATE: { CREATESTRUCTW* cs = (CREATESTRUCTW*) lParam; SetWindowLongPtrW(hWnd, 0, (LONG_PTR) cs->lpCreateParams); break; } case WM_SETFOCUS: { if (window->cursorMode != GLFW_CURSOR_NORMAL) _glfwPlatformApplyCursorMode(window); if (window->monitor && window->autoIconify) enterFullscreenMode(window); _glfwInputWindowFocus(window, GL_TRUE); return 0; } case WM_KILLFOCUS: { if (window->cursorMode != GLFW_CURSOR_NORMAL) restoreCursor(window); if (window->monitor && window->autoIconify) { _glfwPlatformIconifyWindow(window); leaveFullscreenMode(window); } _glfwInputWindowFocus(window, GL_FALSE); return 0; } case WM_SYSCOMMAND: { switch (wParam & 0xfff0) { case SC_SCREENSAVE: case SC_MONITORPOWER: { if (window->monitor) { // We are running in full screen mode, so disallow // screen saver and screen blanking return 0; } else break; } // User trying to access application menu using ALT? case SC_KEYMENU: return 0; } break; } case WM_CLOSE: { _glfwInputWindowCloseRequest(window); return 0; } case WM_KEYDOWN: case WM_SYSKEYDOWN: { const int scancode = (lParam >> 16) & 0x1ff; const int key = translateKey(wParam, lParam); if (key == _GLFW_KEY_INVALID) break; _glfwInputKey(window, key, scancode, GLFW_PRESS, getKeyMods()); break; } case WM_CHAR: { _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_TRUE); return 0; } case WM_SYSCHAR: { _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_FALSE); return 0; } case WM_UNICHAR: { // This message is not sent by Windows, but is sent by some // third-party input method engines if (wParam == UNICODE_NOCHAR) { // Returning TRUE here announces support for this message return TRUE; } _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_TRUE); return FALSE; } case WM_KEYUP: case WM_SYSKEYUP: { const int mods = getKeyMods(); const int scancode = (lParam >> 16) & 0x1ff; const int key = translateKey(wParam, lParam); if (key == _GLFW_KEY_INVALID) break; if (wParam == VK_SHIFT) { // Release both Shift keys on Shift up event, as only one event // is sent even if both keys are released _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, GLFW_RELEASE, mods); _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, GLFW_RELEASE, mods); } else if (wParam == VK_SNAPSHOT) { // Key down is not reported for the print screen key _glfwInputKey(window, key, scancode, GLFW_PRESS, mods); _glfwInputKey(window, key, scancode, GLFW_RELEASE, mods); } else _glfwInputKey(window, key, scancode, GLFW_RELEASE, mods); break; } case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: case WM_XBUTTONDOWN: { const int mods = getKeyMods(); SetCapture(hWnd); if (uMsg == WM_LBUTTONDOWN) _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods); else if (uMsg == WM_RBUTTONDOWN) _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods); else if (uMsg == WM_MBUTTONDOWN) _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods); else { if (HIWORD(wParam) == XBUTTON1) _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_4, GLFW_PRESS, mods); else if (HIWORD(wParam) == XBUTTON2) _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_5, GLFW_PRESS, mods); return TRUE; } return 0; } case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: case WM_XBUTTONUP: { const int mods = getKeyMods(); ReleaseCapture(); if (uMsg == WM_LBUTTONUP) _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE, mods); else if (uMsg == WM_RBUTTONUP) _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_RELEASE, mods); else if (uMsg == WM_MBUTTONUP) _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_RELEASE, mods); else { if (HIWORD(wParam) == XBUTTON1) _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_4, GLFW_RELEASE, mods); else if (HIWORD(wParam) == XBUTTON2) _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_5, GLFW_RELEASE, mods); return TRUE; } return 0; } case WM_MOUSEMOVE: { const int x = GET_X_LPARAM(lParam); const int y = GET_Y_LPARAM(lParam); if (window->cursorMode == GLFW_CURSOR_DISABLED) { if (_glfw.cursorWindow != window) break; _glfwInputCursorMotion(window, x - window->win32.cursorPosX, y - window->win32.cursorPosY); } else _glfwInputCursorMotion(window, x, y); window->win32.cursorPosX = x; window->win32.cursorPosY = y; if (!window->win32.cursorTracked) { TRACKMOUSEEVENT tme; ZeroMemory(&tme, sizeof(tme)); tme.cbSize = sizeof(tme); tme.dwFlags = TME_LEAVE; tme.hwndTrack = window->win32.handle; TrackMouseEvent(&tme); window->win32.cursorTracked = GL_TRUE; _glfwInputCursorEnter(window, GL_TRUE); } return 0; } case WM_MOUSELEAVE: { window->win32.cursorTracked = GL_FALSE; _glfwInputCursorEnter(window, GL_FALSE); return 0; } case WM_MOUSEWHEEL: { _glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA); return 0; } case WM_MOUSEHWHEEL: { // This message is only sent on Windows Vista and later // NOTE: The X-axis is inverted for consistency with OS X and X11. _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0); return 0; } case WM_SIZE: { if (_glfw.cursorWindow == window) { if (window->cursorMode == GLFW_CURSOR_DISABLED) updateClipRect(window); } if (!window->win32.iconified && wParam == SIZE_MINIMIZED) { window->win32.iconified = GL_TRUE; _glfwInputWindowIconify(window, GL_TRUE); } else if (window->win32.iconified && (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED)) { window->win32.iconified = GL_FALSE; _glfwInputWindowIconify(window, GL_FALSE); } _glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam)); _glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam)); return 0; } case WM_MOVE: { if (_glfw.cursorWindow == window) { if (window->cursorMode == GLFW_CURSOR_DISABLED) updateClipRect(window); } // NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as // those macros do not handle negative window positions correctly _glfwInputWindowPos(window, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; } case WM_PAINT: { _glfwInputWindowDamage(window); break; } case WM_ERASEBKGND: { return TRUE; } case WM_SETCURSOR: { if (_glfw.cursorWindow == window && LOWORD(lParam) == HTCLIENT) { if (window->cursorMode == GLFW_CURSOR_HIDDEN || window->cursorMode == GLFW_CURSOR_DISABLED) { SetCursor(NULL); return TRUE; } else if (window->cursor) { SetCursor(window->cursor->win32.handle); return TRUE; } } break; } case WM_DEVICECHANGE: { if (DBT_DEVNODES_CHANGED == wParam) { _glfwInputMonitorChange(); return TRUE; } break; } case WM_DROPFILES: { HDROP hDrop = (HDROP) wParam; POINT pt; int i; const int count = DragQueryFileW(hDrop, 0xffffffff, NULL, 0); char** paths = calloc(count, sizeof(char*)); // Move the mouse to the position of the drop DragQueryPoint(hDrop, &pt); _glfwInputCursorMotion(window, pt.x, pt.y); for (i = 0; i < count; i++) { const UINT length = DragQueryFileW(hDrop, i, NULL, 0); WCHAR* buffer = calloc(length + 1, sizeof(WCHAR)); DragQueryFileW(hDrop, i, buffer, length + 1); paths[i] = _glfwCreateUTF8FromWideString(buffer); free(buffer); } _glfwInputDrop(window, count, (const char**) paths); for (i = 0; i < count; i++) free(paths[i]); free(paths); DragFinish(hDrop); return 0; } } return DefWindowProc(hWnd, uMsg, wParam, lParam); }
LRESULT HotKeyInputWindow::WindowProcedure(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_SETFOCUS: { hasFocus = true; RenderToBuffer(); ShowCustomCaret(); InvalidateRect(windowHandle, nullptr, TRUE); context->GetMessageBus()->SuspendHotkeys(); return TRUE; } case WM_KILLFOCUS: { hasFocus = false; RenderToBuffer(); AssertCriticalWinApiResult(HideCaret(windowHandle)); InvalidateRect(windowHandle, nullptr, TRUE); context->GetMessageBus()->EnableHotkeys(); return TRUE; } case WM_SETCURSOR: { SetCursor(LoadCursor(nullptr, IDC_IBEAM)); return TRUE; } case WM_PAINT: { PAINTSTRUCT ps; AssertCriticalWinApiResult(BeginPaint(GetHandle(), &ps)); Draw(false); EndPaint(GetHandle(), &ps); if (GetFocus() == windowHandle) { ShowCustomCaret(); } return TRUE; } case WM_KEYDOWN: case WM_KEYUP: { int procedureResult = CallBaseWindowProcedure(message, wParam, lParam); currentHotkey = SendMessage(windowHandle, HKM_GETHOTKEY, 0, 0); int virtualCode = LOBYTE(LOWORD(currentHotkey)); int modifier = HIBYTE(LOWORD(currentHotkey)); if(message == WM_KEYUP) { OnHotkeyChanged.Notify(currentHotkey); } else { bool isModifierInvalid = modifier == 0 || (modifier & HOTKEYF_EXT) == HOTKEYF_EXT; bool isKeyInvalid = virtualCode != 0 && MapVirtualKey(virtualCode, MAPVK_VK_TO_CHAR) == 0; if (isModifierInvalid || isKeyInvalid) { currentHotkey = 0; SendMessage(windowHandle, HKM_SETHOTKEY, 0, 0); } } RenderToBuffer(); return procedureResult; } } return ChildWindow::WindowProcedure(message, wParam, lParam); }
LRESULT CALLBACK view_context_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam) { static HWND grippy=0; int lines,dir,do_scroll=FALSE,update_scroll_pos=TRUE; static int divider_drag=FALSE,org_row_width=90,row_width=90,last_pos=0; #ifdef _DEBUG if(FALSE) // if(message!=0x200&&message!=0x84&&message!=0x20&&message!=WM_ENTERIDLE) // if(msg!=WM_MOUSEFIRST&&msg!=WM_NCHITTEST&&msg!=WM_SETCURSOR&&msg!=WM_ENTERIDLE&&msg!=WM_DRAWITEM // &&msg!=WM_CTLCOLORBTN&&msg!=WM_CTLCOLOREDIT&&msg!=WM_CTLCOLORSCROLLBAR) if(msg!=WM_NCHITTEST&&msg!=WM_SETCURSOR&&msg!=WM_ENTERIDLE) { static DWORD tick=0; if((GetTickCount()-tick)>500) printf("--\n"); printf("v"); print_msg(msg,lparam,wparam); tick=GetTickCount(); } #endif switch(msg) { case WM_INITDIALOG: grippy=create_grippy(hwnd); init_context_win_anchor(hwnd); get_ini_value("CONTEXT_WINDOW","row_width",&row_width); set_context_divider(hwnd,row_width); restore_context_rel_pos(hwnd); SendDlgItemMessage(hwnd,IDC_CONTEXT_SCROLLBAR,SBM_SETRANGE,0,10000); { int tabstop=21; //4 fixed chars SendDlgItemMessage(hwnd,IDC_CONTEXT,EM_SETTABSTOPS,1,&tabstop); } set_context_font(hwnd); open_file(&gfh); if(gfh==0){ WCHAR str[MAX_PATH*2]; _snwprintf(str,sizeof(str)/sizeof(WCHAR),L"cant open %s",fname); str[sizeof(str)/sizeof(WCHAR)-1]=0; MessageBoxW(hwnd,str,L"error",MB_OK); EndDialog(hwnd,0); return 0; } get_file_size(gfh,&fsize); _fseeki64(gfh,start_offset,SEEK_SET); set_scroll_pos(hwnd,IDC_CONTEXT_SCROLLBAR,gfh); SetFocus(GetDlgItem(hwnd,IDC_CONTEXT_SCROLLBAR)); line_count=get_number_of_lines(hwnd,IDC_CONTEXT); fill_context(hwnd,IDC_CONTEXT,gfh); close_file(&gfh); last_pos=-1; orig_edit=SetWindowLong(GetDlgItem(hwnd,IDC_CONTEXT),GWL_WNDPROC,subclass_edit); orig_scroll=SetWindowLong(GetDlgItem(hwnd,IDC_CONTEXT_SCROLLBAR),GWL_WNDPROC,subclass_scroll); SetWindowTextW(hwnd,fname); return 0; case WM_DESTROY: save_context_rel_pos(hwnd); break; case WM_HELP: context_help(hwnd); return TRUE; break; case WM_SIZE: grippy_move(hwnd,grippy); set_context_divider(hwnd,row_width); line_count=get_number_of_lines(hwnd,IDC_CONTEXT); open_file(&gfh); fill_context(hwnd,IDC_CONTEXT,gfh); set_scroll_pos(hwnd,IDC_CONTEXT_SCROLLBAR,gfh); close_file(&gfh); break; case WM_RBUTTONDOWN: case WM_LBUTTONUP: ReleaseCapture(); if(divider_drag){ write_ini_value("CONTEXT_WINDOW","row_width",row_width); divider_drag=FALSE; } break; case WM_LBUTTONDOWN: SetCapture(hwnd); SetCursor(LoadCursor(NULL,IDC_SIZEWE)); divider_drag=TRUE; org_row_width=row_width; break; case WM_MOUSEFIRST: { int x=LOWORD(lparam); SetCursor(LoadCursor(NULL,IDC_SIZEWE)); if(divider_drag){ RECT rect; GetClientRect(hwnd,&rect); if((rect.right-x)>25 && x>5){ row_width=x; set_context_divider(hwnd,row_width); } } } break; case WM_MOUSEWHEEL: { short wheel=HIWORD(wparam); int flags=LOWORD(wparam); if(wheel>0){ dir=-1; if(flags&MK_RBUTTON) lines=line_count-2; else lines=3+1; } else{ dir=1; if(flags&MK_RBUTTON) lines=line_count-2-1; else lines=3; } do_scroll=TRUE; } break; case WM_VSCROLL: { int pos=HIWORD(wparam); switch(LOWORD(wparam)){ case SB_TOP: if(GetKeyState(VK_CONTROL)&0x8000){ last_offset=0; current_line=1; } else{ last_offset=start_offset; //_fseeki64(f,start_offset,SEEK_SET); current_line=start_line; } lines=dir=0; do_scroll=TRUE; break; case SB_PAGEUP: dir=-1; lines=line_count-2; if(lines<=0) lines=1; do_scroll=TRUE; break; case SB_PAGEDOWN: dir=1; lines=line_count-2-1; if(lines<=0) lines=1; do_scroll=TRUE; break; case SB_LINEUP: dir=-1; lines=2; do_scroll=TRUE; break; case SB_LINEDOWN: dir=1; lines=1; do_scroll=TRUE; break; case SB_THUMBTRACK: //printf("pos=%i last_pos=%i scroll_pos=%i line_count=%i\n",HIWORD(wparam),last_pos,scroll_pos,line_count); if(pos<last_pos){ dir=-1; lines=line_count/4; if(lines<=1) lines=2; do_scroll=TRUE; } else if(pos>last_pos){ dir=1; lines=line_count/4; if(lines==0) lines=1; do_scroll=TRUE; } if(last_pos==-1) do_scroll=FALSE; last_pos=pos; update_scroll_pos=FALSE; break; case SB_THUMBPOSITION: //dragged and released dir=lines=0; do_scroll=TRUE; break; case SB_ENDSCROLL: last_pos=-1; break; } } break; case WM_COMMAND: switch(LOWORD(wparam)){ case IDCANCEL: if(divider_drag){ divider_drag=FALSE; ReleaseCapture(); set_context_divider(hwnd,org_row_width); row_width=org_row_width; return 0; } if(gfh!=0) fclose(gfh); gfh=0; if(orig_edit!=0)SetWindowLong(GetDlgItem(hwnd,IDC_CONTEXT),GWL_WNDPROC,orig_edit); EndDialog(hwnd,0); return 0; } break; } if(do_scroll) do_scroll_proc(hwnd,lines,dir,update_scroll_pos); return 0; }
void COthelloView::OnMouseMove(UINT nFlags, CPoint point) { int i,j,have=0; CClientDC dc(this); CPoint p; COthelloDoc *pDoc=GetDocument(); for (i=0;i<8;i++) for (j=0;j<8;j++) { p=GetPosition(j,i); if (point.x>p.x && point.x<p.x+35 && point.y>p.y && point.y<p.y+35) { if (m_Current!=i*8+j) { if (m_Current>=0 && (pDoc->m_MainTable).GetTable(m_Current)<1) { if ((pDoc->m_MainTable).IsDown(m_CurCol,m_CurRow,m_CurPlay)) { BiltBitmap(m_CurX,m_CurY,m_CurX+34,m_CurY+34,m_hMaskerX); } else { dc.FillSolidRect(m_CurX,m_CurY,34,34,m_NormalColor); } ::SetClassLong(GetSafeHwnd(),GCL_HCURSOR,NULL); SetCursor(m_hcurDefault); } if ((pDoc->m_MainTable).GetTable(j,i)<1 && (pDoc->m_MainTable).IsDown(j,i,m_CurPlay)) { dc.FillSolidRect(p.x,p.y,34,34,m_SelectColor); ::SetClassLong(GetSafeHwnd(),GCL_HCURSOR,NULL); if (m_CurPlay==T_WHITE) { SetCursor(m_hcurWhite); } else { SetCursor(m_hcurBlack); } } m_Current=i*8+j; m_CurX=p.x; m_CurY=p.y; m_CurCol=j; m_CurRow=i; } have=1; } } if (!have) { if (m_Current>=0 && (pDoc->m_MainTable).GetTable(m_Current)<1) { if ((pDoc->m_MainTable).IsDown(m_CurCol,m_CurRow,m_CurPlay)) { BiltBitmap(m_CurX,m_CurY,m_CurX+34,m_CurY+34,m_hMaskerX); } else { dc.FillSolidRect(m_CurX,m_CurY,34,34,m_NormalColor); } ::SetClassLong(GetSafeHwnd(),GCL_HCURSOR,NULL); SetCursor(m_hcurDefault); } m_Current=-1; } // TODO: Add your message handler code here and/or call default CView::OnMouseMove(nFlags, point); }
/* The function makes the window visible if it is hidden or is not yet shown. */ void SplashRedrawWindow(Splash * splash) { if (!SplashIsStillLooping(splash)) { KillTimer(splash->hWnd, 0); } if (splash->currentFrame < 0) { return; } SplashUpdateScreenData(splash); if (splash->isLayered) { BLENDFUNCTION bf; POINT ptSrc; HDC hdcSrc = CreateCompatibleDC(NULL), hdcDst; BITMAPINFOHEADER bmi; void *bitmapBits; HBITMAP hBitmap, hOldBitmap; RECT rect; POINT ptDst; SIZE size; bf.BlendOp = AC_SRC_OVER; bf.BlendFlags = 0; bf.AlphaFormat = AC_SRC_ALPHA; bf.SourceConstantAlpha = 0xFF; ptSrc.x = ptSrc.y = 0; memset(&bmi, 0, sizeof(bmi)); bmi.biSize = sizeof(BITMAPINFOHEADER); bmi.biWidth = splash->width; bmi.biHeight = -splash->height; bmi.biPlanes = 1; bmi.biBitCount = 32; bmi.biCompression = BI_RGB; // FIXME: this is somewhat ineffective // maybe if we allocate memory for all frames as DIBSections, // then we could select the frames into the DC directly hBitmap = CreateDIBSection(NULL, (BITMAPINFO *) & bmi, DIB_RGB_COLORS, &bitmapBits, NULL, 0); memcpy(bitmapBits, splash->screenData, splash->screenStride * splash->height); hOldBitmap = (HBITMAP) SelectObject(hdcSrc, hBitmap); hdcDst = GetDC(splash->hWnd); GetWindowRect(splash->hWnd, &rect); ptDst.x = rect.left; ptDst.y = rect.top; size.cx = splash->width; size.cy = splash->height; UpdateLayeredWindow(splash->hWnd, hdcDst, &ptDst, &size, hdcSrc, &ptSrc, 0, &bf, ULW_ALPHA); ReleaseDC(splash->hWnd, hdcDst); SelectObject(hdcSrc, hOldBitmap); DeleteObject(hBitmap); DeleteDC(hdcSrc); } else { InvalidateRect(splash->hWnd, NULL, FALSE); if (splash->maskRequired) { HRGN hRgn = CreateRectRgn(0, 0, 0, 0); CombineRgn(hRgn, splash->frames[splash->currentFrame].hRgn, splash->frames[splash->currentFrame].hRgn, RGN_COPY); SetWindowRgn(splash->hWnd, hRgn, TRUE); } else { SetWindowRgn(splash->hWnd, NULL, TRUE); } UpdateWindow(splash->hWnd); } if (!IsWindowVisible(splash->hWnd)) { POINT cursorPos; ShowWindow(splash->hWnd, SW_SHOW); // Windows won't update the cursor after the window is shown, // if the cursor is already above the window. need to do this manually. GetCursorPos(&cursorPos); if (WindowFromPoint(cursorPos) == splash->hWnd) { // unfortunately Windows fail to understand that the window // thread should own the cursor, even though the mouse pointer // is over the window, until the mouse has been moved. // we're using SetCursorPos here to fake the mouse movement // and enable proper update of the cursor. SetCursorPos(cursorPos.x, cursorPos.y); SetCursor(LoadCursor(NULL, IDC_WAIT)); } } if (SplashIsStillLooping(splash)) { int time = splash->time + splash->frames[splash->currentFrame].delay - SplashTime(); if (time < 0) time = 0; SetTimer(splash->hWnd, 0, time, NULL); } }
void COthelloView::OnLButtonDown(UINT nFlags, CPoint point) { CClientDC dc(this); COthelloDoc *pDoc=GetDocument(); if (m_Current>=0 && (pDoc->m_MainTable).GetTable(m_Current)<1) { if (m_CurPlay==T_BLACK && (pDoc->m_MainTable).IsDown(m_CurCol,m_CurRow,T_BLACK)) { BiltBitmap(m_CurX,m_CurY,m_CurX+33,m_CurY+33,m_hBlack); (pDoc->m_MainTable).SetTable(m_Current,T_BLACK); DrawTable(m_CurCol,m_CurRow,T_BLACK); if (!(pDoc->m_MainTable).HaveDown(T_WHITE)) { if (!(pDoc->m_MainTable).HaveDown(T_BLACK)) { pDoc->GameOver(); } else { MessageBox("White Pass!!!"); m_CurPlay=T_BLACK; } } else { ::SetClassLong(GetSafeHwnd(),GCL_HCURSOR,NULL); SetCursor(m_hcurWhite); cont: CPoint point,pos; point=pDoc->TryIt(T_WHITE,T_DEPTH); (pDoc->m_MainTable).SetTable(point.x,point.y,T_WHITE); pos=GetPosition(point.x,point.y); //MessageBeep(MB_ICONINFORMATION); BiltBitmap(pos.x,pos.y,pos.x+33,pos.y+33,m_hWhite); Sleep(100); dc.FillSolidRect(pos.x,pos.y,34,34,m_NormalColor); Sleep(100); BiltBitmap(pos.x,pos.y,pos.x+33,pos.y+33,m_hWhite); Sleep(100); dc.FillSolidRect(pos.x,pos.y,34,34,m_NormalColor); Sleep(100); BiltBitmap(pos.x,pos.y,pos.x+33,pos.y+33,m_hWhite); DrawTable(point.x,point.y,T_WHITE); m_CurPlay=T_BLACK; if (!(pDoc->m_MainTable).HaveDown(T_BLACK)) { if (!(pDoc->m_MainTable).HaveDown(T_WHITE)) { pDoc->GameOver(); } else { MessageBox("Black Pass!!!"); m_CurPlay=T_WHITE; goto cont; } } } ::SetClassLong(GetSafeHwnd(),GCL_HCURSOR,NULL); SetCursor(m_hcurDefault); DispDown(pDoc,&dc); } else { if (m_CurPlay==T_WHITE && (pDoc->m_MainTable).IsDown(m_CurCol,m_CurRow,T_WHITE)) { BiltBitmap(m_CurX,m_CurY,m_CurX+33,m_CurY+33,m_hWhite); (pDoc->m_MainTable).SetTable(m_Current,T_WHITE); DrawTable(m_CurCol,m_CurRow,T_WHITE); if (!(pDoc->m_MainTable).HaveDown(T_BLACK)) { if (!(pDoc->m_MainTable).HaveDown(T_WHITE)) { MessageBox("Game Over!!!"); } else { MessageBox("No!!!"); m_CurPlay=T_WHITE; } } else { m_CurPlay=T_BLACK; } ::SetClassLong(GetSafeHwnd(),GCL_HCURSOR,NULL); SetCursor(m_hcurDefault); } } } // TODO: Add your message handler code here and/or call default CView::OnLButtonDown(nFlags, point); }
LRESULT CALLBACK WndProc (HWND hWnd, UINT message,WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: return 0; case WM_CLOSE: PostQuitMessage (0); return 0; case WM_DESTROY: return 0; case WM_SIZE: return 0; case WM_SETCURSOR: SetCursor(LoadCursor(NULL, currentCursor)); return 0; case WM_KEYDOWN: last_keybdstatus[wParam]=keybdstatus[wParam]; keybdstatus[wParam]=1; return 0; case WM_KEYUP: last_keybdstatus[wParam]=keybdstatus[wParam]; keybdstatus[wParam]=0; return 0; case WM_SYSKEYDOWN: last_keybdstatus[wParam]=keybdstatus[wParam]; keybdstatus[wParam]=1; if (wParam!=18) { if ((lParam&(1<<29))>0) last_keybdstatus[18]=keybdstatus[18], keybdstatus[18]=1; else last_keybdstatus[18]=keybdstatus[18], keybdstatus[18]=0; } return 0; case WM_SYSKEYUP: last_keybdstatus[wParam]=keybdstatus[wParam]; keybdstatus[wParam]=0; if (wParam!=(unsigned int)18) { if ((lParam&(1<<29))>0) last_keybdstatus[18]=keybdstatus[18], keybdstatus[18]=0; else last_keybdstatus[18]=keybdstatus[18], keybdstatus[18]=1; } return 0; case WM_MOUSEWHEEL: vdeltadelta += (int)HIWORD(wParam); mouse_vscrolls += vdeltadelta / WHEEL_DELTA; vdeltadelta %= WHEEL_DELTA; return 0; case WM_MOUSEHWHEEL: hdeltadelta += (int)HIWORD(wParam); mouse_hscrolls += hdeltadelta / WHEEL_DELTA; hdeltadelta %= WHEEL_DELTA; return 0; case WM_LBUTTONUP: mousestatus[0]=0; return 0; case WM_LBUTTONDOWN: mousestatus[0]=1; return 0; case WM_RBUTTONUP: mousestatus[1]=0; return 0; case WM_RBUTTONDOWN: mousestatus[1]=1; return 0; case WM_MBUTTONUP: mousestatus[2]=0; return 0; case WM_MBUTTONDOWN: mousestatus[2]=1; return 0; default: return DefWindowProc (hWnd, message, wParam, lParam); } }
WarkeyDlg::WarkeyDlg(XKeyApp *app) : wxDialog(), app_(app) { assert(app && "null app pointee!"); bkgnd_.LoadFile(wxT("bkgnd"), wxBITMAP_TYPE_BMP_RESOURCE); wxBitmap win_shape("bkgnd_mask", wxBITMAP_TYPE_BMP_RESOURCE); long dlgstyle(0); Create(nullptr, wxID_ANY, "WarXKey v1.0 Alpha", wxDefaultPosition, wxSize(win_shape.GetWidth(), win_shape.GetHeight()), dlgstyle); wxRegion win_region(win_shape, *wxBLACK); SetWindowStyle(GetWindowStyle() | wxFRAME_SHAPED); SetShape(win_region); wxCursor cursor(wxT("main_cursor"), wxBITMAP_TYPE_CUR_RESOURCE); SetCursor(cursor); auto root_szr = new wxBoxSizer(wxVERTICAL); auto top_szr = new wxBoxSizer(wxHORIZONTAL); top_szr->Add(new wxPanel(this), wxSizerFlags(1)); auto t_szr0 = new wxBoxSizer(wxVERTICAL); t_szr0->Add(new wxCheckBox(this, ID_MODENABLED, wxT("Enabled")), wxSizerFlags(1).Border(wxALL, 8)); t_szr0->Add(new wxCheckBox(this, wxID_ANY, wxT("Enable SP Function0")), wxSizerFlags(1).Centre().Border(wxALL, 8)); top_szr->Add(t_szr0, wxSizerFlags(1).Bottom().Border(wxBOTTOM, 8)); auto entip = new wxStaticText(this, wxID_ANY, wxT("NOTE: Before you try to make some changes of the key-maps,") wxT(" disable it at first!"), wxDefaultPosition, wxDefaultSize); entip->Wrap(140); //wxString notrans_reason; //if (!entip->IsTransparentBackgroundSupported(¬rans_reason)) { // wxMessageBox(notrans_reason); //} else { // entip->SetBackgroundStyle(wxBG_STYLE_TRANSPARENT); //} entip->SetForegroundColour(*wxGREEN); top_szr->Add(entip, wxSizerFlags(1).Bottom().Border(wxLEFT, 8)); top_szr->Add(new wxPanel(this), wxSizerFlags(1)); root_szr->Add(top_szr, wxSizerFlags(1)); auto num_szr = new wxGridBagSizer(8, 8); // 3 x 2 wxString nptitles[2][3] = { {wxT("4"), wxT("5"), wxT("6")}, {wxT("3"), wxT("8"), wxT("7")}, }; for (int i = 0, endi = 2; i < endi; ++i) { for (int j = 0, endj = 3; j < endj; ++j) { auto ctrl = new wxTextCtrl(this, wxID_ANY, nptitles[i][j]); num_szr->Add(ctrl, wxGBPosition(j+1, i+1)); } } //num_szr->Add(new wxPanel(this), wxGBPosition(4, 5)); root_szr->Add(num_szr, wxSizerFlags(0).Center().Border(wxBOTTOM | wxTOP, 8)); auto sk_szr = new wxGridBagSizer(8, 8); // 3 x 4 wxString sktitle[3][4] = { {wxT("M"), wxT("S"), wxT("H"), wxT("A")}, {wxT("P"), wxT("G"), wxT("D"), wxT("F")}, {wxT("Q"), wxT("W"), wxT("E"), wxT("R")}, }; for (int i = 0, endi = 3; i < endi; ++i) { for (int j = 0, endj = 4; j < endj; ++j) { auto ctrl = new wxTextCtrl(this, wxID_ANY, sktitle[i][j]); sk_szr->Add(ctrl, wxGBPosition(i+1, j)); } } //sk_szr->Add(new wxPanel(this), wxGBPosition(3, 0)); //sk_szr->Add(new wxPanel(this), wxGBPosition(3, 5)); root_szr->Add(sk_szr, wxSizerFlags(0).Center().Border(wxBOTTOM | wxTOP, 8)); auto bottom_szr = new wxBoxSizer(wxHORIZONTAL); bottom_szr->Add(new wxButton(this, ID_EXIT, wxT("E&xit")), wxSizerFlags(0).Border(wxALL, 8)); bottom_szr->Add(new wxButton(this, wxID_ABOUT, wxT("&About")), wxSizerFlags(0).Border(wxALL, 8)); root_szr->Add(bottom_szr, wxSizerFlags(0).Border(wxTOP | wxBOTTOM, 16)); SetSizer(root_szr); //root_szr->Fit(this); Centre(); }
//----------------------------------------------------------------------------- // Purpose: Handles mouse move events in the 2D view. // Input : Per CWnd::OnMouseMove. // Output : Returns true if the message was handled, false if not. //----------------------------------------------------------------------------- bool Clipper3D::OnMouseMove2D(CMapView2D *pView, UINT nFlags, CPoint point) { CMapDoc *pDoc = pView->GetDocument(); if (!pDoc) { return false; } bool bCursorSet = false; BOOL bDisableSnap = (GetAsyncKeyState(VK_MENU) & 0x8000) ? TRUE : FALSE; // // Make sure the point is visible. // if (m_bLButtonDown) { pView->ToolScrollToPoint(point); } // // Convert to some odd coordinate space that the base tools code uses. // CPoint ptScreen = point; ptScreen.x += pView->GetScrollPos(SB_HORZ); ptScreen.y += pView->GetScrollPos(SB_VERT); // // Convert to world coords. // Vector vecWorld; pView->ClientToWorld(vecWorld, point); point.x = vecWorld[axHorz]; point.y = vecWorld[axVert]; // // Update status bar position display. // char szBuf[128]; m_pDocument->Snap(vecWorld); sprintf(szBuf, " @%.0f, %.0f ", vecWorld[axHorz], vecWorld[axVert]); SetStatusText(SBI_COORDS, szBuf); if (IsTranslating()) { // cursor is cross here bCursorSet = true; UINT uConstraints = 0; if (bDisableSnap) { uConstraints |= Tool3D::constrainNosnap; } if(nFlags & MK_CONTROL) { uConstraints |= Clipper3D::constrainMoveBoth; } if (UpdateTranslation(point, uConstraints, CSize(0,0))) { pDoc->ToolUpdateViews(CMapView2D::updTool); pDoc->Update3DViews(); } } else if (!IsEmpty()) { // // If the cursor is on a handle, set it to a cross. // if (HitTest(ptScreen, TRUE) != -1) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS)); bCursorSet = true; } } if (!bCursorSet) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } return true; }
void Status_OnCaptureMouse(HWND hWnd,WPARAM wParam,LPARAM lParam) { POINT pt; RECT rcInner; int Offest; if ( HIWORD(lParam) == WM_LBUTTONDOWN ) { SetCapture(hWnd); GetCursorPos(&pt); GetWindowRect(hWnd,&drc); rcInner.left = drc.left; rcInner.top=drc.top; rcInner.bottom=drc.bottom; rcInner.right=rcInner.left+60; if (PtInRect(&rcInner,pt)) //电击可移动区域 { ptdif.x = pt.x - drc.left; //计算鼠标坐标与矩形左上角x坐标的距离 ptdif.y = pt.y - drc.top; //算鼠标坐标与矩形左上角y坐标的距离 sz.cx = drc.right - drc.left; //矩形宽度大小 sz.cy = drc.bottom - drc.top; //矩形高度大小 RECT m_drc = drc; DrawUIBorder(&m_drc); SetCursor(LoadCursor(NULL, IDC_SIZEALL)); fCanMove = TRUE; } else //点击按钮 { Offest=pt.x-drc.left; Offest=Offest/20; switch(Offest) { case 3: //英 中 { if (dwType & TYPE_ZHONGWEN) { dwType=dwType&~TYPE_ZHONGWEN; dwType|=TYPE_YINGYU; } else if (dwType & TYPE_YINGYU) { dwType=dwType&~TYPE_YINGYU; dwType|=TYPE_ZHONGWEN; } } break; case 4: //全 半 { if (dwType & TYPE_CHUANGJIAO) { dwType=dwType&~TYPE_CHUANGJIAO; dwType|=TYPE_BANJIAO; } else if (dwType & TYPE_BANJIAO) { dwType=dwType&~TYPE_BANJIAO; dwType|=TYPE_CHUANGJIAO; } } break; case 5: //标点 { if (dwType & TYPE_BIAO1) { dwType=dwType&~TYPE_BIAO1; dwType|=TYPE_BIAO2; } else if (dwType & TYPE_BIAO2) { dwType=dwType&~TYPE_BIAO2; dwType|=TYPE_BIAO1; } } break; case 6: //小键盘 { HWND hDlg=CreateDialog(hInst,(LPSTR)IDD_SOFTKETBOARD,hStatus,(DLGPROC)KeyBoardProc); ShowWindow(hDlg,SW_NORMAL); } break; case 7: //设置 { SendMessage(hWnd,WM_RBUTTONDOWN,wParam,lParam); }//case break; default: break; } HDC hStatusDC=GetDC(hStatus); Status_OnPaint(hStatus,hStatusDC); ReleaseDC(hStatus,hStatusDC); } } else if (HIWORD(lParam) == WM_RBUTTONDOWN ) { SetCapture(hWnd); } else if (HIWORD(lParam) == WM_MOUSEMOVE) { GetCursorPos(&pt); GetWindowRect(hWnd,&drc); rcInner.left = drc.left; rcInner.top=drc.top; rcInner.bottom=drc.bottom; rcInner.right=rcInner.left+60; if (PtInRect(&rcInner,pt)) //在移动窗口区域 { SetCursor(LoadCursor(NULL, IDC_SIZEALL)); } else //在其它区域 { SetCursor(LoadCursor(NULL,IDC_ARROW)); Offest=pt.x-drc.left; Offest=Offest/20; switch(Offest) { case 3: { if (dwType & TYPE_ZHONGWEN) { } else if (dwType & TYPE_YINGYU) { } } break; case 4: break; case 5: break; case 6: break; default: break; } } } }