Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6604867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:12:51+00:00 2026-05-25T19:12:51+00:00

I am trying to display an image in a dialog dynamically, it works no

  • 0

I am trying to display an image in a dialog dynamically, it works no problem if I put the code in the on paint method and use the dc from there, I can’t do this though I need to display after the window is shown, the code I am using is as follows, I am getting the dc of the client window creating the bitmap from a resource and “trying” to display it in the window but nothing displays, Any suggestions what might be wrong?

void CProcessSteps::OnShowWindow(BOOL bShow, UINT nStatus) 
{
    CDialog::OnShowWindow(bShow, nStatus);  

    SetupInstructions();<-----------------Call To Method
}




void CProcessSteps::OnPaint() 
{   
    CPaintDC dc(this);
}

void CProcessSteps::SetupInstructions()
{
    CDC *pDC = new CDC();<------------------------------Problem starts here
    CFontUtil cfu;
    cfu.SetFont(&LineFont,30);

    CDC memDC;
    memDC.CreateCompatibleDC(pDC);

    int stepTop = 10;
    int stepEnd = 230;
    int imageLeft = 30;
    STEP_STRUCT* step;

    CBitmap iconImage;
    iconImage.LoadBitmap ( IDB_TID_CHECK );

    memDC.SelectObject(&iconImage);

    CRect iconRect;
    BITMAP bmInfo;
    iconImage.GetObject ( sizeof ( bmInfo ), &bmInfo );
    iconRect.SetRect ( imageLeft, stepTop, imageLeft+bmInfo.bmWidth, stepTop+bmInfo.bmHeight );

    pDC = this->GetDC();
    pDC->BitBlt(imageLeft, stepTop, imageLeft+bmInfo.bmWidth, stepTop+bmInfo.bmHeight, &memDC, 0, 0, SRCCOPY);

    //RedrawWindow();<-------- tried this here no luck

    int stepCount = m_pageStructure->PageSteps.GetCount();<----------------------------Bellow this works correctly

    POSITION pos = m_pageStructure->PageSteps.GetHeadPosition();
    while (pos)
    {
        step = m_pageStructure->PageSteps.GetNext(pos);

        CStatic *label = new CStatic;
        label->Create(_T( step->StepInstruction ),WS_CHILD | WS_VISIBLE, CRect(80, stepTop, 480, stepEnd), this);
        label->SetFont(&LineFont, true);


        label->GetWindowRect(rect);
        ScreenToClient(rect);

        pDC = label->GetDC();
        pDC->SelectObject(&LineFont);
        pDC->DrawText(step->StepInstruction, &rect, DT_CALCRECT|DT_WORDBREAK); 
        label->ReleaseDC(pDC);
        label->MoveWindow(rect);    

        stepTop += rect.Height();
        stepTop += 30;
        stepEnd += rect.Height();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:12:52+00:00Added an answer on May 25, 2026 at 7:12 pm

    I think there’s more in the BeginPaint-function than just giving you the CDC. And BeginPaint can only be called from the OnPaint-method.

    To solve your problem, use the Invalidate-functions to force a repaint from your “SetupInstructions” method. Then do the drawing inside the OnPaint function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

friends, i am trying to display image from gallery now i want to put
I am trying to display an image from C:\temp. Here's the code: string root
Im trying to display the image i have coming from an intent.putExtra on a
I'm having a newbie problem when trying to display an image in a modal
I am trying to display image, which is dynamically generated on client side with
i am trying to display an image from net..and i am using ignition library
I'm trying to display an image while a sound is playing. I can get
I'm trying to display the biggest image url returned from an xml result. So
I am trying to display an image from the /webroot/img/ folder using the following
I am trying to display an image from my SD card on my BlackBerry.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.