📄 tbareditctrlbase.cpp
字号:
//-----------------------------------------------------------------------------
// (c) 2002 by Basler Vision Technologies
// Section: Vision Components
// Project: BCAM
// $Header: TBarEditCtrlBase.cpp, 4, 26.11.2002 18:49:16, Happe, A.$
//-----------------------------------------------------------------------------
/**
\file TBarEditCtrlBase.cpp
\brief implementation of the CTBarEditCtrlBase class.
*/
//////////////////////////////////////////////////////////////////////
#include <atlbase.h>
#include <atlapp.h>
extern CAppModule _Module;
#include <atlwin.h>
#include "stdio.h"
#include "limits.h"
#include "TBarEditCtrlBase.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
CTBarEditCtrlBase::CTBarEditCtrlBase(bool bPostMsgEnabled /*= true*/, bool bLiveUpdateEnabled /* = true */)
{
m_bPostMsgEnabled = bPostMsgEnabled;
m_bLiveUpdateEnabled = bLiveUpdateEnabled;
m_pWndParent = NULL;
m_nPostMsgID = 0;
m_nValue = 0;
m_dValue = 0.0;
m_nFormatWidth = 1;
m_nFormatPrecision = 1;
m_bSkipEnChange = false;
}
CTBarEditCtrlBase::~CTBarEditCtrlBase()
{
CTBarCtrlBase::Detach();
}
//////////////////////////////////////////////////////////////////////
// Attach
/**********
* Attach - Attach parent, Edit and TrackBar control to your instance of this class
*
* \param pParent Pointer to parent window
* \param nEditCtrlID ID of Edit control to be attached
* \param nTBarCtrlID ID of TrackBar control to be attached
* \param nPostMsgID ID of Message which will be posted instead of the ID of the
* Edit control
*/
void CTBarEditCtrlBase::Attach(CWindow *pParent, int nEditCtrlID, int nTBarCtrlID, int nPostMsgID /*= 0*/)
{
ATLASSERT(m_pWndParent == NULL);
ATLASSERT(::IsWindow(pParent->m_hWnd));
m_pWndParent = pParent;
ATLASSERT(nEditCtrlID != 0);
m_nEditCtrlID = nEditCtrlID;
m_hEditCtrl = m_pWndParent->GetDlgItem(nEditCtrlID);
ATLASSERT(m_hEditCtrl != NULL);
CEditCtrlBase::SubclassWindow(m_hEditCtrl);
CEditCtrlBase::Detach();
CEditCtrlBase::Attach(m_hEditCtrl); // not necessary on subclassed controls
ATLASSERT(nTBarCtrlID != 0);
m_nTBarCtrlID = nTBarCtrlID;
m_hTBarCtrl = m_pWndParent->GetDlgItem(nTBarCtrlID);
ATLASSERT(m_hTBarCtrl != NULL);
CTBarCtrlBase::Attach(m_hTBarCtrl);
m_nPostMsgID = nPostMsgID;
}
/**********
* AttachTextCtrls - Attach static controls for min and max range and the thumb value
*
* \param nTxtLCtrlID ID of Static control to be attached as 'min range'
* \param nTxtRCtrlID ID of Static control to be attached as 'max range'
* \param nTxtThumbCtrlID ID of Static control to be attached as 'thumb value)
*/
void CTBarEditCtrlBase::AttachTextCtrls(int nTxtLCtrlID, int nTxtRCtrlID, int nTxtThumbCtrlID /*= 0*/)
{
ATLASSERT(::IsWindow(*m_pWndParent));
if ( nTxtLCtrlID != 0 )
{
ATLASSERT(!m_ctrlTxtL.IsWindow());
m_nTxtLCtrlID = nTxtLCtrlID;
m_hTxtL = m_pWndParent->GetDlgItem( nTxtLCtrlID );
m_ctrlTxtL.Attach( m_hTxtL );
}
if ( nTxtRCtrlID != 0 )
{
ATLASSERT(!m_ctrlTxtR.IsWindow());
m_nTxtRCtrlID = nTxtRCtrlID;
m_hTxtR = m_pWndParent->GetDlgItem( nTxtRCtrlID );
m_ctrlTxtR.Attach( m_hTxtR );
}
if ( nTxtThumbCtrlID != 0 )
{
ATLASSERT(!m_ctrlTxtThumb.IsWindow());
m_nTxtThumbCtrlID = nTxtThumbCtrlID;
m_hTxtThumb = m_pWndParent->GetDlgItem( nTxtThumbCtrlID );
m_ctrlTxtThumb.Attach( m_hTxtThumb );
}
// UpdateRangeText();
// UpdateThumbText();
}
/**********
* Detach - Detaches all associated controls
*
* \return the parents window handle
*/
HWND CTBarEditCtrlBase::Detach()
{
HWND hRes = m_pWndParent ? m_pWndParent->m_hWnd : NULL;
if (m_pWndParent) {
ATLASSERT(m_pWndParent != NULL);
m_pWndParent = NULL;
CEditCtrlBase::UnsubclassWindow();
CTBarCtrlBase::Detach();
if ( m_ctrlTxtL.IsWindow() )
m_ctrlTxtL.Detach();
if ( m_ctrlTxtR.IsWindow() )
m_ctrlTxtR.Detach();
if ( m_ctrlTxtThumb.IsWindow() )
m_ctrlTxtThumb.Detach();
}
return hRes;
}
//////////////////////////////////////////////////////////////////////
//
BOOL CTBarEditCtrlBase::EnableWindow(BOOL bEnable /*= TRUE*/)
{
return EnableWindow(bEnable, TRUE);
}
BOOL CTBarEditCtrlBase::EnableWindow(BOOL bEnable /*= TRUE*/, BOOL bEnableTextCtrls /*= FALSE*/)
{
BOOL bRes = FALSE;
if ( m_hEditCtrl )
bRes |= ::EnableWindow(m_hEditCtrl, bEnable);
if ( m_hTBarCtrl )
bRes |= ::EnableWindow(m_hTBarCtrl, bEnable);
if ( bEnableTextCtrls && m_hTxtL )
bRes |= ::EnableWindow(m_hTxtL, bEnable);
if ( bEnableTextCtrls && m_hTxtR )
bRes |= ::EnableWindow(m_hTxtR, bEnable);
if ( bEnableTextCtrls && m_hTxtThumb )
bRes |= ::EnableWindow(m_hTxtThumb, bEnable);
return bRes;
}
BOOL CTBarEditCtrlBase::IsWindowEnabled()
{
return IsWindowEnabled(TRUE);
}
BOOL CTBarEditCtrlBase::IsWindowEnabled( BOOL bEnableTextCtrls /*= FALSE*/)
{
BOOL bRes = TRUE;
if ( m_hEditCtrl )
bRes &= ::IsWindowEnabled(m_hEditCtrl);
if ( m_hTBarCtrl )
bRes &= ::IsWindowEnabled(m_hTBarCtrl);
if ( bEnableTextCtrls && m_hTxtL )
bRes &= ::IsWindowEnabled(m_hTxtL);
if ( bEnableTextCtrls && m_hTxtR )
bRes &= ::IsWindowEnabled(m_hTxtR);
if ( bEnableTextCtrls && m_hTxtThumb )
bRes &= ::IsWindowEnabled(m_hTxtThumb);
return bRes;
}
BOOL CTBarEditCtrlBase::IsWindow()
{
BOOL bRes = FALSE;
if ( m_hEditCtrl )
bRes |= ::IsWindow(m_hEditCtrl);
if ( m_hTBarCtrl )
bRes |= ::IsWindow(m_hTBarCtrl);
return bRes;
}
//////////////////////////////////////////////////////////////////////
//
BOOL CTBarEditCtrlBase::ShowWindow(int nCmdShow /*= SW_SHOW*/)
{
return ShowWindow(nCmdShow, TRUE);
}
BOOL CTBarEditCtrlBase::ShowWindow(int nCmdShow /*= TRUE*/, BOOL bShowTextCtrls /*= FALSE*/)
{
BOOL bRes = FALSE;
if ( m_hEditCtrl )
bRes |= ::ShowWindow(m_hEditCtrl, nCmdShow);
if ( m_hTBarCtrl )
bRes |= ::ShowWindow(m_hTBarCtrl, nCmdShow);
if ( bShowTextCtrls && m_hTxtL )
bRes |= ::ShowWindow(m_hTxtL, nCmdShow);
if ( bShowTextCtrls && m_hTxtR )
bRes |= ::ShowWindow(m_hTxtR, nCmdShow);
if ( bShowTextCtrls && m_hTxtThumb )
bRes |= ::ShowWindow(m_hTxtThumb, nCmdShow);
return bRes;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -