I'm learning the WinAPI for now... 3 days ? and I'm already facing a problem. Indeed, in order to create a DialogBox, we need to write its template in a resource file ( resource.rc for example ).
Here is my resource.rc:
#include "IDs.h"
#include <windows.h>
DIALOG_HELP DIALOG
CW_USEDEFAULT, CW_USEDEFAULT, 200, 120
STYLE WS_OVERLAPPEDWINDOW
CAPTION "Title"
BEGIN
DEFPUSHBUTTON "Ok", IDOK, 96, 90, 42, 12
ICON icone1, -1, 60, 55, 32, 32
LTEXT "Test DialogBox", -1, 100, 58, 100, 10
END
The thing is that #include seems not to be working as it should.
I got resource.rc(6): error RC2108: expected numerical dialog constant
when compiling, as if windows.h was not included and that the compiler didn't know what CW_USEDEFAULT is. When I define CW_USEDEFAULT on my own with a simple #define CW_USEDEFAULT 1, it works, no problem, but it would be getting round the problem.
How could I get this to work ? Thanks
error RC2108: expected numerical dialog constant
This means you must use a reasonable number (probably 0). CW_USEDEFAULT
(which is (int)0x80000000L
) is only meaningful for CreateWindow() / CreateWindowEx()
WinAPI functions. As the resource compiler neither supports type casts, nor allows negative dialog coordinates, it results in a syntax error.
Also the style WS_OVERLAPPEDWINDOW
should not be used with dialogs. Consider using WS_POPUP
-based style instead.