tags:

views:

74

answers:

3

Hi,
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?

+1  A: 

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.

Franci Penov
...and if you don't have Spy++ on your system, see this thread on substitutes: http://stackoverflow.com/questions/1811019/i-want-spy-but-i-dont-have-visual-studio
Hostile Fork
Negative... I tried specifically positioning the windows in different places, with no success. I also noticed that if I create another 'dummy' window after the loop the digitWnd[7][6] will show up, but that isn't really the solution, and also doesn't solve the problem with digitWnd[0][0] :(
SirGregg
A: 

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(...)

Holger Kretzschmar
A: 

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.

Warpspace