📄 tbareditctrlbase.h
字号:
//-----------------------------------------------------------------------------
// (c) 2002 by Basler Vision Technologies
// Section: Vision Components
// Project: BCAM
// $Header: TBarEditCtrlBase.h, 3, 02.10.2002 14:31:29, Nebelung, H.$
//-----------------------------------------------------------------------------
/**
\file TBarEditCtrlBase.h
\brief interface for the CTBarEditCtrlBase class.
*/
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TBarEditCtrlBase_H__64039EFE_F624_11D4_B9D7_0050BACEA3A5__INCLUDED_)
#define AFX_TBarEditCtrlBase_H__64039EFE_F624_11D4_B9D7_0050BACEA3A5__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <stdarg.h>
#include <atlctrls.h>
#include "EditCtrlBase.h"
#include "TBarCtrlBase.h"
//////////////////////////////////////////////////////////////////////
/// Base class of combined control
class CTBarEditCtrlBase : public CEditCtrlBase,
public CTBarCtrlBase
{
CWindow * m_pWndParent;
protected:
// ID used when posting messages
int m_nPostMsgID;
// Properties
bool m_bPostMsgEnabled;
bool m_bLiveUpdateEnabled;
int m_nValue;
double m_dValue;
//
bool m_bSkipEnChange;
bool m_bOnChange2Parent;
bool m_bOnUpdate2Parent;
//
int m_nFormatWidth;
int m_nFormatPrecision;
public:
CTBarEditCtrlBase(bool bPostMsgEnabled = true, bool bLiveUpdateEnabled = true);
virtual ~CTBarEditCtrlBase();
BEGIN_MSG_MAP(CTBarEditCtrlBase)
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
MESSAGE_HANDLER(WM_CHAR, OnChar)
COMMAND_HANDLER(m_nEditCtrlID, EN_CHANGE, OnChange)
COMMAND_HANDLER(m_nEditCtrlID, EN_UPDATE, OnUpdate)
COMMAND_HANDLER(m_nEditCtrlID, EN_KILLFOCUS, OnKillFocus)
CHAIN_MSG_MAP(CEditCtrlBase)
CHAIN_MSG_MAP(CTBarCtrlBase)
END_MSG_MAP()
/**********
* 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 Attach(CWindow *pParent, int nEditCtrlID, int nTBarCtrlID, int nPostMsgID = 0);
/**********
* 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 AttachTextCtrls(int nTxtLCtrlID, int nTxtRCtrlID, int nTxtThumbCtrlID = 0);
/**********
* Detach - Detaches al associated controls
*
* \return the parents window handle
*/
HWND Detach();
/**********
* GoCenterValue - Position thumb to center of current range
*/
virtual bool GoCenterValue() = 0;
/**********
* SetPrecision - Set precision and width used by printf to format the values
* Setting this values has currently no effect on integer values
* \param nPrecision Precision used by printf for formatting double values
* \param nWidth Precision used by printf for formatting double values
*/
virtual void SetPrecision(int nPrecision, int nWidth = 0) = 0;
/**********
* SetPostMsgID - Set an message ID which will be posted instead of the ID of the Edit control
*
* \param nPostMsgID Message ID to be used instead of nEditCtrlID (see Attach) when forwarding
* events (EN_CHANGE and EN_UPDATE). Set to 0, if nEditCtrlID should be used.
*/
void SetPostMsgID(int nPostMsgID) { m_nPostMsgID = nPostMsgID; };
/**********
* PostMsgEnable - disables or enables posting of WM_COMMAND::EN_CHANGE and WM_COMMAND::EN_UPDATE
* to the parent
*
* \param bPostMsgEnable
*/
void PostMsgEnable(bool bPostMsgEnable) { m_bPostMsgEnabled = bPostMsgEnable; };
void LiveUpdateEnable(bool bLiveUpdateEnable) { m_bLiveUpdateEnabled = bLiveUpdateEnable; };
/**********
* EnableWindow - see MSDN
* all associated controls will be disabled
*/
BOOL EnableWindow(BOOL bEnable = TRUE);
BOOL EnableWindow(BOOL bEnable, BOOL bEnableTextCtrls);
BOOL IsWindowEnabled();
BOOL IsWindowEnabled(BOOL bEnableTextCtrls);
BOOL IsWindow();
BOOL ShowWindow(int nCmdShow = SW_SHOW);
BOOL ShowWindow(int nCmdShow, BOOL bShowTextCtrls);
protected:
virtual bool LimitValue() = 0;
virtual void UpdateValue() = 0;
virtual bool UpdateEditText() = 0;
virtual void UndoInput() = 0;
virtual LRESULT HScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) = 0;
//
inline void PostParent(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
ATLASSERT(m_pWndParent != NULL);
if ( m_bPostMsgEnabled )
::PostMessage(m_pWndParent->m_hWnd, uMsg, wParam, lParam);
}
private:
// General handlers
LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnChar(UINT uMsg, WPARAM wParam,LPARAM lParam, BOOL& bHandled);
// CEdit handler
LRESULT OnChange(WPARAM uNotifyCode, WPARAM wID, HWND hWndCtrl, BOOL& bHandled);
LRESULT OnUpdate(WPARAM uNotifyCode, WPARAM wID, HWND hWndCtrl, BOOL& bHandled);
LRESULT OnKillFocus(WPARAM uNotifyCode, WPARAM wID, HWND hWndCtrl, BOOL& bHandled);
// CTrackBarCtrl handler
LRESULT OnHScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};
#define DDX_TBAREDIT(nID, ctrl, var) \
if(nCtlID == (UINT)-1 || nCtlID == nID) \
{ \
if ( !ctrl.DDXValue(nID, var, bSaveAndValidate) ) \
return FALSE; \
}
#endif // !defined(AFX_TBarEditCtrlBase_H__64039EFE_F624_11D4_B9D7_0050BACEA3A5__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -