Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
EGPropertyGridItemCombo.cpp
Package: solidgraph_sources.zip [view]
Upload User: kairuinn
Upload Date: 2009-02-07
Package Size: 2922k
Code Size: 5k
Category:
Graph program
Development Platform:
Visual C++
- // PropTreeItemCombo.cpp : implementation file
- //
- // Copyright (C) 1998-2001 Scott Ramsay
- // sramsay@gonavi.com
- // http://www.gonavi.com
- //
- // This material is provided "as is", with absolutely no warranty expressed
- // or implied. Any use is at your own risk.
- //
- // Permission to use or copy this software for any purpose is hereby granted
- // without fee, provided the above notices are retained on all copies.
- // Permission to modify the code and to distribute modified code is granted,
- // provided the above notices are retained, and a notice that the code was
- // modified is included with the above copyright notice.
- //
- // If you use this code, drop me an email. I'd like to know if you find the code
- // useful.
- #include "stdafx.h"
- #include "EGPropertyGrid.h"
- //#include "Resource.h"
- #include "EGPropertyGridItemCombo.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #define DROPDOWN_HEIGHT 100
- /////////////////////////////////////////////////////////////////////////////
- // CEGPropertyGridItemCombo
- CEGPropertyGridItemCombo::CEGPropertyGridItemCombo() :
- m_lComboData(0),
- m_nDropHeight(DROPDOWN_HEIGHT)
- {
- }
- CEGPropertyGridItemCombo::~CEGPropertyGridItemCombo()
- {
- }
- BEGIN_MESSAGE_MAP(CEGPropertyGridItemCombo, CComboBox)
- //{{AFX_MSG_MAP(CEGPropertyGridItemCombo)
- ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)
- ON_CONTROL_REFLECT(CBN_KILLFOCUS, OnKillfocus)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CEGPropertyGridItemCombo message handlers
- void CEGPropertyGridItemCombo::DrawAttribute(CDC* pDC, const RECT& rc)
- {
- ASSERT(m_pProp!=NULL);
- // verify the window has been created
- if (!IsWindow(m_hWnd))
- {
- TRACE0("CEGPropertyGridItemCombo::DrawAttribute() - The window has not been createdn");
- return;
- }
- pDC->SelectObject(IsReadOnly() ? m_pProp->GetNormalFont() : m_pProp->GetBoldFont());
- pDC->SetTextColor(RGB(0,0,0));
- pDC->SetBkMode(TRANSPARENT);
- CRect r = rc;
- CString s;
- LONG idx;
- if ((idx = GetCurSel())!=CB_ERR)
- GetLBText(idx, s);
- else
- s = _T("");
- pDC->DrawText(s, r, DT_SINGLELINE|DT_VCENTER);
- }
- LPARAM CEGPropertyGridItemCombo::GetItemValue()
- {
- return m_lComboData;
- }
- void CEGPropertyGridItemCombo::SetItemValue(LPARAM lParam)
- {
- m_lComboData = lParam;
- OnRefresh();
- }
- void CEGPropertyGridItemCombo::OnMove()
- {
- if (IsWindow(m_hWnd) && IsWindowVisible())
- SetWindowPos(NULL, m_rc.left, m_rc.top, m_rc.Width() + 1, m_rc.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
- }
- void CEGPropertyGridItemCombo::OnRefresh()
- {
- LONG idx = FindCBData(m_lComboData);
- if (idx!=CB_ERR)
- SetCurSel(idx);
- }
- void CEGPropertyGridItemCombo::OnCommit()
- {
- LONG idx;
- // store combo box item data
- if ((idx = GetCurSel())==CB_ERR)
- m_lComboData = 0;
- else
- m_lComboData = (LPARAM)GetItemData(idx);
- ShowWindow(SW_HIDE);
- }
- void CEGPropertyGridItemCombo::OnActivate()
- {
- // activate the combo box
- SetWindowPos(NULL, m_rc.left, m_rc.top, m_rc.Width() + 1, m_rc.Height() + m_nDropHeight, SWP_NOZORDER|SWP_SHOWWINDOW);
- SetFocus();
- if (GetCount())
- ShowDropDown(TRUE);
- }
- BOOL CEGPropertyGridItemCombo::CreateComboBox(DWORD dwStyle)
- {
- ASSERT(m_pProp!=NULL);
- if (IsWindow(m_hWnd))
- DestroyWindow();
- // force as not visible child window
- dwStyle = (WS_CHILD|WS_VSCROLL|dwStyle) & ~WS_VISIBLE;
- if (!Create(dwStyle, CRect(0,0,0,0), m_pProp->GetCtrlParent(), GetCtrlID()))
- {
- TRACE0("CEGPropertyGridItemCombo::CreateComboBox() - failed to create combo boxn");
- return FALSE;
- }
- SendMessage(WM_SETFONT, (WPARAM)m_pProp->GetNormalFont()->m_hObject);
- return TRUE;
- }
- BOOL CEGPropertyGridItemCombo::CreateComboBoxBool()
- {
- ASSERT(m_pProp!=NULL);
- if (IsWindow(m_hWnd))
- DestroyWindow();
- // force as a non-visible child window
- DWORD dwStyle = WS_CHILD|WS_VSCROLL|CBS_SORT|CBS_DROPDOWNLIST;
- if (!Create(dwStyle, CRect(0,0,0,0), m_pProp->GetCtrlParent(), GetCtrlID()))
- {
- TRACE0("CEGPropertyGridItemCombo::CreateComboBoxBool() - failed to create combo boxn");
- return FALSE;
- }
- SendMessage(WM_SETFONT, (WPARAM)m_pProp->GetNormalFont()->m_hObject);
- // file the combo box
- LONG idx;
- CString s;
- //s.LoadString(IDS_TRUE);
- s = _T("泥");
- idx = AddString(s);
- SetItemData(idx, TRUE);
- // s.LoadString(IDS_FALSE);
- s = _T("湾