Question

I tried to create two overlapped windows but only one popped up. I plan to use 1 window to handle the buttons and another separate window(not child) to show images that changes every 1 second. Is it possible? I tried to use 1 window to handle both but the buttons went missing and are unable to click because the program is busy running the display. And what parameter to set for the HINSTANCE for the second window?

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
  HWND hWnd;
 HWND hWnd2;
 hInst = hInstance; // Store instance handle in our global variable

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  100, 0,1000, 700, NULL, NULL, hInstance, NULL);

hWnd2= CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  100, 0,1000, 700, NULL, NULL, NULL, NULL);

         CreateWindow(TEXT("button"), TEXT("\t Start Scanning\n"),
       WS_VISIBLE | WS_CHILD | WS_BORDER,
            810, 320, 150, 150,
             hWnd, (HMENU) IDM_BEGIN, NULL, NULL);

         CreateWindow(TEXT("button"), TEXT("\t STOP \n"),
       WS_VISIBLE | WS_CHILD | WS_BORDER,
            810, 480, 150, 150,
             hWnd, (HMENU) IDM_PERMASTOP, NULL, NULL);




if (!hWnd)
  {
    return FALSE;
  }

  ShowWindow(hWnd, nCmdShow);
  UpdateWindow(hWnd);

  return TRUE;
}
Was it helpful?

Solution

You are creating two overlapped windows, but you are calling ShowWindow() on only the first time. Simply call ShowWindow() on the other one as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top