Page windows

lanocm Messages postés 63 Statut Membre -  
 géry -
- Comment crée une page windows en C ?

3 réponses

  1. gery
     
    Salut

    Heuuu une page je sais pas ce que tu veux

    une fenêtre, une page sur l'imprimante , un aperçu?

    faudrait etre un peu plus précis

    @+
    ps: ce qui est ecrit juste sous le bouton ajouter

    Pour maximiser vos chances d'obtenir des réponses à votre message veuillez s'il vous plaît :
    Faire usage de formules de politesse (Bonjour, merci, SVP),
    Mettre un titre explicite décrivant au mieux votre problème,
    0
  2. lanocm Messages postés 63 Statut Membre 3
     
    au fait c'est une fenetre
    0
  3. géry
     
    Salut ....

    pas trop impatient?

    //VC++ 6

    #include <windows.h>
    #include <stdio.h>
    #include <math.h>
    #include <string.h>

    //definition de mes evenements
    //voir création du bouton
    #define poli 20

    //déclarations
    //instance
    HINSTANCE G_Hinst;
    //nom de ma classe
    const char clasname[]="Ma_fenêtre";
    //handle
    //Ma classe
    WNDCLASS wcx;
    //handle de ma fenetre
    HWND hwfnd;
    //handle de mon bouton
    HWND hwbnd;
    //handle de mon edit
    HWND hwend;
    //mes messages
    MSG msg;

    //**********************************************
    //boucle de message
    //**********************************************
    //tout passe par là

    LRESULT CALLBACK MainWndProc(HWND hwfnd, UINT numevent, WPARAM wparam, LPARAM lparam)
    {
    int wNotifyCode;
    int wID;

    HWND hwndCtl;

    switch (numevent)
    {

    case WM_CREATE:
    //a la création de ma fenetre création d'un bouton et une edit
    hwbnd=CreateWindow("BUTTON","Politesse",WS_VISIBLE|WS_CHILD,10,10,100,100,hwfnd,(HMENU)poli,G_Hinst,NULL);
    hwend=CreateWindowEx (WS_EX_CLIENTEDGE,"EDIT","STP",WS_VISIBLE|WS_CHILD|ES_CENTER|WS_BORDER,10,120,300,20,hwfnd,(HMENU)NULL,G_Hinst,NULL);

    break;

    case WM_CLOSE:
    PostMessage( hwfnd, WM_QUIT, 0, 0 );
    return 0;

    // commande (evenement dans ma fenetre)
    case WM_COMMAND:
    wNotifyCode = HIWORD(wparam); // notification code
    wID = LOWORD(wparam); // item, control, or accelerator identifier
    hwndCtl = (HWND) lparam; // handle of control

    switch (wID)

    {
    //correspond a mon bouton (define poli)
    case poli:
    //ecrit dans l'edit
    SetWindowText(hwend,"Ceci est un Exemple");

    }

    break;

    }

    return DefWindowProc(hwfnd, numevent, wparam, lparam);
    }

    //fin de boucle

    //**********************************************
    // point d'entrée du programme
    //**********************************************

    int WINAPI WinMain( HINSTANCE hInstance, // handle to current instance
    HINSTANCE hPrevInstance, // handle to previous instance
    LPSTR lpCmdLine, // pointer to command line
    int nCmdShow ) // show state of window);

    {
    // Déclarations
    //recupère mon hinstance
    G_Hinst=hInstance;

    // Création d' une classe de fenêtre

    wcx.style = CS_HREDRAW | CS_VREDRAW|CS_SAVEBITS;// redessine si la taille change
    wcx.lpfnWndProc = (WNDPROC) MainWndProc; // fonction de la reception des messages
    wcx.cbClsExtra = 0; // no extra class memory
    wcx.cbWndExtra = 0; // no extra window memory
    wcx.hInstance = G_Hinst; // handle de instance de winmain
    wcx.hIcon = LoadIcon(NULL,IDI_APPLICATION);// predefined app. icon
    wcx.hCursor = LoadCursor(NULL,IDC_ARROW); // predefined souris arrow
    wcx.hbrBackground = (HBRUSH) (COLOR_BTNFACE+1); // fond blanc
    wcx.lpszClassName = clasname; // nom de la classe window

    // enregistrer la classe de window .
    //test si ok
    if(RegisterClass(&wcx)==FALSE)
    {

    return FALSE;
    }

    //Création de la fenêtre
    hwfnd = CreateWindow(clasname, // nom de la classe
    "Ma Page", // barre de titre
    WS_OVERLAPPEDWINDOW|WS_BORDER, // focus
    250, // position horizontal position
    150, // position vertical position
    600, // taille default width
    490, // taille default height
    (HWND) NULL, // no owner window
    (HMENU) NULL, // use class menu
    G_Hinst, // handle of application instance
    (LPVOID) NULL); // no window-creation data

    // Fin Création de la fenêtre

    ShowWindow(hwfnd,SW_SHOW);
    UpdateWindow(hwfnd);
    // variables

    //Boucle gestion de Message
    while( GetMessage( &msg, (HWND)NULL, 0, 0 ) )
    {

    TranslateMessage( &msg );

    DispatchMessage( &msg );

    }
    //Fin de Boucle de Message

    return msg.wParam;
    }
    bye
    0