in this example, even though i will never use the variables WNDCLASSEX, x, y, cx, cy, they will still use memory when i'm in the message loop:
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpArgs, int iCmdShow)
{
WNDCLASSEX wc;
...
RegisterClassEx(&wc);
const int cx = 640;
const int cy = 480;
// center of the screen
int x = (GetSystemMetrics(SM_CXSCREEN) - cx) / 2;
int y = (GetSystemMetrics(SM_CXSCREEN) - cy) / 2;
CreateWindow(..., x, y, cx, cy, ...);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
But i'm wondering, if i put them in a scope, would they still use memory during the message loop? e.g.
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpArgs, int iCmdShow)
{
{
WNDCLASSEX wc;
...
RegisterClassEx(&wc);
const int cx = 640;
const int cy = 480;
// center of the screen
int x = (GetSystemMetrics(SM_CXSCREEN) - cx) / 2;
int y = (GetSystemMetrics(SM_CXSCREEN) - cy) / 2;
CreateWindow(..., x, y, cx, cy, ...);
}
MSG msg;
while (GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
or maybe if i put them into two functions and called them in winmain e.g.
wnd_register(hInst);
wnd_create(hInst);
would that prevent them from using the memory?