Win XP Professional Problem
-
Tach auch,
ich hab da mal ein Problem. Ein ganz simples Programm, das ich geschrieben habe, wird ganz normal mit PostQuitMessage unter WM_DESTROY beendet - zumindest unter Win2K und XP HomeEdition - bei einem Freund mit XP Prof läuft der Prozess munter weiter... Hat irgendjemand eine Idee?
Vielen Dank
-
Mir fällt spontan ein:
- PostQuitMessage(0) - sieht das auch so aus?
- while(GetMessage(&msg,0,0,0)) - dito?
- Richtige Rückgabewerte in der WndProc?MfG SideWinder
-
1.-3. Leider ja

-
Zeig mal Code, kann doch nicht sein. Fängst du WM_CLOSE ab und hast da falsch zurückgegeben? Laufen noch irgendwelche Threads?
MfG SideWinder
-
Code kommt gleich, aber was ich nicht verstehe, wenn ich falsch abfange oder falsch zurückgebe, warum endet das Programm korrekt unter XP Home und Win2k?
-
#include <windows.h> #include <commdlg.h> #include <stdio.h> #include <stdlib.h> #include <commctrl.h> LRESULT CALLBACK WndProc (HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ) ; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static TCHAR szAppName[] = TEXT ("HC") ; HWND hwnd ; MSG msg ; WNDCLASS wndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; wndclass.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH) ; wndclass.lpszMenuName = szAppName; wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass)) { MessageBox (NULL, TEXT ("Das Programm braucht NT!"), szAppName, MB_ICONERROR); return 0; } hwnd = CreateWindow (szAppName, // Name der Fensterklasse TEXT ("HattrickClown"), // Fenstertitel WS_OVERLAPPEDWINDOW, // Fensterstil CW_USEDEFAULT, // X-Position des Fensters CW_USEDEFAULT, // Y-Position des Fensters 700, // Fensterbreite 500, // Fensterhöhe NULL, // übergeordnetes Fenster NULL, // Menü hInstance, // Programm-Kopiezähler (Programm-ID) NULL) ; // zusätzliche Parameter ShowWindow (hwnd, iCmdShow) ; UpdateWindow (hwnd) ; while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } return msg.wParam ; } LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HINSTANCE hInstance; static HWND hwnd_edit, hwnd_edit2, hwnd_edit3; static HWND hwnd_stat, hwnd_stat2, hwnd_stat3; static int cxScreen, cyScreen, i, j, k; char szBuffer[MAX_PATH+2], szBuffer2[256]; char szPfad[MAX_PATH+2]; char *pFilename; char suche[] = "name="; char *pch; FILE *datei; switch (message) { case WM_CREATE: SetLastError(0); cxScreen = GetSystemMetrics (SM_CXSCREEN) ; cyScreen = GetSystemMetrics (SM_CYSCREEN) ; if ((cxScreen < 800) || (cyScreen < 600)) { MessageBox(NULL, TEXT ("Diese Anwendung benötigt mindestens eine Auflösung von 800x600 Pixeln!"), TEXT ("Falsche Auflösung!"), MB_ICONERROR) ; PostQuitMessage (0) ; } MoveWindow(hwnd,(cxScreen-700)/2,(cyScreen-500)/2,700,500,TRUE); PopFileInitialize(hwnd); case WM_SIZE: cxScreen = LOWORD (lParam) ; cyScreen = HIWORD (lParam) ; return 0 ; case WM_DESTROY: PostQuitMessage (0); return 0; } return DefWindowProc (hwnd, message, wParam, lParam) ; }So, dass isser - wo ist jetzt der Fehler?
Edith meinte, ich sollte vielleicht darauf hinweisen, dass einige Subroutinen fehlen, die aber bedeutungslos sein dürften.
-
Bin mir net sicher, aber mach mal so
switch (message) { case WM_DESTROY: PostQuitMessage (0); // return 0; return DefWindowProc (hwnd, message, wParam, lParam) ; }also ohne das "return 0;"
-
oder füg das hier mal hinzu:
case WM_CLOSE: DestroyWindow( hwnd ); return 0;und fehlt bei WM_CREATE das return 0; mit Absicht?
-
das return 0; bei WM_CREATE habe ich jetzt nur vergessen mit zu kopieren, steht aber sonst da. Die beiden Varianten werde ich heute abend mal ausprobieren - vielen Dank.
Hat denn jemand eine Idee, woran das denn liegen kann?
-
Dein Code ist richtig, dann ist wohl sein Windows kaputt.