Bonjour,

J'ai une appli sous XP qui marche mais sous vista elle plante. En pas à pas, je supçonne un CreateWindow() qui retourne un mauvais Handle.

J'ai pu voir sur google certaines choses sur ce sujet mais ça me semble pas assez complet.

quelqu'un aurait-il rencontré ce problème? Est ce qu'il faut un flags ou un argument spécial à changer pour cette fonction sous vista?

Voici mon code :

Une classe Notification crée une window et la call back recoit les messages. En pas à pas le hwnd dans la call back est mauvais. il y a une adresse de pointeur mais il y a marqué "unsed=???" après :

mHwnd = 0x001606d8 {unused=??? }
unused = CXX0030: Error: expression cannot be evaluated

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
LCNotificationWindow::LCNotificationWindow(HINSTANCE aHInstance, LPCWSTR aAppName, bool aIsStatusItem, 
										   int aWidthWindow, int aHeightWindow)
{
	mHInstance = aHInstance;
	mIsStatusItem = aIsStatusItem;

	WNDCLASS lWC;
	lWC.style = 0;
    lWC.lpfnWndProc = WndProc;
    lWC.cbClsExtra = 0;
    lWC.cbWndExtra = 0;
    lWC.hInstance = mHInstance;
	lWC.hIcon = LoadIcon(mHInstance, MAKEINTRESOURCE("IDI_MAINICON"));
    lWC.hCursor = LoadCursor(mHInstance, IDC_ARROW);
    lWC.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
    lWC.lpszMenuName =  NULL;
    lWC.lpszClassName = _T("LCNotificationWindowClass");

	RegisterClass(&lWC);
	mHwnd = CreateWindow(_T("LCNotificationWindowClass"), aAppName, WS_OVERLAPPEDWINDOW,
						CW_USEDEFAULT, CW_USEDEFAULT, aWidthWindow, aHeightWindow,
						NULL, NULL, mHInstance, NULL);
	int lol = GetLastError();
	SetWindowLongPtr(mHwnd, GWLP_USERDATA, (LONG)(LONG_PTR)this);

}
Voici la call back, j'arrive dans WM_COMMAND et le hwnd (qui vient du createwindow est mauvais) :

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

LRESULT CALLBACK LCNotificationWindow::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	LCNotificationWindow* lNotificationWindowPt;
	switch (uMsg)
	{
		...

		case WM_COMMAND:
			lNotificationWindowPt = (LCNotificationWindow*)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_USERDATA);
			lNotificationWindowPt->onNotificationCommand(hwnd, uMsg, wParam, lParam);
			return 0;

		...	
	}
}
Veuillez noter que le GetLastError retourne 0 après le CreateWindow()

Merci

Robux