void CDrivesList::OnNMDblclk(NMHDR * /*pNMHDR*/, LRESULT *pResult) { *pResult = 0; CPoint point= GetCurrentMessage()->pt; ScreenToClient(&point); int i= HitTest(point); if (i == -1) return; for (int k=0; k < GetItemCount(); k++) SetItemState(k, k == i ? LVIS_SELECTED : 0, LVIS_SELECTED); GetParent()->SendMessage(WMU_OK); }
BOOL CMDIChildWnd::OnToolTipText(UINT msg, NMHDR* pNMHDR, LRESULT* pResult) { ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW); UNUSED(pNMHDR); // check to see if the message is going directly to this window or not const MSG* pMsg = GetCurrentMessage(); if (pMsg->hwnd != m_hWnd) { // let top level frame handle this for us return FALSE; } // otherwise, handle it ourselves return CFrameWnd::OnToolTipText(msg, pNMHDR, pResult); }
BOOL CResizableFormView::OnInitDialog() { const MSG* pMsg = GetCurrentMessage(); BOOL bRet = (BOOL)CFormView::WindowProc(pMsg->message, pMsg->wParam, pMsg->lParam); // we need to associate member variables with control IDs UpdateData(FALSE); // set default scroll size CRect rectTemplate; GetWindowRect(rectTemplate); SetScrollSizes(MM_TEXT, rectTemplate.Size()); return bRet; }
void CTreeFileCtrl::OnRclick(NMHDR* /*pNMHDR*/, LRESULT* pResult) { //Remember the old selected item HTREEITEM hOldSelItem = GetSelectedItem(); //Work out the position of where the context menu should be CPoint p(GetCurrentMessage()->pt); CPoint pt(p); ScreenToClient(&pt); Select(HitTest(pt), TVGN_CARET); OnContextMenu(NULL, p); //Reselect the old selected item Select(hOldSelItem, TVGN_CARET); *pResult = 0; }
void NativeTextfieldWin::OnLButtonDown(UINT keys, const gfx::Point& point) { // Check for triple click, then reset tracker. Should be safe to subtract // double_click_time_ from the current message's time even if the timer has // wrapped in between. const bool is_triple_click = tracking_double_click_ && IsDoubleClick(double_click_point_.ToPOINT(), point.ToPOINT(), GetCurrentMessage()->time-double_click_time_); tracking_double_click_ = false; ScopedFreeze freeze(this, GetTextObjectModel()); OnBeforePossibleChange(); DefWindowProc(WM_LBUTTONDOWN, keys, MAKELPARAM(ClipXCoordToVisibleText(point.x(), is_triple_click), point.y())); OnAfterPossibleChange(true); }
LRESULT CDBFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { //派遣鼠标消息给系统按钮与工具提示控件 const MSG *pMsg = GetCurrentMessage(); DWORD dwStyle = GetStyle(); if (dwStyle & WS_SYSMENU && pMsg != NULL) { m_sysCloseBtn.RelayEvent(pMsg); if (dwStyle & WS_MINIMIZEBOX || dwStyle & WS_MAXIMIZEBOX) { m_sysMaxBtn.RelayEvent(pMsg); m_sysMinBtn.RelayEvent(pMsg); } } return CFrameWnd::WindowProc(message, wParam, lParam); }
void CFormGhList_del::OnClickMshflexgrid1() { const int ENDLINES=2; if(m_grid.GetRows() == ENDLINES )return;//判断是否需要显示快捷菜单 MSG *pms; pms=(MSG*)GetCurrentMessage(); if(pms->message != 0x205) {//0x202为鼠标左键,0x205为鼠标右键消息 return; } CMenu pm; CPoint p; pm.LoadMenu(IDR_MENU_QUICK); CMenu* pmenu=pm.GetSubMenu(6); GetCursorPos(&p); pmenu->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON ,p.x,p.y,this); }
void CTreeFileCtrl::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult) { HTREEITEM hItem = GetSelectedItem(); CPoint pt = GetCurrentMessage()->pt; ScreenToClient(&pt); if (hItem && (hItem == HitTest(pt))) { TV_ITEM tvi; ZeroMemory(&tvi, sizeof(TVITEM)); tvi.mask = TVIF_CHILDREN; tvi.hItem = hItem; if (GetItem(&tvi) && tvi.cChildren == 0) OnFileOpen(); } *pResult = 0; }
LRESULT CToolbarHelper::ScWindowProc(HWND hRealWnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_MOUSEMOVE: case WM_MOUSELEAVE: m_tt.RelayEvent(const_cast<MSG*>(GetCurrentMessage())); break; case WM_SIZE: { LRESULT lr = CSubclasser::ScWindowProc(hRealWnd, msg, wp, lp); RefreshTooltipRects(); return lr; } } return CSubclasser::ScDefault(hRealWnd); }
BOOL CXTFlatComboBox::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if (message == WM_MOUSEMOVE) { CRect rcWindow; GetWindowRect (&rcWindow); if (rcWindow.PtInRect(GetCurrentMessage()->pt)) { if (m_bFlatLook) { SetTimer(1,10,NULL); OnTimer(1); } } } return CComboBox::OnSetCursor(pWnd, nHitTest, message); }
BOOL CEnHeaderCtrl::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { CPoint ptCursor = GetCurrentMessage()->pt; ScreenToClient(&ptCursor); UINT nFlags = 0; int nItem = HitTest(ptCursor, &nFlags); if (nItem != -1) { if ((nFlags & (HHT_ONDIVIDER | HHT_ONDIVOPEN)) && !IsItemTrackable(nItem)) { AfxGetApp()->LoadStandardCursor(IDC_ARROW); return TRUE; } } // else return CHeaderCtrl::OnSetCursor(pWnd, nHitTest, message); }
/* ================ CPathTreeCtrl::OnToolTipText ================ */ BOOL CPathTreeCtrl::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ) { // need to handle both ANSI and UNICODE versions of the message TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR; TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR; UINT nID = pNMHDR->idFrom; *pResult = 0; // Do not process the message from built in tooltip if( nID == (UINT)m_hWnd && (( pNMHDR->code == TTN_NEEDTEXTA && pTTTA->uFlags & TTF_IDISHWND ) || ( pNMHDR->code == TTN_NEEDTEXTW && pTTTW->uFlags & TTF_IDISHWND ) ) ) { return FALSE; } CString toolTip = "?"; // Get the mouse position const MSG* pMessage; CPoint pt; pMessage = GetCurrentMessage(); ASSERT ( pMessage ); pt = pMessage->pt; ScreenToClient( &pt ); // get the tree item UINT nFlags; HTREEITEM hitem = HitTest( pt, &nFlags ); if( nFlags & TVHT_ONITEM ) { // relay message to parent pTTTA->hdr.hwndFrom = GetSafeHwnd(); pTTTA->hdr.idFrom = (UINT) hitem; if ( GetParent()->SendMessage( WM_NOTIFY, ( TTN_NEEDTEXT << 16 ) | GetDlgCtrlID(), (LPARAM)pTTTA ) == FALSE ) { return FALSE; } } return TRUE; // message was handled }
void CView::OnFilePrint() { // get default print info CPrintInfo printInfo; ASSERT(printInfo.m_pPD != NULL); // must be set if (LOWORD(GetCurrentMessage()->wParam) == ID_FILE_PRINT_DIRECT) { CCommandLineInfo* pCmdInfo = AfxGetApp()->m_pCmdInfo; if (pCmdInfo != NULL) { if (pCmdInfo->m_nShellCommand == CCommandLineInfo::FilePrintTo) { printInfo.m_pPD->m_pd.hDC = ::CreateDC(pCmdInfo->m_strDriverName, pCmdInfo->m_strPrinterName, pCmdInfo->m_strPortName, NULL); if (printInfo.m_pPD->m_pd.hDC == NULL) { AfxMessageBox(AFX_IDP_FAILED_TO_START_PRINT); return; } } } printInfo.m_bDirect = TRUE; } if (OnPreparePrinting(&printInfo)) { // hDC must be set (did you remember to call DoPreparePrinting?) ASSERT(printInfo.m_pPD->m_pd.hDC != NULL); // gather file to print to if print-to-file selected CString strOutput; if (printInfo.m_pPD->m_pd.Flags & PD_PRINTTOFILE && !printInfo.m_bDocObject) { // construct CFileDialog for browsing CString strDef(MAKEINTRESOURCE(AFX_IDS_PRINTDEFAULTEXT)); CString strPrintDef(MAKEINTRESOURCE(AFX_IDS_PRINTDEFAULT)); CString strFilter(MAKEINTRESOURCE(AFX_IDS_PRINTFILTER)); CString strCaption(MAKEINTRESOURCE(AFX_IDS_PRINTCAPTION)); CFileDialog dlg(FALSE, strDef, strPrintDef, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, strFilter); dlg.m_ofn.lpstrTitle = strCaption; if (dlg.DoModal() != IDOK) return; // set output device to resulting path name strOutput = dlg.GetPathName(); } // set up document info and start the document printing process CString strTitle; CDocument* pDoc = GetDocument(); if (pDoc != NULL) strTitle = pDoc->GetTitle(); else GetParentFrame()->GetWindowText(strTitle); if (strTitle.GetLength() > 31) strTitle.ReleaseBuffer(31); DOCINFO docInfo; memset(&docInfo, 0, sizeof(DOCINFO)); docInfo.cbSize = sizeof(DOCINFO); docInfo.lpszDocName = strTitle; CString strPortName; int nFormatID; if (strOutput.IsEmpty()) { docInfo.lpszOutput = NULL; strPortName = printInfo.m_pPD->GetPortName(); nFormatID = AFX_IDS_PRINTONPORT; } else { docInfo.lpszOutput = strOutput; AfxGetFileTitle(strOutput, strPortName.GetBuffer(_MAX_PATH), _MAX_PATH); nFormatID = AFX_IDS_PRINTTOFILE; } // setup the printing DC CDC dcPrint; if (!printInfo.m_bDocObject) { dcPrint.Attach(printInfo.m_pPD->m_pd.hDC); // attach printer dc dcPrint.m_bPrinting = TRUE; } OnBeginPrinting(&dcPrint, &printInfo); if (!printInfo.m_bDocObject) dcPrint.SetAbortProc(_AfxAbortProc); // disable main window while printing & init printing status dialog AfxGetMainWnd()->EnableWindow(FALSE); CPrintingDialog dlgPrintStatus(this); CString strTemp; dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_DOCNAME, strTitle); dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PRINTERNAME, printInfo.m_pPD->GetDeviceName()); AfxFormatString1(strTemp, nFormatID, strPortName); dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PORTNAME, strTemp); dlgPrintStatus.ShowWindow(SW_SHOW); dlgPrintStatus.UpdateWindow(); // start document printing process if (!printInfo.m_bDocObject && dcPrint.StartDoc(&docInfo) == SP_ERROR) { // enable main window before proceeding AfxGetMainWnd()->EnableWindow(TRUE); // cleanup and show error message OnEndPrinting(&dcPrint, &printInfo); dlgPrintStatus.DestroyWindow(); dcPrint.Detach(); // will be cleaned up by CPrintInfo destructor AfxMessageBox(AFX_IDP_FAILED_TO_START_PRINT); return; } // Guarantee values are in the valid range UINT nEndPage = printInfo.GetToPage(); UINT nStartPage = printInfo.GetFromPage(); if (nEndPage < printInfo.GetMinPage()) nEndPage = printInfo.GetMinPage(); if (nEndPage > printInfo.GetMaxPage()) nEndPage = printInfo.GetMaxPage(); if (nStartPage < printInfo.GetMinPage()) nStartPage = printInfo.GetMinPage(); if (nStartPage > printInfo.GetMaxPage()) nStartPage = printInfo.GetMaxPage(); int nStep = (nEndPage >= nStartPage) ? 1 : -1; nEndPage = (nEndPage == 0xffff) ? 0xffff : nEndPage + nStep; VERIFY(strTemp.LoadString(AFX_IDS_PRINTPAGENUM)); // If it's a doc object, we don't loop page-by-page // because doc objects don't support that kind of levity. BOOL bError = FALSE; if (printInfo.m_bDocObject) { OnPrepareDC(&dcPrint, &printInfo); OnPrint(&dcPrint, &printInfo); } else { // begin page printing loop for (printInfo.m_nCurPage = nStartPage; printInfo.m_nCurPage != nEndPage; printInfo.m_nCurPage += nStep) { OnPrepareDC(&dcPrint, &printInfo); // check for end of print if (!printInfo.m_bContinuePrinting) break; // write current page TCHAR szBuf[80]; wsprintf(szBuf, strTemp, printInfo.m_nCurPage); dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PAGENUM, szBuf); // set up drawing rect to entire page (in logical coordinates) printInfo.m_rectDraw.SetRect(0, 0, dcPrint.GetDeviceCaps(HORZRES), dcPrint.GetDeviceCaps(VERTRES)); dcPrint.DPtoLP(&printInfo.m_rectDraw); // attempt to start the current page if (dcPrint.StartPage() < 0) { bError = TRUE; break; } // must call OnPrepareDC on newer versions of Windows because // StartPage now resets the device attributes. if (afxData.bMarked4) OnPrepareDC(&dcPrint, &printInfo); ASSERT(printInfo.m_bContinuePrinting); // page successfully started, so now render the page OnPrint(&dcPrint, &printInfo); if (dcPrint.EndPage() < 0 || !_AfxAbortProc(dcPrint.m_hDC, 0)) { bError = TRUE; break; } } } // cleanup document printing process if (!printInfo.m_bDocObject) { if (!bError) dcPrint.EndDoc(); else dcPrint.AbortDoc(); } AfxGetMainWnd()->EnableWindow(); // enable main window OnEndPrinting(&dcPrint, &printInfo); // clean up after printing dlgPrintStatus.DestroyWindow(); dcPrint.Detach(); // will be cleaned up by CPrintInfo destructor } }
void CView::OnFilePrint() { // get default print info CPrintInfo printInfo; ASSERT(printInfo.m_pPD != NULL); // must be set if (LOWORD(GetCurrentMessage()->wParam) == ID_FILE_PRINT_DIRECT) { CCommandLineInfo* pCmdInfo = AfxGetApp()->m_pCmdInfo; if (pCmdInfo != NULL) { if (pCmdInfo->m_nShellCommand == CCommandLineInfo::FilePrintTo) { printInfo.m_pPD->m_pd.hDC = ::CreateDC(pCmdInfo->m_strDriverName, pCmdInfo->m_strPrinterName, pCmdInfo->m_strPortName, NULL); if (printInfo.m_pPD->m_pd.hDC == NULL) { AfxMessageBox(AFX_IDP_FAILED_TO_START_PRINT); return; } } } printInfo.m_bDirect = TRUE; } if (OnPreparePrinting(&printInfo)) { // hDC must be set (did you remember to call DoPreparePrinting?) ASSERT(printInfo.m_pPD->m_pd.hDC != NULL); // gather file to print to if print-to-file selected CString strOutput; if (printInfo.m_pPD->m_pd.Flags & PD_PRINTTOFILE && !printInfo.m_bDocObject) { // construct CFileDialog for browsing CString strDef(MAKEINTRESOURCE(AFX_IDS_PRINTDEFAULTEXT)); CString strPrintDef(MAKEINTRESOURCE(AFX_IDS_PRINTDEFAULT)); CString strFilter(MAKEINTRESOURCE(AFX_IDS_PRINTFILTER)); CString strCaption(MAKEINTRESOURCE(AFX_IDS_PRINTCAPTION)); CFileDialog dlg(FALSE, strDef, strPrintDef, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, strFilter, NULL, 0); dlg.m_ofn.lpstrTitle = strCaption; if (dlg.DoModal() != IDOK) return; // set output device to resulting path name strOutput = dlg.GetPathName(); } // set up document info and start the document printing process CString strTitle; CDocument* pDoc = GetDocument(); if (pDoc != NULL) strTitle = pDoc->GetTitle(); else EnsureParentFrame()->GetWindowText(strTitle); DOCINFO docInfo; memset(&docInfo, 0, sizeof(DOCINFO)); docInfo.cbSize = sizeof(DOCINFO); docInfo.lpszDocName = strTitle; CString strPortName; if (strOutput.IsEmpty()) { docInfo.lpszOutput = NULL; strPortName = printInfo.m_pPD->GetPortName(); } else { docInfo.lpszOutput = strOutput; AfxGetFileTitle(strOutput, strPortName.GetBuffer(_MAX_PATH), _MAX_PATH); } // setup the printing DC CDC dcPrint; if (!printInfo.m_bDocObject) { dcPrint.Attach(printInfo.m_pPD->m_pd.hDC); // attach printer dc dcPrint.m_bPrinting = TRUE; } OnBeginPrinting(&dcPrint, &printInfo); if (!printInfo.m_bDocObject) dcPrint.SetAbortProc(_AfxAbortProc); // disable main window while printing & init printing status dialog // Store the Handle of the Window in a temp so that it can be enabled // once the printing is finished CWnd * hwndTemp = AfxGetMainWnd(); hwndTemp->EnableWindow(FALSE); CPrintingDialog dlgPrintStatus(this); CString strTemp; dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_DOCNAME, strTitle); dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PRINTERNAME, printInfo.m_pPD->GetDeviceName()); dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PORTNAME, strPortName); dlgPrintStatus.ShowWindow(SW_SHOW); dlgPrintStatus.UpdateWindow(); // start document printing process if (!printInfo.m_bDocObject) { printInfo.m_nJobNumber = dcPrint.StartDoc(&docInfo); if (printInfo.m_nJobNumber == SP_ERROR) { // enable main window before proceeding hwndTemp->EnableWindow(TRUE); // cleanup and show error message OnEndPrinting(&dcPrint, &printInfo); dlgPrintStatus.DestroyWindow(); dcPrint.Detach(); // will be cleaned up by CPrintInfo destructor AfxMessageBox(AFX_IDP_FAILED_TO_START_PRINT); return; } } // Guarantee values are in the valid range UINT nEndPage = printInfo.GetToPage(); UINT nStartPage = printInfo.GetFromPage(); if (nEndPage < printInfo.GetMinPage()) nEndPage = printInfo.GetMinPage(); if (nEndPage > printInfo.GetMaxPage()) nEndPage = printInfo.GetMaxPage(); if (nStartPage < printInfo.GetMinPage()) nStartPage = printInfo.GetMinPage(); if (nStartPage > printInfo.GetMaxPage()) nStartPage = printInfo.GetMaxPage(); int nStep = (nEndPage >= nStartPage) ? 1 : -1; nEndPage = (nEndPage == 0xffff) ? 0xffff : nEndPage + nStep; VERIFY(strTemp.LoadString(AFX_IDS_PRINTPAGENUM)); // If it's a doc object, we don't loop page-by-page // because doc objects don't support that kind of levity. BOOL bError = FALSE; if (printInfo.m_bDocObject) { OnPrepareDC(&dcPrint, &printInfo); OnPrint(&dcPrint, &printInfo); } else { // begin page printing loop for (printInfo.m_nCurPage = nStartPage; printInfo.m_nCurPage != nEndPage; printInfo.m_nCurPage += nStep) { OnPrepareDC(&dcPrint, &printInfo); // check for end of print if (!printInfo.m_bContinuePrinting) break; // write current page TCHAR szBuf[80]; ATL_CRT_ERRORCHECK_SPRINTF(_sntprintf_s(szBuf, _countof(szBuf), _countof(szBuf) - 1, strTemp, printInfo.m_nCurPage)); dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PAGENUM, szBuf); // set up drawing rect to entire page (in logical coordinates) printInfo.m_rectDraw.SetRect(0, 0, dcPrint.GetDeviceCaps(HORZRES), dcPrint.GetDeviceCaps(VERTRES)); dcPrint.DPtoLP(&printInfo.m_rectDraw); // attempt to start the current page if (dcPrint.StartPage() < 0) { bError = TRUE; break; } // must call OnPrepareDC on newer versions of Windows because // StartPage now resets the device attributes. OnPrepareDC(&dcPrint, &printInfo); ASSERT(printInfo.m_bContinuePrinting); // page successfully started, so now render the page OnPrint(&dcPrint, &printInfo); // If the user restarts the job when it's spooling, all // subsequent calls to EndPage returns < 0. The first time // GetLastError returns ERROR_PRINT_CANCELLED if (dcPrint.EndPage() < 0 && (GetLastError()!= ERROR_SUCCESS)) { HANDLE hPrinter; if (!OpenPrinter(LPTSTR(printInfo.m_pPD->GetDeviceName().GetBuffer()), &hPrinter, NULL)) { bError = TRUE; break; } DWORD cBytesNeeded; if(!GetJob(hPrinter,printInfo.m_nJobNumber,1,NULL,0,&cBytesNeeded)) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { bError = TRUE; break; } } JOB_INFO_1 *pJobInfo; if((pJobInfo = (JOB_INFO_1 *)malloc(cBytesNeeded))== NULL) { bError = TRUE; break; } DWORD cBytesUsed; BOOL bRet = GetJob(hPrinter,printInfo.m_nJobNumber,1,LPBYTE(pJobInfo),cBytesNeeded,&cBytesUsed); DWORD dwJobStatus = pJobInfo->Status; free(pJobInfo); pJobInfo = NULL; // if job status is restart, just continue if(!bRet || !(dwJobStatus & JOB_STATUS_RESTART) ) { bError = TRUE; break; } } if(!_AfxAbortProc(dcPrint.m_hDC, 0)) { bError = TRUE; break; } } } // cleanup document printing process if (!printInfo.m_bDocObject) { if (!bError) dcPrint.EndDoc(); else dcPrint.AbortDoc(); } hwndTemp->EnableWindow(); // enable main window OnEndPrinting(&dcPrint, &printInfo); // clean up after printing dlgPrintStatus.DestroyWindow(); dcPrint.Detach(); // will be cleaned up by CPrintInfo destructor } }
void CEditX::OnLButtonDblClk(UINT nFlags, CPoint point) { CEdit::OnLButtonDblClk(nFlags, point); m_dwLastDblClick = GetCurrentMessage()->time; }
void CMainFrame::ForwardMessage() { const MSG *msg = GetCurrentMessage(); m_wndView.SendMessage(msg->message, msg->wParam, msg->lParam); }
UINT CTestQuestionPage::ShowQuestionnaireSettings(bool &bButtonsChanged, bool bEditNewQuestion) { if (m_iQuestionnaireIndex < 0 || m_iQuestionnaireIndex >= m_aQuestionnaires.GetSize()) { return IDCANCEL; } CQuestionnaireEx *pQuestionnaireOld = m_aQuestionnaires[m_iQuestionnaireIndex]; if (pQuestionnaireOld == NULL) { return IDCANCEL; } const MSG* pMsg = GetCurrentMessage(); CQuestionnaireSettings dialog(IDS_QUESTIONNAIRE_SETTINGS, this, 0, bEditNewQuestion); if (WPARAM(pMsg->wParam) == IDC_SHOW_QUESTIONAIRE_SETTINGS) { dialog.SetActivePage(0); } else { dialog.SetActivePage(2); } dialog.Init(m_pEditorProject, pQuestionnaireOld); UINT nReturn = dialog.DoModal(); if (nReturn == IDOK) { CQuestionnaireEx *pQuestionnaireNew = new CQuestionnaireEx(); dialog.SetUserEntries(m_pEditorProject, pQuestionnaireNew); CQuestionStream *pQuestionStream = m_pEditorProject->GetQuestionStream(true); HRESULT hr = S_OK; bButtonsChanged = false; if (SUCCEEDED(hr)) { bButtonsChanged = pQuestionnaireOld->IsButtonConfigurationDifferent(pQuestionnaireNew); hr = pQuestionStream->ChangeQuestionnaire(pQuestionnaireOld, pQuestionnaireNew, false); } if (m_pEditorProject->FirstQuestionnaireIsRandomTest()) { m_pEditorProject->SetJumpRandomQuestionActions(); } else { m_pEditorProject->ClearJumpRandomQuestionActions(); } // replace result feedback CFeedback *pNewResultFeedback = CQuestionnaireEx::CreateResultFeedback(m_pEditorProject, pQuestionnaireNew); if (SUCCEEDED(hr)) { hr = pQuestionnaireNew->ReplaceFeedback(pNewResultFeedback, true); } _ASSERT(SUCCEEDED(hr)); // update dialog labels m_aQuestionnaires.RemoveAll(); pQuestionStream->GetQuestionnaires(&m_aQuestionnaires); /*/ m_comboQuestionnaires.ResetContent(); if (m_aQuestionnaires.GetSize() > 0) { for (int i = 0; i < m_aQuestionnaires.GetSize(); ++i) { CQuestionnaireEx *pQuestionnaire = m_aQuestionnaires[i]; m_comboQuestionnaires.AddString(pQuestionnaire->GetTitle()); } if (m_iQuestionnaireIndex < 0) m_iQuestionnaireIndex = 0; if (m_iQuestionnaireIndex >= 0 && m_iQuestionnaireIndex < m_aQuestionnaires.GetSize()) m_comboQuestionnaires.SetCurSel(m_iQuestionnaireIndex); } else { m_iQuestionnaireIndex = -1; } /*/ m_iQuestionnaireIndex = 0; } return nReturn; }
void CMainFrame::OnFileOpenNew() { UINT nID = (UINT)LOWORD(GetCurrentMessage()->wParam); TRACE(_T("nID=%u\n"), nID); MessageBox(_T("打开文件。。。")); }
void CDemo::run() { core::dimension2d<u32> resolution ( 800, 600 ); if ( driverType == video::EDT_BURNINGSVIDEO || driverType == video::EDT_SOFTWARE ) { resolution.Width = 640; resolution.Height = 480; } irr::SIrrlichtCreationParameters params; params.DriverType=driverType; params.WindowSize=resolution; params.Bits=32; params.Fullscreen=fullscreen; params.Stencilbuffer=shadows; params.Vsync=vsync; params.AntiAlias=aa; params.EventReceiver=this; device = createDeviceEx(params); if (!device) return; if (device->getFileSystem()->existFile("irrlicht.dat")) device->getFileSystem()->addFileArchive("irrlicht.dat", true, true, io::EFAT_ZIP); else device->getFileSystem()->addFileArchive(IRRLICHT_MEDIA_PATH "irrlicht.dat", true, true, io::EFAT_ZIP); if (device->getFileSystem()->existFile("map-20kdm2.pk3")) device->getFileSystem()->addFileArchive("map-20kdm2.pk3", true, true, io::EFAT_ZIP); else device->getFileSystem()->addFileArchive(IRRLICHT_MEDIA_PATH "map-20kdm2.pk3", true, true, io::EFAT_ZIP); video::IVideoDriver* driver = device->getVideoDriver(); scene::ISceneManager* smgr = device->getSceneManager(); gui::IGUIEnvironment* guienv = device->getGUIEnvironment(); device->setWindowCaption(L"Irrlicht Engine Demo"); // set ambient light smgr->setAmbientLight ( video::SColorf ( 0x00c0c0c0 ) ); // wchar_t tmp[255]; // RakNet startup char dest[1024]; memset(dest,0,sizeof(dest)); wcstombs(dest, playerName.c_str(), playerName.size()); InstantiateRakNetClasses(); // Hook RakNet stuff into this class playerReplica->playerName=RakNet::RakString(dest); playerReplica->demo=this; replicaManager3->demo=this; CalculateSyndeyBoundingBox(); // draw everything s32 now = 0; sceneStartTime = device->getTimer()->getTime(); while(device->run() && driver) { // RakNet: Render even if not active, multiplayer never stops //if (device->isWindowActive()) { #ifdef USE_IRRKLANG // update 3D position for sound engine scene::ICameraSceneNode* cam = smgr->getActiveCamera(); if (cam && irrKlang) irrKlang->setListenerPosition(cam->getAbsolutePosition(), cam->getTarget()); #endif // load next scene if necessary now = device->getTimer()->getTime(); if (now - sceneStartTime > timeForThisScene && timeForThisScene!=-1) switchToNextScene(); createParticleImpacts(); driver->beginScene(timeForThisScene != -1, true, backColor); smgr->drawAll(); guienv->drawAll(); driver->endScene(); /* // write statistics static s32 lastfps = 0; s32 nowfps = driver->getFPS(); swprintf(tmp, 255, L"%ls fps:%3d triangles:%0.3f mio", driver->getName(), driver->getFPS(), (f32) driver->getPrimitiveCountDrawn( 1 ) * ( 1.f / 1000000.f ) ); if ( nowfps != lastfps ) { device->setWindowCaption ( tmp ); lastfps = nowfps; } */ RakNet::RakString curMsg = GetCurrentMessage(); if (curMsg.IsEmpty()==false) { wchar_t dest[1024]; memset(dest,0,sizeof(dest)); mbstowcs(dest, curMsg.C_String(), curMsg.GetLength()); statusText->setText(dest); } else { // statusText->setText(tmp); statusText->setText(0); } } // RakNet per tick update UpdateRakNet(); } // RakNet shutdown DeinitializeRakNetClasses(); device->drop(); }
CRect TranscriptWindow::DrawButton( CDC& dc, CRect& rect, bool centre, const char* text, Button button, bool enable) { // Select the font and measure the text in it CFont* oldFont = dc.SelectObject(theApp.GetFont(InformApp::FontDisplay)); CSize size = dc.GetTextExtent(text); // Adjust the width of the button if (centre) { rect.left = rect.right-(size.cx/2)-m_layout.margin.cx; rect.right = rect.left+size.cx+m_layout.margin.cx*2; } else rect.left = rect.right-size.cx-m_layout.margin.cx*2; // Determine the button's state CPoint mousePoint = GetCurrentMessage()->pt; ScreenToClient(&mousePoint); bool over = (rect.PtInRect(mousePoint) != 0); bool down = (m_buttonDown == button); if (theOS.IsAppThemed()) { // Open the button theme HTHEME theme = theOS.OpenThemeData(this,L"Button"); if (theme) { UINT state = PBS_NORMAL; if (!enable) state = PBS_DISABLED; else if (over && down) state = PBS_PRESSED; else if (down) state = PBS_HOT; else if (over && (m_buttonDown == Button())) state = PBS_HOT; // Draw the themed control frame theOS.DrawThemeBackground(theme,&dc,BP_PUSHBUTTON,state,rect); // Get the background size CRect backRect(rect); theOS.GetThemeBackgroundContentRect(theme,&dc,BP_PUSHBUTTON,state,backRect); // Draw the themed button text CStringW textW(text); theOS.DrawThemeText(theme,&dc,BP_PUSHBUTTON,state,textW, DT_CENTER|DT_VCENTER|DT_SINGLELINE,DTT_GRAYED,backRect); // Close the button theme theOS.CloseThemeData(theme); } } else { UINT state = DFCS_BUTTONPUSH; if (!enable) state |= DFCS_INACTIVE; else if (over && down) state |= DFCS_PUSHED; // Draw the control background dc.DrawFrameControl(rect,DFC_BUTTON,state); // Work out the bounding rectangle for the button text CRect textRect(rect); textRect.DeflateRect((rect.Width()-size.cx)/2,(rect.Height()-size.cy)/2); if (state & DFCS_PUSHED) { textRect.top++; textRect.left++; } // Draw the button text dc.DrawState(textRect.TopLeft(),textRect.Size(),text, (state & DFCS_INACTIVE) ? DSS_DISABLED : DSS_NORMAL,TRUE,0,(HBRUSH)0); } // Select the previous font dc.SelectObject(oldFont); // Store the button rectangle if (enable) m_buttons.push_back(std::make_pair(rect,button)); // Return the button rectangle return rect; }
void CQuestionnaireButtonPage::OnEdit() { const MSG* pMsg = GetCurrentMessage( ); int iAction = -1; CString csTitle; switch (WPARAM(pMsg->wParam)) { case IDC_EDIT_PASSIV: csTitle.LoadString(IDS_PREVIEW_PASSIV); iAction = CButtonAppearanceSettings::ACTION_PASSIV; break; case IDC_EDIT_NORMAL: csTitle.LoadString(IDS_PREVIEW_NORMAL); iAction = CButtonAppearanceSettings::ACTION_NORMAL; break; case IDC_EDIT_MOUSEOVER: csTitle.LoadString(IDS_PREVIEW_MOUSEOVER); iAction = CButtonAppearanceSettings::ACTION_OVER; break; case IDC_EDIT_PRESSED: csTitle.LoadString(IDS_PREVIEW_PRESSED); iAction = CButtonAppearanceSettings::ACTION_PRESSED; break; } // TODO Error message if (iAction < 0) return; if (m_wndChoosebuttonTypes.GetCurSel() == 0) { CEditInteractionTextDialog dlgEdit(this); dlgEdit.Init(csTitle, m_csButtonText, m_rcArea, m_pButtonVisualSettings->m_clrFill[iAction], m_pButtonVisualSettings->m_clrLine[iAction], m_pButtonVisualSettings->m_clrText[iAction], &m_pButtonVisualSettings->m_lf[iAction]); if (dlgEdit.DoModal() == IDOK) { dlgEdit.SetUserEntries(m_rcArea, m_pButtonVisualSettings->m_clrFill[iAction], m_pButtonVisualSettings->m_clrLine[iAction], m_pButtonVisualSettings->m_clrText[iAction], &m_pButtonVisualSettings->m_lf[iAction]); m_wndPreview[iAction].SetColors(m_pButtonVisualSettings->m_clrFill[iAction], m_pButtonVisualSettings->m_clrLine[iAction], m_pButtonVisualSettings->m_clrText[iAction]); m_wndPreview[iAction].SetButtonFont(&m_pButtonVisualSettings->m_lf[iAction]); } } else { CEditInteractionButtonDialog dlgEdit(this); dlgEdit.Init(csTitle, m_csButtonText, m_rcArea, m_pButtonVisualSettings->m_csFileNames[iAction], m_pButtonVisualSettings->m_clrText[iAction], &m_pButtonVisualSettings->m_lf[iAction]); if (dlgEdit.DoModal() == IDOK) { dlgEdit.SetUserEntries(m_rcArea, m_pButtonVisualSettings->m_csFileNames[iAction], m_pButtonVisualSettings->m_clrText[iAction], &m_pButtonVisualSettings->m_lf[iAction]); m_wndPreview[iAction].SetTextColor(m_pButtonVisualSettings->m_clrText[iAction]); m_wndPreview[iAction].SetButtonFont(&m_pButtonVisualSettings->m_lf[iAction]); m_wndPreview[iAction].SetImage(m_pButtonVisualSettings->m_csFileNames[iAction]); m_wndPreview[iAction].GetImageDimension(m_pButtonVisualSettings->m_siImageDimension[iAction]); // if passive button was changed, apply to all other buttons if (WPARAM(pMsg->wParam) == IDC_EDIT_PASSIV) { CString csImagePath = m_pButtonVisualSettings->m_csFileNames[iAction]; int iSlashPos = csImagePath.ReverseFind('\\'); csImagePath = csImagePath.Left(iSlashPos); m_pButtonVisualSettings->m_csFileNames[CButtonAppearanceSettings::ACTION_NORMAL] = csImagePath; m_pButtonVisualSettings->m_csFileNames[CButtonAppearanceSettings::ACTION_NORMAL] += "\\Normal.png"; m_pButtonVisualSettings->m_csFileNames[CButtonAppearanceSettings::ACTION_OVER] = csImagePath; m_pButtonVisualSettings->m_csFileNames[CButtonAppearanceSettings::ACTION_OVER] += "\\MouseOver.png"; m_pButtonVisualSettings->m_csFileNames[CButtonAppearanceSettings::ACTION_PRESSED] = csImagePath; m_pButtonVisualSettings->m_csFileNames[CButtonAppearanceSettings::ACTION_PRESSED] += "\\MouseDown.png"; for (int i = 1; i < CButtonAppearanceSettings::ACTION_EVENT_COUNT; ++i) { m_wndPreview[i].SetImage(m_pButtonVisualSettings->m_csFileNames[i]); m_wndPreview[i].GetImageDimension(m_pButtonVisualSettings->m_siImageDimension[i]); } } } } m_wndPreview[iAction].SetText(m_csButtonText); }
void CEditFrameDialog::OnFilePrint() { m_EditView->PostMessage (WM_COMMAND, LOWORD(GetCurrentMessage()->wParam)); }
void SourceWindow::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // Send the scroll bar message to the edit control const MSG* msg = GetCurrentMessage(); m_edit.SendMessage(WM_VSCROLL,msg->wParam,msg->lParam); }