📄 gfxincombolist.cpp
字号:
// GfxInComboList.cpp : implementation file
//
#include "stdafx.h"
#include "SellMan.h"
#include "GfxInComboList.h"
#include "GfxInCombo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGfxInComboList
CGfxInComboList::CGfxInComboList()
{
pCombo = NULL;
iLastSel = -1;
}
CGfxInComboList::~CGfxInComboList()
{
}
BEGIN_MESSAGE_MAP(CGfxInComboList, CListCtrl)
//{{AFX_MSG_MAP(CGfxInComboList)
ON_WM_KILLFOCUS()
ON_WM_LBUTTONUP()
ON_WM_SETFOCUS()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGfxInComboList message handlers
void CGfxInComboList::OnKillFocus(CWnd* pNewWnd)
{
//iLastSel = GetCurSel();
iLastSel = GetSelectionMark();
if (iLastSel >= 0)
{
stItem.strText = GetItemText(iLastSel, 0) + " " + GetItemText(iLastSel, 1);
stItem.dwData = GetItemData( iLastSel );
}
CListCtrl::OnKillFocus(pNewWnd);
if (pCombo && ::IsWindow(pCombo->GetSafeHwnd()))
{
pCombo->SetFocus();
pCombo->InvalidateButton();
}
// PostMessage(WM_CLOSE);
//ShowWindow( SW_HIDE );
DestroyWindow();
}
void CGfxInComboList::OnLButtonUp(UINT nFlags, CPoint point)
{
CListCtrl::OnLButtonUp(nFlags, point);
if (pCombo && ::IsWindow(pCombo->GetSafeHwnd()))
{
pCombo->SetFocus();
pCombo->InvalidateButton();
if (GetSafeHwnd())
{
int iCurSel = GetSelectionMark();//GetCurSel();
if (iCurSel >= 0)
{
st_iteminfo iteminfo;
iteminfo.strText = GetItemText(iLastSel, 0) + " " + GetItemText(iLastSel, 1);
iteminfo.dwData = GetItemData( iLastSel );
//char * ptx = iteminfo.strText.LockBuffer();
pCombo->SendMessage(WM_USER_SELENDOK, iCurSel, (LPARAM) &iteminfo);
//iteminfo.strText.UnlockBuffer();
}
}
else
{
if (iLastSel >= 0)
{
//char * ptx = stItem.strText.LockBuffer();
pCombo->SendMessage(WM_USER_SELENDOK, iLastSel, (LPARAM) &stItem);
//stItem.strText.UnlockBuffer();
}
}
}
// PostMessage(WM_CLOSE);
DestroyWindow();
}
BOOL CGfxInComboList::PreTranslateMessage(MSG* pMsg)
{
CString str;
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_RETURN)
{
pCombo->SetFocus();
pCombo->InvalidateButton();
if (GetSafeHwnd())
{
//int iCurSel = GetCurSel();
int iCurSel = GetSelectionMark();
if (iCurSel >= 0)
{
st_iteminfo iteminfo;
iteminfo.strText = GetItemText(iLastSel, 0) + " " + GetItemText(iLastSel, 1);
iteminfo.dwData = GetItemData( iLastSel );
//char * ptx = iteminfo.strText.LockBuffer();
pCombo->SendMessage(WM_USER_SELENDOK, iCurSel, (LPARAM) &iteminfo);
//iteminfo.strText.UnlockBuffer();
}
}
else
{
if (iLastSel >= 0)
{
//char * ptx = stItem.strText.LockBuffer();
pCombo->SendMessage(WM_USER_SELENDOK, iLastSel, (LPARAM) &stItem);
//stItem.strText.UnlockBuffer();
}
}
// PostMessage(WM_CLOSE);
DestroyWindow();
return true;
}
if (pMsg->wParam == VK_ESCAPE)
{
pCombo->SetFocus();
pCombo->InvalidateButton();
// PostMessage(WM_CLOSE);
DestroyWindow();
return true;
}
if( pMsg->wParam != VK_RETURN )
{
if( pCombo->bEditable ) pCombo->wndEdit.SendMessage( WM_KEYDOWN, pMsg->wParam );
else if( pCombo->bEditable ) pCombo->wndStatic.SendMessage( WM_KEYDOWN, pMsg->wParam );
}
if( pMsg->wParam != VK_RETURN && pMsg->wParam != VK_UP &&
pMsg->wParam != VK_DOWN && pMsg->wParam != VK_LEFT && pMsg->wParam != VK_RIGHT )
{
pCombo->ListScroll();
}
}
else if (pMsg->message == WM_CHAR)
{
if( pCombo->bEditable ) pCombo->wndEdit.SendMessage( WM_CHAR, pMsg->wParam );
else if( pCombo->bEditable ) pCombo->wndStatic.SendMessage( WM_KEYDOWN, pMsg->wParam );
pCombo->ListScroll();
}
return CListCtrl::PreTranslateMessage(pMsg);
}
int CGfxInComboList::GetColumnCount()
{
return GetHeaderCtrl()->GetItemCount();
}
void CGfxInComboList::OnSetFocus(CWnd* pOldWnd)
{
CListCtrl::OnSetFocus(pOldWnd);
//pCombo->SetFocus();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -