Child unsichtbar machen, "sichtbar" wird es nicht unsichtbar, programmtechnisch ist es weg



  • Hey all,
    irgendwann hatte ich mal das Selbe Problem mit dem Selben Programm aber ich find den Post nicht.
    Ich habe ein HWND mit x*y Childs(Minesweeper-like) und die sollen beim daraufklicken auch verschwinden...

    Rein Programmtechnisch ist der angeklickte Button weg, allerdings ist seine Form noch in dem Parentfenster "aufgezeichnet"/"sichtbar"...

    .
    .
    .
    LRESULT CALLBACK WndProc( HWND myWnd, UINT wndMsg, WPARAM wParam, LPARAM lParam )
    	//This function will recieve all messages, wich where send by windows to this window.
    {
    	switch( wndMsg )
    	{
    		case WM_CREATE:					//on window creation
    			for( y = 0; y < Yaxe; y++ )		//create all Buttons
    			{
    				for( x = 0; x < Xaxe; x++ )
    				{
    					mines[y][x] = CreateWindow( "BUTTON", "", BS_FLAT | WS_CHILD | WS_VISIBLE | WS_DLGFRAME | BS_ICON, aktXPos, aktYPos, buttonX, buttonY, myWnd, (HMENU)bmMine, ((LPCREATESTRUCT)lParam)->hInstance, NULL );
    					prevBtnProc = (WNDPROC)SetWindowLong( mines[y][x], GWL_WNDPROC, (LONG)myBtn );
    
    					aktXPos += buttonX;					//generate the position of the new button
    				}
    				aktYPos += buttonY;
    				aktXPos = 0;
    			}
    			for( y = 0; y < numberOfMines; y++ )	//generate the mine infos, so that there are some mines in the game.
    			{
    				do
    				{
    					tmpX = zufall( 0, Xaxe*10 );
    					tmpY = zufall( 0, Yaxe*10 );
    				}while( isMine( tmpX/10, tmpY/10 ) );
    				arrayOfMines[y][1] = tmpX/10;
    				arrayOfMines[y][2] = tmpY/10;
    			}
    			visitMsg = true;
    		break;
    		case WM_PAINT:
    			myHdc = BeginPaint( myWnd, &myPaint );
    			{
    				if( !isEnd )
    				{
    					for( y = 0; y < numberOfMines; y++ )	//write down the mines
    						TextOut( myHdc, arrayOfMines[y][1]*buttonX+3, arrayOfMines[y][2]*buttonY, "X", 1 );
    
    					for( y = 0; y < Yaxe; y++ )				//create the number of mines for a field
    					{
    						for( x = 0; x < Xaxe; x++ )
    						{
    							if( !isMine( x, y ) && countMines( x, y ) > 0 )
    							{
    								itoa( countMines( x, y ), &zahl, 10 );
    
    								TextOut( myHdc, x*buttonX+4, y*buttonY, &zahl, 1 );
    							}
    						}
    					}
    				}
    			}
    			EndPaint( myWnd, &myPaint );
    			visitMsg = true;
    		break;
    	}
    	return visitMsg;
    }
    .
    .
    .
    

    Wenn ich jetzt

    ShowWindow( mines[1][1], SW_HIDE );
    

    mache, bleibt die Kontur noch da... Wie geht das weg?

    Danke schonmal, bei Fragen, einfach posten

    [edit]wenn ich

    ShowWindow( myAppWnd, SW_HIDE );
    ShowWindow( myAppWnd, SW_SHOW );
    

    mache, ist der Button wirklich weg...

    SendMessage( myAppWnd, WM_PAINT, 0, 0 );
    

    Geht allerdings nicht

    InvalidateRect( myAppWnd, NULL, TRUE );
    

    geht auch nicht...(button wird nicht übermalt)
    Nur bei TextOut ist der Button halt wirklich weg...



  • Hm, ich sag einfach mal, was mit so auffällt, weil der Code etwas wirrsch ist:

    1. 'visitMsg' ist eigentlich überflüssig ( ➡ Gibst Du auch immer FALSE zurück, wenn Du eine Nachricht nicht behandelst?)
    2. Lass mal testweise die Zeile mit dem SetWindowLong (Subclassing) weg, oder poste die SubclassProc der Buttons.
    3. Was enthält 'bmMine', bzw. wie ist die Variable definiert?
    4. Zeig mal die Stelle des Aufrufs von ShowWindow.
    5. Eventuell empfiehlt sich beim Zeichnen mit Back-Buffern zu arbeiten, je nachdem, ob es flackert 😉 (noch so als Tipp).
    6. Hast Du beim Erstellen des Hauptfensters WS_CLIPCHILDREN als Style-Flag angegeben?

    Grüße!


Anmelden zum Antworten