Setdlgitemtext

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
drivers102797Asked:
Who is Participating?
 
Tommy HuiEngineerCommented:
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
 
drivers102797Author Commented:
Edited text of question
0
 
BigRatCommented:
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
 
nietodCommented:
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
 
Answers2000Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.