"Error 'SetWindowTextA': is not a member of 'CStatic' AND char *fgets(char*, int, FILE*): can not convert argument 1 from 'TCHAR' to 'char*'

  • Thread starter Thread starter Satyaprakash A
  • Start date Start date
S

Satyaprakash A

Guest
Hi,

I migrated my C++ project from Visual Studio 2005 to Visual Studio 2017 Professional and when i build in Debug and Release modes i am getting the below errors:

1.

In the Debug build when I use SetWindowTextA like as shown below, I am getting the error "Error C2039 'SetWindowTextA': is not a member of 'CStatic'

m_status_text.SetWindowTextA(theStr);

m_status_text is declared as CStatic like as shown below:

CStatic m_status_text;

If I use SetWindowTextW, it is throwing an error in the Release Build.

m_status_text.SetWindowTextW(theStr);

When I changed it to "SetWindowText" like as shown below it is working for both Debug and Release Builds. Is it the correct way?

m_status_text.SetWindowText(theStr);

As far as my knowledge when we use "SetWindowText", in the Unicode format it treats it as "SetWindowTextW" and for multibyte character set format it treats as "SetWindowTextA".

But how SetWindowText works for Debug and Release builds?

2.

And also Can we use "_fgetts" instead of "fgets" (For release build) "fgetws" (For debug build) as in Debug build if i use "fgets", i am getting the below error:

char fgets(char, int, FILE*): can not convert argument 1 from 'TCHAR[260]' to 'char*'

fgets(currDir,MAX_PATH,f); // For release build
fgetws(currDir, MAX_PATH, f);
// For Debug build


  1. Can I use "_tfopen" instead of "fopen" (For release build) and "_wfopen" (For debug build)

    f = _tfopen(fileName, _T("r"));

In place of

f = fopen(fileName,"r"); // For release build
f = _wfopen(fileName, L
"r"); // For Debug build


Please help me on this.

Continue reading...
 
Back
Top