Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #define p1 101
- #define p2 102
- #define p3 103
- /* Declare Windows procedure */
- LRESULT CALLBACK WindowProcedure1 (HWND, UINT, WPARAM, LPARAM);
- LRESULT CALLBACK WindowProcedure2 (HWND, UINT, WPARAM, LPARAM);
- LRESULT CALLBACK WindowProcedure3 (HWND, UINT, WPARAM, LPARAM);
- LRESULT CALLBACK tworzPrzycisk(HWND);
- HWND global;
- HWND przycisk1;
- HWND przycisk2;
- HWND przycisk3;
- /* Make the class name into a global variable */
- char szClassName1[ ] = "WindowsApp1";
- char szClassName2[ ] = "WindowsApp2";
- char szClassName3[ ] = "WindowsApp3";
- HINSTANCE hInstance;
- int WINAPI WinMain (HINSTANCE hThisInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpszArgument,
- int nFunsterStil)
- {
- hInstance = hThisInstance;
- HWND hwnd1;
- HWND hwnd2;
- HWND hwnd3; /* This is the handle for our window */
- MSG messages; /* Here messages to the application are saved */
- WNDCLASSEX wincl1;
- WNDCLASSEX wincl2;
- WNDCLASSEX wincl3; /* Data structure for the windowclass */
- /* The Window structure */
- wincl1.hInstance = hThisInstance;
- wincl1.lpszClassName = szClassName1;
- wincl1.lpfnWndProc = WindowProcedure1; /* This function is called by windows */
- wincl1.style = CS_DBLCLKS; /* Catch double-clicks */
- wincl1.cbSize = sizeof (WNDCLASSEX);
- wincl2.hInstance = hThisInstance;
- wincl2.lpszClassName = szClassName2;
- wincl2.lpfnWndProc = WindowProcedure2; /* This function is called by windows */
- wincl2.style = CS_DBLCLKS; /* Catch double-clicks */
- wincl2.cbSize = sizeof (WNDCLASSEX);
- wincl3.hInstance = hThisInstance;
- wincl3.lpszClassName = szClassName3;
- wincl3.lpfnWndProc = WindowProcedure3; /* This function is called by windows */
- wincl3.style = CS_DBLCLKS; /* Catch double-clicks */
- wincl3.cbSize = sizeof (WNDCLASSEX);
- /* Use default icon and mouse-pointer */
- wincl1.hIcon = LoadIcon (NULL, IDI_APPLICATION);
- wincl1.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
- wincl1.hCursor = LoadCursor (NULL, IDC_ARROW);
- wincl1.lpszMenuName = NULL; /* No menu */
- wincl1.cbClsExtra = 0; /* No extra bytes after the window class */
- wincl1.cbWndExtra = 0;
- wincl2.hIcon = LoadIcon (NULL, IDI_APPLICATION);
- wincl2.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
- wincl2.hCursor = LoadCursor (NULL, IDC_ARROW);
- wincl2.lpszMenuName = NULL; /* No menu */
- wincl2.cbClsExtra = 0; /* No extra bytes after the window class */
- wincl2.cbWndExtra = 0;
- wincl3.hIcon = LoadIcon (NULL, IDI_APPLICATION);
- wincl3.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
- wincl3.hCursor = LoadCursor (NULL, IDC_ARROW);
- wincl3.lpszMenuName = NULL; /* No menu */
- wincl3.cbClsExtra = 0; /* No extra bytes after the window class */
- wincl3.cbWndExtra = 0; /* structure or the window instance */
- /* Use Windows's default color as the background of the window */
- wincl1.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
- wincl2.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
- wincl3.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
- /* Register the window class, and if it fails quit the program */
- if (!RegisterClassEx (&wincl1))
- return 0;
- if (!RegisterClassEx (&wincl2))
- return 0;
- if (!RegisterClassEx (&wincl3))
- return 0;
- /* The class is registered, let's create the program*/
- hwnd1 = CreateWindowEx (
- 0, /* Extended possibilites for variation */
- szClassName1, /* Classname */
- "Program nr.1", /* Title Text */
- WS_OVERLAPPEDWINDOW, /* default window */
- 100, /* Windows decides the position */
- 100, /* where the window ends up on the screen */
- 544, /* The programs width */
- 375, /* 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 */
- );
- /* Make the window visible on the screen */
- ShowWindow (hwnd1, nFunsterStil);
- hwnd2 = CreateWindowEx (
- 0, /* Extended possibilites for variation */
- szClassName2, /* Classname */
- "Program nr.2", /* Title Text */
- WS_OVERLAPPEDWINDOW, /* default window */
- 300, /* Windows decides the position */
- 200, /* where the window ends up on the screen */
- 544, /* The programs width */
- 375, /* 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 */
- );
- ShowWindow (hwnd2, nFunsterStil);
- hwnd3 = CreateWindowEx (
- 0, /* Extended possibilites for variation */
- szClassName3, /* Classname */
- "Program nr.3", /* Title Text */
- WS_OVERLAPPEDWINDOW, /* default window */
- 500, /* Windows decides the position */
- 300, /* where the window ends up on the screen */
- 544, /* The programs width */
- 375, /* 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 */
- );
- global = hwnd2;
- /* Make the window visible on the screen */
- ShowWindow (hwnd3, nFunsterStil);
- /* Run the message loop. It will run until GetMessage() returns 0 */
- while (GetMessage (&messages, NULL, 0, 0))
- {
- /* Translate virtual-key messages into character messages */
- TranslateMessage(&messages);
- /* Send message to WindowProcedure */
- DispatchMessage(&messages);
- }
- /* The program return-value is 0 - The value that PostQuitMessage() gave */
- return messages.wParam;
- }
- /* This function is called by the Windows function DispatchMessage() */
- LRESULT CALLBACK WindowProcedure1 (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message) /* handle the messages */
- {
- case WM_DESTROY:
- if(hwnd == global)
- {
- PostQuitMessage (0); /* send a WM_QUIT to the message queue */
- break;
- }
- default: /* for messages that we don't deal with */
- return DefWindowProc (hwnd, message, wParam, lParam);
- case WM_CHAR:
- switch(wParam)
- {
- case '1':
- PostQuitMessage (0);
- break;
- }
- }
- return 0;
- }
- LRESULT CALLBACK WindowProcedure2 (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message) /* handle the messages */
- {
- case WM_DESTROY:
- if(hwnd == global)
- {
- PostQuitMessage (0); /* send a WM_QUIT to the message queue */
- break;
- }
- default: /* for messages that we don't deal with */
- return DefWindowProc (hwnd, message, wParam, lParam);
- case WM_CHAR:
- switch(wParam)
- {
- case '2':
- PostQuitMessage (0);
- break;
- }
- }
- return 0;
- }
- LRESULT CALLBACK WindowProcedure3 (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message) /* handle the messages */
- {
- case WM_DESTROY:
- if(hwnd == global)
- {
- PostQuitMessage (0); /* send a WM_QUIT to the message queue */
- break;
- }
- default: /* for messages that we don't deal with */
- return DefWindowProc (hwnd, message, wParam, lParam);
- case WM_CHAR:
- switch(wParam)
- {
- case '3':
- PostQuitMessage (0);
- break;
- }
- case WM_CREATE:
- tworzPrzycisk(hwnd);
- break;
- case WM_COMMAND:
- switch(wParam)
- case p1:
- PostQuitMessage (0);
- break;
- }
- return 0;
- }
- LRESULT CALLBACK tworzPrzycisk(HWND hwnd)
- {
- przycisk1 = CreateWindowEx (
- 0, /* Extended possibilites for variation */
- "BUTTON", /* Classname */
- "Przycisk1", /* Title Text */
- WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, /* default window */
- 50, /* Windows decides the position */
- 50, /* where the window ends up on the screen */
- 100, /* The programs width */
- 50, /* and height in pixels */
- hwnd, /* The window is a child-window to desktop */
- (HMENU)p1, /* No menu */
- hInstance, /* Program Instance handler */
- NULL /* No Window Creation data */
- );
- przycisk2 = CreateWindowEx (
- 0, /* Extended possibilites for variation */
- "BUTTON", /* Classname */
- "Przycisk2", /* Title Text */
- WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, /* default window */
- 150, /* Windows decides the position */
- 150, /* where the window ends up on the screen */
- 100, /* The programs width */
- 50, /* and height in pixels */
- hwnd, /* The window is a child-window to desktop */
- (HMENU)p2, /* No menu */
- hInstance, /* Program Instance handler */
- NULL /* No Window Creation data */
- );
- przycisk3 = CreateWindowEx (
- 0, /* Extended possibilites for variation */
- "BUTTON", /* Classname */
- "Przycisk3", /* Title Text */
- WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, /* default window */
- 250, /* Windows decides the position */
- 250, /* where the window ends up on the screen */
- 100, /* The programs width */
- 50, /* and height in pixels */
- hwnd, /* The window is a child-window to desktop */
- (HMENU)p3, /* No menu */
- hInstance, /* Program Instance handler */
- NULL /* No Window Creation data */
- );
- }
Add Comment
Please, Sign In to add comment