Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I try and change the picture control bitmap using the commands below nothing happens. What am I doing wrong?

C++
pStatic-> ModifyStyle(0, SS_BITMAP);
pStatic-> SetBitmap(::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP2)));

Here is the the code segment with the calls.

C++
void CHebrewDlg::OnBnClickedNext()
{
	CEdit *pCtrl = (CEdit*) GetDlgItem(IDC_EDIT1);
	CButton *pNormal = (CButton*) GetDlgItem(IDC_RADIO1);
	CButton *pRandom = (CButton*) GetDlgItem(IDC_RADIO2);
	CStatic *pStatic = (CStatic*) GetDlgItem(IDC_STATIC); //IDC_BITMAP is CStatic control,


	int static count = 0;
	int random_count = 0;
	wchar_t hebrew_ch[30] = { L'א', L'בּ', L'ב', L'ג', L'ד', L'ה', L'ו', L'ז', L'ח', L'ט', 
	                          L'י', L'כּ', L'כ', L'ל', L'מ', L'נ', L'ס', L'ע', L'פּ', L'פ',        
	                          L'צ', L'ק', L'ר', L'שׁ', L'שׂ', L'ת' };


	pStatic-> ModifyStyle(0, SS_BITMAP);
	pStatic-> SetBitmap(::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP2)));
	
	if((pNormal->GetCheck()) == 1)
	{
		pCtrl->SetWindowTextW((CString)hebrew_ch[count]);
		count = ++count % 26;	
	}
	else
	{
		random_count = (rand() % 26);
		pCtrl->SetWindowTextW((CString)hebrew_ch[random_count]);
	}
}



[edit]Code block added, "Treat my content as plain text..." option disabled, Tags - OriginalGriff[/edit]
Posted
Updated 31-Jan-12 20:28pm
v2
Comments
Sergey Alexandrovich Kryukov 1-Feb-12 2:36am    
Nothing happens -- where? Maybe just on screen. If so, you could, for example, forget to invalidate. If you minimize the window and then show again, is it updated properly?
--SA

hi there you can use pStatic->ModifyStyle( SS_BLACKFRAME, SS_BITMAP );
 
Share this answer
 
Your code shoud work. Remember, in the static picture control (dialog editor), properties, type, set it to "Bitmap" (by default is frame).
 
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