Dsl, mais ca marche pas non plus....
le bouton quitter est valide et fonctionne bien....
Dsl, mais ca marche pas non plus....
le bouton quitter est valide et fonctionne bien....
code minimal et compilable ?
SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.
"Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
Apparently everyone. -- Raymond Chen.
Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.
ola, qu'est ce que tu apL code compilable et minimal ?? lol
Un code le plus petit possible qui met en évidence l'erreur, mais que je peux compiler direct, c'est-à-dire qu'il ne manque aucune déclaration ni aucun header non-standard et non-fourni, etc.
"C'est un code, que je le mets dans ma moulinette, il marche de suite"
SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.
"Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
Apparently everyone. -- Raymond Chen.
Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.
Voila.. ca ca sevrai compiler... !!!! C'est ca que tu voulai ?
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 #include "stdafx.h" #include <shlwapi.h> #include <windows.h> #include <shlobj.h> HWND hwnd; HWND boutonQuitter; HINSTANCE hinst; PWINDOWINFO pwi; LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; WNDCLASS wc; hinst = hinstance; wc.style = CS_HREDRAW|CS_VREDRAW; wc.lpfnWndProc = MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinst; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = CreateSolidBrush(RGB(240,240,240));//reinterpret_cast<HBRUSH>(GRAY_BRUSH-1); wc.lpszMenuName = "Menu"; wc.lpszClassName = "MaWinClass"; if(!RegisterClass(&wc)) return FALSE; pwi = (PWINDOWINFO)malloc(sizeof(WINDOWINFO)); pwi->cbSize = sizeof(WINDOWINFO); hwnd = CreateWindow("MaWinClass", "essai", WS_OVERLAPPEDWINDOW, 0, 0, 200, 200, NULL, NULL, hinstance, NULL); if (!hwnd) return FALSE; ShowWindow(hwnd, nCmdShow); UpdateWindow (hwnd); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int)msg.wParam; } LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { int quit = 0; PAINTSTRUCT ps; HDC hdc; switch (uMsg) { case WM_PAINT: hdc = BeginPaint(hwnd, &ps); EndPaint(hwnd,&ps); return 0; case WM_COMMAND: if( (HWND)lParam == boutonQuitter) { quit = MessageBox(hwnd,"Vous voulez réellement Quitter", "Message",MB_YESNO|MB_ICONQUESTION); if (quit == IDNO) {return 0; break;} SendMessage( hwnd, WM_CLOSE, 0, 0L); return 0; } return 0; case WM_CREATE: boutonQuitter = CreateWindow("BUTTON","Quitter",WS_CHILD| WS_VISIBLE | BS_DEFPUSHBUTTON | BS_CENTER , 20, 20 , 70, 90 , hwnd,0,hinst,0); case WM_CTLCOLORBTN : if((HWND)lParam == boutonQuitter) { HBRUSH brush = CreateSolidBrush(RGB(20,0,0)); return (LRESULT)brush;//(LRESULT); } else return 0; case WM_DESTROY: DestroyWindow(hwnd); PostQuitMessage(0); return 0; default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } }
Que contient ton stdafx.h ?
Edit: Bon, sans compiler, j'ai vu deux choses qui me choquent:
1°) Pas de break après le case WM_CREATE (ni de return, mais le break aurait été mieux)
2°) Tu re-crées encore la brush à chaque fois... J'ai dit tu la crées une fois pour toutes et tu la mémorises...
SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.
"Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
Apparently everyone. -- Raymond Chen.
Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.
Pas gd chose.. les includes données par défault...
Et ok pour les modif, je vais faire ca...
Partager