Guest User

GroupBox WINAPI

a guest
Sep 15th, 2016
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <windows.h>
  3. char ClassName[] = "ClassName";
  4. HWND test56;
  5. HWND ndat;
  6. LRESULT CALLBACK Windowpr(HWND, UINT, WPARAM, LPARAM);
  7. int WINAPI WinMain(HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil)
  8. {
  9.     WNDCLASSEX t,t5;
  10.     HWND t2,t6;
  11.     MSG t3;
  12.     t.cbSize = sizeof(WNDCLASSEX);
  13.     t.cbWndExtra = 0;
  14.     t.cbClsExtra = 0;
  15.     t.lpfnWndProc = Windowpr;
  16.     t.lpszClassName = ClassName;
  17.     t.lpszMenuName = NULL;
  18.     t.hIcon = LoadIcon(NULL,IDI_APPLICATION);
  19.     t.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
  20.     t.hCursor = LoadCursor(NULL,IDC_ARROW);
  21.     t.hInstance = hThisInstance;
  22.     t.hbrBackground = (HBRUSH)(7);
  23.     if (!RegisterClassEx(&t)){
  24.         printf("Error Ocurred 0001\n");
  25.         return -1;
  26.     }
  27.     t2 = CreateWindowEx(0,ClassName,"My title",WS_OVERLAPPEDWINDOW,0,0,300,300,NULL,NULL,NULL,NULL);
  28.     if (t2 == NULL){
  29.         printf("Error Ocurred 0002\n");
  30.         MessageBox(NULL,"Error Ocurred 0002","Error",MB_ICONERROR);
  31.         return -1;
  32.     }
  33.     ShowWindow(t2,nFunsterStil);
  34.     while(GetMessage(&t3,NULL,0,0) > 0){
  35.         TranslateMessage(&t3);
  36.         DispatchMessage(&t3);
  37.     }
  38.     return 0;
  39. }
  40.  
  41. LRESULT CALLBACK Windowpr(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam){
  42.     switch(message){
  43.         case WM_CREATE:
  44.             test56 = CreateWindow("button",NULL,WS_CHILD | WS_VISIBLE | BS_GROUPBOX,4,4,130,130,hwnd,NULL,NULL,NULL);
  45.             test56 = hwnd;
  46.             ndat = CreateWindow("button","TESTING",WS_CHILD | WS_VISIBLE | WS_BORDER | BS_CENTER,40,65,60,30,test56,(HMENU)45,NULL,NULL);
  47.             break;
  48.         case WM_COMMAND:
  49.             if (LOWORD(wparam) == 45){
  50.                 printf("Pressed button inside of groupbox :)\n");
  51.             }
  52.             break;
  53.         case WM_CLOSE:
  54.             DestroyWindow(hwnd);
  55.             break;
  56.         case WM_DESTROY:
  57.             PostQuitMessage(0);
  58.             break;
  59.         default:
  60.             DefWindowProc(hwnd,message,wparam,lparam);
  61.             break;
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment