InputComboBox.cpp
资源名称:ictprop.rar [点击查看]
上传用户:tenhai
上传日期:2021-02-19
资源大小:492k
文件大小:2k
源码类别:
组合框控件
开发平台:
Visual C++
- // InputComboBox.cpp : implementation file
- //
- #include "stdafx.h"
- #include "prop.h"
- #include "InputComboBox.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CInputComboBox
- CInputComboBox::CInputComboBox()
- {
- }
- CInputComboBox::~CInputComboBox()
- {
- }
- BEGIN_MESSAGE_MAP(CInputComboBox, CComboBox)
- //{{AFX_MSG_MAP(CInputComboBox)
- ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CInputComboBox message handlers
- void CInputComboBox::OnSelchange()
- {
- // TODO: Add your control notification handler code here
- int nIndex = GetCurSel();
- GetLBText(nIndex, m_strInput);
- // InvokeAction();
- }
- BOOL CInputComboBox::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
- if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) {
- OnCmd();
- }
- return CComboBox::PreTranslateMessage(pMsg);
- }
- void CInputComboBox::InvokeAction()
- {
- extern CPropApp theApp;
- theApp.ExecCmd(m_strInput);
- }
- void CInputComboBox::UpdateInput()
- {
- int nIndex=AddUniqueString(m_strInput);
- SetCurSel(nIndex);
- }
- void CInputComboBox::OnCmd()
- {
- GetWindowText(m_strInput);
- AddUniqueString(m_strInput);
- InvokeAction();
- }
- int CInputComboBox::AddUniqueString(CString str)
- {
- int nIndex=0;
- int nCount=GetCount();
- nIndex=FindStringExact(nIndex, LPCSTR(str));
- if (nIndex!=LB_ERR)
- return nIndex;
- else
- return InsertString(0, (LPCSTR)str);
- }