>DansTonCode();

Citation de code source en C++107

 19 June 2014 à 05:52
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <cstdlib>
#include <cstdio>
#include <Shellapi.h>



LPSTR NazwaKlasy = "Klasa Okienka";
MSG Komunikat;
HWND Przycisk1,Przycisk2,Przycisk3,Przycisk4, hText;

char * szText;

LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{

    //WYPE£NIANIE STRUKTURY
    WNDCLASSEX wc;

    wc.cbSize = sizeof( WNDCLASSEX );
    wc.style = 0;
    wc.lpfnWndProc = WndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
    wc.hCursor = LoadCursor( NULL, IDC_ARROW );
    wc.hbrBackground =( HBRUSH )( COLOR_WINDOW + 1 );
    wc.lpszMenuName = NULL;
    wc.lpszClassName = NazwaKlasy;
    wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION );



    //REJESTROWANIE KLASY OKNA
    if( !RegisterClassEx( & wc ) )
    {
        MessageBox( NULL, "Blad", "hehe", MB_ICONEXCLAMATION | MB_OK );
        return 1;
    }


    //TWORZENIE OKNA

    HWND hwnd;

    hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, NazwaKlasy, " Figury by k4rpi", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 510, 480, NULL, NULL, hInstance, NULL );

    Przycisk1 = CreateWindowEx( 0, "BUTTON", "Lalka", WS_CHILD | WS_VISIBLE, 10, 10, 90, 40, hwnd, NULL, hInstance, NULL );
    Przycisk4 = CreateWindowEx( 0, "BUTTON", "Exit", WS_CHILD | WS_VISIBLE, 400, 380, 80, 40, hwnd, NULL, hInstance, NULL );




    hText = CreateWindowEx( WS_EX_CLIENTEDGE, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 410, 210, 20, hwnd, NULL, hInstance, NULL );
    SetWindowText( hText, "Pozdrawiam Jarek Kurpiewski");





    if( hwnd == NULL )
    {
        MessageBox( NULL, "Pusto", "Pusto", MB_ICONEXCLAMATION );
        return 1;
    }

    ShowWindow( hwnd, nCmdShow ); //Poka¿ okienko...
    UpdateWindow( hwnd );

    //Pêtla komunikatów
    while( GetMessage( & Komunikat, NULL, 0, 0 ) )
    {
        TranslateMessage( & Komunikat );
        DispatchMessage( & Komunikat );
    }
    return Komunikat.wParam;
}


//OBS£UGA ZDARZEÑ
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg )
    {
    case WM_COMMAND:
        if(( HWND ) lParam == Przycisk1 )
        {
            //==================================================
               HDC hdcOkno = GetDC(hwnd);
               POINT stary;
               HBRUSH Zielony, Pudelko;
               HPEN Czerwony, Piornik;
               Zielony = CreateSolidBrush(0xFFFFFF);
               Czerwony = CreatePen(NULL, 2, 0x0000FF);
               Pudelko = (HBRUSH) SelectObject (hdcOkno, Zielony);  //okrag z obramowaniem
               Piornik = (HPEN) SelectObject (hdcOkno, Czerwony);
               Ellipse(hdcOkno, 60, 60, 150, 150);
               MoveToEx(hdcOkno ,107 ,148, & stary);
               LineTo (hdcOkno, 107, 250);
               MoveToEx(hdcOkno ,107, 250, & stary);
               LineTo (hdcOkno, 150, 330);
               MoveToEx(hdcOkno, 107, 250, & stary);
               LineTo (hdcOkno, 56, 329);
               MoveToEx(hdcOkno, 107, 150, & stary);
               LineTo (hdcOkno, 56, 230);
               MoveToEx(hdcOkno, 107, 150, & stary);
               LineTo (hdcOkno, 160, 230);
               SelectObject(hdcOkno, Pudelko);
               SelectObject(hdcOkno, Piornik);
               DeleteObject(Czerwony);
               DeleteObject(Zielony);
               ReleaseDC(hwnd, hdcOkno );

            //==================================================

        }
         if(( HWND ) lParam == Przycisk2 )
        {
            //================================================== siatka


            //==================================================

        }
        if(( HWND ) lParam == Przycisk3 )
        {
            //==================================================

            //==================================================

        }

         if(( HWND ) lParam == Przycisk4 )
        {
            //==================================================
              PostQuitMessage( 0 );
            //==================================================

        }

        break;

    case WM_CLOSE:
        DestroyWindow( hwnd );
        break;
    case WM_DESTROY:
        PostQuitMessage( 0 );
        break;
        default:
        return DefWindowProc( hwnd, msg, wParam, lParam );
    }
    return 0;
}

Allez voir les citations similaires

Partagez cette citation