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++ - !!funzione TextOut!!
Forum - C/C++ - !!funzione TextOut!! - Pagina 3

Pagine: [ 1 2 3 ] Precedente | Prossimo
Avatar
theprogrammer (Normal User)
Guru^2


Messaggi: 2509
Iscritto: 28/01/2009

Segnala al moderatore
Postato alle 18:57
Domenica, 24/05/2009
Qualcosa del genere ...

Codice sorgente - presumibilmente C++

  1. #define MAX_LOADSTRING 100
  2.  
  3. HINSTANCE hInst;                                                               
  4. TCHAR szTitle[MAX_LOADSTRING];                                 
  5. TCHAR szWindowClass[MAX_LOADSTRING];                   
  6.  
  7. ATOM                            MyRegisterClass(HINSTANCE hInstance);
  8. BOOL                            InitInstance(HINSTANCE, int);
  9. LRESULT CALLBACK        WndProc(HWND, UINT, WPARAM, LPARAM);
  10.  
  11. int APIENTRY _tWinMain(HINSTANCE hInstance,
  12.                      HINSTANCE hPrevInstance,
  13.                      LPTSTR    lpCmdLine,
  14.                      int       nCmdShow)
  15. {
  16.         strcpy(szTitle, "Esempio");
  17.         strcpy(szWindowClass, "Esempio");
  18.         MyRegisterClass(hInstance);
  19.  
  20.         if (!InitInstance (hInstance, nCmdShow))
  21.                 return FALSE;
  22.  
  23.         MSG msg;
  24.         while (GetMessage(&msg, NULL, 0, 0))
  25.         {
  26.                 if (!TranslateAccelerator(msg.hwnd, NULL, &msg))
  27.                 {
  28.                         TranslateMessage(&msg);
  29.                         DispatchMessage(&msg);
  30.                 }
  31.         }
  32.  
  33.         return (int) msg.wParam;
  34. }
  35.  
  36. ATOM MyRegisterClass(HINSTANCE hInstance)
  37. {
  38.         WNDCLASSEX wcex;
  39.  
  40.         wcex.cbSize = sizeof(WNDCLASSEX);
  41.  
  42.         wcex.style                      = CS_HREDRAW | CS_VREDRAW;
  43.         wcex.lpfnWndProc        = WndProc;
  44.         wcex.cbClsExtra         = 0;
  45.         wcex.cbWndExtra         = 0;
  46.         wcex.hInstance          = hInstance;
  47.         wcex.hIcon                      = NULL;
  48.         wcex.hCursor            = LoadCursor(NULL, IDC_ARROW);
  49.         wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW+1);
  50.         wcex.lpszMenuName       = NULL;
  51.         wcex.lpszClassName      = szWindowClass;
  52.         wcex.hIconSm            = NULL;
  53.  
  54.         return RegisterClassEx(&wcex);
  55. }
  56.  
  57. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  58. {
  59.    HWND hWnd;
  60.  
  61.    hInst = hInstance;
  62.  
  63.    hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  64.       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
  65.  
  66.    if (!hWnd) return FALSE;
  67.    
  68.    ShowWindow(hWnd, nCmdShow);
  69.    UpdateWindow(hWnd);
  70.  
  71.    return TRUE;
  72. }
  73.  
  74. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  75. {
  76.         PAINTSTRUCT ps;
  77.         HDC hdc;
  78.  
  79.         switch (message)
  80.         {
  81.                 case WM_PAINT:
  82.                         hdc = BeginPaint(hWnd, &ps);
  83.                         TextOut(hdc, 100, 100, "ok", 2);
  84.                         EndPaint(hWnd, &ps);
  85.                         break;
  86.                 case WM_DESTROY:
  87.                         PostQuitMessage(0);
  88.                         break;
  89.                 default:
  90.                         return DefWindowProc(hWnd, message, wParam, lParam);
  91.         }
  92.  
  93.         return 0;
  94. }


PM Quote
Avatar
()
Newbie


Messaggi:
Iscritto:

Segnala al moderatore
Postato alle 15:29
Martedė, 26/05/2009
grazie 1000!!! mi sei stato utilissimo:k::k:

PM Quote
Pagine: [ 1 2 3 ] Precedente | Prossimo