ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SetWindowTextW

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
cadproman
535 Views, 4 Replies

SetWindowTextW

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

4 REPLIES 4
Message 2 of 5
oliver253m
in reply to: cadproman

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".

Message 3 of 5
owenwengerd
in reply to: cadproman

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.

--
Owen Wengerd
ManuSoft
Message 4 of 5
cadproman
in reply to: owenwengerd

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.

Message 5 of 5
owenwengerd
in reply to: cadproman

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.

--
Owen Wengerd
ManuSoft

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost