Click here to Skip to main content
15,917,709 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
Generalstatic members in templates... Pin
GDavy19-Nov-03 0:04
GDavy19-Nov-03 0:04 
GeneralRe: static members in templates... Pin
Joaquín M López Muñoz19-Nov-03 8:24
Joaquín M López Muñoz19-Nov-03 8:24 
GeneralRe: static members in templates... Pin
GDavy19-Nov-03 21:25
GDavy19-Nov-03 21:25 
GeneralRe: static members in templates... Pin
Joaquín M López Muñoz19-Nov-03 23:36
Joaquín M López Muñoz19-Nov-03 23:36 
GeneralRe: static members in templates... Pin
Nemanja Trifunovic22-Nov-03 10:02
Nemanja Trifunovic22-Nov-03 10:02 
GeneralRe: static members in templates... Pin
Joaquín M López Muñoz23-Nov-03 2:30
Joaquín M López Muñoz23-Nov-03 2:30 
GeneralInformation of running application's objects Pin
naveensg18-Nov-03 23:08
naveensg18-Nov-03 23:08 
GeneralDDX DLL and CComboBoxImpl in WTL Pin
bryces18-Nov-03 17:17
bryces18-Nov-03 17:17 
Hi All,

I seem to be having the most stupid problem (well I am the stupid one) with retrieving the selected value out of a ComboBox.

Background info:
All my development is within an ATL Com based DLL. I have extended its functionality by including the WTL libraries in the stdafx.h header.

The DLL is a set of tools and dlgs that are loaded into the calling application.

I have read Michael Dunns intro to WTL articles and found them encouraging... hence trying to use them in my project. However I seem to be having trouble implementing the msg maps and ddx maps etc in the dialogs as they seem to crash the calling application. For the calling application and DLL to work, the dialogs must be of type CAxDialogImpl.

I have one Dialog that I have managed to use WTL message maps in and it works ok. However other time it doesn't. I cannot get the DDX map to map the values from my ComboBox to my class members:

<br />
class CTargetDialog : public CAxDialogImpl<CTargetDialog>,//public CUpdateUI<CTargetDialog>,<br />
                      //public CMessageFilter, public CIdleHandler,<br />
                      public CWinDataExchange<CTargetDialog>,<br />
                      public CComObjectRootEx<CComSingleThreadModel>,<br />
                      public CComCoClass<CTargetDialog><br />
{<br />
public:<br />
	CTargetDialog(IApplicationPtr pApp);<br />
	~CTargetDialog();<br />
<br />
	enum { IDD = IDD_TARGETDIALOG };<br />
<br />
BEGIN_MSG_MAP(CTargetDialog)<br />
   MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)<br />
   COMMAND_ID_HANDLER(IDOK, OnOK)<br />
   COMMAND_ID_HANDLER(IDCANCEL, OnCancel)<br />
   COMMAND_HANDLER(IDC_COMBO_TARGET, CBN_SELCHANGE, OnSelchangeCombo_target)<br />
   COMMAND_HANDLER(IDC_COMBO_TARGET, CBN_DROPDOWN, OnDropdownCombo_target)<br />
END_MSG_MAP()<br />
<br />
BEGIN_DDX_MAP(CTargetDialog)<br />
   DDX_CONTROL(IDC_COMBO_TARGET, m_pComboBox)<br />
   DDX_TEXT(IDC_COMBO_TARGET, m_szTargetLayer)<br />
END_DDX_MAP()<br />
// Handler prototypes:<br />
//  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);<br />
//  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);<br />
//  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);<br />
<br />
   LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);<br />
   LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);<br />
   LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);<br />
   LRESULT OnSelchangeCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);<br />
   LRESULT OnDropdownCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);<br />
   HWND GetPicHandle();<br />
<br />
private:<br />
   CComboBoxImpl m_pComboBox;<br />
   CString m_szTargetLayer;<br />
   IApplicationPtr m_ipApp;<br />
   IMxApplicationPtr m_ipMxApp;<br />
   IDocumentPtr m_ipDoc;<br />
   IMxDocumentPtr m_ipMxDoc;<br />
   IEditorPtr m_ipEditor;<br />
   IMapPtr m_ipMap;<br />
};<br />


