I have a problem with my winAPI GUI I'm coding for my 2nd Year A-Level Computing coursework. I'm still trying to get my head around the winAPI stuff, and I'm sure It's a very simple problem I'm overlooking. The main form works fine, and just has a simple edit-box and button for testing, but when I close and open a new form, the new form takes on the characteristics I outlined in the CreateWindowEx() function (i.e a different size to the main form), but the problem is that it also contains the objects from the first form.
Here is the handle for the main form being initialised:
hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ "Child-minding App", /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ 640, /* The programs width */ 480, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ );
Here's the handle for the new form I'm opening:
hwndLogin = CreateWindowEx (0, szClassName, "Login Form", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 330, HWND_DESKTOP, NULL, hInst, NULL);
And here's an example of an object which appears on both forms
hwndButton = CreateWindowEx(0, /* more or ''extended'' styles */ TEXT("BUTTON"), /* GUI ''class'' to create */ TEXT("Push Me"), /* GUI caption */ WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON, /* control styles separated by | */ 10, /* LEFT POSITION (Position from left) */ 40, /* TOP POSITION (Position from Top) */ 200, /* WIDTH OF CONTROL */ 30, /* HEIGHT OF CONTROL */ hwnd, /* Parent window handle */ (HMENU)IDBUTTON, /* control''s ID for WM_COMMAND */ g_hInst, /* application instance */ NULL);
So just to clarify, when the hwnd form closes, and the hwndLogin form opens, the hwndLogin form also contains the button, wheras I on'y want the hwnd form to contain the button.
Can anyone see what I've done wrong?
(P.S. sorry if this is worded horribly.)