?
Solved

Setdlgitemtext

Posted on 1998-11-10
5
Medium Priority
?
925 Views
Last Modified: 2013-12-03
Why do I get the error message "SetdlgItemTextA doesn't take two parameters?" when I am compiling the program.  I'm calling "SetdlgItemText" to update a control in a Modal dialog.

Thanks,

Kelvin
0
Comment
Question by:drivers102797
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Author Comment

by:drivers102797
ID: 1415959
Edited text of question
0
 
LVL 27

Expert Comment

by:BigRat
ID: 1415960
One reason why I dislike C. You often can't see the wood for the trees. For Win95 (NOT NT) the non-Unicode procedure for the API procedure SetDlgItemText is called SetDlgItemTextA and is defined so in windows.h. Under Windows NT, where one can use Unicode the Unicode version of the procedure is called SetDlgItemTextW. The W suffix stands for Wide Character. The A probably stands for Atrocious.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1415961
What BigRat is saying is that there is no function called SetDlgItemText(), instead there is one called SetDlgItemTextA and one called SetDlgItemTextW().  Why you use SetDlgItemText() in your C++ code you aren't calling a function by that name.  You are invoking a C preprocessor macro (#define) that expands to one of the actual functions (depending on whehtor or not your projects uses unicode.).

BigRat sems to be blamming C for this.  I blame Microsoft.  Use of preprocessor macros (and the like)  is seriously discuraged for many reasons, yet they use thousands of them.  
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 200 total points
ID: 1415962
Perhaps you are confusing the code with one taken from an MFC application. CWnd has a member function called SetDlgItemText() which takes two parameters. In your case, you probably are assuming this or took code which assumes this, in which case, you need to add an HWND of the dialog as the first argument.

The SetDlgItemText() from C's point of view takes three arguments. Make sure you have three. MFC's CWnd::SetDlgItemText() only takes two because it knows which window you are referring to.
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1415963
to expand thui's comment

SetDlgItemText( ...etc...) if called in a CWnd/CView/CDialog etc class, means

this->SetDlgItemText(...etc...) calling the MFC version (member of CWnd)

If you want to call the API version use

::SetDlgItemText( ...etc...)


The preprocessor stuff mentioned by others is because the API version of the function has 2 flavours depending on if you are compiling for unicode - SetDlgItemTextA (8 character set) and SetDlgItemTextW (Unicode charset)

In some windows header file it basically #define's SetDlgItemText to either of the real API names (with ending A or W) depending on the presence/absence of the unicode flag.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question