Click here to Skip to main content
15,889,810 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
My code is

C++
pStatic->Create(sCaption,WS_CHILD|WS_VISIBLE,CRect(x,y,x+sz.cx,y+sz.cy),this,nID);
	pStatic->SetFont(GetFont());
	CBitmap m_Bitmap;
	LPCSTR str="C:\\Users\\ABC\\Desktop\\imran khan\\ZFDemo_03Sep\\ZF1SDKDemo\\res\\Matched.bmp";
	 
	HBITMAP  hBitMap = (HBITMAP)::LoadImageA(NULL,str,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
	
	pStatic->SetBitmap(hBitMap);
	bool j=pStatic->GetBitmap();
	if(iTab == 0)
	{
		pStatic->ShowWindow(SW_SHOW);
	}
	else
	{
		pStatic->ShowWindow(SW_HIDE);
	}
	iLastBottom = y + sz.cy;
	iLastRight = x + sz.cx;
	iLastLeft = x;
	iLastTop = y;
	//save the item struct to the object array
	ITEM* pItem = new ITEM;
	pItem->bTabStop = FALSE;
	pItem->iTab = iTab;
	pItem->wnd = (CWnd*)pStatic;
	obArray.Add((CObject*)pItem);

It does not render Match.bmp image.
Posted
Updated 29-Apr-18 21:05pm

You will need to add the SS_BITMAP style when you create your static control.

http://msdn.microsoft.com/en-us/library/b7w5x74z.aspx[^]
 
Share this answer
 
Comments
Member 7909353 6-Sep-12 8:05am    
thank you!
Jochen Arndt 6-Sep-12 8:07am    
+5. You posted while I'm typing.
You must pass the SS_BITMAP style to CStatic::Create() to display a bitmap image. See CStatic::Create()[^] in the MSDN.

This makes no sense:
bool j=pStatic->GetBitmap();

The return value of GetBitmap() is a HBITMAP handle, not bool and will be the same as your hBitMap variable if SetBitmap() was successful.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900