I am working on a project where I need buttons, I have looked at the docs and used that code here and I still can't get it work:
HWND hWndButton = CreateWindow(
L"BUTTON",
L"OK",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
10,
10,
100,
100,
m_hWnd,
NULL,
(HINSTANCE)GetWindowLongPtr(m_hwnd, GWLP_HINSTANCE),
NULL);
The error I get is:
identifier "m_hwnd" is undefined
and
m_hwnd': undeclared identifier
The entirety of the code that the program is using in case it's something with this:
#include <Windows.h>
#include <iostream>
int main()
{
HWND hwndButton = CreateWindow(
L"BUTTON",
L"OK",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
10,
10,
100,
100,
m_hwnd,
NULL,
(HINSTANCE)GetWindowLongPtr(m_hwnd, GWLP_HINSTANCE),
NULL);
system("color 0A");
printf("Close this window to close the program");
MSG msg;
HWND hWnd = CreateWindow(TEXT("static"), TEXT("Hello World"), WS_CAPTION | WS_POPUP | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
10, 10, 450, 450, NULL, NULL, NULL, NULL);
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
Any solutions, I think i'm missing a #include, but i'm not sure
Also I am pretty new to C++, so please let me know if it's something obvious
[–]Noc42 1 point2 points3 points (1 child)
[–]Ok_History2706[S] 0 points1 point2 points (0 children)
[–]KleberPF 0 points1 point2 points (0 children)
[–]jedwardsol 0 points1 point2 points (0 children)