Solved

Setdlgitemtext

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

13 Experts available now in Live!

Get 1:1 Help Now