Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. SetIcon Error / Exception

SetIcon Error / Exception

Scheduled Pinned Locked Moved C / C++ / MFC
hardwaredebugginghelp
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    ScotDolan
    wrote on last edited by
    #1

    I have a MDI application where, i am using a picture control to load icons of leds. The goal is to load the picture control with ICON that look like leds green and red. However, I am getting a Debug Assertion Failed where i set the new icon value. iconPitchActiveFault is CStatic control variable for a ICON void Lenze8200_Dlg::OnShowWindow(BOOL bShow, UINT nStatus) { CFormView::OnShowWindow(bShow, nStatus); //UpdateData(TRUE); HICON Red_ON; HICON Red_OFF; HICON Green_ON; HICON Green_OFF; // TODO: Add your message handler code here Red_ON = AfxGetApp()->LoadIcon(IDI_RED_ON_LED); Red_OFF = AfxGetApp()->LoadIcon(IDI_OFF_LED); Green_ON = AfxGetApp()->LoadIcon(IDI_GREEN_ON_LED); Green_OFF = AfxGetApp()->LoadIcon(IDI_OFF_LED); ******** The exceptions shows up here ************** m_iconPitchActiveFault.SetIcon( Red_OFF ); }

    Scott Dolan Jernie Corporation Engineering & Manufacturing Software, Hardware, & Enclosures

    S D H H 4 Replies Last reply
    0
    • S ScotDolan

      I have a MDI application where, i am using a picture control to load icons of leds. The goal is to load the picture control with ICON that look like leds green and red. However, I am getting a Debug Assertion Failed where i set the new icon value. iconPitchActiveFault is CStatic control variable for a ICON void Lenze8200_Dlg::OnShowWindow(BOOL bShow, UINT nStatus) { CFormView::OnShowWindow(bShow, nStatus); //UpdateData(TRUE); HICON Red_ON; HICON Red_OFF; HICON Green_ON; HICON Green_OFF; // TODO: Add your message handler code here Red_ON = AfxGetApp()->LoadIcon(IDI_RED_ON_LED); Red_OFF = AfxGetApp()->LoadIcon(IDI_OFF_LED); Green_ON = AfxGetApp()->LoadIcon(IDI_GREEN_ON_LED); Green_OFF = AfxGetApp()->LoadIcon(IDI_OFF_LED); ******** The exceptions shows up here ************** m_iconPitchActiveFault.SetIcon( Red_OFF ); }

      Scott Dolan Jernie Corporation Engineering & Manufacturing Software, Hardware, & Enclosures

      S Offline
      S Offline
      ScotDolan
      wrote on last edited by
      #2

      Changing where the code is placed will make the fix the problem. Put the code in OnUdpated not in OnShowUpWindow

      Scott Dolan Jernie Corporation Engineering & Manufacturing Software, Hardware, & Enclosures

      1 Reply Last reply
      0
      • S ScotDolan

        I have a MDI application where, i am using a picture control to load icons of leds. The goal is to load the picture control with ICON that look like leds green and red. However, I am getting a Debug Assertion Failed where i set the new icon value. iconPitchActiveFault is CStatic control variable for a ICON void Lenze8200_Dlg::OnShowWindow(BOOL bShow, UINT nStatus) { CFormView::OnShowWindow(bShow, nStatus); //UpdateData(TRUE); HICON Red_ON; HICON Red_OFF; HICON Green_ON; HICON Green_OFF; // TODO: Add your message handler code here Red_ON = AfxGetApp()->LoadIcon(IDI_RED_ON_LED); Red_OFF = AfxGetApp()->LoadIcon(IDI_OFF_LED); Green_ON = AfxGetApp()->LoadIcon(IDI_GREEN_ON_LED); Green_OFF = AfxGetApp()->LoadIcon(IDI_OFF_LED); ******** The exceptions shows up here ************** m_iconPitchActiveFault.SetIcon( Red_OFF ); }

        Scott Dolan Jernie Corporation Engineering & Manufacturing Software, Hardware, & Enclosures

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Is it an exception or an assertion?


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        1 Reply Last reply
        0
        • S ScotDolan

          I have a MDI application where, i am using a picture control to load icons of leds. The goal is to load the picture control with ICON that look like leds green and red. However, I am getting a Debug Assertion Failed where i set the new icon value. iconPitchActiveFault is CStatic control variable for a ICON void Lenze8200_Dlg::OnShowWindow(BOOL bShow, UINT nStatus) { CFormView::OnShowWindow(bShow, nStatus); //UpdateData(TRUE); HICON Red_ON; HICON Red_OFF; HICON Green_ON; HICON Green_OFF; // TODO: Add your message handler code here Red_ON = AfxGetApp()->LoadIcon(IDI_RED_ON_LED); Red_OFF = AfxGetApp()->LoadIcon(IDI_OFF_LED); Green_ON = AfxGetApp()->LoadIcon(IDI_GREEN_ON_LED); Green_OFF = AfxGetApp()->LoadIcon(IDI_OFF_LED); ******** The exceptions shows up here ************** m_iconPitchActiveFault.SetIcon( Red_OFF ); }

          Scott Dolan Jernie Corporation Engineering & Manufacturing Software, Hardware, & Enclosures

          H Offline
          H Offline
          Hans Dietrich
          wrote on last edited by
          #4

          As soon as a window is created, many different messages, including WM_SHOWWINDOW will start flying. But just because the parent window is created, doesn't mean its children are also alive and well. You can avoid this problem by making liberal use of IsWindow():

           if (::IsWindow(m\_iconPitchActiveFault.m\_hWnd))
                m\_iconPitchActiveFault.SetIcon( Red\_OFF );
          

          Best wishes, Hans

          1 Reply Last reply
          0
          • S ScotDolan

            I have a MDI application where, i am using a picture control to load icons of leds. The goal is to load the picture control with ICON that look like leds green and red. However, I am getting a Debug Assertion Failed where i set the new icon value. iconPitchActiveFault is CStatic control variable for a ICON void Lenze8200_Dlg::OnShowWindow(BOOL bShow, UINT nStatus) { CFormView::OnShowWindow(bShow, nStatus); //UpdateData(TRUE); HICON Red_ON; HICON Red_OFF; HICON Green_ON; HICON Green_OFF; // TODO: Add your message handler code here Red_ON = AfxGetApp()->LoadIcon(IDI_RED_ON_LED); Red_OFF = AfxGetApp()->LoadIcon(IDI_OFF_LED); Green_ON = AfxGetApp()->LoadIcon(IDI_GREEN_ON_LED); Green_OFF = AfxGetApp()->LoadIcon(IDI_OFF_LED); ******** The exceptions shows up here ************** m_iconPitchActiveFault.SetIcon( Red_OFF ); }

            Scott Dolan Jernie Corporation Engineering & Manufacturing Software, Hardware, & Enclosures

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            How do you make m_iconPitchActiveFault?


            WhiteSky


            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups