SirGregg
SirGregg

Reputation: 100

First and last window don't show up

I'm creating a WinApi application for my programming course. The program is supposed to show an LED clock using a separate window for each 'block'. I have figured most of it out, except for one thing: when creating the two-dimensional array of windows, the first and last window never show up. Here's the piece of code from the InitInstance function:

for (int x=0;x<8;x++)
    for (int y=0;y<7;y++) {
    digitWnd[x][y] = CreateWindowEx((WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_NOACTIVATE | WS_EX_STATICEDGE),
        szWindowClass, szTitle, (WS_POPUP| WS_BORDER), NULL, NULL, NULL, NULL, dummyWnd, NULL, hInstance, NULL);
    ShowWindow(digitWnd[x][y], nCmdShow);
    UpdateWindow(digitWnd[x][y]);
    } 

The same loop bounds are used everytime I interact with the windows (set position and enable/disable). All the windows seem to be working fine, except for digitWnd[0][0] and digitWnd[7][6]... Any ideas as to what is happening?

Upvotes: 0

Views: 149

Answers (3)

Warpspace
Warpspace

Reputation: 3478

Is this your first call to ShowWindow()? If so, according to MSDN, "nCmdShow: [in] Specifies how the window is to be shown. This parameter is ignored the first time an application calls ShowWindow". This could mean that you can fix your program by simply calling ShowWindow() twice. Give it a try and see if it works. Other than that, you'll probably have to provide more of the code for us to look at.

Upvotes: 0

codencandy
codencandy

Reputation: 1721

To validate your creation mechanism I would check:

  1. the array initialisation HWND digitWnd[8][7]

  2. if the parent window dummyWnd is valid

  3. the return value of CreateWindowEx() != NULL

Another point which comes to my mind is, that you create windows with dimension 0 - no width or height. So maybe it would be a good idea to set the size within CreateWindowEx(...)

Upvotes: 0

Franci Penov
Franci Penov

Reputation: 76021

Open Spy++ and check if the missing windows are really missing or just overlapped by other windows. It's possible that you have some small error in the position calculations code that puts them behind another window or outside of the screen.

Upvotes: 1

Related Questions