Click here to Skip to main content
15,889,867 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: problem showing while i m making the dialog Pin
super_ttd1-Nov-07 1:10
super_ttd1-Nov-07 1:10 
AnswerRe: problem showing while i m making the dialog Pin
Hamid_RT1-Nov-07 1:20
Hamid_RT1-Nov-07 1:20 
QuestionRe: problem showing while i m making the dialog Pin
David Crow1-Nov-07 2:54
David Crow1-Nov-07 2:54 
Questionhow to cut a segment from an image? Pin
King Tran1-Nov-07 0:49
King Tran1-Nov-07 0:49 
AnswerRe: how to cut a segment from an image? Pin
Hamid_RT1-Nov-07 1:43
Hamid_RT1-Nov-07 1:43 
GeneralRe: how to cut a segment from an image? Pin
Mark Salsbery1-Nov-07 5:47
Mark Salsbery1-Nov-07 5:47 
GeneralRe: how to cut a segment from an image? Pin
Hamid_RT1-Nov-07 5:59
Hamid_RT1-Nov-07 5:59 
GeneralRe: how to cut a segment from an image? Pin
Mark Salsbery1-Nov-07 6:49
Mark Salsbery1-Nov-07 6:49 
Besides the fact that it has nothing to do with the question asked?

Like I stated, it leaks.  "Only" one GDI object - you get lucky - the system
cleans up most of the problems.  Here's an analysis:
    CDC m_dc,m_dc2;
    
    m_dc.CreateCompatibleDC(GetDC());
    m_dc2.CreateCompatibleDC(GetDC());

    HBITMAP hbit=CreateCompatibleBitmap(GetDC()->m_hDC,800,600);
    HBITMAP hbit2=CreateCompatibleBitmap(GetDC()->m_hDC,800,600);
    hbit=(HBITMAP)m_dc.SelectObject(hbit);
    <font color="Red">// hbit is m_dc's original bitmap
    // m_dc has compatible bitmap 1</font>
    hbit2=(HBITMAP)m_dc2.SelectObject(hbit2);
    <font color="Red">// hbit2 is m_dc2's original bitmap
    // m_dc2 has compatible bitmap 2</font>

    hbit=(HBITMAP)LoadImage(NULL, _T("e:\\8bit.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    <font color="Red">// hbit is loaded bitmap (m_dc's original bitmap is lost)</font>
    hbit=(HBITMAP)m_dc.SelectObject(hbit);
    <font color="Red">// hbit is compatible bitmap 1
    // m_dc has loaded bitmap</font>
    m_dc.TextOut(0,0,_T("And is this your answer"),23);

    m_dc2.BitBlt(300,300,200,200,&m_dc,0,0,SRCCOPY);
    hbit2=(HBITMAP)m_dc2.SelectObject(hbit);
    <font color="Red">// hbit2 is compatible bitmap 2 (m_dc2's original bitmap is lost)
    // m_dc2 has compatible bitmap 1</font>

    CImage m_Image;
    m_Image.Attach(hbit2);
    m_Image.Save(_T("e:\\8bit_test.bmp"));
    m_Image.Destroy();
    <font color="Red">// compatible bitmap 2 destroyed</font>
    m_dc.DeleteDC();
    m_dc2.DeleteDC();
    DeleteObject(hbit);
    <font color="Red">// compatible bitmap 1 destroyed</font>
    DeleteObject(hbit2);
    <font color="Red">// hbit2 was already destroyed above so this line was useless</font>

    <font color="Red">// loaded bitmap is lost - leak</font>





Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: how to cut a segment from an image? Pin
Hamid_RT1-Nov-07 7:00
Hamid_RT1-Nov-07 7:00 
QuestionModeless Dialog Box hangs... [modified] Pin
GauranG Shah1-Nov-07 0:40
GauranG Shah1-Nov-07 0:40 
QuestionRe: Modeless Dialog Box hangs... Pin
Hamid_RT1-Nov-07 1:06
Hamid_RT1-Nov-07 1:06 
AnswerRe: Modeless Dialog Box hangs... Pin
GauranG Shah1-Nov-07 1:40
GauranG Shah1-Nov-07 1:40 
QuestionRe: Modeless Dialog Box hangs... Pin
Mark Salsbery1-Nov-07 5:51
Mark Salsbery1-Nov-07 5:51 
AnswerRe: Modeless Dialog Box hangs... Pin
GauranG Shah1-Nov-07 18:10
GauranG Shah1-Nov-07 18:10 
GeneralRe: Modeless Dialog Box hangs... Pin
Mark Salsbery2-Nov-07 8:04
Mark Salsbery2-Nov-07 8:04 
QuestionProblem working with Created Local User Pin
narayanagvs1-Nov-07 0:04
narayanagvs1-Nov-07 0:04 
AnswerRe: Problem working with Created Local User Pin
Iain Clarke, Warrior Programmer1-Nov-07 2:11
Iain Clarke, Warrior Programmer1-Nov-07 2:11 
QuestionRe: Problem working with Created Local User Pin
David Crow1-Nov-07 3:03
David Crow1-Nov-07 3:03 
QuestionWake On LAN (WOL) Problem Pin
joshiprashant31-Oct-07 23:39
joshiprashant31-Oct-07 23:39 
QuestionExecuteQuery of CDatabase not working Pin
prithaa31-Oct-07 22:09
prithaa31-Oct-07 22:09 
QuestionRe: ExecuteQuery of CDatabase not working Pin
David Crow1-Nov-07 3:10
David Crow1-Nov-07 3:10 
AnswerRe: ExecuteQuery of CDatabase not working Pin
prithaa1-Nov-07 23:06
prithaa1-Nov-07 23:06 
QuestionRe: ExecuteQuery of CDatabase not working Pin
David Crow2-Nov-07 2:35
David Crow2-Nov-07 2:35 
QuestionUpdating resource in yourself Pin
LiveShell31-Oct-07 22:06
LiveShell31-Oct-07 22:06 
AnswerRe: Updating resource in yourself Pin
Paresh Chitte31-Oct-07 22:39
Paresh Chitte31-Oct-07 22:39 

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.