LRESULT CModuleSettings::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { std::wstring strWName; WinUTF8::UTF8string_to_wstring(m_strModuleName, strWName); SetWindowText(strWName.c_str()); int iDlgWidth = 7 + CModuleControl::CAPTION_WIDTH + CModuleControl::CHILD_WIDTH + 7; int iTop = 7; for (int i(0); i < m_iCount; ++i) { RECT controlRect = { 7, iTop, iDlgWidth - 7, iTop + m_pControls[i]->GetHeight() }; MapDialogRect(&controlRect); m_pControls[i]->Create(m_hWnd, controlRect); m_pControls[i]->Initialise(m_pAppSets); iTop += m_pControls[i]->GetHeight() + 2; } iTop += -2 + 7; MoveButton(IDCANCEL, iDlgWidth - 57, iTop); MoveButton(IDOK, iDlgWidth - 2 * (57), iTop); RECT size = { 0, 0, iDlgWidth, iTop + 14 + 7 }; MapDialogRect(&size); ResizeClient(size.right, size.bottom); SendMessageToDescendants(WM_SETFONT, (WPARAM)GetFont(), true); return 1; }
void KeyboardWidget::MoveButtons(const PixelRect &rc) { MoveButtonsToRow(rc, _T("1234567890"), 0); MoveButtonsToRow(rc, _T("QWERTYUIOP"), 1); MoveButtonsToRow(rc, _T("ASDFGHJKL"), 2, button_width / 3); MoveButtonsToRow(rc, _T("ZXCVBNM,."), 3, button_width); if (IsLandscape(rc)) { MoveButton(_T('-'), rc.left + button_width * 9, rc.top + Layout::Scale(160)); MoveButton(_T(' '), rc.left + Layout::Scale(80), rc.top + Layout::Scale(160)); ResizeButton(_T(' '), Layout::Scale(93), Layout::Scale(40)); } else { MoveButton(_T('-'), rc.left + button_width * 8, rc.top + button_height * 4); MoveButton(_T(' '), rc.left + button_width * 2, rc.top + button_height * 4); ResizeButton(_T(' '), button_width * 11 / 2, button_height); } if (show_shift_button) shift_button.Move(rc.left, rc.top + 3 * button_height); }
BOOL CMessageBoxEx::OnInitDialog() { CDialog::OnInitDialog(); SetWindowText (m_strCaption); // Größe des gesamten Dialoges an Text anpassen m_Prompt.SetWindowText (m_strPrompt); m_PromptStatic.SetWindowText(m_strPrompt); int iLines = m_Prompt.GetLineCount(); if (iLines > 3) { // Editcontrol behandeln CDC *pDC = m_PromptStatic.GetDC(); TEXTMETRIC tm; pDC->GetTextMetrics(&tm); int iHeight = iLines * tm.tmHeight; CRect rcOld; m_PromptStatic.GetWindowRect(&rcOld); m_PromptStatic.SetWindowPos(NULL, 0, 0, rcOld.Width(), iHeight, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE); // Buttons verschieben int iDelta = iHeight - rcOld.Height(); MoveButton(IDYES, iDelta); MoveButton(IDC_YESALL, iDelta); MoveButton(IDNO, iDelta); MoveButton(IDC_NOALL, iDelta); MoveButton(IDCANCEL, iDelta); // Fenster selbst behandeln GetWindowRect(&rcOld); rcOld.bottom += iDelta; SetWindowPos (NULL, 0, 0, rcOld.Width(), rcOld.Height(), SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void KeyboardControl::MoveButtons() { MoveButtonsToRow(_T("1234567890"), 0); MoveButtonsToRow(_T("QWERTYUIOP"), 1); MoveButtonsToRow(_T("ASDFGHJKL"), 2, button_width / 3); MoveButtonsToRow(_T("ZXCVBNM,."), 3, button_width * 2 / 3); if (IsLandscape()) { MoveButton(_T('-'), button_width * 9, Layout::Scale(160)); MoveButton(_T(' '), Layout::Scale(80), Layout::Scale(160)); ResizeButton(_T(' '), Layout::Scale(93), Layout::Scale(40)); } else { MoveButton(_T('-'), button_width * 8, button_height * 4); MoveButton(_T(' '), button_width * 2, button_height * 4); ResizeButton(_T(' '), button_width * 11 / 2, button_height); } }
BOOL CPositionUsersDlg::PreTranslateMessage(MSG* pMsg) { if(pMsg->message == WM_KEYDOWN) { CWnd* pWnd = GetFocus(); if(pWnd) { for(map_userbtn_t::iterator ite = m_mapUserBtn.begin(); ite != m_mapUserBtn.end(); ite++) { if(ite->second == pWnd) { bool bHandled = true; switch(pMsg->wParam) { case VK_UP : MoveButton(ite->second, 0, -10); break; case VK_DOWN : MoveButton(ite->second, 0, 10); break; case VK_LEFT : MoveButton(ite->second, -10, 0); break; case VK_RIGHT : MoveButton(ite->second, 10, 0); break; default : bHandled = false; } if(bHandled) return TRUE; } } } } return CDialog::PreTranslateMessage(pMsg); }
void KeyboardWidget::MoveButtonsToRow(const PixelRect &rc, const TCHAR *buttons, unsigned row, int offset) { if (StringIsEmpty(buttons)) return; for (unsigned i = 0; buttons[i] != _T('\0'); i++) { MoveButton(buttons[i], rc.left + i * button_width + offset, rc.top + row * button_height); } }
Bool SlideButton(int button) { int x, y, done = 0; /* locate the button */ for (y = 0; y < Size; y++) { for (x = 0; x < Size; x++) { if (MAP(x,y) == button) { done = 1; break; } } if (done) break; } if (x > 0 && MAP(x-1, y) < 0) { MAP(x,y) = -1; MoveButton(button, x-1, y); MAP(x-1,y) = button; } else if (x < Size-1 && MAP(x+1, y) < 0) { MAP(x,y) = -1; MoveButton(button, x+1, y); MAP(x+1,y) = button; } else if (y > 0 && MAP(x, y-1) < 0) { MAP(x,y) = -1; MoveButton(button, x, y-1); MAP(x,y-1) = button; } else if (y < Size-1 && MAP(x, y+1) < 0) { MAP(x,y) = -1; MoveButton(button, x, y+1); MAP(x,y+1) = button; } else { return False; } return True; }
LRESULT CNSToolbar2::OnButtonDrag(WPARAM wParam, LPARAM lParam) { HWND hWnd = (HWND) lParam; CWnd *pButton = CWnd::FromHandle(hWnd); int nButtonIndex = FindButton(pButton); if(nButtonIndex != -1) { MoveButton(nButtonIndex); } return 1; }
void ResetGame(void) { int i, x, y, ox, oy; MoveCount = 0; for (i = 0; i < Size*Size-1; i++) { Map[i] = i; } Map[i] = -1; ox = x = Size-1; oy = y = Size-1; for (i = 0; i < 5; i++) { int ok; ok = 1; switch (rand()%4) { case 0: if (x > 0) x--; else ok = 0; break; case 2: if (x < Size-1) x++; else ok = 0; break; case 1: if (y > 0) y--; else ok = 0; break; case 3: if (y < Size-1) y++; else ok = 0; break; } if (ok) { MoveButton(MAP(x,y), ox, oy); SWAP(MAP(ox, oy), MAP(x, y)); while (XPending(WMScreenDisplay(WMWidgetScreen(win)))) { XEvent ev; WMNextEvent(WMScreenDisplay(WMWidgetScreen(win)), &ev); WMHandleEvent(&ev); } ox = x; oy = y; } } }
//================================================================================================================ void MenuEditorSystem::OnMouseMove(WPARAM btnState, int x, int y) { int dX, dY, tdX, tdY; // Calculate movement delta from previous frame if (dragPrevX != -1) { dX = x - dragPrevX; dY = y - dragPrevY; tdX = x - dragStartX; tdY = y - dragStartY; } if (gridMode == GM_Snap) { XMFLOAT2 selToolPoint = SnapToGrid(x, y); m_StampNormal->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0); m_StampHighlight->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0); // Move a button display cover if in button mode UpdateDisplaySprite(selToolPoint.x, selToolPoint.y); // If a button or text is being moved then continue to move it MoveButton(selToolPoint.x, selToolPoint.y); MoveText(selToolPoint.x, selToolPoint.y); HighlightButton(selToolPoint.x, selToolPoint.y); HighlightText(selToolPoint.x, selToolPoint.y); } else { // Move a button display cover if in button mode UpdateDisplaySprite(x, y); // If a button or text is being moved then continue to move it MoveButton(x, y); MoveText(x, y); HighlightButton(x, y); HighlightText(x, y); } // Start a left button drag of an item if ((btnState & MK_LBUTTON) != 0) { CalculateSelectedMousePosition(x, y); stampPressed = true; // If applicable, Add a button AddButton(); // If applicable, Add a text AddText(); // Selects a button on the map and deletes it if in button delete mode DeleteButton(); // Selects a text on the map and deletes it if in text delete mode DeleteText(); } // Remember current mouse co-ordinates for next frame if (dragPrevX != -1) { dragPrevX = x; dragPrevY = y; } }
CStepDlg::CStepDlg(CPaintWidget* pPaint, QListWidget* pList, QWidget* parent) : QDialog(parent), m_pPaint(pPaint), m_pList(pList) { //SuperTerminal sp; MoveValueSum = 0; CorrectNum = 0; GearNum = 0; fd =0; this->setWindowTitle(tr("step")); /*****************************/ //QVBoxLayout *topLayout = new QVBoxLayout();//垂直布局 //QVBoxLayout *testLayout = new QVBoxLayout(); /**************************/ QGridLayout *LeftLayout = new QGridLayout(); QGridLayout *RightLayout = new QGridLayout(); QHBoxLayout *mainLayout = new QHBoxLayout(); mainLayout->addLayout(LeftLayout); mainLayout->addLayout(RightLayout); //m_pButtonMove = new QPushButton(tr("移动")); m_pButtonMove = new QPushButton(QString::fromLocal8Bit("移动")); connect(m_pButtonMove, SIGNAL(clicked()), this, SLOT(MoveButton()));//clicked信号后调用MoveButton()槽函数 connect(m_pButtonMove, SIGNAL(clicked()), this, SLOT(setPosition())); LeftLayout->addWidget(m_pButtonMove,0,0); m_pLineMove = new QLineEdit(this); LeftLayout->addWidget(m_pLineMove,0,1); m_pButtonRecord = new QPushButton(QString::fromLocal8Bit("记录")); connect(m_pButtonRecord, SIGNAL(clicked()), this, SLOT(RecordButton())); connect(m_pButtonRecord, SIGNAL(clicked()), this, SLOT(setPosition())); LeftLayout->addWidget(m_pButtonRecord,1,0); m_pButtonErrnum = new QPushButton(QString::fromLocal8Bit("无法矫正齿位")); connect(m_pButtonErrnum, SIGNAL(clicked()), this, SLOT(ErrnumButton())); connect(m_pButtonErrnum, SIGNAL(clicked()), this, SLOT(setPosition())); LeftLayout->addWidget(m_pButtonErrnum,1,1); m_pButtonZerocorrect = new QPushButton(QString::fromLocal8Bit("零位调整")); connect(m_pButtonZerocorrect, SIGNAL(clicked()), this, SLOT(ZerocorrectButton())); connect(m_pButtonZerocorrect, SIGNAL(clicked()), this, SLOT(setPosition())); LeftLayout->addWidget(m_pButtonZerocorrect,2,0); m_pButtonSinglecorrect = new QPushButton(QString::fromLocal8Bit("单齿调整")); connect(m_pButtonSinglecorrect, SIGNAL(clicked()), this, SLOT(SinglecorrectButton())); connect(m_pButtonSinglecorrect, SIGNAL(clicked()), this, SLOT(setPosition())); LeftLayout->addWidget(m_pButtonSinglecorrect,2,1); m_pButtonDatareset = new QPushButton(QString::fromLocal8Bit("数据重置")); connect(m_pButtonDatareset, SIGNAL(clicked()), this, SLOT(DataresetButton())); connect(m_pButtonDatareset, SIGNAL(clicked()), this, SLOT(setPosition())); LeftLayout->addWidget(m_pButtonDatareset,3,0); m_pComboDataReset = new QComboBox(); m_pComboDataReset->addItem(QString::fromLocal8Bit("")); m_pComboDataReset->addItem(QString::fromLocal8Bit("清除全部数据")); m_pComboDataReset->addItem(QString::fromLocal8Bit("重置矫正数据")); m_pComboDataReset->addItem(QString::fromLocal8Bit("清除全齿数据")); m_pComboDataReset->addItem(QString::fromLocal8Bit("清除半齿数据")); LeftLayout->addWidget(m_pComboDataReset,3,1); m_pButtonForward = new QPushButton(QString::fromLocal8Bit("前进")); connect(m_pButtonForward, SIGNAL(clicked()), this, SLOT(ForwardButton())); connect(m_pButtonForward, SIGNAL(clicked()), this, SLOT(setPosition())); RightLayout->addWidget(m_pButtonForward,0,0); m_pButtonBackward = new QPushButton(QString::fromLocal8Bit("后退")); connect(m_pButtonBackward, SIGNAL(clicked()), this, SLOT(BackwardButton())); connect(m_pButtonBackward, SIGNAL(clicked()), this, SLOT(setPosition())); RightLayout->addWidget(m_pButtonBackward,1,0); m_pButtonReset = new QPushButton(QString::fromLocal8Bit("复位")); connect(m_pButtonReset, SIGNAL(clicked()), this, SLOT(ResetButton())); connect(m_pButtonReset, SIGNAL(clicked()), this, SLOT(setPosition())); RightLayout->addWidget(m_pButtonReset,2,0); m_pLabelPace = new QLabel(QString::fromLocal8Bit("步距")); RightLayout->addWidget(m_pLabelPace,3,0); m_pComboPace = new QComboBox(); m_pComboPace->addItem(QString::fromLocal8Bit("")); m_pComboPace->addItem(QString::fromLocal8Bit("2mm")); m_pComboPace->addItem(QString::fromLocal8Bit("4mm")); m_pComboPace->addItem(QString::fromLocal8Bit("8mm")); m_pComboPace->addItem(QString::fromLocal8Bit("12mm")); RightLayout->addWidget(m_pComboPace,3,1); this->setLayout(mainLayout); /*************接收处理****************/ /* SuperTerminal sp; sp.read_from_serial(); sp.call_handle(); getchar();*/ }
static INT_PTR CALLBACK TemplateDlg(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HWND hTreeCtrl; static HWND hOkBtn; static HWND hEditBtn; static HWND hInsertBtn; static HWND hRemoveMarkerBtn; static int LDX, LDY, BDX; static LPARAM param; if(WM_INITDIALOG == uMsg) { RECT rcWR, rcCR; POINT pt; EDITINFO ei; param = lParam; GetClientRect(hWndDlg,&rcWR); hTreeCtrl = GetDlgItem(hWndDlg,IDC_TREE); hOkBtn = GetDlgItem(hWndDlg,IDOK); hEditBtn = GetDlgItem(hWndDlg,IDC_EDIT); hInsertBtn = GetDlgItem(hWndDlg,IDC_INSERT); hRemoveMarkerBtn = GetDlgItem(hWndDlg, IDC_REMMARKER); GetWindowRect(hTreeCtrl,&rcCR); pt.x = rcCR.right; pt.y = rcCR.bottom; ScreenToClient(hWndDlg,&pt); LDX = rcWR.right - pt.x; LDY = rcWR.bottom - pt.y; GetWindowRect(hOkBtn,&rcCR); pt.x=rcCR.left; pt.y=0; ScreenToClient(hWndDlg,&pt); BDX = rcWR.right - pt.x; { TVINSERTSTRUCTW tvi; HTREEITEM hEmpty; WCHAR szRoot[MAX_PATH]; SHFILEINFOW sfi; HIMAGELIST hList = (HIMAGELIST)SHGetFileInfoW(g_szAkelPath,0,&sfi,sizeof(sfi),SHGFI_SYSICONINDEX|SHGFI_SMALLICON); TreeView_SetImageList(hTreeCtrl,hList,TVSIL_NORMAL); lstrcpyW(szRoot,g_szAkelPath); lstrcatW(szRoot,TEMPLATES_PATH); FillTreeCtrl(hTreeCtrl,szRoot,TVI_ROOT); TreeView_SortChildren(hTreeCtrl,TVI_ROOT,FALSE); tvi.hParent = TVI_ROOT; tvi.hInsertAfter = TVI_FIRST; tvi.item.pszText = L"<Empty>"; tvi.item.lParam = TVNT_EMPTY; tvi.item.iImage = tvi.item.iSelectedImage = 3; tvi.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; hEmpty = TreeView_InsertItem(hTreeCtrl,&tvi); if(TreeView_GetCount(hTreeCtrl)>0) { TreeView_SelectItem(hTreeCtrl,hEmpty); EnableWindow(hOkBtn,TRUE); } else { EnableWindow(hOkBtn,FALSE); } } if(!(lParam&DCP_ALLOWEDIT)) { DestroyWindow(hEditBtn); hEditBtn = NULL; } if(SendMessageW(g_hMainWnd,AKD_GETEDITINFO,(WPARAM)NULL,(LPARAM)&ei)) { if(!IsWindow(ei.hWndEdit) || (!(lParam&DCP_ALLOWINSERT))) { DestroyWindow(hInsertBtn); hInsertBtn = NULL; } } SendMessageW(hRemoveMarkerBtn, BM_SETCHECK,g_bRemoveMarker?BST_CHECKED:BST_UNCHECKED,0); PostMessageW(hWndDlg,WM_COMMAND,MAKEWPARAM(IDC_TREE,LBN_SELCHANGE),0); RestorePosition(hWndDlg); #ifndef NO_SMALL_ICON SendMessageW(hWndDlg, WM_SETICON,(WPARAM)ICON_SMALL,(LPARAM)g_hMainIcon); #endif SendMessageW(hWndDlg, WM_SETICON,(WPARAM)ICON_BIG,(LPARAM)g_hMainIcon); return TRUE; } else if(WM_COMMAND == uMsg) { if(((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDC_EDIT) || (LOWORD(wParam) == IDC_INSERT)) && (HIWORD(wParam) == BN_CLICKED)) { HTREEITEM hItem = TreeView_GetSelection(hTreeCtrl); TVITEM item; INT_PTR len = 0; if(!hItem) return TRUE; item.hItem = hItem; item.lParam = 0; item.mask = TVIF_PARAM; if(!TreeView_GetItem(hTreeCtrl,&item)) return TRUE; if(item.lParam==TVNT_DIR) return TRUE; lstrcpyW(g_szTemplate,g_szAkelPath); lstrcatW(g_szTemplate,TEMPLATES_PATH); lstrcatW(g_szTemplate,L"\\"); g_bRemoveMarker = (SendMessageW(hRemoveMarkerBtn, BM_GETCHECK, 0, 0)==BST_CHECKED)?TRUE:FALSE; UpdateSettings(TSF_REMOVEMARKER,FALSE); len = lstrlenW(g_szTemplate); if(RebuildPath(hTreeCtrl, hItem, g_szTemplate+len)) { if(lstrlenW(g_szTemplate) == len) { //! Opening empty template g_szTemplate[0] = 0; } EndDialog(hWndDlg,LOWORD(wParam)); } else { g_szTemplate[0]=0; } return TRUE; } else if((LOWORD(wParam)==IDCANCEL) && (HIWORD(wParam) == BN_CLICKED)) { EndDialog(hWndDlg,IDCANCEL); return TRUE; } } else if(WM_NOTIFY == uMsg) { if(IDC_TREE == wParam) { if(((LPNMHDR)lParam)->code == TVN_SELCHANGED) { LPNMTREEVIEWW ptv = (LPNMTREEVIEWW)lParam; if(ptv->itemNew.hItem && (ptv->itemNew.mask&TVIF_PARAM)) { if(hOkBtn) { EnableWindow(hOkBtn, (ptv->itemNew.lParam != TVNT_DIR)); } if(hEditBtn) { EnableWindow(hEditBtn, ptv->itemNew.lParam == TVNT_FILE); } if(hInsertBtn) { EnableWindow(hInsertBtn, ptv->itemNew.lParam == TVNT_FILE); } } return TRUE; } else if(((LPNMHDR)lParam)->code == NM_DBLCLK) { DWORD pos = GetMessagePos(); TVHITTESTINFO thi; HTREEITEM hit=0; thi.pt.x = GET_X_LPARAM(pos); thi.pt.y = GET_Y_LPARAM(pos); ScreenToClient(hTreeCtrl,&thi.pt); thi.hItem =0; thi.flags =0; hit = TreeView_HitTest(hTreeCtrl,&thi); if(thi.hItem) { TVITEM item; item.hItem = thi.hItem; item.mask = TVIF_PARAM; TreeView_GetItem(hTreeCtrl,&item); if(hOkBtn) { EnableWindow(hOkBtn, item.lParam != TVNT_DIR); } if(hEditBtn) { EnableWindow(hEditBtn, item.lParam == TVNT_FILE); } if(hInsertBtn) { EnableWindow(hInsertBtn, item.lParam != TVNT_DIR); } if(item.lParam != TVNT_DIR) PostMessageW(hWndDlg,WM_COMMAND,MAKEWPARAM(IDOK,BN_CLICKED),0); } return TRUE; } } } else if(WM_CLOSE == uMsg) { PostMessageW(hWndDlg,WM_COMMAND,MAKEWPARAM(IDCANCEL,BN_CLICKED),0); return TRUE; } else if(WM_DESTROY == uMsg) { SavePosition(hWndDlg); } else if(WM_SIZE == uMsg) { RECT rcWindow, rcNew; POINT pt; GetClientRect(hWndDlg,&rcWindow); GetWindowRect(hTreeCtrl,&rcNew); pt.x = rcNew.left; pt.y = rcNew.top; ScreenToClient(hWndDlg,&pt); MoveWindow(hTreeCtrl,pt.x,pt.y,rcWindow.right-LDX-pt.x, rcWindow.bottom-LDY-pt.y,TRUE); MoveButton(hWndDlg,hOkBtn,rcWindow, BDX); MoveButton(hWndDlg,GetDlgItem(hWndDlg,IDCANCEL),rcWindow, BDX); MoveButton(hWndDlg,hEditBtn,rcWindow, BDX); MoveButton(hWndDlg,hInsertBtn,rcWindow, BDX); MoveButton(hWndDlg,hRemoveMarkerBtn,rcWindow,BDX); InvalidateRect(hWndDlg,NULL,TRUE); } else if(WM_PAINT == uMsg) { RECT rc; PAINTSTRUCT ps; HDC dc = BeginPaint(hWndDlg, &ps); if(dc) { GetClientRect(hWndDlg, &rc); rc.left = rc.right - GetSystemMetrics(SM_CXVSCROLL); rc.top = rc.bottom - GetSystemMetrics(SM_CYVSCROLL); DrawFrameControl(dc, &rc, DFC_SCROLL, DFCS_SCROLLSIZEGRIP); EndPaint(hWndDlg, &ps); } } return FALSE; }