Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C/C++ - Gui win api, bottoni a tema windows
Forum - C/C++ - Gui win api, bottoni a tema windows

Avatar
Raggio (Normal User)
Newbie


Messaggi: 1
Iscritto: 17/12/2010

Segnala al moderatore
Postato alle 18:36
Venerdė, 17/12/2010
Codice sorgente - presumibilmente C++

  1. #include <windows.h>
  2.  
  3. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  4.  
  5. static char gszClassName[]  = "MAIN1";
  6. static HINSTANCE ghInstance = NULL;
  7.  
  8. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  9.         WNDCLASSEX WndClass;
  10.         HWND hwnd;
  11.         MSG Msg;
  12.  
  13.         ghInstance = hInstance;
  14.  
  15.         WndClass.cbSize        = sizeof(WNDCLASSEX);
  16.         WndClass.style         = NULL;
  17.         WndClass.lpfnWndProc   = WndProc;
  18.         WndClass.cbClsExtra    = 0;
  19.         WndClass.cbWndExtra    = 0;
  20.         WndClass.hInstance     = ghInstance;
  21.         WndClass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
  22.         WndClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
  23.         WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  24.         WndClass.lpszMenuName  = NULL;
  25.         WndClass.lpszClassName = gszClassName;
  26.         WndClass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
  27.  
  28.         if(!RegisterClassEx(&WndClass)) {
  29.                 MessageBox(0, "Window Registration Failed!", "Error!", MB_ICONSTOP | MB_OK);
  30.                 return 0;
  31.         }
  32.  
  33.         hwnd = CreateWindowEx(
  34.                 WS_EX_STATICEDGE,
  35.                 gszClassName,
  36.                 "Main1",
  37.                 WS_OVERLAPPEDWINDOW,
  38.                 CW_USEDEFAULT, CW_USEDEFAULT,
  39.                 600, 400,
  40.                 NULL, NULL,
  41.                 ghInstance,
  42.                 NULL);
  43.  
  44.                 HWND boton = CreateWindow(
  45.                 "BUTTON","Caption",
  46.                 WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,  // Styles.0xed44332
  47.                 40,40,150,80,
  48.                 hwnd,NULL,NULL,NULL);
  49.  
  50.  
  51.  
  52.         if(hwnd == NULL) {
  53.                 MessageBox(0, "Window Creation Failed!", "Error!", MB_ICONSTOP | MB_OK);
  54.                 return 0;
  55.         }
  56.  
  57.         ShowWindow(hwnd, nCmdShow);
  58.         UpdateWindow(hwnd);
  59.  
  60.         while(GetMessage(&Msg, NULL, 0, 0)) {
  61.                 TranslateMessage(&Msg);
  62.                 DispatchMessage(&Msg);
  63.         }
  64.         return Msg.wParam;
  65. }
  66.  
  67. LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
  68.         switch(Message) {
  69.                 case WM_CLOSE:
  70.                         DestroyWindow(hwnd);
  71.                         break;
  72.                 case WM_DESTROY:
  73.                         PostQuitMessage(0);
  74.                         break;
  75.                 default:
  76.                         return DefWindowProc(hwnd, Message, wParam, lParam);
  77.         }
  78.         return 0;
  79. }



Con questo il bottone viene senza Theme e essendo su windows č un po bruttino, sapete come posso metterlo a tema?

PM
Avatar
lorenzo (Normal User)
Guru


Messaggi: 1178
Iscritto: 15/04/2008

Up
0
Down
V
Segnala al moderatore
Postato alle 21:25
Venerdė, 17/12/2010

PM