I am trying to create a popup window when I click a button on my main window, and I am using the CreateWindowEX function for that purpose. However, the CreateWindowEx function recieves the HINSTANCE type variable as its second last parameter. Given that I am making this new window from inside the WndProcedure when a button is being clicked, the HINSTANCE variable in the WinMain function will not be available to me because it is not a global variable.
The following code was obtained from the WndProcedure callback function:
case IDC_BUTTON PRESSED:
{
const char g_szClassName2[] = "POPWIND";
const char WndName2[] = "POPUP WINDOW";
HWND invisWindowHandle = CreateWindowEx(0,
g_szClassName2,
WndName2,
WS_OVERLAPPEDWINDOW,
200,
200,
800,
500,
NULL,
NULL,
hInstance,//THIS IS THE VARIABLE I AM HAVING TROUBLE GETTING
NULL);
ShowWindow(invisWindowHandle, 3);// SW_SHOWNORMAL);
UpdateWindow(invisWindowHandle);
}
How would I go about getting the hInstance variable I need so that the CreateWindowEx function works from inside the WndProcedure callback function?
Note: I considered making the hInstance variable global, but I am not sure if the same hInstance has to be used for every single window my application makes.