GME  13
ComboBoxSelectDlg.cpp
Go to the documentation of this file.
00001 // ComboBoxSelectDlg.cpp : implementation file
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "objectinspector.h"
00006 #include "ComboBoxSelectDlg.h"
00007 #include "InspectorDefs.h"
00008 #include "ItemData.h"
00009 #include "InPlaceCommon.h"
00010 
00011 #ifdef _DEBUG
00012 #define new DEBUG_NEW
00013 #undef THIS_FILE
00014 static char THIS_FILE[] = __FILE__;
00015 #endif
00016 
00018 // CComboBoxSelectDlg dialog
00019 
00020 class CListItem;
00021 
00022 CComboBoxSelectDlg::CComboBoxSelectDlg(CWnd* pParent, int comboboxLineHeight)
00023         : CDialog(CComboBoxSelectDlg::IDD, pParent), m_ComboboxLineHeight(comboboxLineHeight)
00024 {
00025         //{{AFX_DATA_INIT(CComboBoxSelectDlg)
00026                 // NOTE: the ClassWizard will add member initialization here
00027         //}}AFX_DATA_INIT
00028 
00029         m_bInited = true;
00030         m_bClosed = false;
00031 }
00032 
00033 
00034 void CComboBoxSelectDlg::SetParameters(const CRect& rectBound, CListItem* pListItem, CFont* pFontWnd)
00035 {
00036         m_RectBound                     = rectBound;
00037         m_pListItem                     = pListItem;
00038         m_pFontWnd                      = pFontWnd;
00039 }
00040 
00041 
00042 void CComboBoxSelectDlg::DoDataExchange(CDataExchange* pDX)
00043 {
00044         CDialog::DoDataExchange(pDX);
00045         //{{AFX_DATA_MAP(CComboBoxSelectDlg)
00046                 // NOTE: the ClassWizard will add DDX and DDV calls here
00047         //}}AFX_DATA_MAP
00048 }
00049 
00050 
00051 BEGIN_MESSAGE_MAP(CComboBoxSelectDlg, CDialog)
00052         //{{AFX_MSG_MAP(CComboBoxSelectDlg)
00053         ON_WM_NCACTIVATE()
00054         ON_MESSAGE(HLB_SELENDOK, OnComboSelEnd)
00055         //}}AFX_MSG_MAP
00056 END_MESSAGE_MAP()
00057 
00058 BOOL CComboBoxSelectDlg::OnNcActivate(BOOL bActive)
00059 {
00060         if (!bActive && !m_bClosed) {
00061                 m_bClosed = true;
00062                 EndDialog(IDCANCEL);
00063                 DWORD pos = GetMessagePos();
00064                 CPoint msgPoint(GET_X_LPARAM(pos), GET_Y_LPARAM(pos));
00065                 // FIXME: this doesn't work correctly
00066                 //RelayMouseClickToInspectorList(m_pParentWnd, msgPoint);
00067         }
00068         return FALSE;//CDialog::OnNcActivate(bActive);
00069 }
00070 
00071 BOOL CComboBoxSelectDlg::OnInitDialog()
00072 {
00073         CDialog::OnInitDialog();
00074 
00075         SetWindowPos( NULL, m_RectBound.left, m_RectBound.top, m_RectBound.Width(), m_RectBound.Height(), SWP_NOZORDER );
00076         CRect rect( 0, 0, m_RectBound.Width(), m_RectBound.Height() + m_ComboboxLineHeight);
00077         m_lstBox.Create( LBS_NOTIFY | WS_VSCROLL, rect, this, IDC_COMBO_LISTBOX );
00078         m_lstBox.SetFont( m_pFontWnd );
00079 
00080         if ( m_pListItem->Value.dataType == ITEMDATA_BOOLEAN ) {
00081                 m_lstBox.AddString(_T("True"));
00082                 m_lstBox.AddString(_T("False"));
00083                 m_lstBox.SetCurSel( m_pListItem->Value.boolVal );
00084         }
00085         else {
00086                 for( int i=0 ; i  <= m_pListItem->Value.stringVal.GetUpperBound()  ; i++ )
00087                         m_lstBox.AddString( m_pListItem->Value.stringVal[ i ] );
00088                 m_lstBox.SetCurSel( m_pListItem->Value.listVal );
00089         }
00090 
00091         m_lstBox.ShowWindow(SW_SHOW);
00092         //m_lstBox.SetFocus();
00093         // m_lstBox.Invalidate();
00094 
00095         return TRUE;  // return TRUE unless you set the focus to a control
00096                       // EXCEPTION: OCX Property Pages should return FALSE
00097 }
00098 
00099 void CComboBoxSelectDlg::OnOK()
00100 {
00101         if( m_pListItem->Value.dataType == ITEMDATA_BOOLEAN )
00102                 m_pListItem->Value.SetBoolValue( ! m_lstBox.GetCurSel() );
00103         else
00104                 m_pListItem->Value.listVal = m_lstBox.GetCurSel();
00105         m_bClosed = true;
00106         CDialog::OnOK();
00107 }
00108 
00109 LRESULT CComboBoxSelectDlg::OnComboSelEnd( WPARAM lParam, LPARAM /*wParam*/)
00110 {
00111         // m_uiSelItem = lParam;
00112         OnOK();
00113         return TRUE;
00114 }