IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C Discussion :

comment enleve la bande blanche du raffraichissement


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Juillet 2003
    Messages
    140
    Détails du profil
    Informations forums :
    Inscription : Juillet 2003
    Messages : 140
    Par défaut [RESOLU]comment enleve la bande blanche du raffraichissement
    je cherche un moyen pour ne plus voir cette bande blanche qui apparait quand ma fenetre reaffiche toutes les images?

    vous avez des solutions?

  2. #2
    Membre expérimenté
    Avatar de GLDavid
    Homme Profil pro
    Head of Service Delivery
    Inscrit en
    Janvier 2003
    Messages
    2 892
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Head of Service Delivery
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : Janvier 2003
    Messages : 2 892
    Par défaut
    Euuuhhh, tu veux bien préciser ta pensée ? Qu'est ce que tu utilises comme GUI pour afficher tes images, t'aurais pas du code pour nous aiguiller ? Parce que là, c'est plutôt lég' pour t'aider !
    @ ++
    GLDavid
    Consultez la FAQ Perl ainsi que mes cours de Perl.
    N'oubliez pas les balises code :tagcode: ni le tag :resolu:

    Je ne répond à aucune question technique par MP.

  3. #3
    Membre confirmé
    Inscrit en
    Juillet 2003
    Messages
    140
    Détails du profil
    Informations forums :
    Inscription : Juillet 2003
    Messages : 140
    Par défaut
    voila mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
     
    #include <stdio.h>
    #include <windows.h>
    #include <conio.c>
    #pragma hdrstop
     
    static char g_szClassName[] = "MyWindowClass";
    static HINSTANCE g_hInst = NULL;
     
     
    HBITMAP hb1,hb2,hb3,hb4,hb5,hb6;
    BITMAP bm[6];
    int htitfn=25, largfen=5, winX = 0, winY = 0, winfX = 900, winfY = 700, i, j, X, Y,bsourisapp=2,bapp=-2;
    int bouton[][5]={{663+largfen,71+htitfn,793+largfen,111+htitfn},{663+largfen,142+htitfn,793+largfen,182+htitfn},{663+largfen,213+htitfn,793+largfen,253+htitfn},{663+largfen,526+htitfn,793+largfen,566+htitfn}};
    RECT rc;
    int bx[] = {0, 663, 663, 663, 663};
    int by[] = {0, 71, 142, 213, 526};
    POINT pt;
     
    void DrawBall(HDC hdc)
    {
     
       HDC hdcMemory;
       hdcMemory = CreateCompatibleDC(hdc);
     
     
             SelectObject(hdcMemory, hb1);
             BitBlt(hdc, bx[0], by[0], bm[1].bmWidth, bm[1].bmHeight, hdcMemory, 0, 0, SRCAND);
             SelectObject(hdcMemory, hb2);
             BitBlt(hdc, bx[1], by[1], bm[2].bmWidth, bm[2].bmHeight, hdcMemory, 0, 0, SRCAND);
             SelectObject(hdcMemory, hb3);
             BitBlt(hdc, bx[2], by[2], bm[3].bmWidth, bm[3].bmHeight, hdcMemory, 0, 0, SRCAND);
             SelectObject(hdcMemory, hb4);
             BitBlt(hdc, bx[3], by[3], bm[4].bmWidth, bm[4].bmHeight, hdcMemory, 0, 0, SRCAND);
             SelectObject(hdcMemory, hb5);
             BitBlt(hdc, bx[4], by[4], bm[5].bmWidth, bm[5].bmHeight, hdcMemory, 0, 0, SRCAND);
     
       DeleteDC(hdcMemory);
    }
     
    LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
    if(bapp==-2)
    {
    hb1 = LoadBitmap(g_hInst, "TITRE");
             GetObject(hb1, sizeof(bm[1]), &bm[1]);
             hb2 = LoadBitmap(g_hInst, "BTSOLO");
             GetObject(hb2, sizeof(bm[2]), &bm[2]);
             hb3 = LoadBitmap(g_hInst, "BTOPTIONS");
             GetObject(hb3, sizeof(bm[3]), &bm[3]);
             hb4 = LoadBitmap(g_hInst, "BTCREDITS");
             GetObject(hb4, sizeof(bm[4]), &bm[4]);
             hb5 = LoadBitmap(g_hInst, "BTQUITTER");
             GetObject(hb5, sizeof(bm[5]), &bm[5]);
             bapp=-1;
    }
    if(bapp==0)
    {
             DeleteObject(hb2);
             hb2 = LoadBitmap(g_hInst, "BTSOLOS");
             GetObject(hb2, sizeof(bm[2]), &bm[2]);
             InvalidateRect(hwnd, NULL, 250,20,300,40);
             bapp=-1;
    }
     
       switch(Message)
       {
          case WM_PAINT:
          if(hb1 && hb2 && hb3 && hb4 && hb5)
                {
                PAINTSTRUCT ps;
                HDC hdcWindow;
                hdcWindow = BeginPaint(hwnd, &ps);
                DrawBall(hdcWindow);
                SetBkMode(hdcWindow,TRANSPARENT);
                SetTextColor(hdcWindow,RGB(255,100,50));
                TextOut(hdcWindow, 0, 0, " Hello, Windows!", 15);
                EndPaint(hwnd, &ps);
                }
          break;
          case WM_CHAR: 
                switch (wParam) 
                { 
                    default: 
     
                        // Process displayable characters. 
     
                        break; 
                }
          if(bsourisapp!=1)
          {
          case WM_LBUTTONDOWN:
               bsourisapp=1;
               if(bsourisapp==1)
               {
               GetCursorPos(&pt);
               X=pt.x;
               Y=pt.y;
               for (i=0;i<=3;i++)
                   {
                   if(X>=bouton[i][j] && X<=bouton[i][j+2])
                     {
                     if(Y>=bouton[i][j+1] && Y<=bouton[i][j+3])
                       {
                       bapp=i;
                       break;
                       }
                     }
                   }
               }
          break;
          }
          case WM_LBUTTONUP:
               bsourisapp=0;
          break;
          case WM_CLOSE:
             DestroyWindow(hwnd);
          break;
          case WM_DESTROY:
             DeleteObject(hb1);
             DeleteObject(hb2);
             DeleteObject(hb3);
             DeleteObject(hb4);
             DeleteObject(hb5);
             PostQuitMessage(0);
          break;
          default:
             return DefWindowProc(hwnd, Message, wParam, lParam);
       }
       return 0;
    }
     
     
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
       LPSTR lpCmdLine, int nCmdShow)
    {
       WNDCLASSEX WndClass;
       HWND hwnd;
       MSG Msg;
     
       g_hInst = hInstance;
     
       WndClass.cbSize        = sizeof(WNDCLASSEX);
       WndClass.style         = 0;
       WndClass.lpfnWndProc   = WndProc;
       WndClass.cbClsExtra    = 0;
       WndClass.cbWndExtra    = 0;
       WndClass.hInstance     = g_hInst;
       WndClass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
       WndClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
       WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE);
       WndClass.lpszMenuName  = NULL;
       WndClass.lpszClassName = g_szClassName;
       WndClass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
     
       if(!RegisterClassEx(&WndClass))
       {
          MessageBox(0, "Window Registration Failed!", "Error!",
             MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
          return 0;
       }
     
       hwnd = CreateWindowEx(
          WS_EX_CLIENTEDGE,
          g_szClassName,
          "A Bitmap Program",
          WS_OVERLAPPEDWINDOW,
          winX, winY, winfX, winfY,
          NULL, NULL, g_hInst, NULL);
     
       if(hwnd == NULL)
       {
          MessageBox(0, "Window Creation Failed!", "Error!",
             MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
          return 0;
       }
     
       ShowWindow(hwnd, nCmdShow);
       UpdateWindow(hwnd);
     
       while(GetMessage(&Msg, NULL, 0, 0))
       {
          TranslateMessage(&Msg);
          DispatchMessage(&Msg);
       }
       return Msg.wParam;
    }

  4. #4
    Expert éminent

    Avatar de Anomaly
    Homme Profil pro
    Inscrit en
    Juin 2003
    Messages
    10 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2003
    Messages : 10 379
    Billets dans le blog
    1
    Par défaut
    Remplace :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE);
    Par :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    WndClass.hbrBackground = NULL;
    Ainsi le fond ne se réaffichera pas et tu n'auras pas de clignotement. Mais par contre tu dois bien t'assurer que tu dessines le fond quand même, sinon tu auras des effets de pseudo-transparences qui ne seront pas du plus bel effet.

  5. #5
    Membre confirmé
    Inscrit en
    Juillet 2003
    Messages
    140
    Détails du profil
    Informations forums :
    Inscription : Juillet 2003
    Messages : 140
    Par défaut
    le probleme c'est que maintenant j'ai ces effets de pseudo-transparence....

    je fait comment pour les enlever

  6. #6
    Expert confirmé

    Homme Profil pro
    pdg
    Inscrit en
    Juin 2003
    Messages
    5 756
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : pdg

    Informations forums :
    Inscription : Juin 2003
    Messages : 5 756
    Billets dans le blog
    3
    Par défaut
    Faut d'abord effacer le bitmap.
    Dans la fonction DrawBall avant le premier blit tu fais un PatBlt ou un FillRect.

  7. #7
    Expert éminent

    Avatar de Anomaly
    Homme Profil pro
    Inscrit en
    Juin 2003
    Messages
    10 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2003
    Messages : 10 379
    Billets dans le blog
    1
    Par défaut
    HW>> S'il fait ça, il va revenir dans le cas initial.

    Non, ici, la solution, c'est de faire du double-buffering.
    - Tu crées un bitmap de la taille de la fenêtre
    - Sur le bitmap, tu dessines un rectangle rempli avec la couleur de fond avec FillRect, de la taille du bitmap
    - Tu dessines tes différents objets sur ton bitmap
    - Tu copies le bitmap entièrement sur l'écran
    - Tu libères le bitmap

    Pour créer un bitmap : CreateCompatibleBitmap().
    Pour dessiner sur un bitmap : tu crées un DC avec CreateCompatibleDC(),
    tu sélectionnes le bitmap avec SelectObject().
    Le DC sera supprimé avec DeleteDC()
    (n'oublie pas de désélectionner le bitmap et de le supprimer).

    En espérant t'avoir aidé.

  8. #8
    Membre confirmé
    Inscrit en
    Juillet 2003
    Messages
    140
    Détails du profil
    Informations forums :
    Inscription : Juillet 2003
    Messages : 140
    Par défaut
    oki j'ai a peu pres compris comment il fallait faire

  9. #9
    Membre confirmé
    Inscrit en
    Juillet 2003
    Messages
    140
    Détails du profil
    Informations forums :
    Inscription : Juillet 2003
    Messages : 140
    Par défaut
    j'ai rajouter ca mais ca me fait toujours la bande blanche, ce qui est rajouter est preceder de //

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
     
    #include <stdio.h>
    #include <windows.h>
    #include <conio.c>
    #pragma hdrstop
     
    static char g_szClassName[] = "MyWindowClass";
    static HINSTANCE g_hInst = NULL;
     
     
    HBITMAP hb1,hb2,hb3,hb4,hb5,hb6,     // hbfond;
    BITMAP bm[6];
    int htitfn=25, largfen=5, winX = 0, winY = 0, winfX = 900, winfY = 700, i, j, X, Y,bsourisapp=2,bapp=-2;
    int bouton[][5]={{663+largfen,71+htitfn,793+largfen,111+htitfn},{663+largfen,142+htitfn,793+largfen,182+htitfn},{663+largfen,213+htitfn,793+largfen,253+htitfn},{663+largfen,526+htitfn,793+largfen,566+htitfn}};
     
    // RECT rc;
     
    int bx[] = {0, 663, 663, 663, 663};
    int by[] = {0, 71, 142, 213, 526};
    POINT pt;
     
    void DrawBall(HDC hdc)
    {
     
       HDC hdcMemory;
       hdcMemory = CreateCompatibleDC(hdc);
     
             //        hbfond = CreateCompatibleBitmap ( hdc, 800, 600 );
             //        SelectObject ( hdcMemory, hbfond );
             //        SetRect (&rc,0,0,800,600);
             //        FillRect(hdc, &rc, (HBRUSH) (COLOR_WINDOW+1));
             SelectObject(hdcMemory, hb1);
             BitBlt(hdc, bx[0], by[0], bm[1].bmWidth, bm[1].bmHeight, hdcMemory, 0, 0, SRCAND);
             SelectObject(hdcMemory, hb2);
             BitBlt(hdc, bx[1], by[1], bm[2].bmWidth, bm[2].bmHeight, hdcMemory, 0, 0, SRCAND);
             SelectObject(hdcMemory, hb3);
             BitBlt(hdc, bx[2], by[2], bm[3].bmWidth, bm[3].bmHeight, hdcMemory, 0, 0, SRCAND);
             SelectObject(hdcMemory, hb4);
             BitBlt(hdc, bx[3], by[3], bm[4].bmWidth, bm[4].bmHeight, hdcMemory, 0, 0, SRCAND);
             SelectObject(hdcMemory, hb5);
             BitBlt(hdc, bx[4], by[4], bm[5].bmWidth, bm[5].bmHeight, hdcMemory, 0, 0, SRCAND);
     
       DeleteDC(hdcMemory);
    }
     
    LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
    if(bapp==-2)
    {
    hb1 = LoadBitmap(g_hInst, "TITRE");
             GetObject(hb1, sizeof(bm[1]), &bm[1]);
             hb2 = LoadBitmap(g_hInst, "BTSOLO");
             GetObject(hb2, sizeof(bm[2]), &bm[2]);
             hb3 = LoadBitmap(g_hInst, "BTOPTIONS");
             GetObject(hb3, sizeof(bm[3]), &bm[3]);
             hb4 = LoadBitmap(g_hInst, "BTCREDITS");
             GetObject(hb4, sizeof(bm[4]), &bm[4]);
             hb5 = LoadBitmap(g_hInst, "BTQUITTER");
             GetObject(hb5, sizeof(bm[5]), &bm[5]);
             bapp=-1;
    }
    if(bapp==0)
    {
             DeleteObject(hb2);
             hb2 = LoadBitmap(g_hInst, "BTSOLOS");
             GetObject(hb2, sizeof(bm[2]), &bm[2]);
             InvalidateRect(hwnd, NULL, TRUE);
             bapp=-1;
    }
     
       switch(Message)
       {
          case WM_PAINT:
          if(hb1 && hb2 && hb3 && hb4 && hb5)
                {
                PAINTSTRUCT ps;
                HDC hdcWindow;
                hdcWindow = BeginPaint(hwnd, &ps);
                DrawBall(hdcWindow);
                SetBkMode(hdcWindow,TRANSPARENT);
                SetTextColor(hdcWindow,RGB(255,100,50));
                TextOut(hdcWindow, 0, 0, " Hello, Windows!", 15);
                EndPaint(hwnd, &ps);
                }
          break;
          case WM_CHAR: 
                switch (wParam) 
                { 
                    default: 
     
                        // Process displayable characters. 
     
                        break; 
                }
          if(bsourisapp!=1)
          {
          case WM_LBUTTONDOWN:
               bsourisapp=1;
               if(bsourisapp==1)
               {
               GetCursorPos(&pt);
               X=pt.x;
               Y=pt.y;
               for (i=0;i<=3;i++)
                   {
                   if(X>=bouton[i][j] && X<=bouton[i][j+2])
                     {
                     if(Y>=bouton[i][j+1] && Y<=bouton[i][j+3])
                       {
                       bapp=i;
                       break;
                       }
                     }
                   }
               }
          break;
          }
          case WM_LBUTTONUP:
               bsourisapp=0;
          break;
          case WM_CLOSE:
             DestroyWindow(hwnd);
          break;
          case WM_DESTROY:
             DeleteObject(hb1);
             DeleteObject(hb2);
             DeleteObject(hb3);
             DeleteObject(hb4);
             DeleteObject(hb5);
             PostQuitMessage(0);
          break;
          default:
             return DefWindowProc(hwnd, Message, wParam, lParam);
       }
       return 0;
    }
     
     
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
       LPSTR lpCmdLine, int nCmdShow)
    {
       WNDCLASSEX WndClass;
       HWND hwnd;
       MSG Msg;
     
       g_hInst = hInstance;
     
       WndClass.cbSize        = sizeof(WNDCLASSEX);
       WndClass.style         = 0;
       WndClass.lpfnWndProc   = WndProc;
       WndClass.cbClsExtra    = 0;
       WndClass.cbWndExtra    = 0;
       WndClass.hInstance     = g_hInst;
       WndClass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
       WndClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
       WndClass.hbrBackground = NULL;
       WndClass.lpszMenuName  = NULL;
       WndClass.lpszClassName = g_szClassName;
       WndClass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
     
       if(!RegisterClassEx(&WndClass))
       {
          MessageBox(0, "Window Registration Failed!", "Error!",
             MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
          return 0;
       }
     
       hwnd = CreateWindowEx(
          WS_EX_CLIENTEDGE,
          g_szClassName,
          "A Bitmap Program",
          WS_OVERLAPPEDWINDOW,
          winX, winY, winfX, winfY,
          NULL, NULL, g_hInst, NULL);
     
       if(hwnd == NULL)
       {
          MessageBox(0, "Window Creation Failed!", "Error!",
             MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
          return 0;
       }
     
       ShowWindow(hwnd, nCmdShow);
       UpdateWindow(hwnd);
     
       while(GetMessage(&Msg, NULL, 0, 0))
       {
          TranslateMessage(&Msg);
          DispatchMessage(&Msg);
       }
       return Msg.wParam;
    }

  10. #10
    Expert éminent

    Avatar de Anomaly
    Homme Profil pro
    Inscrit en
    Juin 2003
    Messages
    10 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2003
    Messages : 10 379
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par gaut
    j'ai rajouter ca mais ca me fait toujours la bande blanche
    Pas étonnant. Tu crées bien le DC mémoire, tu sélectionnes bien le bitmap
    dedans, mais tu dessines toujours dans le DC principal, donc en fin de
    compte, tu fais rien de plus qu'avant

    Dans les instructions ki suivent (notamment tes BitBlt) il te faut utiliser ton
    hdcMemory et non pas ton DC. Et à la fin, tu dois copier tout le contenu de
    ton hdcMemory dans ton DC avec un BitBlt.

  11. #11
    Membre confirmé
    Inscrit en
    Juillet 2003
    Messages
    140
    Détails du profil
    Informations forums :
    Inscription : Juillet 2003
    Messages : 140
    Par défaut
    j'ai reussis :

    voila ce que j'ai fait, le resultat est bon:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
     
    #include <stdio.h>
    #include <windows.h>
    #include <conio.c>
    #pragma hdrstop
     
    static char g_szClassName[] = "MyWindowClass";
    static HINSTANCE g_hInst = NULL;
     
    HBITMAP hb1,hb2,hb3,hb4,hb5,hb6, hbfond;
    BITMAP bm[6];
    int htitfn=25, largfen=5, winX = 0, winY = 0, winfX = 900, winfY = 700, i, j, X, Y,bapp=-2;
    int bouton[][5]={{663+largfen,71+htitfn,793+largfen,111+htitfn},{663+largfen,142+htitfn,793+largfen,182+htitfn},{663+largfen,213+htitfn,793+largfen,253+htitfn},{663+largfen,526+htitfn,793+largfen,566+htitfn}};
    RECT rc;
    int bx[] = {0, 663, 663, 663, 663};
    int by[] = {0, 71, 142, 213, 526};
    POINT pt;
     
    void DrawBall(HDC hdc)
    {
       HDC hdcMem;
       hdcMem = CreateCompatibleDC(hdc);
       HDC hdcMemory;
       hdcMemory = CreateCompatibleDC(hdc);
     
             hbfond = CreateCompatibleBitmap ( hdc, 800, 600 );
             SelectObject(hdcMemory, hb1);
             SelectObject(hdcMem, hbfond);
             StretchBlt(hdcMem,0,0,800,600,hdcMemory,0,0,800,600,SRCCOPY);
     
             SelectObject(hdcMemory, hb2);
             BitBlt(hdcMem, bx[1], by[1], bm[2].bmWidth, bm[2].bmHeight, hdcMemory, 0, 0, SRCCOPY);
     
             SelectObject(hdcMemory, hb3);
             BitBlt(hdcMem, bx[2], by[2], bm[3].bmWidth, bm[3].bmHeight, hdcMemory, 0, 0, SRCCOPY);
     
             SelectObject(hdcMemory, hb4);
             BitBlt(hdcMem, bx[3], by[3], bm[4].bmWidth, bm[4].bmHeight, hdcMemory, 0, 0, SRCCOPY);
     
             SelectObject(hdcMemory, hb5);
             BitBlt(hdcMem, bx[4], by[4], bm[5].bmWidth, bm[5].bmHeight, hdcMemory, 0, 0, SRCCOPY);
     
             SelectObject(hdcMem, hbfond);
             BitBlt(hdc,0,0,800,600,hdcMem,0,0,SRCCOPY);
             DeleteDC(hdcMemory);
             DeleteDC(hdcMem);
    }
     
    LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
    if(bapp==-2)
    {
    hb1 = LoadBitmap(g_hInst, "TITRE");
             GetObject(hb1, sizeof(bm[1]), &bm[1]);
             hb2 = LoadBitmap(g_hInst, "BTSOLO");
             GetObject(hb2, sizeof(bm[2]), &bm[2]);
             hb3 = LoadBitmap(g_hInst, "BTOPTIONS");
             GetObject(hb3, sizeof(bm[3]), &bm[3]);
             hb4 = LoadBitmap(g_hInst, "BTCREDITS");
             GetObject(hb4, sizeof(bm[4]), &bm[4]);
             hb5 = LoadBitmap(g_hInst, "BTQUITTER");
             GetObject(hb5, sizeof(bm[5]), &bm[5]);
             bapp=-1;
    }
     
       switch(Message)
       {
          case WM_PAINT:
          if(hb1 && hb2 && hb3 && hb4 && hb5)
                {
                PAINTSTRUCT ps;
                HDC hdcWindow;
                hdcWindow = BeginPaint(hwnd, &ps);
                DrawBall(hdcWindow);
                SetBkMode(hdcWindow,TRANSPARENT);
                SetTextColor(hdcWindow,RGB(255,100,50));
                TextOut(hdcWindow, 0, 0, " Hello, Windows!", 15);
                EndPaint(hwnd, &ps);
                }
          break;
          case WM_CHAR: 
                switch (wParam) 
                { 
                    default: 
     
                        // Process displayable characters. 
     
                        break; 
                }
          case WM_LBUTTONDOWN:
               GetCursorPos(&pt);
               X=pt.x;
               Y=pt.y;
               for (i=0;i<=3;i++)
                   {
                   if(X>=bouton[i][j] && X<=bouton[i][j+2])
                     {
                     if(Y>=bouton[i][j+1] && Y<=bouton[i][j+3])
                       {
                       bapp=i;
                       if(bapp==0)
    {
             DeleteObject(hb2);
             hb2 = LoadBitmap(g_hInst, "BTSOLOS");
             GetObject(hb2, sizeof(bm[2]), &bm[2]);
             InvalidateRect(hwnd, NULL, TRUE);
             bapp=-1;
    }
                       }
                     }
                   }
          break;
          case WM_CLOSE:
             DestroyWindow(hwnd);
          break;
          case WM_DESTROY:
             DeleteObject(hb1);
             DeleteObject(hb2);
             DeleteObject(hb3);
             DeleteObject(hb4);
             DeleteObject(hb5);
             DeleteObject(hbfond);
             PostQuitMessage(0);
          break;
          default:
             return DefWindowProc(hwnd, Message, wParam, lParam);
       }
       return 0;
    }
     
     
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
       LPSTR lpCmdLine, int nCmdShow)
    {
       WNDCLASSEX WndClass;
       HWND hwnd;
       MSG Msg;
     
       g_hInst = hInstance;
     
       WndClass.cbSize        = sizeof(WNDCLASSEX);
       WndClass.style         = 0;
       WndClass.lpfnWndProc   = WndProc;
       WndClass.cbClsExtra    = 0;
       WndClass.cbWndExtra    = 0;
       WndClass.hInstance     = g_hInst;
       WndClass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
       WndClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
       WndClass.hbrBackground = NULL;
       WndClass.lpszMenuName  = NULL;
       WndClass.lpszClassName = g_szClassName;
       WndClass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
     
       if(!RegisterClassEx(&WndClass))
       {
          MessageBox(0, "Window Registration Failed!", "Error!",
             MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
          return 0;
       }
     
       hwnd = CreateWindowEx(
          WS_EX_CLIENTEDGE,
          g_szClassName,
          "A Bitmap Program",
          WS_OVERLAPPEDWINDOW,
          winX, winY, winfX, winfY,
          NULL, NULL, g_hInst, NULL);
     
       if(hwnd == NULL)
       {
          MessageBox(0, "Window Creation Failed!", "Error!",
             MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
          return 0;
       }
     
       ShowWindow(hwnd, nCmdShow);
       UpdateWindow(hwnd);
     
       while(GetMessage(&Msg, NULL, 0, 0))
       {
          TranslateMessage(&Msg);
          DispatchMessage(&Msg);
       }
       return Msg.wParam;
    }

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 5
    Dernier message: 01/06/2008, 07h28
  2. Comment enlever le boot linux (LILO)
    Par rcs dans le forum Administration système
    Réponses: 21
    Dernier message: 09/09/2005, 10h42
  3. Réponses: 14
    Dernier message: 07/03/2005, 10h04
  4. [DBGRID] Comment enlever les ascenseurs H et V
    Par kase74 dans le forum Bases de données
    Réponses: 6
    Dernier message: 16/09/2004, 18h33
  5. Comment creer une bande bootable ?
    Par sdeb dans le forum Administration système
    Réponses: 7
    Dernier message: 13/01/2004, 17h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo