/* OnKeyDown() */ void CWallBrowserStretchView::OnKeyDown(UINT nChar,UINT nRepCnt,UINT nFlags) { switch(nChar) { // redo case 'y': case 'Y': { if(::GetKeyState(VK_CONTROL) < 0) { OnEditRedo(); return; } break; } // ctrl inizio-fine su barra vert, senza inizio-fine su barra oriz case VK_HOME: SendMessage(::GetAsyncKeyState(VK_CONTROL) ? WM_VSCROLL : WM_HSCROLL,SB_TOP); // SendMessage(WM_VSCROLL,SB_TOP); // SendMessage(WM_HSCROLL,SB_TOP); return; case VK_END: SendMessage(::GetAsyncKeyState(VK_CONTROL) ? WM_VSCROLL : WM_HSCROLL,SB_BOTTOM); // SendMessage(WM_VSCROLL,SB_BOTTOM); // SendMessage(WM_HSCROLL,SB_BOTTOM); return; case VK_PRIOR: SendMessage(WM_VSCROLL,SB_PAGEUP); return; case VK_NEXT: SendMessage(WM_VSCROLL,SB_PAGEDOWN); return; case VK_UP: SendMessage(WM_VSCROLL,SB_LINEUP); return; case VK_DOWN: SendMessage(WM_VSCROLL,SB_LINEDOWN); return; // next picture case VK_RIGHT: { if(::GetKeyState(VK_SHIFT) < 0) { CWnd* pWnd = AfxGetMainWnd(); if(pWnd) pWnd->SendMessage(WM_COMMAND,MAKELONG(ID_VIEW_NEXT_PICTURE,0),0L); return; } else { SendMessage(WM_HSCROLL,SB_LINEDOWN); return; } break; } // previous picture case VK_LEFT: { if(::GetKeyState(VK_SHIFT) < 0) { CWnd* pWnd = AfxGetMainWnd(); if(pWnd) pWnd->SendMessage(WM_COMMAND,MAKELONG(ID_VIEW_PREVIOUS_PICTURE,0),0L); return; } else { SendMessage(WM_HSCROLL,SB_LINEUP); return; } break; } // passa alla vista seguente case VK_TAB: { CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument(); if(pDoc) pDoc->GotoNextView(); break; } } CZoomView::OnKeyDown(nChar,nRepCnt,nFlags); }
BOOL ZTitleTip::PreTranslateMessage( MSG *pMsg ) { // Used to qualify WM_LBUTTONDOWN messages as double-clicks. DWORD dwTick = 0; BOOL bDoubleClick = FALSE; CWnd *pWnd; int nHitTest; switch ( pMsg->message ) { case WM_LBUTTONDOWN: // Get tick count since last LButtonDown. dwTick = GetTickCount( ); bDoubleClick = ((dwTick - m_dwLastLButtonDown) <= m_ulDblClickInterval); // TraceLine( "ZTitleTip::PreTranslateMessage WM_LBUTTONDOWN DoubleClick: %s Tick Count: %d", // bDoubleClick ? "TRUE" : "FALSE", dwTick ); m_dwLastLButtonDown = dwTick; // NOTE: No break; Intentionally fall through! case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: { POINTS pts = MAKEPOINTS( pMsg->lParam ); CPoint pt; pt.x = pts.x; pt.y = pts.y; ClientToScreen( &pt ); Hide( ); pWnd = WindowFromPoint( pt ); if ( pWnd == 0 ) return( CWnd::PreTranslateMessage( pMsg ) ); // if ( pWnd->GetSafeHwnd( ) == GetSafeHwnd( ) ) if ( pWnd == this ) pWnd = m_pParentWnd; nHitTest = (int) pWnd->SendMessage( WM_NCHITTEST, 0, MAKELONG( pt.x, pt.y ) ); if ( nHitTest == HTCLIENT ) { pWnd->ScreenToClient( &pt ); pMsg->lParam = MAKELONG( pt.x, pt.y ); } else { switch ( pMsg->message ) { case WM_LBUTTONDOWN: pMsg->message = WM_NCLBUTTONDOWN; break; case WM_RBUTTONDOWN: pMsg->message = WM_NCRBUTTONDOWN; break; case WM_MBUTTONDOWN: pMsg->message = WM_NCMBUTTONDOWN; break; } pMsg->wParam = nHitTest; pMsg->lParam = MAKELONG( pt.x, pt.y ); } // If this is the 2nd WM_LBUTTONDOWN in x milliseconds, // post a WM_LBUTTONDBLCLK message instead of a single click. pWnd->PostMessage( bDoubleClick ? WM_LBUTTONDBLCLK : pMsg->message, pMsg->wParam, pMsg->lParam ); // m_pParentWnd->PostMessage( bDoubleClick ? WM_LBUTTONDBLCLK : pMsg->message, // pMsg->wParam, pMsg->lParam ); return( TRUE ); } case WM_KEYDOWN: case WM_SYSKEYDOWN: { Hide( ); m_pParentWnd->PostMessage( pMsg->message, pMsg->wParam, pMsg->lParam ); return( TRUE ); } } if ( GetFocus( ) == 0 ) { Hide( ); return( TRUE ); } return( CWnd::PreTranslateMessage( pMsg ) ); }
/* OnUpdate() */ void CWallBrowserStretchView::OnUpdate(CView* pSender,LPARAM lHint,CObject* pHint) { CWaitCursor cursor; BOOL bHint = FALSE; static BOOL bTreeExpandedEx = FALSE; if(lHint & ONUPDATE_FLAG_TREEEXPANDEDEX) { TRACE("%s(%d): receiving ONUPDATE_FLAG_TREEEXPANDEDEX\n",__FILE__,__LINE__); bTreeExpandedEx = TRUE; } if(!bTreeExpandedEx) goto done; // cambio immagine/libreria correnti if((lHint & ONUPDATE_FLAG_FILECHANGED) || (lHint & ONUPDATE_FLAG_DEFAULTLIBRARY)) { TRACE("%s(%d): receiving ONUPDATE_FLAG_FILECHANGED || ONUPDATE_FLAG_DEFAULTLIBRARY\n",__FILE__,__LINE__); m_bLoaded = FALSE; CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument(); CImage* pImage = NULL; memset(m_szStatus,'\0',sizeof(m_szStatus)); if(pDoc) { // salva l'immagine se e' stata modificata if(pDoc->IsModified()) pDoc->SaveModified(m_szFileName); pImage = pDoc->GetImage(); if(pImage) { if(pDoc->HaveFileName()) { // ricava il nome del file da caricare _snprintf(m_szFileName, sizeof(m_szFileName)-1, "%s%s", pDoc->GetPathName(), pDoc->GetFileName() ); strcpyn(m_szStatus,"loading...",sizeof(m_szStatus)); if(m_pMainFrameStatusBar) m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_FILENAME_ID,m_szStatus); pDoc->SetTitle(m_szStatus); // carica l'immagine m_bHavePicture = TRUE; if(pImage->Load(m_szFileName)) { m_bLoaded = TRUE; strcpyn(m_szStatus,pDoc->GetFileName(),sizeof(m_szStatus)); } else { m_bLoaded = FALSE; _snprintf(m_szStatus,sizeof(m_szStatus)-1,"load failed - %s",pDoc->GetFileName()); } pDoc->SetTitle(m_szStatus); pDoc->SetPictureFlag(m_bLoaded); if(!m_bLoaded) pDoc->ResetFileName(); } } } // caricamento dell'immagine riuscito if(m_bLoaded) { if(m_pMainFrameStatusBar) { EnableMenu(); m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_FILENAME_ID,m_szStatus); } } else // caricamento fallito { if(m_pMainFrameStatusBar) { DisableMenu(); m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_FILENAME_ID,""); //m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_FILES_ID,""); m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_INFO_ID,""); m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_LIBRARY_ID,""); m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_MEM_ID,""); //m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_PICTURES_ID,""); m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_RATIO_ID,""); m_pMainFrameStatusBar->SetPaneText(ID_INDICATOR_ZOOM_ID,""); } } // aggiorna la GUI CWnd* pWnd = AfxGetMainWnd(); if(pWnd) { pWnd->SendMessage(WM_FILE_SAVE,FALSE,0L); pWnd->SendMessage(WM_FILE_SAVE_AS,m_bLoaded,0L); pWnd->SendMessage(WM_FILE_MOVE,m_bHavePicture,0L); pWnd->SendMessage(WM_FILE_DELETE,m_bHavePicture,0L); pWnd->SendMessage(WM_EDIT_COPY,m_bLoaded,0L); pWnd->SendMessage(WM_EDIT_PASTE,m_bLoaded ? ::IsClipboardFormatAvailable(CF_DIB) : FALSE,0L); pWnd->SendMessage(WM_EDIT_UNDO,FALSE,0L); pWnd->PostMessage(WM_EDIT_REDO,FALSE,0L); UndoEmpty(); RedoEmpty(); } // per evitare di cancellare il fondo se la nuova immagine e' piu' grande della precedente BOOL bEraseOnInvalidate = TRUE; // modalita' stretch, calcola la dimensione dello stretch if(m_nViewType==VIEWTYPE_STRETCH) { // modalita' visualizzazione (centrato/text) SetCenterMode(FALSE); SetMapMode(MM_TEXT); SetCursorZoomMode(CURSOR_MODE_NONE); // elimina le barre dello scroll CSize size(0,0); SetZoomSizes(size); bEraseOnInvalidate = m_bLoaded ? ((lHint & ONUPDATE_FLAG_DEFAULTLIBRARY) ? FALSE : TRUE) : TRUE; if(bEraseOnInvalidate && m_rcInvalid.right!=-1 && m_rcInvalid.bottom!=-1 && pImage) { double nRemains = 0.0; double nWidth = (double)pImage->GetWidth(); double nHeight = (double)pImage->GetHeight(); GetClientRect(&m_rcClient); if(nHeight > (double)m_rcClient.bottom) { nRemains = FDIV(nHeight,(double)m_rcClient.bottom); if(nRemains > 0.0) { nHeight = FDIV(nHeight,nRemains); nWidth = FDIV(nWidth,nRemains); } } if(nWidth > (double)m_rcClient.right) { nRemains = FDIV(nWidth,(double)m_rcClient.right); if(nRemains > 0.0) { nHeight = FDIV(nHeight,nRemains); nWidth = FDIV(nWidth,nRemains); } } if((int)nWidth >= m_rcInvalid.right && (int)nHeight >= m_rcInvalid.bottom) bEraseOnInvalidate = FALSE; } } // modalita' scroll else if(m_nViewType==VIEWTYPE_SCROLL) { // deve cancellare lo sfondo e riposizionare le barre dello scroll a 0,0 bEraseOnInvalidate = TRUE; POINT point = {0,0}; ScrollToPosition(point); NotifyRanges(); } // (ri)disegna l'immagine Invalidate(bEraseOnInvalidate); bHint = TRUE; } // click sull'immagine gia' selezionata (ma non attiva) if(lHint & ONUPDATE_FLAG_FILESELECTED) { TRACE("%s(%d): receiving ONUPDATE_FLAG_FILESELECTED\n",__FILE__,__LINE__); CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument(); if(pDoc) { CImage* pImage = pDoc->GetImage(); if(pImage && pImage->GetWidth() > 0 && pImage->GetHeight() > 0) { // aggiorna la GUI CWnd* pWnd = AfxGetMainWnd(); if(pWnd) { m_bLoaded = pDoc->GetPictureFlag(); pWnd->SendMessage(WM_FILE_SAVE,pDoc->IsModified(),0L); pWnd->SendMessage(WM_FILE_SAVE_AS,m_bLoaded,0L); pWnd->SendMessage(WM_FILE_MOVE,m_bHavePicture,0L); pWnd->SendMessage(WM_FILE_DELETE,m_bHavePicture,0L); pWnd->SendMessage(WM_EDIT_COPY,m_bLoaded,0L); pWnd->SendMessage(WM_EDIT_PASTE,m_bLoaded ? ::IsClipboardFormatAvailable(CF_DIB) : FALSE,0L); pWnd->SendMessage(WM_EDIT_UNDO,UndoEnabled(),0L); pWnd->PostMessage(WM_EDIT_REDO,RedoEnabled(),0L); } } } //Invalidate(FALSE); bHint = TRUE; } // eliminazione dell'immagine corrente if(lHint & ONUPDATE_FLAG_FILEDELETED) { TRACE("%s(%d): receiving ONUPDATE_FLAG_FILEDELETED\n",__FILE__,__LINE__); // se l'immagine e' stata modificata resetta il flag CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument(); if(pDoc->IsModified()) pDoc->SetModifiedFlag(FALSE); // aggiorna la GUI CWnd* pWnd = AfxGetMainWnd(); if(pWnd) { pWnd->SendMessage(WM_FILE_SAVE,FALSE,0L); pWnd->SendMessage(WM_FILE_SAVE_AS,FALSE,0L); pWnd->SendMessage(WM_FILE_MOVE,FALSE,0L); pWnd->SendMessage(WM_FILE_DELETE,FALSE,0L); pWnd->SendMessage(WM_EDIT_COPY,FALSE,0L); pWnd->SendMessage(WM_EDIT_PASTE,FALSE,0L); pWnd->SendMessage(WM_EDIT_UNDO,FALSE,0L); pWnd->PostMessage(WM_EDIT_REDO,FALSE,0L); UndoEmpty(); RedoEmpty(); } // deve disegnare il contenuto della nuova immagine o ripulire l'area client se era l'unica immagine della directory Invalidate(TRUE); // se il file era l'unico nella directory pDoc->SetTitle(pDoc->GetPathName()); bHint = TRUE; } // cambio della directory corrente if(lHint & ONUPDATE_FLAG_DIRCHANGED || lHint & ONUPDATE_FLAG_DIRSELECTED) { TRACE("%s(%d): receiving ONUPDATE_FLAG_DIRCHANGED || ONUPDATE_FLAG_DIRSELECTED\n",__FILE__,__LINE__); m_bLoaded = FALSE; // salva l'immagine se e' stata modificata CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument(); if(pDoc) { if(pDoc->IsModified()) pDoc->SaveModified(m_szFileName); m_bLoaded = pDoc->GetPictureFlag(); } // aggiorna la GUI CWnd* pWnd = AfxGetMainWnd(); if(pWnd) { pWnd->SendMessage(WM_FILE_SAVE,FALSE,0L); pWnd->SendMessage(WM_FILE_SAVE_AS,m_bLoaded,0L); pWnd->SendMessage(WM_FILE_MOVE,m_bHavePicture,0L); pWnd->SendMessage(WM_FILE_DELETE,m_bHavePicture,0L); pWnd->SendMessage(WM_EDIT_COPY,m_bLoaded,0L); pWnd->SendMessage(WM_EDIT_PASTE,m_bLoaded ? ::IsClipboardFormatAvailable(CF_DIB) : FALSE,0L); pWnd->SendMessage(WM_EDIT_UNDO,FALSE,0L); pWnd->PostMessage(WM_EDIT_REDO,FALSE,0L); UndoEmpty(); RedoEmpty(); } // deve ripulire l'area client if(m_nViewType==VIEWTYPE_SCROLL) NotifyRanges(); Invalidate(TRUE); bHint = TRUE; } // e' stato svuotato lo stack per l'undo/redo if(lHint & ONUPDATE_FLAG_EMPTYSTACK) { TRACE("%s(%d): receiving ONUPDATE_FLAG_EMPTYSTACK\n",__FILE__,__LINE__); CWnd* pWnd = AfxGetMainWnd(); if(pWnd) { pWnd->SendMessage(WM_EDIT_UNDO,FALSE,0L); pWnd->PostMessage(WM_EDIT_REDO,FALSE,0L); } UndoEmpty(); RedoEmpty(); bHint = TRUE; } // e' stata cambiata la modalita' di visualizzazione (stretch/scroll) if(lHint & ONUPDATE_FLAG_VIEWTYPE) { TRACE("%s(%d): receiving ONUPDATE_FLAG_VIEWTYPE\n",__FILE__,__LINE__); m_nViewType = m_pWinAppEx->m_Config.GetNumber(WALLBROWSER_OPTIONS_KEY,WALLBROWSER_VIEWTYPE_KEY); if(m_nViewType==VIEWTYPE_SCROLL) { // modalita' visualizzazione (centrato/isotropic) SetCenterMode(TRUE); SetMapMode(MM_ANISOTROPIC); SetCursorZoomMode(CURSOR_MODE_BYCLICK); // risposiziona le barre dello scroll a 0,0 POINT point = {0,0}; ScrollToPosition(point); SetZoomMode(MODE_ZOOMOFF); NotifyRanges(); } else if(m_nViewType==VIEWTYPE_STRETCH) { // modalita' visualizzazione (centrato/text) SetCenterMode(FALSE); SetMapMode(MM_TEXT); SetCursorZoomMode(CURSOR_MODE_NONE); // elimina le barre dello scroll CSize size(0,0); SetZoomSizes(size); } // deve ridisegnare l'immagine ripulendo l'area client (dato che passa da una modalita' all'altra) Invalidate(TRUE); bHint = TRUE; } // e' stata cambiata la modalita' di disegno if((lHint & ONUPDATE_FLAG_DRAWSTRETCHDIBITS) || (lHint & ONUPDATE_FLAG_DRAWSTRETCHBLT) || (lHint & ONUPDATE_FLAG_DRAWVFWDRAWDIB)) { TRACE("%s(%d): receiving ONUPDATE_FLAG_DRAWSTRETCHDIBITS || ONUPDATE_FLAG_DRAWSTRETCHBLT || ONUPDATE_FLAG_DRAWVFWDRAWDIB\n",__FILE__,__LINE__); if(lHint & ONUPDATE_FLAG_DRAWSTRETCHDIBITS) m_nDrawMode = DRAW_STRETCHDIBITS; else if(lHint & ONUPDATE_FLAG_DRAWSTRETCHBLT) m_nDrawMode = DRAW_STRETCHBLT; else if (lHint & ONUPDATE_FLAG_DRAWVFWDRAWDIB) m_nDrawMode = DRAW_VFWDRAWDIB; else m_nDrawMode = DEFAULT_DRAWMODE; // deve ridisegnare l'immagine senza ripulire l'area client (cambia solo la modalita' di disegno, non quella di visualizzazione) Invalidate(FALSE); bHint = TRUE; } // e' stato cambiato il fattore di zoom if((lHint & ONUPDATE_FLAG_ZOOMIN) || (lHint & ONUPDATE_FLAG_ZOOMOUT) || (lHint & ONUPDATE_FLAG_ZOOMRESET)) { TRACE("%s(%d): receiving ONUPDATE_FLAG_ZOOMIN || ONUPDATE_FLAG_ZOOMOUT || ONUPDATE_FLAG_ZOOMRESET\n",__FILE__,__LINE__); if(lHint & ONUPDATE_FLAG_ZOOMIN) { SetZoomMode(MODE_ZOOMIN); TRACE("zoom ratio: %.2f\n",GetZoomRatio()); if(GetZoomRatio() <= 28.42) DoZoomIn(); } else if(lHint & ONUPDATE_FLAG_ZOOMOUT) { SetZoomMode(MODE_ZOOMOUT); TRACE("zoom ratio: %.2f\n",GetZoomRatio()); if(GetZoomRatio() >= 0.04) DoZoomOut(); } else if(lHint & ONUPDATE_FLAG_ZOOMRESET) { SetZoomMode(MODE_ZOOMOFF); NotifyRanges(); Invalidate(TRUE); } bHint = TRUE; } done: // classe base if(!bHint) CZoomView::OnUpdate(pSender,lHint,pHint); }
void CXTPEditListBox::OnEndLabelEdit() { // Get a pointer to the owner window. CWnd* pOwner = GetOwner(); ASSERT(pOwner); if (!pOwner) return; if (!m_pItemEdit) return; m_strItemText = m_pItemEdit->m_strWindowText; if (m_bNewItem) { // Delete the temp string. DeleteString(m_nIndex); // If the text string is empty, then send a cancel message. if (m_strItemText.IsEmpty()) { pOwner->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), LBN_XTP_LABELEDITCANCEL), (LPARAM)m_hWnd); m_nIndex = LB_ERR; } // The user has entered text, send the new item message // and insert the new string. else { m_nIndex = AddString(m_strItemText); // NB: SetTopIndex below causes some confusion if you have editing session, change content // and then double click on another item - the result looks like misplaced // edit control //SetTopIndex(m_nIndex); pOwner->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), LBN_XTP_NEWITEM), (LPARAM)m_hWnd); } } else { // set the index to the current selection. m_nIndex = GetCurSel(); // Get the text for the selected item. CString strItemText; GetText(m_nIndex, strItemText); // If the new string is the same as the old string, // then send a cancel message. if (strItemText == m_strItemText) { pOwner->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), LBN_XTP_LABELEDITCANCEL), (LPARAM)m_hWnd); } // The user has updated the text string, delete the // existing string and replace it with the new text. else { DWORD_PTR dwData = GetItemData(m_nIndex); DeleteString(m_nIndex); InsertString(m_nIndex, m_strItemText); SetItemData(m_nIndex, dwData); // NB: SetTopIndex below causes some confusion if you have editing session, change content // and then double click on another item - the result looks like misplaced // edit control //SetTopIndex(m_nIndex); pOwner->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), LBN_XTP_LABELEDITEND), (LPARAM)m_hWnd); } } // Set the focus back to the listbox. SetCurSel(m_nIndex); SetFocus(); m_pItemEdit = NULL; }
LRESULT CGraphicWindowChildFrame::OnTabChange(WPARAM wParam, LPARAM /*lParam*/) { // add this tab move to the back list int newTab = (int)wParam; int prevTab = -1; if( backTabCount() > 0 ) { prevTab = m_backTabList[backTabCount()]; } if( prevTab != newTab ) m_backTabList.add( newTab ); switch( wParam ) { case 0: // Model Window Selected ASSERT_RETURN_ITEM( m_pGraphicWindow, FALSE ); m_pGraphicWindow->ShowWindow( SW_SHOW ); m_pMemberWindow->ShowWindow( SW_HIDE ); m_pMultiMemberWindow->ShowWindow( SW_HIDE ); m_pReportWindow->ShowWindow( SW_HIDE ); m_pGridWindow->ShowWindow( SW_HIDE ); windowFilter().windowType = MODEL_WINDOW; VAHelpPane.updateActiveWindow( windowFilter().windowType ); m_pGraphicWindow->SetAServiceCase(); SetIcon( theApp.LoadIcon( MAKEINTRESOURCE( IDI_MODEL )), TRUE ); break; case 1: // Results Window Selected ASSERT_RETURN_ITEM( m_pGraphicWindow, FALSE ); m_pGraphicWindow->ShowWindow( SW_SHOW ); m_pMemberWindow->ShowWindow( SW_HIDE ); m_pMultiMemberWindow->ShowWindow( SW_HIDE ); m_pReportWindow->ShowWindow( SW_HIDE ); m_pGridWindow->ShowWindow( SW_HIDE ); windowFilter().windowType = POST_WINDOW; VAHelpPane.updateActiveWindow( windowFilter().windowType ); SetIcon( theApp.LoadIcon( MAKEINTRESOURCE( IDI_RESULT )), TRUE ); if( theProject.useBackgroundEngine() == false ) { if( !AnalyzeIfNoResults() ) { ; // assume analysis engine has displayed a message on failure... } } m_pGraphicWindow->SetAResultCase( false ); break; case 2: // Design Window Selected ASSERT_RETURN_ITEM( m_pGraphicWindow, FALSE ); m_pGraphicWindow->ShowWindow( SW_SHOW ); m_pMemberWindow->ShowWindow( SW_HIDE ); m_pMultiMemberWindow->ShowWindow( SW_HIDE ); m_pReportWindow->ShowWindow( SW_HIDE ); m_pGridWindow->ShowWindow( SW_HIDE ); // TeK Add 4/26/2007: Only if we have something to design! if( theModel.nodes() < 2 ) { AfxMessageBox( "Please create a model, then you may work on design!", MB_ICONINFORMATION ); windowFilter().windowType = MODEL_WINDOW; SetTab( 0 ); } else if( theController.designSoftwareIsPresent() ) { // for speed improvement, lets stop the feaBacgroundProcessor, first see if it is working if( theEngine.FEABackgroundProcessorHasWorkToDo() ) { VAHelpPane.showTempTip( "The model has not been set up for analysis." " Analyze the project first!", true ); } else { theEngine.stopSetupFEABackgroundProcessor(); SetupAutoDesignGroups(); theController.doAllUnityChecks(); theEngine.startSetupFEABackgroundProcessor(); windowFilter().windowType = DESIGN_WINDOW; VAHelpPane.updateActiveWindow( windowFilter().windowType ); if( !theController.designCasesHaveValidResults() ) { VAHelpPane.showTempTip( "There are no 'design' load combinations with results." " Check design settings in Load Case Manager, or Analyze!", true ); } } Invalidate(); SetIcon( theApp.LoadIcon( MAKEINTRESOURCE( IDI_DESIGN )), TRUE ); } else { AfxMessageBox( "You have not purchased the optional design features, please visit www.iesweb.com or call 1-800-707-0816.", MB_ICONINFORMATION | MB_OK ); SetTab(0); return LRESULT(0); } break; case 3: // reportView or gridView SetReportView(); break; case 4: // memberView (or multi) { if( m_pGraphicWindow ) m_pGraphicWindow->ShowWindow( SW_HIDE ); m_pMemberWindow->ShowWindow( SW_HIDE ); m_pMultiMemberWindow->ShowWindow( SW_HIDE ); m_pReportWindow->ShowWindow( SW_HIDE ); m_pGridWindow->ShowWindow( SW_HIDE ); // we've got to decide whether or not we show the single member view // or the multi member view // lets see if we've got a selected chain if( m_pGraphicWindow ) { m_pGraphicWindow->SetAResultCase( false ); CLoadCase* aLoadCase = m_pGraphicWindow->windowFilter().loadCase(); const CResultCase* aResultCase = m_pGraphicWindow->windowFilter().resultCase(); // see if we have a chain int count = theModel.elements( MEMBER_ELEMENT, OnlySelected ); bool forceSingleMemberPlot = false; CCombineMembers cm(true); bool haveAChain = (OK_TO_COMBINE == cm.CanCombine()); //areSelectedMembersAChain( true ); if( count > 1 && haveAChain ) { // make sure we don't have too many members int graphPoints = 0; //const TPointerArray<const CMember>& chain = theMemberChain(); const CMemberArray& chain = cm.GetChain(); if( aResultCase != NULL ) { for( int i = 1; i <= count; i++ ) { const CMember* pM = chain[i]; const CResult* pMFR = aResultCase->result( *pM ); if( pMFR ) graphPoints += ((CResult*)pMFR)->locations(); } } if( graphPoints >= MAX_GRAPH_DATA_COUNT || count+1 >= MAX_X_ANNOTATION_COUNT ) { MessageBox( "You have selected too many members. Please select fewer members for your multi-member plot.", "VisualAnalysis", MB_OK | MB_ICONEXCLAMATION ); forceSingleMemberPlot = true; } else { // we can set up the multi member view m_pMultiMemberWindow->memberChain().flush(); for( int i = 1; i <= chain.getItemsInContainer(); i++ ) m_pMultiMemberWindow->memberChain().add( chain[i] ); m_pMultiMemberWindow->windowFilter().windowType = MULTIMEMBER_GRAPHIC_WINDOW; SetupMemberPlotFilter( m_pMultiMemberWindow->windowFilter(), aLoadCase, aResultCase, NULL ); m_tabWnd.GetTabCtrl()->ChangeTabClient( 4, m_pMultiMemberWindow ); } } if( forceSingleMemberPlot || haveAChain == false || count <= 1 ) { // create a single member view CMember* pM = (CMember*)theModel.element( MEMBER_ELEMENT, 1, (count > 0) ); m_pMemberWindow->windowFilter().windowType = MEMBER_GRAPHIC_WINDOW; SetupMemberPlotFilter( m_pMemberWindow->windowFilter(), aLoadCase, aResultCase, pM ); m_tabWnd.GetTabCtrl()->ChangeTabClient( 4, m_pMemberWindow ); } } // m_pGraphicWindow else { // this should not happen ASSERT( FALSE ); m_pMemberWindow->ShowWindow( SW_HIDE ); m_pMultiMemberWindow->ShowWindow( SW_HIDE ); m_pReportWindow->ShowWindow( SW_HIDE ); } } break; default: ASSERT( FALSE ); break; } CWnd* theClient = AfxGetMainWnd(); if( theClient ) { theClient->SendMessage( VIEW_MANAGER_CHANGE_MESSAGE, 0, 0 ); } if( wParam == 3 ) { m_tabWnd.GetTabCtrl()->SetFocus(); } // TeK Add 10/13/2009: Prevent the entire tab row from disappearing! // UpdateWindows didn't work?, try ShowWindow! // RDV Note 10/1/09 - Add this to hopefully clear up the tab visibility issues reported //m_tabWnd.UpdateWindow(); //#pragma message( TEK "Tab windows still disappear, sometimes, for some customers..." ) m_tabWnd.ShowWindow( SW_SHOW ); return FALSE; }
void CBCGPWindowsManagerDlg::OnBcgbarresWindowHelp() { CWnd* pParentFrame = AfxGetMainWnd(); pParentFrame->SendMessage(WM_BCGWINDOW_HELP, 0, (LPARAM) this); }
/*! Set the dialog's default pushbutton \param pDialog Dialog to set the default pushbutton \param nID Button ID to make default \note It fixes the drawing problem that sometimes occurs when using plain CDialog::SetDefID, see also MS kb Q67655 (<A HREF="http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q67655&"> HOWTO: Change or Set the Default Push Button in a Dialog Box</A>) */ void COddButton::SetDefID(CDialog* pDialog, const UINT nID) { if( !pDialog || !::IsWindow(pDialog->m_hWnd) ) { ASSERT(FALSE); // Bad pointer or dialog is not a window return; } // get the current default button const DWORD dwPrevDefID = pDialog->GetDefID(); const UINT nPrevID = (HIWORD(dwPrevDefID) == DC_HASDEFID) ? LOWORD(dwPrevDefID) : 0; /* * Set the new default ID in the dialog */ pDialog->SetDefID(nID); /* * Make sure the previous default button doesn't have the default state anymore */ // check previous ID is a default-compatible button // and it has the default state LRESULT lRes = (nPrevID == 0) ? 0 : pDialog->SendDlgItemMessage(nPrevID, WM_GETDLGCODE); if( (lRes & DLGC_BUTTON) && (lRes & DLGC_DEFPUSHBUTTON) ) { pDialog->SendDlgItemMessage(nPrevID, BM_SETSTYLE, BS_PUSHBUTTON, MAKELPARAM(TRUE, 0)); } /* * Make sure the new default button receives the default state */ // check new ID is a button lRes = (nID == 0) ? 0 : pDialog->SendDlgItemMessage(nID, WM_GETDLGCODE); if( lRes & DLGC_BUTTON ) { // exception: current focused button should keep its default state (IMHO) CWnd* pFocusWnd = GetFocus(); LRESULT lResFocus = (pFocusWnd == NULL) ? 0 : pFocusWnd->SendMessage(WM_GETDLGCODE); // check focused control is a default-compatible button if( (lResFocus & DLGC_BUTTON) && (lResFocus & (DLGC_DEFPUSHBUTTON | DLGC_UNDEFPUSHBUTTON)) ) { // remove default state (if needed) if( (lRes & DLGC_DEFPUSHBUTTON) && (nID != (UINT)pFocusWnd->GetDlgCtrlID()) ) { pDialog->SendDlgItemMessage(nID, BM_SETSTYLE, BS_PUSHBUTTON, MAKELPARAM(TRUE, 0)); } // set default state (if needed) if( lResFocus & DLGC_UNDEFPUSHBUTTON ) { pFocusWnd->SendMessage(BM_SETSTYLE, BS_DEFPUSHBUTTON, MAKELPARAM(TRUE, 0)); } } else if( lRes & DLGC_UNDEFPUSHBUTTON ) { // not default-compatible button has the focus // set default state pDialog->SendDlgItemMessage(nID, BM_SETSTYLE, BS_DEFPUSHBUTTON, MAKELPARAM(TRUE, 0)); } } }
void CCheckListBox::OnLButtonDown(UINT nFlags, CPoint point) { SetFocus(); if (GetStyle() & LBS_OWNERDRAWFIXED) { int cyItem = GetItemHeight(0); if (point.y < cyItem * GetCount()) { int nIndex = GetTopIndex() + point.y / cyItem; if (IsEnabled(nIndex)) { if (m_nStyle != BS_CHECKBOX && m_nStyle != BS_3STATE) { _AFX_CHECKLIST_STATE* pChecklistState = _afxChecklistState; if (point.x < pChecklistState->m_sizeCheck.cx + 2) { CWnd* pParent = GetParent(); ASSERT_VALID(pParent); int nModulo = (m_nStyle == BS_AUTO3STATE) ? 3 : 2; int nCheck = GetCheck(nIndex); nCheck = (nCheck == nModulo) ? nCheck - 1 : nCheck; SetCheck(nIndex, (nCheck + 1) % nModulo); InvalidateCheck(nIndex); CListBox::OnLButtonDown(nFlags, point); // Inform of check pParent->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CLBN_CHKCHANGE), (LPARAM)m_hWnd); return; } } } else return; // Swallow LButtons for disabled items } } else { CRect rectCheck; for (int nIndex = GetTopIndex(); (rectCheck.bottom < point.y) || (nIndex < GetCount()); nIndex++) { GetItemRect(nIndex, rectCheck); if (rectCheck.PtInRect(point)) { if (IsEnabled(nIndex)) { if (m_nStyle != BS_CHECKBOX && m_nStyle != BS_3STATE) { _AFX_CHECKLIST_STATE* pChecklistState = _afxChecklistState; if (point.x < pChecklistState->m_sizeCheck.cx + 2) { CWnd* pParent = GetParent(); ASSERT_VALID(pParent); int nModulo = (m_nStyle == BS_AUTO3STATE) ? 3 : 2; int nCheck = GetCheck(nIndex); nCheck = (nCheck == nModulo) ? nCheck - 1 : nCheck; SetCheck(nIndex, (nCheck + 1) % nModulo); InvalidateCheck(nIndex); CListBox::OnLButtonDown(nFlags, point); // Inform of check pParent->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CLBN_CHKCHANGE), (LPARAM)m_hWnd); return; } } } else return; // Swallow LButtons for disabled items } } } CListBox::OnLButtonDown(nFlags, point); }
void CCheckListBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { if (nChar == VK_SPACE) { int nIndex = GetCaretIndex(); CWnd* pParent = GetParent(); ASSERT_VALID(pParent); if (nIndex != LB_ERR) { if (m_nStyle != BS_CHECKBOX && m_nStyle != BS_3STATE) { if ((GetStyle() & LBS_MULTIPLESEL) != 0) { if (IsEnabled(nIndex)) { BOOL bSelected = GetSel(nIndex); if (bSelected) { int nModulo = (m_nStyle == BS_AUTO3STATE) ? 3 : 2; int nCheck = GetCheck(nIndex); nCheck = (nCheck == nModulo) ? nCheck - 1 : nCheck; SetCheck(nIndex, (nCheck + 1) % nModulo); // Inform of check pParent->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CLBN_CHKCHANGE), (LPARAM)m_hWnd); } SetSel(nIndex, !bSelected); } else SetSel(nIndex, FALSE); // unselect disabled items return; } else { // If there is a selection, the space bar toggles that check, // all other keys are the same as a standard listbox. if (IsEnabled(nIndex)) { int nModulo = (m_nStyle == BS_AUTO3STATE) ? 3 : 2; int nCheck = GetCheck(nIndex); nCheck = (nCheck == nModulo) ? nCheck - 1 : nCheck; SetCheck(nIndex, (nCheck + 1) % nModulo); InvalidateCheck(nIndex); // Inform of check pParent->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CLBN_CHKCHANGE), (LPARAM)m_hWnd); } else SetSel(nIndex, FALSE); // unselect disabled items return; } } } } CListBox::OnKeyDown(nChar, nRepCnt, nFlags); }
LONG CIrcWnd::OnSelEndOK(UINT lParam, LONG /*wParam*/) { if (lParam != CLR_DEFAULT) { int iColour = 0; while(iColour<16 && (COLORREF)lParam!=s_aColors[iColour]) iColour++; if(iColour>=0 && iColour<16)//iColour in valid range { CString sAddAttribute; int iSelStart; int iSelEnd; TCHAR iSelEnd3Char; TCHAR iSelEnd6Char; m_wndInput.GetSel(iSelStart, iSelEnd);//get selection area m_wndInput.GetWindowText(sAddAttribute);//get the whole line if(iSelEnd > iSelStart) { sAddAttribute.Insert(iSelEnd, _T('1'));//if a selection add default black colour tag sAddAttribute.Insert(iSelEnd, _T('0'));//add first half of colour tag sAddAttribute.Insert(iSelEnd, _T('\003'));//if a selection add 'end' tag } iColour += 0x30; //a number greater than 9 if(iColour>0x39) { sAddAttribute.Insert(iSelStart, (TCHAR)(iColour-10));//add second half of colour tag 1 for range 10 to 15 sAddAttribute.Insert(iSelStart, _T('1')); //add first half of colour tag } else { sAddAttribute.Insert(iSelStart, (TCHAR)(iColour));//add second half of colour tag 1 for range 0 to 9 sAddAttribute.Insert(iSelStart, _T('0')); //add first half of colour tag } //if this is the start of the line not a selection in the line and a colour has already just been set allow background to be set if(iSelEnd>2) iSelEnd3Char = sAddAttribute[iSelEnd-3]; else iSelEnd3Char = _T(' '); if(iSelEnd>5) iSelEnd6Char = sAddAttribute[iSelEnd-6]; else iSelEnd6Char = _T(' '); if(iSelEnd == iSelStart && iSelEnd3Char == _T('\003') && iSelEnd6Char!= _T('\003')) sAddAttribute.Insert(iSelStart, _T(','));//separator for background colour else sAddAttribute.Insert(iSelStart, _T('\003'));//add start tag iSelStart+=3;//add 3 to start position iSelEnd+=3;//add 3 to end position m_wndInput.SetWindowText(sAddAttribute);//write new line to edit control m_wndInput.SetSel(iSelStart, iSelEnd);//update selection info m_wndInput.SetFocus();//set focus (from button) to edit control } } else {//Default button clicked set black CString sAddAttribute; int iSelStart; int iSelEnd; TCHAR iSelEnd3Char; TCHAR iSelEnd6Char; m_wndInput.GetSel(iSelStart, iSelEnd);//get selection area m_wndInput.GetWindowText(sAddAttribute);//get the whole line //if this is the start of the line not a selection in the line and a colour has already just been set allow background to be set if(iSelEnd>2) iSelEnd3Char = sAddAttribute[iSelEnd-3]; else iSelEnd3Char = _T(' '); if(iSelEnd>5) iSelEnd6Char = sAddAttribute[iSelEnd-6]; else iSelEnd6Char = _T(' '); if(iSelEnd == iSelStart && iSelEnd3Char == _T('\003') && iSelEnd6Char!= _T('\003')) {//Set DEFAULT white background sAddAttribute.Insert(iSelStart, _T('0'));//add second half of colour tag 0 for range 0 to 9 sAddAttribute.Insert(iSelStart, _T('0'));//add first half of colour tag sAddAttribute.Insert(iSelStart, _T(','));//separator for background colour } else {//Set DEFAULT black foreground sAddAttribute.Insert(iSelStart, _T('1'));//add second half of colour tag 1 for range 0 to 9 sAddAttribute.Insert(iSelStart, _T('0'));//add first half of colour tag sAddAttribute.Insert(iSelStart, _T('\003'));//add start tag } iSelStart+=3;//add 2 to start position iSelEnd+=3; m_wndInput.SetWindowText(sAddAttribute);//write new line to edit control m_wndInput.SetSel(iSelStart, iSelEnd);//update selection info m_wndInput.SetFocus();//set focus (from button) to edit control } CWnd *pParent = GetParent(); if(pParent) { pParent->SendMessage(UM_CPN_CLOSEUP, lParam, (WPARAM) GetDlgCtrlID()); pParent->SendMessage(UM_CPN_SELENDOK, lParam, (WPARAM) GetDlgCtrlID()); } return TRUE; }
LRESULT CToolbarHelper::WindowProc(HWND hRealWnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_NOTIFY: { LPNMHDR pNMHDR = (LPNMHDR)lp; switch (pNMHDR->code) { case TBN_DROPDOWN: // check its our toolbar if (pNMHDR->hwndFrom == m_pToolbar->GetSafeHwnd()) { // load the menu LPNMTOOLBAR pNMTB = (LPNMTOOLBAR)pNMHDR; if (DisplayDropMenu((UINT)pNMTB->iItem)) { return FALSE; // we handled it } } break; case TTN_NEEDTEXT: { // to be thorough we will need to handle UNICODE versions of the message also !! TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR; UINT nID = pNMHDR->idFrom; if (pTTT->uFlags & TTF_IDISHWND) // idFrom is actually the HWND of the tool { nID = ::GetDlgCtrlID((HWND)nID); } // get cursor pos CPoint point(::GetMessagePos()); m_pToolbar->ScreenToClient(&point); // get tip static CString sTipText; sTipText = GetTip(nID, &point); if (!sTipText.IsEmpty()) // will be zero on a separator { pTTT->lpszText = (LPTSTR)(LPCTSTR)sTipText; return TRUE; } } break; case TTN_SHOW: { CWnd* pTooltipCtrl = CWnd::FromHandle(pNMHDR->hwndFrom); ASSERT(pTooltipCtrl); pTooltipCtrl->SendMessage(TTM_SETMAXTIPWIDTH, 0, m_bMultiline ? m_nMultilineWidth : UINT_MAX); } break; } } break; case WM_COMMAND: { HWND hCtrlFrom = (HWND)lp; // if m_pToolbar sent the command and we have a mapping for it then // change it to the default cmd for that button if (hCtrlFrom == *m_pToolbar) { THButton dm; UINT nCmdID = LOWORD(wp); if (m_mapTHButtons.Lookup(nCmdID, dm)) { // if we have an enabled default command then send it if (dm.nDefCmdID && IsCmdEnabled(dm.nDefCmdID)) { wp = MAKEWPARAM(dm.nDefCmdID, HIWORD(wp)); } else { BOOL bRes = DisplayDropMenu(nCmdID, TRUE); if (bRes) { return 0L; // we handled it } } } } } break; case WM_KICKIDLE: break; case WM_DESTROY: { // must call rest of chain first LRESULT lr = CSubclassWnd::WindowProc(hRealWnd, msg, wp, lp); HookWindow(NULL); return lr; } } return CSubclassWnd::WindowProc(hRealWnd, msg, wp, lp); }
/////////////////////////////////////////////////////////////////////////////// // SendRegisteredMessage void CXComboList::SendRegisteredMessage(UINT nMsg, WPARAM wParam, LPARAM lParam) { CWnd *pWnd = m_pParent; if (pWnd) pWnd->SendMessage(nMsg, wParam, lParam); }
void CMenuButton::OnShowMenu() { m_bRealMenuIsActive = true; // Begin CMFCMenuButton::OnShowMenu() if (m_hMenu == NULL || m_bMenuIsActive) { return; } CRect rectWindow; GetWindowRect(rectWindow); int x, y; if (m_bRightArrow) { x = rectWindow.right; y = rectWindow.top; } else { x = rectWindow.left; y = rectWindow.bottom; } if (m_bStayPressed) { m_bPushed = TRUE; m_bHighlighted = TRUE; } m_bMenuIsActive = TRUE; Invalidate(); TPMPARAMS params; params.cbSize = sizeof(TPMPARAMS); params.rcExclude = rectWindow; m_nMenuResult = ::TrackPopupMenuEx(m_hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD | TPM_VERTICAL, x, y, GetSafeHwnd(), ¶ms); CWnd* pParent = GetParent(); #ifdef _DEBUG if ((pParent->IsKindOf(RUNTIME_CLASS(CDialog))) && (!pParent->IsKindOf(RUNTIME_CLASS(CDialogEx)))) { TRACE(_T("CMFCMenuButton parent is CDialog, should be CDialogEx for popup menu handling to work correctly.\n")); } #endif if (m_nMenuResult != 0) { //------------------------------------------------------- // Trigger mouse up event(to button click notification): //------------------------------------------------------- if (pParent != NULL) { pParent->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd); } } m_bPushed = FALSE; m_bHighlighted = FALSE; m_bMenuIsActive = FALSE; Invalidate(); UpdateWindow(); if (m_bCaptured) { ReleaseCapture(); m_bCaptured = FALSE; } // End CMFCMenuButton::OnShowMenu() m_bRealMenuIsActive = false; }
LRESULT CSystemTray::OnTrayNotification(UINT wParam, LONG lParam) { //Return quickly if its not for this tray icon if (wParam != m_tnd.uID) return 0L; CMenu menu, *pSubMenu; CWnd* pTarget = AfxGetMainWnd(); // Clicking with right button brings up a context menu if (LOWORD(lParam) == WM_RBUTTONUP) { if (!menu.LoadMenu(m_tnd.uID)) return 0; if (!(pSubMenu = menu.GetSubMenu(0))) return 0; // Make chosen menu item the default (bold font) ::SetMenuDefaultItem(pSubMenu->m_hMenu, m_DefaultMenuItemID, m_DefaultMenuItemByPos); if (m_mnuStatus->StartAsMinimized) { menu.CheckMenuItem(m_mnuStatus->StartAsMinimized, MF_CHECKED); } if (m_mnuStatus->StartAsMinimized) menu.CheckMenuItem(IDC_ST_STARTASMINIMIZED, MF_CHECKED); if (m_mnuStatus->SpeedHigh) menu.CheckMenuItem(IDC_ST_SPEED_HIGH, MF_CHECKED); if (m_mnuStatus->SpeedNormal) menu.CheckMenuItem(IDC_ST_SPEED_NORMAL, MF_CHECKED); if (m_mnuStatus->SpeedLow) menu.CheckMenuItem(IDC_ST_SPEED_LOW, MF_CHECKED); // Display and track the popup menu CPoint pos; GetCursorPos(&pos); pTarget->SetForegroundWindow(); ::TrackPopupMenu(pSubMenu->m_hMenu, 0, pos.x, pos.y, 0, pTarget->GetSafeHwnd(), NULL); // BUGFIX: See "PRB: Menus for Notification Icons Don't Work Correctly" pTarget->PostMessage(WM_NULL, 0, 0); menu.DestroyMenu(); } else if (LOWORD(lParam) == WM_LBUTTONDBLCLK) { // double click received, the default action is to execute default menu item pTarget->SetForegroundWindow(); UINT uItem; if (m_DefaultMenuItemByPos) { if (!menu.LoadMenu(m_tnd.uID)) return 0; if (!(pSubMenu = menu.GetSubMenu(0))) return 0; uItem = pSubMenu->GetMenuItemID(m_DefaultMenuItemID); } else uItem = m_DefaultMenuItemID; pTarget->SendMessage(WM_COMMAND, uItem, 0); menu.DestroyMenu(); } return 1; }
void CFFPlugsRow::NotifyEdit(int CtrlID) { CWnd *NotifyWnd = GetNotifyWnd(); NotifyWnd->SendMessage(UWM_FFROWEDIT, m_RowIdx, CtrlID); }
BOOL CTitleTip::PreTranslateMessage(MSG* pMsg) { // Used to qualify WM_LBUTTONDOWN messages as double-clicks DWORD dwTick = 0; BOOL bDoubleClick = FALSE; CWnd *pWnd; int hittest; switch (pMsg->message) { case WM_LBUTTONDOWN: // Get tick count since last LButtonDown dwTick = GetTickCount(); bDoubleClick = ((dwTick - m_dwLastLButtonDown) <= m_dwDblClickMsecs); m_dwLastLButtonDown = dwTick; // NOTE: DO NOT ADD break; STATEMENT HERE! Let code fall through case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: { POINTS pts = MAKEPOINTS( pMsg->lParam ); POINT point; point.x = pts.x; point.y = pts.y; ClientToScreen( &point ); Hide(); pWnd = WindowFromPoint( point ); if (!pWnd) return CWnd::PreTranslateMessage(pMsg); if( pWnd->GetSafeHwnd() == GetSafeHwnd()) pWnd = m_pParentWnd; hittest = (int)pWnd->SendMessage(WM_NCHITTEST, 0, MAKELONG(point.x, point.y)); if (hittest == HTCLIENT) { pWnd->ScreenToClient( &point ); pMsg->lParam = MAKELONG(point.x, point.y); } else { switch (pMsg->message) { case WM_LBUTTONDOWN: pMsg->message = WM_NCLBUTTONDOWN; break; case WM_RBUTTONDOWN: pMsg->message = WM_NCRBUTTONDOWN; break; case WM_MBUTTONDOWN: pMsg->message = WM_NCMBUTTONDOWN; break; } pMsg->wParam = hittest; pMsg->lParam = MAKELONG(point.x, point.y); } // If this is the 2nd WM_LBUTTONDOWN in x milliseconds, // post a WM_LBUTTONDBLCLK message instead of a single click. pWnd->PostMessage( bDoubleClick ? WM_LBUTTONDBLCLK : pMsg->message, pMsg->wParam, pMsg->lParam); return TRUE; } case WM_KEYDOWN: case WM_SYSKEYDOWN: Hide(); m_pParentWnd->PostMessage( pMsg->message, pMsg->wParam, pMsg->lParam ); return TRUE; } if( GetFocus() == NULL ) { Hide(); return TRUE; } return CWnd::PreTranslateMessage(pMsg); }
/////////////////////////////////////////////////////////////////////////////// // OnPaint void CXColorStatic::OnPaint() { CWnd *pOwner = GetOwner(); if (pOwner && IsWindow(pOwner->m_hWnd)) { NMHDR hdr; hdr.hwndFrom = m_hWnd; hdr.idFrom = GetDlgCtrlID(); hdr.code = NM_CUSTOMDRAW; pOwner->SendMessage(WM_NOTIFY, hdr.idFrom, (LPARAM)&hdr); } CPaintDC dc(this); // device context for painting dc.SaveDC(); dc.SetTextColor(m_rgbText); dc.SetBkColor(m_rgbBackground); dc.SetBkMode(OPAQUE); dc.SelectObject(m_pBrush); CRect rect; GetClientRect(rect); // cannot have both an icon and text if (m_hIcon) { int nIconX = ::GetSystemMetrics(SM_CXICON); int nIconY = ::GetSystemMetrics(SM_CYICON); rect.left = rect.left + (rect.Width() - nIconX) / 2; rect.top = rect.top + (rect.Height() - nIconY) / 2; dc.DrawIcon(rect.left, rect.top, m_hIcon); } else { dc.SelectObject(&m_font); // get static's text CString strText = _T(""); GetWindowText(strText); UINT nFormat = 0; DWORD dwStyle = GetStyle(); // set DrawText format from static style settings if (m_nHorzAlignment==X_ALIGNHORZ_CENTER) nFormat |= DT_CENTER; else if (m_nHorzAlignment==X_ALIGNHORZ_LEFT) nFormat |= DT_LEFT; else if (m_nHorzAlignment==X_ALIGNHORZ_RIGHT) nFormat |= DT_RIGHT; if (m_nVertAlignment==X_ALIGNVERT_CENTER) // vertical centering ==> single line only nFormat |= DT_VCENTER | DT_SINGLELINE; //else if (m_nVertAlignment==X_ALIGNVERT_TOP) // nFormat |= DT_TOP; //else if (m_nVertAlignment==X_ALIGNVERT_BOTTOM) // nFormat |= DT_BOTTOM; else nFormat |= DT_WORDBREAK; rect.left += m_nXMargin; rect.top += m_nYMargin; dc.DrawText(strText, rect, nFormat); } dc.RestoreDC(-1); }
BOOL CXTPRibbonGroup::SetButtons(UINT* pButtons, int nCount) { BOOL bSeparator = FALSE; CXTPRibbonBar* pRibbonBar = GetRibbonBar(); CWnd* pSite = pRibbonBar->GetSite(); for (int i = 0; i < nCount; i++) { if (pButtons[i] == 0) bSeparator = TRUE; else { XTPControlType controlType = xtpControlButton; XTPButtonStyle buttonStyle = xtpButtonAutomatic; CXTPControl* pControl = NULL; UINT nID = pButtons[i]; XTP_COMMANDBARS_CREATECONTROL cs; if (pSite) { cs.nID = nID; cs.pControl = NULL; cs.bToolBar = TRUE; cs.pMenu = NULL; cs.nIndex = i; cs.strCaption = pRibbonBar->GetTitle(); cs.controlType = controlType; cs.pCommandBar = pRibbonBar; cs.buttonStyle = buttonStyle; if (pSite->SendMessage(WM_XTP_BEFORECREATECONTROL, 0, (LPARAM)&cs) != 0) { pControl = cs.pControl; controlType = cs.controlType; buttonStyle = cs.buttonStyle; nID = cs.nID; } } int nControlPos = m_pControlGroupOption->GetIndex(); if (pControl == NULL) { pControl = pRibbonBar->GetControls()->Add(controlType, nID, NULL, nControlPos); if (pControl) { pControl->SetStyle(buttonStyle); if (controlType == xtpControlPopup) pControl->SetIconId(nID); } } else pRibbonBar->GetControls()->Add(pControl, nID, NULL, nControlPos); if (!pControl) continue; if (bSeparator) { pControl->SetBeginGroup(TRUE); bSeparator = FALSE; } m_arrControls.InsertAt(GetCount(), pControl); pControl->InternalAddRef(); pControl->m_pRibbonGroup = this; pControl->SetHideFlag(xtpHideRibbonTab, !IsVisible()); if (pSite) { cs.pControl = pControl; pSite->SendMessage(WM_XTP_AFTERCREATECONTROL, 0, (LPARAM)&cs); } } } return TRUE; }
LRESULT CSystemTray::OnTrayNotification(UINT wParam, LONG lParam) { //Return quickly if its not for this tray icon if (wParam != m_tnd.uID) return 0L; CMenu menu, *pSubMenu; CWnd* pTarget = AfxGetMainWnd(); if(IsBadReadPtr(pTarget,sizeof(CWnd))) return 0L; // Clicking with right button brings up a context menu if (LOWORD(lParam) == WM_RBUTTONUP) { if (!menu.LoadMenu(m_tnd.uID)) return 0; if (!(pSubMenu = menu.GetSubMenu(0))) return 0; UpdateMenu(pTarget,pSubMenu); // Make chosen menu item the default (bold font) ::SetMenuDefaultItem(pSubMenu->m_hMenu, m_DefaultMenuItemID, m_DefaultMenuItemByPos); // Display and track the popup menu CPoint pos; GetCursorPos(&pos); pTarget->SetForegroundWindow(); ::TrackPopupMenu(pSubMenu->m_hMenu, 0, pos.x, pos.y, 0, pTarget->GetSafeHwnd(), NULL); // BUGFIX: See "PRB: Menus for Notification Icons Don't Work Correctly" pTarget->PostMessage(WM_NULL, 0, 0); menu.DestroyMenu(); } else if (LOWORD(lParam) == WM_LBUTTONDOWN) { // double click received, the default action is to execute default menu item pTarget->SetForegroundWindow(); UINT uItem; if (m_DefaultMenuItemByPos) { uItem = ID_LCLK_TRAY; } else uItem = m_DefaultMenuItemID; if(::IsWindow(pTarget->GetSafeHwnd())) pTarget->SendMessage(WM_COMMAND, uItem, 0); } else if (LOWORD(lParam) == WM_LBUTTONDBLCLK) { // double click received, the default action is to execute default menu item pTarget->SetForegroundWindow(); UINT uItem; if (m_DefaultMenuItemByPos) { uItem = ID_DBLCLK_TRAY; } else uItem = m_DefaultMenuItemID; if(::IsWindow(pTarget->GetSafeHwnd())) pTarget->SendMessage(WM_COMMAND, uItem, 0); } return 1; }
/* DoImageOperation() */ UINT CWallBrowserStretchView::DoImageOperation(UINT nID) { CWaitCursor cursor; UINT nRet = GDI_ERROR; m_nLastOperation = nID; CImage* pImage = NULL; CWallBrowserDoc* pDoc = (CWallBrowserDoc*)GetDocument(); if(pDoc) pImage = pDoc->GetImage(); if(pImage && pImage->GetWidth() > 0 && pImage->GetHeight() > 0) { BOOL bModified = FALSE; if(!UndoPush(nID)) if(::MessageBoxResource(this->m_hWnd,MB_ICONWARNING|MB_YESNO,WALLBROWSER_PROGRAM_NAME,IDS_ERROR_UNDOSTACKFULL)==IDNO) return(TRUE); m_ImageOperation.SetImage(pImage); BOOL bEraseOnInvalidate = FALSE; switch(nID) { // Image->Mirror case ID_IMAGE_MIRROR_H: nRet = m_ImageOperation.MirrorHorizontal(); break; case ID_IMAGE_MIRROR_V: nRet = m_ImageOperation.MirrorVertical(); break; // Image->Rotate case ID_IMAGE_ROTATE_90_LEFT: nRet = m_ImageOperation.Rotate90Left(); bEraseOnInvalidate = TRUE; break; case ID_IMAGE_ROTATE_90_RIGHT: nRet = m_ImageOperation.Rotate90Right(); bEraseOnInvalidate = TRUE; break; case ID_IMAGE_ROTATE_180: nRet = m_ImageOperation.Rotate180(); bEraseOnInvalidate = TRUE; break; // Image->Deskew case ID_IMAGE_DESKEW: nRet = m_ImageOperation.Deskew(); break; // Image->Size case ID_IMAGE_SIZE: nRet = m_ImageOperation.Size(); bEraseOnInvalidate = TRUE; break; // Image->Effects case ID_IMAGE_POSTERIZE: nRet = m_ImageOperation.Posterize(); break; case ID_IMAGE_MOSAIC: nRet = m_ImageOperation.Mosaic(); break; case ID_IMAGE_BLUR: nRet = m_ImageOperation.Blur(); break; case ID_IMAGE_MEDIAN: nRet = m_ImageOperation.Median(); break; case ID_IMAGE_SHARPEN: nRet = m_ImageOperation.Sharpen(); break; case ID_IMAGE_DESPECKLE: nRet = m_ImageOperation.Despeckle(); break; case ID_IMAGE_NOISE: nRet = m_ImageOperation.Noise(); break; case ID_IMAGE_EMBOSS: nRet = m_ImageOperation.Emboss(); break; case ID_IMAGE_EDGE_ENHANCE: nRet = m_ImageOperation.EdgeEnhance(); break; case ID_IMAGE_FIND_EDGE: nRet = m_ImageOperation.FindEdge(); break; case ID_IMAGE_EROSION: nRet = m_ImageOperation.Erosion(); break; case ID_IMAGE_DILATE: nRet = m_ImageOperation.Dilate(); break; case ID_COLOR_HALFTONE: nRet = m_ImageOperation.Halftone(); m_bRebuildPalette = TRUE; break; case ID_COLOR_GRAYSCALE: nRet = m_ImageOperation.Grayscale(); m_bRebuildPalette = TRUE; break; case ID_COLOR_INVERT: nRet = m_ImageOperation.Invert(); m_bRebuildPalette = TRUE; break; case ID_COLOR_BRIGHTNESS: nRet = m_ImageOperation.Brightness(); m_bRebuildPalette = TRUE; break; case ID_COLOR_CONTRAST: nRet = m_ImageOperation.Contrast(); m_bRebuildPalette = TRUE; break; case ID_COLOR_HISTOGRAM_CONTRAST: nRet = m_ImageOperation.HistoContrast(); m_bRebuildPalette = TRUE; break; case ID_COLOR_HUE: nRet = m_ImageOperation.Hue(); m_bRebuildPalette = TRUE; break; case ID_COLOR_SATURATION_H: nRet = m_ImageOperation.SaturationHorizontal(); m_bRebuildPalette = TRUE; break; case ID_COLOR_SATURATION_V: nRet = m_ImageOperation.SaturationVertical(); m_bRebuildPalette = TRUE; break; case ID_COLOR_EQUALIZE: nRet = m_ImageOperation.Equalize(); m_bRebuildPalette = TRUE; break; case ID_COLOR_INTENSITY: nRet = m_ImageOperation.Intensity(); m_bRebuildPalette = TRUE; break; case ID_COLOR_INTENSITY_DETECT: nRet = m_ImageOperation.IntensityDetect(); m_bRebuildPalette = TRUE; break; case ID_COLOR_GAMMA_CORRECTION: nRet = m_ImageOperation.GammaCorrection(); m_bRebuildPalette = TRUE; break; } if(nRet==NO_ERROR) { bModified = TRUE; if(m_nViewType==VIEWTYPE_SCROLL) { POINT point = {0,0}; ScrollToPosition(point); NotifyRanges(); } Invalidate(bEraseOnInvalidate); ((CWallBrowserDoc*)GetDocument())->SetModifiedFlag(TRUE); CWnd* pWnd = AfxGetMainWnd(); if(pWnd) { pWnd->SendMessage(WM_FILE_SAVE_AS,TRUE,0L); pWnd->SendMessage(WM_FILE_SAVE,TRUE,0L); pWnd->SendMessage(WM_FILE_MOVE,TRUE,0L); pWnd->SendMessage(WM_FILE_DELETE,TRUE,0L); } } if(!bModified) UndoPop(); } return(nRet); }
void CRButtonCtrl::OnDraw( CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid) { // note that palette entry 254 is the transparent colour//JW 15Dec98 // TODO: Replace the following code with your own drawing code. if (m_bDrawing) return; GetParentWndInfo(); // need to use an offscreenDC soley because we are //JW 15Dec98 // using dallas's crappy transparent blit function // which leaves pink flashes if not rendered offscreen CDC* pOffScreenDC; //JW 15Dec98 CWnd* parent ; //JW 15Dec98 CBitmap* pOldBitmap; //JW 15Dec98 CBitmap bitmap; //JW 15Dec98 m_bDrawing=TRUE; if (m_hWnd) //JW 15Dec98 parent = GetParent(); //JW 15Dec98 else //JW 15Dec98 parent = NULL ; //JW 15Dec98 if (m_bInit) { m_bInit=FALSE; // if (m_bCloseButton || m_bTickButton) // m_bHelpButton=TRUE; // remove this if it becomes a persistent property // else // m_bHelpButton=FALSE; //DEADCODE JIM 01/06/99 if(!m_bCloseButton && !m_bTickButton) //DEADCODE JIM 01/06/99 m_bHelpButton=FALSE; if (m_bCloseButton) { m_closeUpIcon=LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_BYEUP)); m_closeDownIcon=LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_BYEDOWN)); } if (m_bTickButton) { m_tickUpIcon=LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_TICKUP)); m_tickDownIcon=LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_TICKDOWN)); } if (m_bHelpButton) { m_helpUpIcon=LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_HELPUP)); m_helpDownIcon=LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_HELPDOWN)); } } long filenum=m_NormalFileNum; if (m_PressedFileNum<6 && m_PressedFileNum>0) { if (m_bDisabled && m_PressedFileNum>=4 && !m_bPressed) filenum=m_NormalFileNum+3; else if (m_bDisabled && m_PressedFileNum>=5 && m_bPressed) filenum=m_NormalFileNum+4; else if (m_bDisabled && m_PressedFileNum==4) //JIM 14/04/99 filenum=m_NormalFileNum+3; //JIM 14/04/99 else if (m_LButtonDown && m_PressedFileNum>=2) filenum=m_NormalFileNum+1; else if (m_bPressed && m_PressedFileNum>=3) filenum=m_NormalFileNum+2; } else if (m_PressedFileNum && m_LButtonDown) filenum=m_PressedFileNum; if (m_hWnd && (m_BitMapWithTransparencies || m_TransparentInnerFileNum)) //JW 15/2/98 { if(m_FirstSweep != TRUE) { pOffScreenDC = (CDC*)parent->SendMessage(WM_GETOFFSCREENDC,NULL,NULL); bitmap.CreateCompatibleBitmap(pdc,rcBounds.right,rcBounds.bottom); pOldBitmap=pOffScreenDC->SelectObject(&bitmap); } else { pOffScreenDC = pdc; } FileNum artnum=FIL_NULL; // only need to draw background if we are in transparent mode JW 15Dec98 if (m_hWnd) { long offsetx, offsety ; long offsets; CRect parentrect; CRect rect ; offsets=parent->SendMessage(WM_GETXYOFFSET,NULL,NULL); if(m_FirstSweep != TRUE) artnum = (FileNum)parent->SendMessage(WM_GETARTWORK,NULL,NULL); GetWindowRect(rect); parent->GetWindowRect(parentrect); offsetx=short(offsets & 0x0000FFFF)+parentrect.left-rect.left; offsety=short((offsets & 0xFFFF0000)>>16)+parentrect.top-rect.top; BYTE* pData; if (artnum) { pData = (BYTE*)parent->SendMessage(WM_GETFILE,artnum,NULL); if (pData[0]=='B' && pData[1]=='M') // checks if its a bitmap file//JW 15Dec98 { // now render it... BITMAPFILEHEADER* pFile=(BITMAPFILEHEADER*)pData; BITMAPINFO* pInfo=(BITMAPINFO*)(pData+sizeof(BITMAPFILEHEADER)); pData+=pFile->bfOffBits; VERIFY(SetDIBitsToDevice(pOffScreenDC->m_hDC,offsetx,offsety,pInfo->bmiHeader.biWidth, pInfo->bmiHeader.biHeight, 0,0,0,pInfo->bmiHeader.biHeight,pData,pInfo,DIB_RGB_COLORS)); } parent->SendMessage(WM_RELEASELASTFILE,NULL,NULL);//JW 15Dec98 } } // DrawBitmapWTrans((FileNum)filenum,pOffScreenDC); DrawBitmapWithTransparencies((FileNum)filenum,pOffScreenDC);//JW 15Dec98 } else {
/* EnableMenu() */ void CWallBrowserStretchView::EnableMenu(void) { CWnd* pWnd = AfxGetMainWnd(); CImage* pImage = GetDocument()->GetImage(); LPIMAGEOPERATION pImageOperation; while((pImageOperation = pImage->EnumImageOperation())!=(LPIMAGEOPERATION)NULL) { if(strcmp(pImageOperation->name,"MirrorHorizontal")==0) pWnd->SendMessage(WM_IMAGE_MIRROR_H,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"MirrorVertical")==0) pWnd->SendMessage(WM_IMAGE_MIRROR_V,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Rotate90Left")==0) pWnd->SendMessage(WM_IMAGE_ROTATE_90_LEFT,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Rotate90Right")==0) pWnd->SendMessage(WM_IMAGE_ROTATE_90_RIGHT,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Rotate180")==0) pWnd->SendMessage(WM_IMAGE_ROTATE_180,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Deskew")==0) pWnd->SendMessage(WM_IMAGE_DESKEW,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Size")==0) pWnd->SendMessage(WM_IMAGE_SIZE,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Posterize")==0) pWnd->SendMessage(WM_IMAGE_POSTERIZE,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Mosaic")==0) pWnd->SendMessage(WM_IMAGE_MOSAIC,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Blur")==0) pWnd->SendMessage(WM_IMAGE_BLUR,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Median")==0) pWnd->SendMessage(WM_IMAGE_MEDIAN,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Sharpen")==0) pWnd->SendMessage(WM_IMAGE_SHARPEN,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Despeckle")==0) pWnd->SendMessage(WM_IMAGE_DESPECKLE,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Noise")==0) pWnd->SendMessage(WM_IMAGE_NOISE,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Emboss")==0) pWnd->SendMessage(WM_IMAGE_EMBOSS,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"EdgeEnhance")==0) pWnd->SendMessage(WM_IMAGE_EDGEENHANCE,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"FindEdge")==0) pWnd->SendMessage(WM_IMAGE_FINDEDGE,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Erosion")==0) pWnd->SendMessage(WM_IMAGE_EROSION,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Dilate")==0) pWnd->SendMessage(WM_IMAGE_DILATE,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Halftone")==0) pWnd->SendMessage(WM_COLOR_HALFTONE,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Grayscale")==0) pWnd->SendMessage(WM_COLOR_GRAYSCALE,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Invert")==0) pWnd->SendMessage(WM_COLOR_INVERT,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Brightness")==0) pWnd->SendMessage(WM_COLOR_BRIGHTNESS,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Contrast")==0) pWnd->SendMessage(WM_COLOR_CONTRAST,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"HistoContrast")==0) pWnd->SendMessage(WM_COLOR_HISTOGRAM_CONTRAST,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Hue")==0) pWnd->SendMessage(WM_COLOR_HUE,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"SaturationHorizontal")==0) pWnd->SendMessage(WM_COLOR_SATURATION_H,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"SaturationVertical")==0) pWnd->SendMessage(WM_COLOR_SATURATION_V,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Equalize")==0) pWnd->SendMessage(WM_COLOR_EQUALIZE,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"Intensity")==0) pWnd->SendMessage(WM_COLOR_INTENSITY,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"IntensityDetect")==0) pWnd->SendMessage(WM_COLOR_INTENSITY_DETECT,pImageOperation->flag,0L); else if(strcmp(pImageOperation->name,"GammaCorrection")==0) pWnd->SendMessage(WM_COLOR_GAMMA_CORRECTION,pImageOperation->flag,0L); } }
void CXTPEditListBox::EditListItem(BOOL bNewItem) { if (!m_bEnableEdit) return; CWnd* pOwner = GetOwner(); ASSERT(pOwner); if (!pOwner) return; // Turn off redraw until we are ready to // create the edit field. SetRedraw(FALSE); // flush the item text string. m_strItemText = m_strItemDefaultText; // if this is a new item, add a temporary string // to the list box and set the selection to it. This // is where the in place edit box will appear. if (bNewItem || GetCurSel() == LB_ERR) { pOwner->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), LBN_XTP_PRENEWITEM), (LPARAM)m_hWnd); m_nIndex = AddString(m_strItemText); SetCurSel(m_nIndex); m_bNewItem = TRUE; } // get the text for the currently selected // item and set the new flag to FALSE. else { m_bNewItem = FALSE; int iCount = GetCount(); m_nIndex = GetCurSel(); if (m_nIndex >= iCount || iCount <= 0) { m_nIndex = LB_ERR; SetCurSel(LB_ERR); // turn redraw back. SetRedraw(TRUE); Invalidate(); return; } GetEditItemText(); } // turn redraw back. SetRedraw(TRUE); Invalidate(); if (m_dwLStyle & LBS_XTP_BROWSE_ONLY) { // Send notification to owner. pOwner->SendMessage( WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), LBN_XTP_ONBROWSE), (LPARAM)m_hWnd ); return; } // Get the size of the currently selected item. CRect rcItem; GetItemRect(m_nIndex, rcItem); rcItem.InflateRect(-2, 2); // create the edit box. m_pItemEdit = CreateEditControl(rcItem); // if defined, set the filter for the item edit control. if (!m_strFilter.IsEmpty()) { m_pItemEdit->SetDlgFilter(m_strFilter); } if (!m_strInitialDir.IsEmpty()) { m_pItemEdit->SetDlgInitialDir(m_strInitialDir); } }
/* DisableMenu() */ void CWallBrowserStretchView::DisableMenu(void) { CWnd* pWnd = AfxGetMainWnd(); pWnd->SendMessage(WM_IMAGE_MIRROR_H,FALSE,0L); pWnd->SendMessage(WM_IMAGE_MIRROR_V,FALSE,0L); pWnd->SendMessage(WM_IMAGE_ROTATE_90_LEFT,FALSE,0L); pWnd->SendMessage(WM_IMAGE_ROTATE_90_RIGHT,FALSE,0L); pWnd->SendMessage(WM_IMAGE_ROTATE_180,FALSE,0L); pWnd->SendMessage(WM_IMAGE_DESKEW,FALSE,0L); pWnd->SendMessage(WM_IMAGE_SIZE,FALSE,0L); pWnd->SendMessage(WM_IMAGE_POSTERIZE,FALSE,0L); pWnd->SendMessage(WM_IMAGE_MOSAIC,FALSE,0L); pWnd->SendMessage(WM_IMAGE_BLUR,FALSE,0L); pWnd->SendMessage(WM_IMAGE_MEDIAN,FALSE,0L); pWnd->SendMessage(WM_IMAGE_SHARPEN,FALSE,0L); pWnd->SendMessage(WM_IMAGE_DESPECKLE,FALSE,0L); pWnd->SendMessage(WM_IMAGE_NOISE,FALSE,0L); pWnd->SendMessage(WM_IMAGE_EMBOSS,FALSE,0L); pWnd->SendMessage(WM_IMAGE_EDGEENHANCE,FALSE,0L); pWnd->SendMessage(WM_IMAGE_FINDEDGE,FALSE,0L); pWnd->SendMessage(WM_IMAGE_EROSION,FALSE,0L); pWnd->SendMessage(WM_IMAGE_DILATE,FALSE,0L); pWnd->SendMessage(WM_COLOR_HALFTONE,FALSE,0L); pWnd->SendMessage(WM_COLOR_GRAYSCALE,FALSE,0L); pWnd->SendMessage(WM_COLOR_INVERT,FALSE,0L); pWnd->SendMessage(WM_COLOR_BRIGHTNESS,FALSE,0L); pWnd->SendMessage(WM_COLOR_CONTRAST,FALSE,0L); pWnd->SendMessage(WM_COLOR_HISTOGRAM_CONTRAST,FALSE,0L); pWnd->SendMessage(WM_COLOR_HUE,FALSE,0L); pWnd->SendMessage(WM_COLOR_SATURATION_H,FALSE,0L); pWnd->SendMessage(WM_COLOR_SATURATION_V,FALSE,0L); pWnd->SendMessage(WM_COLOR_EQUALIZE,FALSE,0L); pWnd->SendMessage(WM_COLOR_INTENSITY,FALSE,0L); pWnd->SendMessage(WM_COLOR_INTENSITY_DETECT,FALSE,0L); pWnd->SendMessage(WM_COLOR_GAMMA_CORRECTION,FALSE,0L); }
// //--------------------------------------------------------- // BOOL CEasyBDoc::WriteFile(CArchive& ar) { pFile = ar.GetFile(); ASSERT(pFile != NULL); int i,j,numCards; CString strTemp,strHand; // write the data // //----------------------------------------------------- // // first the file ID // WriteBlockHeader(BLOCK_FILEINFO); WriteString(ITEM_PROGRAM_ID,(LPCTSTR)theApp.GetValue(tstrProgramTitle)); WriteInt(ITEM_MAJOR_VERSIONNO,theApp.GetValue(tnProgramMajorVersion)); WriteInt(ITEM_MINOR_VERSIONNO,theApp.GetValue(tnProgramMinorVersion)); WriteInt(ITEM_INCREMENT_VERSIONNO,theApp.GetValue(tnProgramIncrementVersion)); WriteInt(ITEM_BUILD_NUMBER,theApp.GetValue(tnProgramBuildNumber)); WriteString(ITEM_BUILD_DATE,(LPCTSTR)theApp.GetValue(tstrProgramBuildDate)); CTime time = CTime::GetCurrentTime(); strTemp.Format(" %s",(LPCTSTR)time.Format("%c")); WriteString(ITEM_FILE_DATE,strTemp); SkipLine(); // then the file description WriteBlockHeader(BLOCK_FILEDESC); WriteString(ITEM_NONE,m_strFileDescription); // SkipLine(); // //----------------------------------------------------- // // hand information // WriteBlockHeader(BLOCK_HANDINFO); // first the current hand for(i=0;i<4;i++) { numCards = PLAYER(i).GetNumCards(); strHand.Empty(); for(j=0;j<numCards;j++) { strHand += PLAYER(i).GetCardByPosition(j)->GetName(); strHand += " "; } switch(i) { case NORTH: WriteString(ITEM_CURRHAND_NORTH,strHand); break; case EAST: WriteString(ITEM_CURRHAND_EAST,strHand); break; case SOUTH: WriteString(ITEM_CURRHAND_SOUTH,strHand); break; case WEST: WriteString(ITEM_CURRHAND_WEST,strHand); break; } } // then the original hand for(i=0;i<4;i++) { if (pVIEW->GetCurrentMode() == CEasyBView::MODE_CARDLAYOUT) { numCards = PLAYER(i).GetNumCards(); strHand.Empty(); for(j=0;j<numCards;j++) { strHand += PLAYER(i).GetCardByPosition(j)->GetName(); strHand += " "; } } else { strHand.Empty(); for(j=0;j<13;j++) { strHand += PLAYER(i).GetInitialHandCard(j)->GetName(); strHand += " "; } } switch(i) { case NORTH: WriteString(ITEM_ORIGHAND_NORTH,strHand); break; case EAST: WriteString(ITEM_ORIGHAND_EAST,strHand); break; case SOUTH: WriteString(ITEM_ORIGHAND_SOUTH,strHand); break; case WEST: WriteString(ITEM_ORIGHAND_WEST,strHand); break; } } SkipLine(); // //----------------------------------------------------- // // current round information // WriteBlockHeader(BLOCK_ROUNDINFO); /* WriteString(ITEM_CURR_ROUND_LEAD, PositionToString(m_nRoundLead)); // WriteInt(ITEM_NUM_CARDS_PLAYED_IN_ROUND, m_numCardsPlayedInRound); // tricks in current round for(i=0;i<m_numCardsPlayedInRound;i++) WriteString(ITEM_TRICK_CARD_1+i,m_pCurrTrick[i]->GetName()); */ // SkipLine(); // //----------------------------------------------------- // // game status info // WriteBlockHeader(BLOCK_GAMEINFO); WriteInt(ITEM_VIEW_STATUS_CODE,pVIEW->GetCurrentMode()); WriteBool(ITEM_RUBBER_IN_PROGRESS,theApp.IsRubberInProgress()); WriteBool(ITEM_GAME_IN_PROGRESS,theApp.IsGameInProgress()); WriteBool(ITEM_BIDDING_IN_PROGRESS,theApp.IsBiddingInProgress()); WriteBool(ITEM_HANDS_DEALT,m_bHandsDealt); strTemp.Format("%s",SuitToString(m_nContractSuit)); WriteString(ITEM_CONTRACT_SUIT,strTemp); WriteInt(ITEM_CONTRACT_LEVEL,m_nContractLevel); WriteInt(ITEM_CONTRACT_MODIFIER, m_bRedoubled? 2 : m_bDoubled? 1 : 0); WriteString(ITEM_DEALER,PositionToString(m_nDealer)); WriteInt(ITEM_NUM_BIDS,m_numBidsMade); // declarer & bidding history strTemp.Empty(); int nIndex = 0; for(i=0;i<=m_numBidsMade;i++) { strTemp += BidToShortString(m_nBiddingHistory[i]); strTemp += " "; } WriteString(ITEM_DECLARER,PositionToString(m_nDeclarer)); WriteString(ITEM_BIDDING_HISTORY,strTemp); SkipLine(); // //----------------------------------------------------- // // game play record // WriteBlockHeader(BLOCK_GAMERECORD); if (m_bSaveIntermediatePositions) { // write the # tricks played int numTricks = m_numTricksPlayed; // see if the current trick is incomplete if ((pDOC->GetNumCardsPlayedInRound() > 0) && (numTricks < 13)) numTricks++; WriteInt(ITEM_NUM_TRICKS_PLAYED,numTricks); // # tricks won by each side WriteInt(ITEM_NUM_TRICKS_WON_NS,m_numTricksWon[0]); WriteInt(ITEM_NUM_TRICKS_WON_EW,m_numTricksWon[1]); WriteString(ITEM_GAME_LEAD,PositionToString(m_nGameLead)); // and the record of tricks for(i=0;i<13;i++) { if (i <= m_numTricksPlayed) { strTemp.Empty(); strTemp += PositionToString(m_nTrickLead[i]); strTemp += " "; for(j=0;j<4;j++) { CCard* pCard = NULL; if (i < m_numTricksPlayed) pCard = m_pGameTrick[i][j]; else pCard = m_pCurrTrick[j]; // if (pCard != NULL) { strTemp += pCard->GetName(); strTemp += " "; } else { strTemp += "-- "; } } strTemp += PositionToString(m_nTrickWinner[i]); } else { strTemp = ""; } WriteString(ITEM_GAME_TRICK_1+i,strTemp); } } else { WriteInt(ITEM_NUM_TRICKS_PLAYED, 0); } // SkipLine(); // //----------------------------------------------------- // // match info // if (theApp.IsRubberInProgress()) { // write block header WriteBlockHeader(BLOCK_MATCHINFO); // write out scores WriteInt(ITEM_SCORE_NS_BONUS, m_nBonusScore[NORTH_SOUTH]); WriteInt(ITEM_SCORE_NS_GAME0, m_nGameScore[0][NORTH_SOUTH]); WriteInt(ITEM_SCORE_NS_GAME1, m_nGameScore[1][NORTH_SOUTH]); WriteInt(ITEM_SCORE_NS_GAME2, m_nGameScore[2][NORTH_SOUTH]); WriteInt(ITEM_SCORE_NS_GAMES_WON, m_numGamesWon[NORTH_SOUTH]); // WriteInt(ITEM_SCORE_EW_BONUS, m_nBonusScore[EAST_WEST]); WriteInt(ITEM_SCORE_EW_GAME0, m_nGameScore[0][EAST_WEST]); WriteInt(ITEM_SCORE_EW_GAME1, m_nGameScore[1][EAST_WEST]); WriteInt(ITEM_SCORE_EW_GAME2, m_nGameScore[2][EAST_WEST]); WriteInt(ITEM_SCORE_EW_GAMES_WON, m_numGamesWon[EAST_WEST]); // write out current game WriteInt(ITEM_CURRENT_GAME_INDEX, m_nCurrGame+1); // write out score record int numBonusScoreRecords = m_strArrayBonusPointsRecord.GetSize(); for(int i=0;i<numBonusScoreRecords;i++) WriteString(ITEM_BONUS_SCORE_RECORD, WrapInQuotes(m_strArrayBonusPointsRecord.GetAt(i))); // int numGameScoreRecords = m_strArrayTrickPointsRecord.GetSize(); for(i=0;i<numGameScoreRecords;i++) WriteString(ITEM_GAME_SCORE_RECORD, WrapInQuotes(m_strArrayTrickPointsRecord.GetAt(i))); // SkipLine(); } // //----------------------------------------------------- // // misc info // WriteBlockHeader(BLOCK_MISCINFO); WriteBool(ITEM_AUTOSHOW_COMMENTS,m_bShowCommentsUponOpen); WriteBool(ITEM_AUTOSHOW_BID_HISTORY,m_bShowBidHistoryUponOpen); WriteBool(ITEM_AUTOSHOW_PLAY_HISTORY,m_bShowPlayHistoryUponOpen); WriteBool(ITEM_AUTOSHOW_ANALYSES,m_bShowAnalysesUponOpen); SkipLine(); // //----------------------------------------------------- // // file comments // WriteBlockHeader(BLOCK_COMMENTS); // get the current file comments text if the dialog is open CWnd* pWnd = pMAINFRAME->GetDialog(twFileCommentsDialog); if (pWnd) pWnd->SendMessage(WM_COMMAND, WMS_UPDATE_TEXT, TRUE); WriteString(0,m_strFileComments); SkipLine(); // //----------------------------------------------------- // // PlayerAnalysis, if appropriate // for(i=0;i<4;i++) { if (m_bSavePlayerAnalysis[i]) { // save out the player analysis text WriteBlockHeader(BLOCK_PLAYER_ANALYSIS + i); WriteString(0, m_pPlayer[i]->GetValueString(tszAnalysis)); SkipLine(); } } // //----------------------------------------------------- // // All done // ar.Flush(); return TRUE; }
BOOL ZListTip::PreTranslateMessage( MSG *pMsg ) { CWnd *pWnd; int nHitTest; switch ( pMsg->message ) { case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: { POINTS pts = MAKEPOINTS( pMsg->lParam ); CPoint pt; pt.x = pts.x; pt.y = pts.y; #ifdef DEBUG_ALL TracePoint( "ZListTip::OnButtonDown: ", pt ); #endif ClientToScreen( &pt ); pWnd = WindowFromPoint( pt ); if ( pWnd == 0 ) return( CWnd::PreTranslateMessage( pMsg ) ); if ( pWnd == this ) pWnd = m_pParentWnd; nHitTest = (int) pWnd->SendMessage( WM_NCHITTEST, 0, MAKELONG( pt.x, pt.y ) ); if ( nHitTest == HTCLIENT ) { if ( pMsg->message == WM_LBUTTONDOWN ) { zULONG ulTime = GetCurrentTime( ); zULONG ulDblclkTime = GetDoubleClickTime( ); if ( m_ulDblClickInterval == 0 ) { m_ulDblClickInterval = ulTime; m_ptStart = pt; } else { if ( ulTime - m_ulDblClickInterval > ulDblclkTime || m_ptStart.x - pt.x > g_lDblClkX || pt.x - m_ptStart.x > g_lDblClkX || m_ptStart.y - pt.y > g_lDblClkY || pt.y - m_ptStart.y > g_lDblClkY ) { m_ptStart = pt; m_ulDblClickInterval = ulTime; } else { pMsg->message = WM_LBUTTONDBLCLK; m_ulDblClickInterval = 0; m_ptStart.x = m_ptStart.y = 0; } } } pWnd->ScreenToClient( &pt ); pMsg->lParam = MAKELONG( pt.x, pt.y ); } else { switch ( pMsg->message ) { case WM_LBUTTONDOWN: { pMsg->message = WM_NCLBUTTONDOWN; break; } case WM_RBUTTONDOWN: { pMsg->message = WM_NCRBUTTONDOWN; break; } case WM_MBUTTONDOWN: { pMsg->message = WM_NCMBUTTONDOWN; break; } } pMsg->wParam = nHitTest; pMsg->lParam = MAKELONG( pt.x, pt.y ); } Hide( ); pWnd->PostMessage( pMsg->message, pMsg->wParam, pMsg->lParam ); return( TRUE ); } case WM_KEYDOWN: case WM_SYSKEYDOWN: { Hide( ); m_pParentWnd->PostMessage( pMsg->message, pMsg->wParam, pMsg->lParam ); return( TRUE ); } } if ( GetFocus( ) == 0 ) { Hide( ); return( TRUE ); } return( CWnd::PreTranslateMessage( pMsg ) ); }