void CColoredButton::OnClicked() { if( m_iColorIndex != -1) return; // colored button can call eather custom palette window for choosing colors (where variable // to recieve result color is pointed with _pcolColorToSet) eather trough MFC-provided // color picker if( m_ptPickerType == PT_CUSTOM) { // instantiate new choose color palette window CColorPaletteWnd *pColorPalette = new CColorPaletteWnd; // calculate palette window's rectangle CRect rectWindow; CPoint ptMousePoint( 0,0); ClientToScreen( &ptMousePoint); // set screen coordinates of LU point of clicked tool button rectWindow.left = ptMousePoint.x; rectWindow.top = ptMousePoint.y - 200; rectWindow.right = rectWindow.left + 100; rectWindow.bottom = ptMousePoint.y; // create window BOOL bResult = pColorPalette->CreateEx( WS_EX_TOOLWINDOW, NULL, "Palette", WS_CHILD|WS_POPUP|WS_VISIBLE, rectWindow.left, rectWindow.top, rectWindow.Width(), rectWindow.Height(), m_hWnd, NULL, NULL); if( !bResult) { AfxMessageBox( "Error: Failed to create color palette"); return; } // initialize canvas for active texture button _pGfx->CreateWindowCanvas( pColorPalette->m_hWnd, &pColorPalette->m_pViewPort, &pColorPalette->m_pDrawPort); // get new color _pcolColorToSet = &m_colColor; } // request was made for MFC-type color picker else { COLORREF TmpColor = CLRF_CLR( m_colColor); if( MyChooseColor( TmpColor, *GetParent())) { m_bMixedColor = FALSE; // restore alpha value m_colColor = CLR_CLRF( TmpColor) | m_colColor&0x000000FF; Invalidate( FALSE); } } // invalidate parent dialog if( m_pwndParentDialog != NULL) m_pwndParentDialog->UpdateData( TRUE); }
void CColoredButton::OnClicked() { if( m_iColorIndex != -1) return; // colored button can call eather custom palette window for choosing colors (where variable // to receive result color is pointed with _pcolColorToSet) eather trough MFC-provided // color picker ASSERT( m_ptPickerType != PT_CUSTOM); COLORREF TmpColor = CLRF_CLR( m_colColor); if( MyChooseColor( TmpColor, *GetParent())) { m_bMixedColor = FALSE; // restore alpha value m_colColor = CLR_CLRF( TmpColor) | m_colColor&0x000000FF; OnColorChange(); Invalidate( FALSE); } // invalidate parent dialog if( m_pwndParentDialog != NULL) m_pwndParentDialog->UpdateData( TRUE); }
void CWndAnimationFrames::OnLButtonDown(UINT nFlags, CPoint point) { // get clicked frame INDEX iFrame = point.x/FRAME_BOX_WIDTH+m_iStartingFrame; // return if frame is not visible (clicked beyond last frame) if( !IsFrameVisible(iFrame)) return; Invalidate(FALSE); // if clicked frame was not selected previously if( iFrame != m_iSelectedFrame) { // select clicked frame m_iSelectedFrame = iFrame; m_pParentDlg->UpdateData( FALSE); // return return; } // select clicked frame m_iSelectedFrame = iFrame; m_pParentDlg->UpdateData( FALSE); // get curently selected light animation combo member INDEX iLightAnimation = m_pParentDlg->GetSelectedLightAnimation(); // get animation data CAnimData *pAD = m_pParentDlg->m_padAnimData; COLORREF newFrameColor = CLRF_CLR( pAD->GetFrame(iLightAnimation, iFrame)); if( MyChooseColor( newFrameColor, *m_pParentDlg) ) { // set new key frame value pAD->SetFrame(iLightAnimation, iFrame, CLR_CLRF(newFrameColor)|0x000000FF); // spread frames m_pParentDlg->SpreadFrames(); // redraw window Invalidate( FALSE); m_pParentDlg->UpdateData( FALSE); m_pParentDlg->m_bChanged = TRUE; } CWnd::OnLButtonDown(nFlags, point); }