Can someone help with making this function call? I am using:
typedef std::basic_string<TCHAR> tstring;
//in dialog class...
tstring m_strAngle;
CAcUiAngleEdit m_ctrlAngleEdit;
// stuff to modify m_strAngle here...
LPCTSTR buf = m_strAngle.c_str();
m_ctrlAngleEdit.SetWindowTextW(buf); //crashes here.
Also, are the _T() macros the thing to use with AutoCAD, or are they outdated/unnecessary?
I'm attempting to use the acuisample_dg in the MFC samples. (If anyone from AutoDesk sees this, updated samples that are built using the current ARXwizard and compile would be much easier to learn from!)
Thanks for any help,
Ralph Gaston
Solved! Go to Solution.
Solved by oliver253m. Go to Solution.
Have you mapped the variable to the control in DoDataExchange, like:
DDX_Control( pDX, ID_OF_CONTROL, m_ctrlAngleEdit );
You need to use the _T() macro with string literals if you need your code to work with both MBCS and Unicode versions of AutoCAD (up to 2007 or 2007 and above). If you only ever need to target Unicode, then you can use the L prefix instead, as in L"String here".
The code you show does not create a window for the m_ctrlAngleEdit control. You should use _T() and TCHAR for maximum backward and forward compatibility, but to be consistent you need to call the TCHAR SetWindowText instead of the Unicode SetWindowTextW.
Looks like the DoDataExchange was causing it. It was also preventing my command buttons from displaying. Thanks!
I saw last week that the respondant to a forum question was surprised that someone was "still" using the T() macros. I don't know anything about it, but I began to wonder if I should be using unicode only now for clarity and since it appears to be the newer. I'm only using AutoCAD 2008 and up, but based on the answers you guys gave directly related to AutoCAD, It looks like I should continue to use them. Thanks again to both of you for responding! Once again I am unstuck for at least 30 more minutes.
I don't think it would be "wrong" to stick with Unicode only if you're not worried about porting backward, but we don't know what future Windows SDK changes might repurpose the _T() macro, so I recommend to use it.