Ca va mieu mais je viens de remarquer que lorsque je reduis la fenêtre, elle prend 100% du processeur, alors que quand elle est affichée, ça se passe bien. Ceci avec la methode que tu m'a proposé.
Version imprimable
Ca va mieu mais je viens de remarquer que lorsque je reduis la fenêtre, elle prend 100% du processeur, alors que quand elle est affichée, ça se passe bien. Ceci avec la methode que tu m'a proposé.
Personne ne sait pourquoi?
Voici mon code :
Merci de votre aide.Code:
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 #include <iostream> #include <windows.h> #include "resource.h" #include "main.h" HBITMAP hBmp; /////////////////////////////////////////////////////////// int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX main; main.cbSize = sizeof(WNDCLASSEX); main.style = CS_HREDRAW|CS_VREDRAW; main.lpfnWndProc = MainProc; main.cbClsExtra = 0; main.cbWndExtra = 0; main.hInstance = hInstance; main.hIcon = LoadIcon(hInstance, "APPICON"); main.hIconSm = LoadIcon(hInstance, "WINICON"); main.hCursor = LoadCursor(NULL, IDC_ARROW); main.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); main.lpszMenuName = NULL; main.lpszClassName = "std"; RegisterClassEx(&main); HWND hWnd; hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, "std", "Installation", WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 609, 429, NULL, NULL, hInstance, NULL); ShowWindow(hWnd, SW_SHOW); SetTimer(hWnd, NULL, 1000, NULL); MSG messages; hBmp = (HBITMAP)LoadImage(hInstance, "BGSTEP1", IMAGE_BITMAP, 0, 0, NULL); while (GetMessage(&messages, NULL, 0, 0) == TRUE) { TranslateMessage(&messages); DispatchMessage(&messages); } return 0; } /////////////////////////////////////////////////////////// LRESULT CALLBACK MainProc(HWND hWnd, UINT messages, WPARAM wParam, LPARAM lParam) { switch (messages) { case WM_PAINT: HDC hDC; hDC = GetDC(hWnd); DrawState(hDC, NULL, NULL, (LPARAM)hBmp, NULL, 0, 0, 0, 0, DST_BITMAP); ReleaseDC(hWnd, hDC); break; case WM_CLOSE: if(MessageBox(hWnd, "Êtes vous sûr de vouloir annuler l'installation ?", "Installation", MB_YESNO|MB_ICONQUESTION) == IDYES) DestroyWindow(hWnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, messages, wParam, lParam); } }
Pourquoi avoir abandonné bitblt ?
ps : pour récuperer le dc, en général on fait comme ca :Code:
1
2
3
4
5
6
7 HDC hdc ; PAINTSTRUCT ps ; case WM_PAINT : hdc = BeginPaint (hwnd, &ps) ; ... EndPaint (hwnd, &ps) ;
Ceci ne fonctionne toujours pas.
ça fait une semaine que j'essaie d'afficher ce bitmap. Quelqu'un pourrait me le faire afin que je puisse analyser le code?Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 case WM_PAINT: HDC hdc; HBITMAP hbitmap; HDC hdcMemory; PAINTSTRUCT ps; BITMAP bm; HINSTANCE hInstance; hdc = BeginPaint(hWnd, &ps); hInstance = GetModuleHandle(NULL); hbitmap = (HBITMAP)LoadImage(hInstance, "BGSTEP1", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); hdcMemory = CreateCompatibleDC(NULL); SelectObject(hdcMemory, hbitmap); GetObject(hbitmap, sizeof(bm), &bm); BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCCOPY); DeleteDC(hdcMemory); EndPaint (hWnd, &ps); break;
C'est à se demander si le C++ est si puissant que ça. Je ne comprends pas le fait de trouver si peut de tuto sur le sujet.
Merci de votre aide
tu as tracé pour voir si tous les retours des apis sont cohérents ?
Bon allez, j'avais deux minutes ...
cet exemple fonctionne chez moiCode:
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 #include <windows.h> LRESULT CALLBACK MainProc(HWND hWnd, UINT messages, WPARAM wParam, LPARAM lParam) { switch (messages) { case WM_PAINT: { HDC hdc; POINT pt; HBITMAP hBitmap; HDC hMemDC; PAINTSTRUCT ps; BITMAP bm; hdc = BeginPaint(hWnd, &ps); hBitmap = (HBITMAP) LoadImage( NULL, "d:\\but_valid.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); hMemDC = CreateCompatibleDC (hdc); SelectObject (hMemDC, hBitmap); GetObject (hBitmap, sizeof (BITMAP), &bm) ; pt.x = bm.bmWidth; pt.y = bm.bmHeight; BitBlt (hdc, 0, 0, pt.x, pt.y, hMemDC, 0, 0, SRCCOPY) ; EndPaint (hWnd, &ps); break; } case WM_CLOSE: case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hWnd, messages, wParam, lParam); } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX main; main.cbSize = sizeof(WNDCLASSEX); main.style = CS_HREDRAW|CS_VREDRAW; main.lpfnWndProc = MainProc; main.cbClsExtra = 0; main.cbWndExtra = 0; main.hInstance = hInstance; main.hIcon = LoadIcon(hInstance, "APPICON"); main.hIconSm = LoadIcon(hInstance, "WINICON"); main.hCursor = LoadCursor(NULL, IDC_ARROW); main.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); main.lpszMenuName = NULL; main.lpszClassName = "std"; RegisterClassEx(&main); HWND hWnd; hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, "std", "Installation", WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 609, 429, NULL, NULL, hInstance, NULL); ShowWindow(hWnd, SW_SHOW); MSG messages; while(GetMessage(&messages, NULL, 0, 0) == TRUE) { TranslateMessage(&messages); DispatchMessage(&messages); } return 0; }