I was trying to show a window using ShowWindow in a Callback function that called is set by a SetTime after I have hided it, but it didn't worked.
Please check the following code example.
#define _WIN32_WINNT 0x0500
#include<windows.h>
void CALLBACK f(HWND hwnd, UINT uMsg, UINT timerId, DWORD dwTime)
{
MessageBoxA(NULL,"Test","test2",MB_OK);
ShowWindow( hwnd, SW_SHOW ); //This will not show the window :(
MessageBoxA(NULL,"Is it shown?","test2",MB_OK);
}
int main()
{
MSG msg;
ShowWindow( GetConsoleWindow(), SW_HIDE );
SetTimer(NULL, 0, 1000*3, &f);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
Thank you.
As @IInspectable suggested, it is the wrong handle that the call back function carries (which is the handle
NULLwhich have been passed toSetTimer).To correct the code above, you should use the same handle for both show and hide.
Thank you.