CreateStatusWindow

#include "framework.h"
#include <commctrl.h>

/code */

HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
x_pos,y_pos,wWidth,wHeight, nullptr, nullptr, hInstance, nullptr);
// works fine

HWND status_hnd = CreateStatusWindowA(WS_CHILD | WS_VISIBLE, 0, hWnd, 9000);

ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);

error:
LNK2019 Verweis auf nicht aufgelöstes externes Symbol "__imp__CreateStatusWindowA@16"
It is most likely the mix of 'A' (ANSI) and 'W' (UNICODE) variant.
So change CreateStatusWindowA(...) to CreateStatusWindowW(...).
> CreateWindowW
This is for UNICODE builds.

> CreateStatusWindowA
This is for ASCII builds.

Decide which version you're going with.
You managed it with ShowWindow for example.

You can solve the whole problem by NOT trying to second-guess which version you're building, and just use the function names WITHOUT the A/W suffixes.

salem,
No. It ain't that easy. I checked all three possibilities before. CreateStatusWindow A/W.
I have seen various questions on this problem in the net ... Didn't see any satisfying answer.

Forgot to mention ... Visual studio 1900.
btw. the linkerror is LNK1120.
Last edited on
Nonetheless You need to be consitent with the A/W variant.

Do you linke against the 'comctl32.lib' library?
When in doubt, RTFM.

https://docs.microsoft.com/en-us/windows/desktop/api/commctrl/nf-commctrl-createstatuswindowa
Note This function is obsolete. Use CreateWindow instead.

I guess M$ with the latest version of the compiler finally dropped the symbol from the library to force people to upgrade.

Salem,
MS ... "This function is obsolete. Use CreateWindow instead".
Yes, this always means: "stable function because of compability".
The function is in commctrl.h.

Of course I could use CreateWindowEx instead, but would like to know what causes the problem
coder 777,
"Do you link against the 'comctl32.lib' library? "
I do not know nothing on c++ ... What do you mean with this ?
Your linker disagrees, otherwise it would have resolved the symbol.

I do not know nothing on c++ ... What do you mean with this ?

He's asking how exactly are you trying to build the program?

On the command line? If so, what is the command?

In an IDE? Which IDE? Did you set it up as a "console" project? Did you add any libraries to the linker settings? Presumably not since you don't seem to know what they are. Try looking for them and adding comctl32.lib.
salem,
"Your linker disagrees, otherwise it would have resolved the symbol"
Beautyful, that's quite obvious. I am asking why ?


dutch,
"On the command line? If so, what is the command?"
No, using Visual studio 1900 ...
Loading a filename.vcxproj and clicking create filename.

If I add comctl32.lib, no errormessage, but the linker creates: filename.dll instead of filename.exe

> Beautyful, that's quite obvious. I am asking why ?
Why is because the symbol doesn't exist in any libraries any more.
That's what obsolete means.

Now go and edit your 1990's code and bring it up to date with a better function.

salem c,
Of course I am using Visual Studio 2019 (not 1990), because I installed it today (my mistake).

"Why is because the symbol doesn't exist in any libraries any more.
That's what obsolete means"

That's what it usually doesn't mean if MS uses this sentence.
Like I said:
This always means: "stable function because of compatibility".
I can use CreateStatusWindow in other languages.

Of course It might be different in Visual studio 2019, but I doubt it.
But ok. ... So I use CreateWindowEx.
Have a good one !

statuswindow with CreateWindowEx.

char status_win_text[] = "Der Text in dem Status Window";

status_hnd = CreateWindowEx(0, STATUSCLASSNAME,0, WS_CHILD | WS_VISIBLE, 0, client.bottom, client.right, 26, hWnd, NULL, hInstance, NULL);

SendMessage(status_hnd,SB_SETTEXT, SBT_NOBORDERS, (LPARAM)status_win_text);

It works, but the text in the window seems to be chinese.
Visual studio is interesting.
If you're building Unicode, but supplying a char based string, Windows is not able to "understand" what is actually an "ASCII" text. It's interpreting that as Unicode, sending out what it thinks is right.

Change the char to a unicode compatible declaration, and issue the string literal as a Unicode string, not an ASCII (8 bit) character array (which is what you have now).

Windows isn't the problem here, compatibility with the configuration of the compiler is.

We all must use string literal methods (and variable declarations) compatible with the configuration of the compiler. Use a version that mutates according to configuration automatically and you're good.
I do not know nothing on c++ ... What do you mean with this ?
See this for how add a library to your project:

https://stackoverflow.com/questions/4445418/how-to-add-additional-libraries-to-visual-studio-project

It works, but the text in the window seems to be chinese.
The reason is that you send a local copy of the string to the window that does not longer exists when the function is done. Besides the problem that it might or might not the right encoding.

Which encoding you use depends also on the project setting.
Topic archived. No new replies allowed.