Solved

Setdlgitemtext

Posted on 1998-11-10
5
829 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
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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now