?? chameleonctl.cpp
字號:
RelayEvent( WM_MOUSEMOVE, (WPARAM)nFlags,
MAKELPARAM(LOWORD(point.x), LOWORD(point.y)) );
//COleControl::OnMouseMove(nFlags, point);
}
void CChameleonCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)
{
if( m_bEnabled )
{
//按下鼠標左鍵時重繪控件
Redraw( 1, false );
//屏蔽掉雙擊之后的OnLButtonUp事件
m_bMouseDBClk = true;
FireMouseDown( 0, 0, point.x, point.y );
}
//COleControl::OnLButtonDblClk(nFlags, point);
}
void CChameleonCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if( m_bEnabled )
{
USHORT usKey = nChar;
short sShift = 0;
m_nLastKey = nChar;
if( m_nLastKey == 32 )
{
//響應空格鍵
Redraw( 1, false );
}
else if( m_nLastKey == 39 || m_nLastKey == 40 )
{
//right and down arrows
//When use in VC and VB,don't need to handle this
}
else if( m_nLastKey == 37 || m_nLastKey == 38 )
{
//left and up arrows
//When use in VC and VB,don't need to handle this
}
FireKeyDown( &usKey, sShift );
}
//COleControl::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CChameleonCtrl::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if( m_bEnabled )
{
USHORT usKey = nChar;
short sShift = 0;
if( m_nLastKey == 32 && usKey == 32 )
{
//響應空格鍵
if( m_bPress )
{
m_bPressState = !m_bPressState;
}
if( m_bPressState )
{
Redraw( 1, true );
}
else
{
Redraw( 0, true );
}
FireClick();
}
FireKeyUp( &usKey, sShift );
FireKeyPress( &usKey );
}
//COleControl::OnKeyUp(nChar, nRepCnt, nFlags);
}
void CChameleonCtrl::OnSize(UINT nType, int cx, int cy)
{
if( !m_bStretch && m_lButtonType == 13 )
{
//在Stretch為false,且按鈕類型為圖片的時候,
//將按鈕設為圖片的大小
int nWidth;
int nHeight;
GetPictureSize( 1, nWidth, nHeight );
if( nWidth == 0 || nHeight == 0 )
{
SetControlSize( 32, 32 );
}
else
{
SetControlSize( nWidth, nHeight );
}
}
else
{
COleControl::OnSize(nType, cx, cy);
}
//保存按鈕的大小
GetClientRect( m_recFocusRect );
m_nWidth = m_recFocusRect.Width();
m_nHeight = m_recFocusRect.Height();
//計算焦點框的大小
if( m_lButtonType == 7 )
{
InflateRect( m_recFocusRect, -3, -3 );
}
else if( m_lButtonType == 12 )
{
InflateRect( m_recFocusRect, -5, -5 );
OffsetRect( m_recFocusRect, 1, 1 );
}
else
{
InflateRect( m_recFocusRect, -4, -4 );
}
//根據按鈕類型創建按鈕繪畫區域
MakeRegion( m_rgnControl );
SetWindowRgn( m_rgnControl, true );
}
void CChameleonCtrl::OnRButtonUp(UINT nFlags, CPoint point)
{
//丟棄鼠標右鍵和中鍵的響應
//COleControl::OnRButtonUp(nFlags, point);
}
void CChameleonCtrl::OnRButtonDown(UINT nFlags, CPoint point)
{
//丟棄鼠標右鍵和中鍵的響應
//COleControl::OnRButtonDown(nFlags, point);
}
void CChameleonCtrl::OnMButtonUp(UINT nFlags, CPoint point)
{
//丟棄鼠標右鍵和中鍵的響應
//COleControl::OnMButtonUp(nFlags, point);
}
void CChameleonCtrl::OnMButtonDown(UINT nFlags, CPoint point)
{
//丟棄鼠標右鍵和中鍵的響應
//COleControl::OnMButtonDown(nFlags, point);
}
/////////////////////////////////////////////////////////////////////////////
// CChameleonCtrl::AboutBox - Display an "About" box to the user
void CChameleonCtrl::AboutBox()
{
CDialog dlgAbout(IDD_ABOUTBOX_CHAMELEON);
dlgAbout.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CChameleonCtrl message handlers
void CChameleonCtrl::OnBackColorChanged()
{
if( IsWindow( m_hWnd ) )
{
Redraw( m_nStatus, true );
}
}
void CChameleonCtrl::OnForeColorChanged()
{
if( IsWindow( m_hWnd ) )
{
Redraw( m_nStatus, true );
}
}
void CChameleonCtrl::OnTextChanged()
{
CString strCaption = InternalGetText();
int nFind = strCaption.Find( "&" );
if( nFind != -1 )
{
if( strCaption.GetLength() > nFind + 1 )
{
m_ucAccessKey = (BYTE)strCaption.GetAt( nFind + 1 );
}
else
{
m_ucAccessKey = 0;
}
}
else
{
m_ucAccessKey = 0;
}
if( IsWindow( m_hWnd ) )
{
Redraw( m_nStatus, true );
}
}
void CChameleonCtrl::OnEnabledChanged()
{
if( IsWindow( m_hWnd ) )
{
Redraw( m_nStatus, true );
}
}
void CChameleonCtrl::OnFontChanged()
{
if( IsWindow( m_hWnd ) )
{
Redraw( m_nStatus, true );
}
}
long CChameleonCtrl::GetMousePointer()
{
return m_lMousePointer;
}
void CChameleonCtrl::SetMousePointer(long nNewValue)
{
m_lMousePointer = nNewValue;
if( ( m_lMousePointer < 0 || m_lMousePointer > 15 )
&& m_lMousePointer != 99 )
{
m_lMousePointer = 0;
}
SetModifiedFlag();
}
LPPICTUREDISP CChameleonCtrl::GetMouseIcon()
{
return m_phdMouseIcon.GetPictureDispatch();
}
void CChameleonCtrl::SetMouseIcon(LPPICTUREDISP newValue)
{
m_phdMouseIcon.SetPictureDispatch(newValue);
SetModifiedFlag();
}
LPPICTUREDISP CChameleonCtrl::GetPicture()
{
return m_phdPicture.GetPictureDispatch();
}
void CChameleonCtrl::SetPicture(LPPICTUREDISP newValue)
{
m_phdPicture.SetPictureDispatch(newValue);
if( IsWindow( m_hWnd ) )
{
Redraw( m_nStatus, true );
}
SetModifiedFlag();
}
long CChameleonCtrl::GetButtonType()
{
return m_lButtonType;
}
void CChameleonCtrl::SetButtonType(long newValue)
{
m_lButtonType = newValue;
if( m_lButtonType < 1 || m_lButtonType > 13 )
{
m_lButtonType = 3;
}
if( IsWindow( m_hWnd ) )
{
MakeRegion( m_rgnControl );
SetWindowRgn( m_rgnControl, true );
Redraw( m_nStatus, true );
}
SetModifiedFlag();
}
long CChameleonCtrl::GetColorScheme()
{
return m_lColorScheme;
}
void CChameleonCtrl::SetColorScheme(long nNewValue)
{
m_lColorScheme = nNewValue;
if( m_lButtonType < 1 || m_lButtonType > 4 )
{
m_lButtonType = 1;
}
if( IsWindow( m_hWnd ) )
{
Redraw( m_nStatus, true );
}
SetModifiedFlag();
}
BOOL CChameleonCtrl::GetPress()
{
return m_bPress;
}
void CChameleonCtrl::SetPress(BOOL bNewValue)
{
m_bPress = bNewValue;
if( IsWindow( m_hWnd ) )
{
Redraw( m_nStatus, true );
}
SetModifiedFlag();
}
BOOL CChameleonCtrl::GetShowFocusRect()
{
return m_bShowFocusRect;
}
void CChameleonCtrl::SetShowFocusRect(BOOL bNewValue)
{
m_bShowFocusRect = bNewValue;
if( IsWindow( m_hWnd ) )
{
Redraw( m_nStatus, true );
}
SetModifiedFlag();
}
BOOL CChameleonCtrl::GetStretch()
{
return m_bStretch;
}
void CChameleonCtrl::SetStretch(BOOL bNewValue)
{
CRect recClient;
m_bStretch = bNewValue;
if( IsWindow( m_hWnd ) )
{
GetClientRect( recClient );
OnSize( 0, recClient.Width(), recClient.Height() );
Redraw( m_nStatus, true );
}
SetModifiedFlag();
}
BSTR CChameleonCtrl::GetToolTipText()
{
return m_strTipText.AllocSysString();
}
void CChameleonCtrl::SetToolTipText(LPCTSTR lpszNewValue)
{
m_strTipText = lpszNewValue;
if( AmbientUserMode() && m_ttpMes.m_hWnd != NULL )
{
if( m_strTipText.GetLength() > 0 )
{
m_ttpMes.Activate( true );
m_ttpMes.UpdateTipText( m_strTipText, this );
}
else
{
m_ttpMes.Activate( false );
}
}
SetModifiedFlag();
}
OLE_COLOR CChameleonCtrl::GetBackOverColor()
{
return m_lBackOverColor;
}
void CChameleonCtrl::SetBackOverColor(OLE_COLOR nNewValue)
{
m_lBackOverColor = nNewValue;
if( IsWindow( m_hWnd ) )
{
Redraw( m_nStatus, true );
}
SetModifiedFlag();
}
OLE_COLOR CChameleonCtrl::GetForeOverColor()
{
return m_lForeOverColor;
}
void CChameleonCtrl::SetForeOverColor(OLE_COLOR nNewValue)
{
m_lForeOverColor = nNewValue;
if( IsWindow( m_hWnd ) )
{
Redraw( m_nStatus, true );
}
SetModifiedFlag();
}
long CChameleonCtrl::GetTextEffect()
{
return m_lTextEffect;
}
void CChameleonCtrl::SetTextEffect(long nNewValue)
{
m_lTextEffect = nNewValue;
if( m_lTextEffect < 0 || m_lTextEffect > 3 )
{
m_lTextEffect = 0;
}
if( IsWindow( m_hWnd ) )
{
Redraw( m_nStatus, true );
}
SetModifiedFlag();
}
BOOL CChameleonCtrl::GetHandPointer()
{
return m_bHandPointer;
}
void CChameleonCtrl::SetHandPointer(BOOL bNewValue)
{
m_bHandPointer = bNewValue;
SetModifiedFlag();
}
LPPICTUREDISP CChameleonCtrl::GetDownPicture()
{
return m_phdDownPicture.GetPictureDispatch();
}
void CChameleonCtrl::SetDownPicture(LPPICTUREDISP newValue)
{
m_phdDownPicture.SetPictureDispatch(newValue);
SetModifiedFlag();
}
LPPICTUREDISP CChameleonCtrl::GetOverPicture()
{
return m_phdOverPicture.GetPictureDispatch();
return NULL;
}
void CChameleonCtrl::SetOverPicture(LPPICTUREDISP newValue)
{
m_phdOverPicture.SetPictureDispatch(newValue);
SetModifiedFlag();
}
LPPICTUREDISP CChameleonCtrl::GetDisablePicture()
{
return m_phdDisablePicture.GetPictureDispatch();
return NULL;
}
void CChameleonCtrl::SetDisablePicture(LPPICTUREDISP newValue)
{
m_phdDisablePicture.SetPictureDispatch(newValue);
SetModifiedFlag();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -