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 7435549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:05:34+00:00 2026-05-29T10:05:34+00:00

Okay I am having some problems with being able to change bitmaps when a

  • 0

Okay I am having some problems with being able to change bitmaps when a certain parameter is greater than another. I am a massive newbie to this and my coding isn’t great (at all). I have code that reads the limits (parameters) and displays as text which is this:

CFont* def_font = argDC->SelectObject(&m_Font);
   CString csText;
   int StartPos = WindowRect.Width()/5;
   CRect TextRect(StartPos, WindowRect.top + 5, StartPos + 100, WindowRect.top + 35);
   csText.Format(_T("%.2ft"), argSystemDataPtr->GetMaxSWL());
   int32_t iSWLDigits = csText.GetLength();
   if (iSWLDigits < m_SWLDigitsNum)
   {
      m_RedPanelBitmap.LoadBitmapW(IDB_BITMAP_PANEL_RED);
      //argDC->FillSolidRect(TextRect, RGB(255, 255, 255));
   }
   m_SWLDigitsNum = iSWLDigits;
   argDC->DrawText(csText, TextRect, DT_LEFT);

The bitmaps that are usually displayed are green but if a limit is breached like the one above then I want the bitmap to change to a red one. Here is what I’ve got for the green ones.

CRect PanelRect1, PanelRect2;

         CRect PanelsRect(WindowRect);

         const int BarHeight = 30;
         PanelsRect.OffsetRect(0,m_bShowTitleBar?BarHeight:-BarHeight);
         PanelsRect.DeflateRect(0,m_bShowTitleBar?BarHeight*-1:BarHeight);


         m_GreenPanelBitmap.Detach();


         m_GreenPanelBitmap.LoadBitmapW(IDB_BITMAP_PANEL_GREEN);

         CBitmap* pOld = memDC.SelectObject(&m_GreenPanelBitmap);

         BITMAP bits;

         m_GreenPanelBitmap.GetObject(sizeof(BITMAP),&bits);

         PanelRect1.SetRect(0,PanelsRect.top, PanelsRect.right /2 , PanelsRect.Height()/3);
         PanelRect2.SetRect(0,PanelsRect.top+PanelRect1.Height(), PanelsRect.right /2 ,(PanelsRect.Height()/3) + PanelRect1.Height());


         //Now draw the Panels
         if (pOld != NULL)
         {

            argDC->StretchBlt(PanelRect1.left ,PanelRect1.top,PanelRect1.Width(),PanelRect1.Height(),
            &memDC,0,0,bits.bmWidth-1, bits.bmHeight-1, SRCCOPY);

            argDC->StretchBlt(PanelRect2.left,PanelRect2.top,PanelRect2.Width(),PanelRect2.Height(),
            &memDC,0,0,bits.bmWidth-1, bits.bmHeight-1, SRCCOPY);


            memDC.SelectObject(pOld);

I would be extremely grateful for any help, I understand there probably is a simple answer but I’ve been scratching my head over it and can’t seem to find an answer anywhere else on how change the m_GreenPanelBitmap to m_RedPanelBitmap when this statement is true.

 `if (iSWLDigits < m_SWLDigitsNum).`
  • 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-29T10:05:35+00:00Added an answer on May 29, 2026 at 10:05 am

    Well, I do think your question is a bit messy but…

    On the second code snippet you posted (I suppose from a OnPaint method in a dialog) you are displaying the green bitmap by using StretchBlt.
    If your problem is you need to display one bitmap or another depending on a condition you should load both images (maybe you can do that elsewhere to avoid loading the images everytime the dialog is painted) and then display the one you really need based on the condition. Something like that:

    bool bCondition = /*whatever*/
    
    m_GreenPanelBitmap.LoadBitmapW(IDB_BITMAP_PANEL_GREEN);
    m_RedPanelBitmap.LoadBitmapW(IDB_BITMAP_PANEL_RED);
    
    CBitmap* pBitmapToDisplay = bCondition ? &m_GreenPanelBitmap : &m_RedPanelBitmap;
    
    CBitmap* pOld = memDC.SelectObject(pBitmapToDisplay);
    
    BITMAP bits;
    pBitmapToDisplay->GetObject(sizeof(BITMAP),&bits);
    
    PanelRect1.SetRect(0,PanelsRect.top, PanelsRect.right /2 , PanelsRect.Height()/3);
    PanelRect2.SetRect(0,PanelsRect.top+PanelRect1.Height(), PanelsRect.right /2, PanelsRect.Height()/3) + PanelRect1.Height());
    
    argDC->StretchBlt(PanelRect1.left ,PanelRect1.top,PanelRect1.Width(),PanelRect1.Height(),
                &memDC,0,0,bits.bmWidth-1, bits.bmHeight-1, SRCCOPY);
    
    memDC.SelectObject(pOld);
    

    Maybe with a more detailed question we would be able to help you more.

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

Sidebar

Related Questions

Okay, I'm trying to load a 2d array and having some problems. Here's my
Okay, I am having another UITableView problem. For some reason the indexPath.row is all
Okay, I might confuse some people who might be able to answer this question,
Okay, I'm having some headaches regarding the Friend and Protected Friend qualifiers. The information
Having some problems with a site I'm developing for a friend. I've been using
Okay I'm having a problem. I have a social networking site and have some
Okay so I am having this problem. I write up a script to be
Okay, I seem to be having a problem. I'm trying to create a twicker
Okay, these two related questions are in reference to Railscast #21 : I'm having
I'm having trouble getting my head around algorithm analysis. I seem to be okay

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.