Hi. The code:
#include "stdafx.h"
LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam);
HINSTANCE hInst;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hWnd;
MSG msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "Base";
wc.hIconSm = LoadIcon(NULL,IDI_WINLOGO);
if (!RegisterClassEx(&wc))
return 0;
if (!(hWnd = CreateWindowEx (NULL, "Base", "Програма керування локальними групами користувачів", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 425, 300, NULL, NULL, hInst, NULL)))
return (0);
ShowWindow(hWnd, SW_SHOWDEFAULT);
UpdateWindow(hWnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND hButton, hListBox, hComboBox, hWindow1;
switch(message)
{
case WM_CREATE:
{
hButton = CreateWindow ("BUTTON", "Створення локальної групи", WS_CHILD | WS_VISIBLE,
33, 0, 350, 20, hWnd, (HMENU)100, hInst, 0);
hButton = CreateWindow ("BUTTON", "Визначення інформації про локальну групу", WS_CHILD | WS_VISIBLE,
33, 50, 350, 20, hWnd, (HMENU)100, hInst, 0);
hButton = CreateWindow ("BUTTON", "Перерахування створених локальних груп", WS_CHILD | WS_VISIBLE,
33, 100, 350, 20, hWnd, (HMENU)100, hInst, 0);
hButton = CreateWindow ("BUTTON", "Зміна інформації про групу", WS_CHILD | WS_VISIBLE,
33, 150, 350, 20, hWnd, (HMENU)100, hInst, 0);
hButton = CreateWindow ("BUTTON", "Видалення локальної групи", WS_CHILD | WS_VISIBLE,
33, 200, 350, 20, hWnd, (HMENU)100, hInst, 0);
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case 100:
{
}
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
return (0);
}
break;
}
return (DefWindowProc(hWnd, message, wParam, lParam));
}
So, how to create new window with special stuff like buttons and editbox? And how to take the information from that editbox, for some calculation. I need that after clicking the button, new window appears.
P.S.: I get a new window, but:
1. It's similar to main(or parent).
2. If I close it, all program is closing.
hWindow1 = CreateWindowEx (NULL, "Base", "Програма керування локальними групами користувачів", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 425, 300, GetParent(hWnd), NULL, hInst, NULL);
There are no other changes to the code, only this.