I have defined the CComboBoxImpl in my stdafx.h like
<br />
class CComboBoxImpl : public CWindowImpl<CComboBoxImpl, CComboBox><br />
    { DECLARE_EMPTY_MSG_MAP(); };<br />


So I have pretty much given up on trying to change the message_maps and the DDX stuff, as compiler gives error when I request
<br />
DoDataExhange(true);<br />


That being said and done, how do you get the value from a combo box?
I have tried the following but the itellisense definition of the object is different to what the compiler accepts. Instead of using DDX I have:
<br />
LRESULT CTargetDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
   //DoDataExhange(true);<br />
   m_pComboBox.Attach(GetDlgItem(IDC_COMBO_TARGET));<br />
   ATLASSERT(m_pComboBox.m_hWnd != NULL);<br />
<br />
   return 1;  // Let the system set the focus<br />
}<br />

<br />
LRESULT CTargetDialog::OnSelchangeCombo_target(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)<br />
{<br />
   CString pValueString; <br />
   BSTR pBSTR<br />
   int i = this->m_pComboBox.GetDlgItemText(IDC_COMBO_TARGET, pBSTR); //Only works with BSTR<br />
   this->m_pComboBox.GetLBText(0, pValueString); //Works, but not the selected item.<br />
<br />
   AtlMessageBox(NULL, pValueString.AllocSysString(), _T("Selection"), MB_OK);<br />
	return 0;<br />
}


Are the Dialogs meant to work in DLL the same message map way as in EXE? I know they are not in terms of the greater picture, but in terms of there own object entity.

your guidance would be greatly appreciated.

cheers
Bryce
GeneralRe: DDX DLL and CComboBoxImpl in WTL Pin
Michael Dunn18-Nov-03 17:26
sitebuilderMichael Dunn18-Nov-03 17:26 
GeneralRe: DDX DLL and CComboBoxImpl in WTL Pin
bryces18-Nov-03 17:39
bryces18-Nov-03 17:39 
GeneralRe: DDX DLL and CComboBoxImpl in WTL Pin
Michael Dunn22-Nov-03 16:30
sitebuilderMichael Dunn22-Nov-03 16:30 
GeneralRe: DDX DLL and CComboBoxImpl in WTL Pin
bryces23-Nov-03 11:47
bryces23-Nov-03 11:47 
GeneralRe: DDX DLL and CComboBoxImpl in WTL Pin
bryces23-Nov-03 11:53
bryces23-Nov-03 11:53 
GeneralRe: DDX DLL and CComboBoxImpl in WTL Pin
bryces23-Nov-03 12:29
bryces23-Nov-03 12:29 
GeneralRe: DDX DLL and CComboBoxImpl in WTL Pin
Michael Dunn23-Nov-03 14:57
sitebuilderMichael Dunn23-Nov-03 14:57 
GeneralRe: DDX DLL and CComboBoxImpl in WTL Pin
bryces23-Nov-03 15:17
bryces23-Nov-03 15:17 
GeneralRe: DDX DLL and CComboBoxImpl in WTL Pin
Michael Dunn23-Nov-03 17:37
sitebuilderMichael Dunn23-Nov-03 17:37 
GeneralRe: DDX DLL and CComboBoxImpl in WTL Pin
bryces23-Nov-03 17:57
bryces23-Nov-03 17:57 
GeneralATL & DHTML Pin
Leesen18-Nov-03 5:33
Leesen18-Nov-03 5:33 
GeneralTemplate and message map Pin
Stephane David18-Nov-03 3:59
Stephane David18-Nov-03 3:59 
GeneralRe: Template and message map Pin
Member 20218605-Jun-05 22:50
Member 20218605-Jun-05 22:50 
GeneralTemplate issue.. Pin
GDavy18-Nov-03 2:11
GDavy18-Nov-03 2:11 
GeneralRe: Template issue.. Pin
GDavy18-Nov-03 2:16
GDavy18-Nov-03 2:16 
GeneralRe: Template issue.. Pin
GDavy18-Nov-03 3:25
GDavy18-Nov-03 3:25 
GeneralIOleInPlaceObjectWindowLessImpl::GetDropTarget Pin
Jörgen Sigvardsson18-Nov-03 0:31
Jörgen Sigvardsson18-Nov-03 0:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.