question

DanielShepherd-8507 avatar image
0 Votes"
DanielShepherd-8507 asked DanielShepherd-8507 commented

E0167 argument of type "HWND" is incompatible with parameter of type "int"

I am on the tutorial on winprog.org, and I am on the article "creating controls at runtime", and my code gets errors. here is my code:

 case WM_CREATE:
     {
         HFONT hfDefault;
         HWND hEdit;
         hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"", WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL, 0, 0, 100, hWnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
     }

errors:

windows-api
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RLWA32-6355 avatar image
0 Votes"
RLWA32-6355 answered DanielShepherd-8507 commented

Review the parameters passed to the CreateWindowEx function. nf-winuser-createwindowexa
The code posted above has omitted a required parameter for the new window's height.


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@DanielShepherd-8507 When I cut and paste the posted code into an app created by the Windows Desktop wizard and add a #define for IDC_MAIN_EDIT various intellisense errors are issued in addition to the one mentioned in your question. Didn't you also see these, including E0165?
117580-intellisense.png


0 Votes 0 ·
intellisense.png (17.7 KiB)

So I changed CreateWindowEx to CreateWindowA, and I changed the LPCSTR values to ConstChar values. it still gets some errors.
here is my code:

 hEdit = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL, 0, 0, 100, hWnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);

Errors returned:
117607-screenshot-2021-07-25-090106.png


0 Votes 0 ·

Did you read my answer and look at all of the error messages? It's still the same mistake.

0 Votes 0 ·
Show more comments