Sign in to follow this  

Is My Bitmap Behind My Controls? (Win32 + C++)

This topic is 2848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm not sure what I did wrong, but for some reason my bitmap keeps showing behind the static window I want it to display over. How I know it's behind it or could be... Is when ever I resize my window, it flickers the "static" window containing the first one to hold the bitmap and I see my bitmap when ever I scale my window really fast for a split second. I'm not sure what I did wrong to cause it, but here is what I have:

//////////////////////////
///   ImageList variable is a class called ImageGrid at the bottom!
/// m_hWnd = is the main static window that holds child static windows.
//////////////////////////


void ImageGrid::DrawBitmaps()
{

	 IMG_LIST* dgList = GetIMGGrid(m_hWnd);

	 if(dgList == NULL)
	 {
		 return;
	 }


	 for(int i = 0; i<dgList->PictureList.size(); i++)
	 {
		 
		 	 HDC LocalDisplay = GetDC(dgList->PictureList[i].img_staticContainer);

			 if(LocalDisplay == NULL)
			 {
				 break;
			 }
			 SelectObject(dgList->PictureList[i].MemDC, dgList->PictureList[i].bmp);
			 if(!BitBlt(LocalDisplay, 0, 0, 200, 200, dgList->PictureList[i].MemDC, 0, 0, SRCCOPY))
			 {
			break;
			 }
	 }


}

void ImageGrid::ResizeWindow(int width, int height)
{

	MoveWindow(m_hWnd, 0, 0, width, height, true);

}




////////////////////////////////////////////////////
///  Main Core
////////////////////////////////////////////////////


//How I made the window

	WNDCLASS	wc;
	ZeroMemory(&wc, sizeof(wc));

	//Window class for the main application parent window

	wc.style			= CS_VREDRAW | CS_HREDRAW;
	wc.lpfnWndProc	=   TextureWndProc;
	wc.cbClsExtra		= 0;
	wc.cbWndExtra		= 0;
	wc.hInstance		= hInstance;
	wc.hIcon			= 0;
	wc.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground	= (HBRUSH)(BLACK_BRUSH);
	wc.lpszMenuName	= MAKEINTRESOURCE(IDR_MENU3);
	wc.lpszClassName	= "TextureBrowser";

	if(RegisterClass(&wc) == 0){
	return false;
	}else{
	return true;
	}

if (!(TextureBrowser = CreateWindowEx(WS_EX_TOOLWINDOW, 
    "TextureBrowser", "Texture Browser",
    WS_POPUP | WS_SYSMENU | WS_THICKFRAME | WS_CAPTION | WS_HSCROLL | WS_VSCROLL,
    (rcWnd.right - rcWnd.left)+190, 1, 200, CenterY,
    hWnd, NULL, hInst, (void*)this))) {

m_pErrorHandler.ShowErrorMessage();

		return false;							// Return FALSE

  }



The message handler..
case WM_PAINT: {
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(TextureBrowser, &ps);

ImageList.DrawBitmaps(hdc); //Look at the first source snippet of DrawBitmaps

 EndPaint(TextureBrowser, &ps);
}
break;

case WM_SIZE:{

			RECT rect;
			GetWindowRect(TextureBrowser, &rect);
			ImageList.ResizeWindow(200, rect.bottom);
return true;
}


			default: {

		return false;
			}




Thank you, any questions about the source code is welcomed, I'm not afraid to show what I have. [Edited by - ajm113 on February 25, 2010 10:40:11 PM]

Share this post


Link to post
Share on other sites
It's kind of hard to see what's going on just from snippets. It might be easier if you could pare your app down to a minimal example and post all the code in a single source block.

Anyway, is TextureBrowser supposed to be a child window, like a custom Win32 control? Because if so you need to call CreateWindowEx using the WS_CHILD style rather than WS_POPUP.

Share this post


Link to post
Share on other sites
I got it fixed, some how when erase background is called to my window it clears out even the bitmap I have displaying. I have it fixed now, but thank you for your offer to help! :)

Share this post


Link to post
Share on other sites

This topic is 2848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this