Click here to Skip to main content
15,917,176 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionTrying to save a stored file onto a buffer Pin
bobfilar3-Nov-05 12:34
bobfilar3-Nov-05 12:34 
AnswerRe: Trying to save a stored file onto a buffer Pin
Christian Graus3-Nov-05 13:39
protectorChristian Graus3-Nov-05 13:39 
GeneralRe: Trying to save a stored file onto a buffer Pin
bobfilar3-Nov-05 14:09
bobfilar3-Nov-05 14:09 
GeneralRe: Trying to save a stored file onto a buffer Pin
Christian Graus3-Nov-05 14:12
protectorChristian Graus3-Nov-05 14:12 
QuestionDisappear bitmap Pin
GoodQuestion3-Nov-05 11:28
GoodQuestion3-Nov-05 11:28 
AnswerRe: Disappear bitmap Pin
Christian Graus3-Nov-05 11:46
protectorChristian Graus3-Nov-05 11:46 
GeneralRe: Disappear bitmap Pin
GoodQuestion3-Nov-05 12:02
GoodQuestion3-Nov-05 12:02 
GeneralRe: Disappear bitmap Pin
Christian Graus3-Nov-05 12:07
protectorChristian Graus3-Nov-05 12:07 
class CAssignDlg
{

HBITMAP m_Bitmap; <- THIS is a member variable

void CAssignDlg::OnPaint() <- THIS is a paint handler.
{
CPaintDC dc(this);
CBitmap mybmp;
CPoint org(0,0);
HBITMAP hBitmap;
HANDLE hImageFile;


if(m_bNoPicture)//before choose pic
{
CBitmap mybmp;
mybmp.LoadBitmap(IDB_BITMAP1);
m_Picture.SetBitmap((HBITMAP)mybmp);
}
else)//after chose pic
{

HBITMAP hBit = (HBITMAP)LoadImage( NULL,
"C:\\Test.bmp",
IMAGE_BITMAP,
0,
0,
LR_CREATEDIBSECTION | LR_DEFAULTSIZE | LR_LOADFROMFILE ); <- THIS code loads an image EVERY TIME the form gets painted.

CBitmap* b = new CBitmap;
b->Attach(hBit); <- THIS creates a new pointer every time, and because it's not a member variable, you lose it ( you can't ever clean this memory up )
m_Picture.SetBitmap(*b);
//DeleteObject(hBit);

}
}

I would have a CBitmap * in your class, and set it to NULL. Wrap the code to assign the value in a block that checks if the pointer is currently NULL. Delete the pointer in your destructor.
}

Christian Graus - Microsoft MVP - C++
AnswerRe: Disappear bitmap Pin
vikas amin3-Nov-05 20:17
vikas amin3-Nov-05 20:17 
QuestionCompile program in command line??And OpenGL Pin
Ming Luo3-Nov-05 11:16
Ming Luo3-Nov-05 11:16 
AnswerRe: Compile program in command line??And OpenGL Pin
Christian Graus3-Nov-05 11:18
protectorChristian Graus3-Nov-05 11:18 
GeneralRe: Compile program in command line??And OpenGL Pin
Ming Luo3-Nov-05 11:25
Ming Luo3-Nov-05 11:25 
Questionlocalization tools Pin
jim4563-Nov-05 10:22
jim4563-Nov-05 10:22 
AnswerRe: localization tools Pin
softwareguy12-Apr-06 3:51
softwareguy12-Apr-06 3:51 
Questionmultiple filename for single resource Pin
jim4563-Nov-05 10:17
jim4563-Nov-05 10:17 
QuestionList Ctrl and LVS_EX_HEADERDRAGDROP Pin
#realJSOP3-Nov-05 9:50
professional#realJSOP3-Nov-05 9:50 
GeneralRe: List Ctrl and LVS_EX_HEADERDRAGDROP Pin
Shog93-Nov-05 10:47
sitebuilderShog93-Nov-05 10:47 
QuestionApp crashes Pin
ita_cas3-Nov-05 9:45
ita_cas3-Nov-05 9:45 
AnswerRe: App crashes Pin
Christian Graus3-Nov-05 11:19
protectorChristian Graus3-Nov-05 11:19 
AnswerRe: App crashes Pin
kakan3-Nov-05 19:12
professionalkakan3-Nov-05 19:12 
Questiontooltips in MDI app Pin
cje3-Nov-05 9:22
cje3-Nov-05 9:22 
QuestionCListCtrl Pin
DanYELL3-Nov-05 8:12
DanYELL3-Nov-05 8:12 
AnswerRe: CListCtrl Pin
act_x3-Nov-05 8:53
act_x3-Nov-05 8:53 
AnswerRe: CListCtrl Pin
Ravi Bhavnani3-Nov-05 11:00
professionalRavi Bhavnani3-Nov-05 11:00 
QuestionWindows Hooks Pin
act_x3-Nov-05 7:29
act_x3-Nov-05 7:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.