ObjectARX

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

SetWindowTextW

193 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

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

Contributor
oliver253m
Posts: 16
Registered: ‎07-25-2012
Message 2 of 5 (183 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: 671
Registered: ‎08-06-2002
Message 3 of 5 (180 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 (164 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: 671
Registered: ‎08-06-2002
Message 5 of 5 (162 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!