Run-Time Error - Variable nicht initialisiert????



  • Mein Programm sollte beim drücken eines Buttons den Text eines Edit-fields ändern, aber dann:

    Run-Time Check Failure #3 - The variable 'textfield_zoom' is being used without being initialized.
    

    Hier der Quellcode:

    LRESULT CALLBACK WndProc (HWND fenster, UINT message, WPARAM wParam, LPARAM lParam) 
    { 
    HDC hdc; 
    PAINTSTRUCT ps;
    HWND button_start;
    HWND button_end;
    HWND button_zoom;
    HWND button_unzoom;
    HWND button_delete;
    HWND textfield_zoom;
    HWND textfield_unzoom;
    HWND textfield_delete;
    int int_zoom;
    int int_unzoom;
    int int_delete;
    
    switch (message) 
    { 
    
    	case WM_CREATE:
    		button_start		= CreateWindow (
    											  "button", "START", 
    											  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
    											  20, 20, 50, 30, 
    											  fenster, (HMENU)1,
    											  hInst, NULL
    										   ); 
    		button_end			= CreateWindow (
    											  "button", "END", 
    											  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
    											  90, 20, 50, 30,
    											  fenster, (HMENU)2,
    											  hInst, NULL
    										   ); 
    		button_zoom			= CreateWindow (
    											  "button", "ZOOM", 
    											  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
    											  20, 70, 70, 30, 
    											  fenster, (HMENU)3,
    											  hInst, NULL
    										   ); 
    		textfield_zoom		= CreateWindow (
    											  "edit", "SHIFT", 
    											  WS_CHILD | WS_VISIBLE | ES_READONLY, 
    											  110, 70, 150, 30, 
    											  fenster, NULL,
    											  hInst, NULL
    										   ); 
    		button_unzoom		= CreateWindow (
    											  "button", "UNZOOM", 
    											  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
    											  20, 120, 70, 30,
    											  fenster, (HMENU)4,
    											  hInst, NULL
    										   ); 
    		textfield_unzoom	= CreateWindow (
    											  "edit", "ALT", 
    											  WS_CHILD | WS_VISIBLE | ES_READONLY, 
    											  110, 120, 150, 30, 
    											  fenster, NULL,
    											  hInst, NULL
    										   ); 
    		button_delete		= CreateWindow (
    											  "button", "DELETE", 
    											  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 
    											  20, 170, 70, 30,
    											  fenster, (HMENU)5,
    											  hInst, NULL
    										   ); 
    		textfield_delete	= CreateWindow (
    											  "edit", "BACKSPACE", 
    											  WS_CHILD | WS_VISIBLE | ES_READONLY, 
    											  110, 170, 150, 30, 
    											  fenster, NULL,
    											  hInst, NULL
    										   ); 
    		return 0 ;
    
    	case WM_COMMAND: 
    		if(LOWORD(wParam) == 1) 
    		{ 
    			int c_x,c_y,hs;
    			bool i=true;
    			long x,y;
    			HWND h;
    			HDC dc;
    
    			h = FindWindow(NULL,"ioUrbanTerror"); 
    			dc = GetDC(h); 
    			c_x =800/2;
    			c_y=600/2;
    			hs=26/2; 
    			while(i==true) { 
    				if(GetAsyncKeyState(0x08)) { 
    					i=false;
    				} 
    				if(GetAsyncKeyState(VK_SHIFT)) { 
    					hs=600/2;
    				} 
    				if(GetAsyncKeyState(0x01)) { 
    					hs=26/2;
    				} 
    				if(GetAsyncKeyState(VK_MENU)) {
    					hs=26/2;
    				}
    				for(x=c_x-hs;x<c_x+hs;x++) { 
    					SetPixel(dc,x,c_y,RGB(255,0,0)); 
    				} 
    				for(y=c_y-hs;y<c_y+hs;y++) { 
    					SetPixel(dc,c_x,y,RGB(255,0,0)); 
    				} 
    				Sleep(5); 
    			} 
    			ReleaseDC(h, dc); 
    		} 
    		if(LOWORD(wParam) == 2) 
    		{ 
    			PostQuitMessage(0);
    		} 
    		if(LOWORD(wParam) == 3) 
    		{ 
    			SetWindowText(textfield_zoom,"Taste drücken...");
    		} 
    		if(LOWORD(wParam) == 4) 
    		{ 
    			SetWindowText(textfield_unzoom,"Taste drücken...");
    		} 
    		if(LOWORD(wParam) == 5) 
    		{ 
    			SetWindowText(textfield_delete,"Taste drücken...");
    		} 
    		return 0;
    
    	case WM_DESTROY: 
    		PostQuitMessage(0);  
    		return 0; 
    } 
    
    return DefWindowProc (fenster, message, wParam, lParam); 
    }
    

    Ich weiss nicht ob ich blind bin, aber ich seh den Fehler einfach nicht, hoffe einer von euch Pros findet ein bisschen zeit für mich 😃



  • Du solltest den Lebensbereich einer Variablen beachten, bei jedem Funktionsaufruf sind die lokalen Variablen wieder unbelegt.



  • ich danke dir 😃


Log in to reply