_michel
Messages postés77Date d'inscriptionmardi 27 juin 2006StatutMembreDernière intervention12 août 2010
-
8 août 2006 à 12:39
_michel
Messages postés77Date d'inscriptionmardi 27 juin 2006StatutMembreDernière intervention12 août 2010
-
8 août 2006 à 17:40
Je suis amené à me servir de la fonction SetWorldTransform (), qui permet les transformations graphiques, mais même en recopiant l'exemple de l'aide Windows, je n'arrive pas à la faire marcher.
Voici le code (condensé) :
/* Fonction de transformation */
void TransformAndDraw(HWND hWnd);
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
LPSTR lpszArgument, int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = "Window App";
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
racpp
Messages postés1909Date d'inscriptionvendredi 18 juin 2004StatutModérateurDernière intervention14 novembre 201417 8 août 2006 à 16:29
Salut,
La fonction SetGraphicsMode() ne doit pas être utilisée pendant le traitement de WM_CREATE car le HDC de la fenêtre n'est pas encore disponible. Tu peux placer cette fonction dans ta fonction de transformation juste après la récupéraion du HDC de la fenêtre:
hDC = GetDC(hWnd);
SetGraphicsMode (hDC, GM_ADVANCED);
Pour le traitement de WM_PAINT, tu dois faire comme ceci:
case WM_PAINT:
PAINTSTRUCT ps;
BeginPaint(hwnd,&ps);
TransformAndDraw (hwnd);
EndPaint(hwnd,&ps);
return 0;