cs_papi2
Messages postés44Date d'inscriptionvendredi 22 avril 2005StatutMembreDernière intervention 6 mars 2009
-
21 déc. 2006 à 12:12
cs_papi2
Messages postés44Date d'inscriptionvendredi 22 avril 2005StatutMembreDernière intervention 6 mars 2009
-
22 déc. 2006 à 09:09
Bonjour,
Quand je peux mettre l'image entière, elle ne prend pas les dimentions de MAXIMIZE (par exemple).
Avec ce code:
Je n'ai qu'une portion de l'image que j'ai mis en fond (d'une fenêtre).
#include <windows.h>
#include "Projet1_private.h"
#define BITMAP_X 200
#define BITMAP_Y 150
[......]
PAINTSTRUCT ps;
RECT rect;
HGLOBAL hgbl;
HDC hdc, hdc2;
HBITMAP hbmp;
[......]
hbmp = LoadBitmap(hThisInstance, (LPCTSTR)IDB_BITMAP1);
[......]
hdc = BeginPaint( hwnd, &ps );
GetClientRect(hwnd,&rect);
hdc2 = CreateCompatibleDC(hdc);
SelectObject(hdc2, hbmp);
StretchBlt(hdc, 0, 0, rect.right, rect.bottom, hdc2, 0, 0, BITMAP_X, BITMAP_Y, SRCCOPY);
Si je mets ceci:
StretchBlt(hdc,0,0,340,441,hdc2,0,0,340,441, SRCCOPY);
j'ai l'image entière mais lorsque j'agrandi la fenêtre, elle reste intacte. DeleteDC(hdc2);
EndPaint( hwnd, &ps );
break;
J'ai cherché, tout retourner pour trouver une piste mais je n'ai rien fait de bien concluant...
Si vous pouviez m'aider pour qu'elle soit entière et qu'elle suive les dimentions de la fenêtre lorsque je l'agrandi.
Je programme avec DEV-C++ 4.9.9.2
Merci
A voir également:
Il manque une partie de l'image (fond d'une fenêtre)
racpp
Messages postés1909Date d'inscriptionvendredi 18 juin 2004StatutModérateurDernière intervention14 novembre 201417 21 déc. 2006 à 22:08
Salut,
C'est normal car apparemment, BITMAP_X et BITMAP_Y ne correspondent pas aux dimensions réelles de l'image. Ils doivent corrrespondre respectivement à la largeur et la hauteur de l'image en pixels. Pour le redimensionnement il faudra traiter le message WM_SIZING ou WM_SIZE. Si c'est une image de fond, il est préférable de la dessiner pendant WM_ERASEBKGND au lieu de WM_PAINT.
Voici un exemple:
LRESULT CALLBACK WndProc(.........)
{
static HDC hdc2;
static HBITMAP hbmp;
RECT rect;
switch(msg)
{
case WM_CREATE:
{
HDC hDC = GetDC(0);
hdc2 = CreateCompatibleDC(hDC);
hbmp = LoadBitmap(GetModuleHandle(0), (LPCTSTR)IDB_BITMAP1);
SelectObject(hdc2, hbmp);
ReleaseDC(0, hDC);
return 0;
}
case WM_ERASEBKGND:
{
GetClientRect(hwnd,&rect);
StretchBlt((HDC)wParam, 0, 0, rect.right, rect.bottom, hdc2, 0, 0, BITMAP_X, BITMAP_Y, SRCCOPY);
return 1;
}
case WM_SIZING:
{
GetClientRect(hwnd,&rect);
HDC winDC=GetDC(hwnd);
StretchBlt(winDC, 0, 0, rect.right, rect.bottom, hdc2, 0, 0, BITMAP_X, BITMAP_Y, SRCCOPY);
Si tu veux traiter WM_SIZE au lieu de WM_SIZING tu fais:
case WM_SIZE:
{
HDC winDC=GetDC(hwnd);
StretchBlt(winDC, 0, 0, LOWORD(lParam), HIWORD(lParam), hdc2, 0, 0, BITMAP_X, BITMAP_Y, SRCCOPY);
ReleaseDC(hwnd,winDC);
return 0;
}
cs_papi2
Messages postés44Date d'inscriptionvendredi 22 avril 2005StatutMembreDernière intervention 6 mars 2009 22 déc. 2006 à 09:09
Bonjour Racpp
Je n'ai pas pu te répondre plus tôt car mon ordi à CLAQUé... (juste au moment où je t'envoyais le message) !
Alors j'ai trouvé une autre machine pour te remercier au plus tôt!!!
Ca fonstionne et cerise sur le gâteau:
j'ai mis "MAXIMIZE et POPUP" et j'ai un plein écran !!!!!
Je ne sais pas comment vous arrivé à trouver et ingurgiter toutes ces formules... c'est formidable...!
Encore merci.
A+