ObjectARX

Reply
Active Contributor
cadproman
Posts: 43
Registered: ‎03-20-2002
Message 1 of 5 (179 Views)
Accepted Solution

SetWindowTextW

179 Views, 4 Replies
11-14-2012 10:28 AM

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

Contributor
oliver253m
Posts: 16
Registered: ‎07-25-2012
Message 2 of 5 (169 Views)

Re: SetWindowTextW

11-14-2012 02:30 PM 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".

Distinguished Mentor
owenwengerd
Posts: 622
Registered: ‎08-06-2002
Message 3 of 5 (166 Views)

Re: SetWindowTextW

11-14-2012 06:54 PM 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
Active Contributor
cadproman
Posts: 43
Registered: ‎03-20-2002
Message 4 of 5 (150 Views)

Re: SetWindowTextW

11-15-2012 03:14 PM 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.

Distinguished Mentor
owenwengerd
Posts: 622
Registered: ‎08-06-2002
Message 5 of 5 (148 Views)

Re: SetWindowTextW

11-15-2012 05:32 PM 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
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.