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. Unhandled exception in PathEdit.exe (COMDLG32.DLL): 0xC0000005: Access Violation.

Unhandled exception in PathEdit.exe (COMDLG32.DLL): 0xC0000005: Access Violation.

Scheduled Pinned Locked Moved C / C++ / MFC
help
11 Posts 5 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.
  • R Radhakrishnan G

    Hai All Crash occured while displaying Color Chooser Dialog form a Property Sheet

    CHOOSECOLOR* pstChooseColor = new CHOOSECOLOR;
    ZeroMemory( pstChooseColor, sizeof( CHOOSECOLOR ));
    pstChooseColor->Flags = CC_RGBINIT;
    pstChooseColor->lStructSize = sizeof( CHOOSECOLOR );
    pstChooseColor->hwndOwner = m_hWnd;
    pstChooseColor->rgbResult = ConfigMgr::Instance().GetBkColor();
    ChooseColor( pstChooseColor );

    called from the DialogProc of PropertyPage

    case WM_COMMAND:
    {
    int nCtrlCode = LOWORD( wParam_i );
    if( IDC_BTN_CHANGE_COLORS == nCtrlCode )
    {
    pDisplaySettingsPage->OnChangeColor();
    }
    }
    break;

    Please help:confused:

    C Offline
    C Offline
    Cedric Moonen
    wrote on last edited by
    #2

    Use your debugger to track the problem more in detail. Where does the crash occur exactly ? What does the call stack look like ?

    Cédric Moonen Software developer
    Charting control [v1.5] OpenGL game tutorial in C++

    R 1 Reply Last reply
    0
    • C Cedric Moonen

      Use your debugger to track the problem more in detail. Where does the crash occur exactly ? What does the call stack look like ?

      Cédric Moonen Software developer
      Charting control [v1.5] OpenGL game tutorial in C++

      R Offline
      R Offline
      Radhakrishnan G
      wrote on last edited by
      #3

      COMDLG32! 763bdbd2() COMDLG32! 763bdf24() USER32! 77d48709() USER32! 77d551cd() USER32! 77d54af2() USER32! 77d54d1c() USER32! 77d48709() USER32! 77d487eb() USER32! 77d4b743() USER32! 77d558ef() USER32! 77d56877() USER32! 77d568cc() COMDLG32! 763bedf2() COMDLG32! 763bf019() DisplaySettingsPage::OnChangeColor() line 91 + 12 bytes DisplaySettingsPage::DisplaySettingsPageDlgProc(HWND__ * May be useful

      C 1 Reply Last reply
      0
      • R Radhakrishnan G

        COMDLG32! 763bdbd2() COMDLG32! 763bdf24() USER32! 77d48709() USER32! 77d551cd() USER32! 77d54af2() USER32! 77d54d1c() USER32! 77d48709() USER32! 77d487eb() USER32! 77d4b743() USER32! 77d558ef() USER32! 77d56877() USER32! 77d568cc() COMDLG32! 763bedf2() COMDLG32! 763bf019() DisplaySettingsPage::OnChangeColor() line 91 + 12 bytes DisplaySettingsPage::DisplaySettingsPageDlgProc(HWND__ * May be useful

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #4

        Radhakrishnan G. wrote:

        May be useful

        Not really for us. In fact for these kind of problems, you'll have to find the root cause yourself and fix it. There's no magic way of solving the problem. Use the call stack to locate the problem in your code, put breakpoints before the crash occur and inspect the different variables. The exception means that you are trying to access an invalid memory region (e.g reading or writing to a NULL pointer, ...)

        Cédric Moonen Software developer
        Charting control [v1.5] OpenGL game tutorial in C++

        1 Reply Last reply
        0
        • R Radhakrishnan G

          Hai All Crash occured while displaying Color Chooser Dialog form a Property Sheet

          CHOOSECOLOR* pstChooseColor = new CHOOSECOLOR;
          ZeroMemory( pstChooseColor, sizeof( CHOOSECOLOR ));
          pstChooseColor->Flags = CC_RGBINIT;
          pstChooseColor->lStructSize = sizeof( CHOOSECOLOR );
          pstChooseColor->hwndOwner = m_hWnd;
          pstChooseColor->rgbResult = ConfigMgr::Instance().GetBkColor();
          ChooseColor( pstChooseColor );

          called from the DialogProc of PropertyPage

          case WM_COMMAND:
          {
          int nCtrlCode = LOWORD( wParam_i );
          if( IDC_BTN_CHANGE_COLORS == nCtrlCode )
          {
          pDisplaySettingsPage->OnChangeColor();
          }
          }
          break;

          Please help:confused:

          J Offline
          J Offline
          Jijo Raj
          wrote on last edited by
          #5

          Radhakrishnan G. wrote:

          pDisplaySettingsPage->OnChangeColor();

          I saw the callstack and could you please check whether pDisplaySettingsPage a valid pointer when the function is being called? Regards, Jijo.

          _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

          R 1 Reply Last reply
          0
          • J Jijo Raj

            Radhakrishnan G. wrote:

            pDisplaySettingsPage->OnChangeColor();

            I saw the callstack and could you please check whether pDisplaySettingsPage a valid pointer when the function is being called? Regards, Jijo.

            _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

            R Offline
            R Offline
            Radhakrishnan G
            wrote on last edited by
            #6

            Here is the code of Dialog Proc

            INT_PTR CALLBACK DisplaySettingsPage::DisplaySettingsPageDlgProc( HWND hWnd_i,
            UINT uMessage_i,
            WPARAM wParam_i,
            LPARAM lParam_i )
            {
            // Get user data from the window.
            DisplaySettingsPage* pDisplaySettingsPage = reinterpret_cast<displaysettingspage*>( GetWindowLong( hWnd_i, GWL_USERDATA ));
            switch (uMessage_i)
            {
            case WM_INITDIALOG:
            {
            pDisplaySettingsPage = reinterpret_cast<displaysettingspage*>( lParam_i );
            if( 0 != pDisplaySettingsPage )
            {
            // Set user data
            SetWindowLong( hWnd_i, GWL_USERDATA, lParam_i );
            pDisplaySettingsPage->m_hWnd = hWnd_i;
            pDisplaySettingsPage->OnInitDialog();
            }
            return TRUE;
            }
            break;
            case WM_CTLCOLORSTATIC:
            {
            if( IDC_STATIC_BKCOLOR == GetDlgCtrlID( (HWND)lParam_i ))
            {
            RECT stRect;
            GetClientRect( (HWND)lParam_i, &stRect );
            FillRect( (HDC)wParam_i, &stRect, pDisplaySettingsPage->m_hBkBrush);
            return (BOOL)GetStockObject(NULL_BRUSH);
            }
            }
            break;
            case WM_NOTIFY:
            {
            NMHDR* pstNMHDR = reinterpret_cast< NMHDR*>( lParam_i );
            if( PSN_APPLY == pstNMHDR->code )
            {
            }
            }
            break;
            case WM_COMMAND:
            {
            int nCtrlCode = LOWORD( wParam_i );
            if( IDC_BTN_CHANGE_COLORS == nCtrlCode )
            {
            pDisplaySettingsPage->OnChangeColor();
            }
            }
            break;
            }
            return DefWindowProc( hWnd_i, uMessage_i, wParam_i, lParam_i );
            }

            Here is the Display setting page class

            class DisplaySettingsPage
            {
            public:
            DisplaySettingsPage();
            ~DisplaySettingsPage();

                operator LPPROPSHEETPAGE();
            
                static INT\_PTR CALLBACK DisplaySettingsPageDlgProc( HWND hWnd\_i, UINT uMessage\_i,
            	                                            WPARAM wParam\_i, LPARAM lParam\_i );
            
            void OnInitDialog();
            void OnChangeColor();
            

            private:

            HWND          m\_hWnd; // Handle to the Property page
            HBRUSH        m\_hBkBrush;
            PROPSHEETPAGE m\_stPropertyPage; // Property page information.
            

            };

            Initializing Property page information in constructor

            DisplaySettingsPage::DisplaySettingsPage() : m_hWnd( 0 ),
            m_hBkBrush( 0 )
            {
            ZeroMemory( &m_stPropertyPage, sizeof( PROPSHEETPAGE ));
            m_stPropertyPage.dwSize = sizeof( PROPSHEETPAGE );
            m_st

            J 1 Reply Last reply
            0
            • R Radhakrishnan G

              Hai All Crash occured while displaying Color Chooser Dialog form a Property Sheet

              CHOOSECOLOR* pstChooseColor = new CHOOSECOLOR;
              ZeroMemory( pstChooseColor, sizeof( CHOOSECOLOR ));
              pstChooseColor->Flags = CC_RGBINIT;
              pstChooseColor->lStructSize = sizeof( CHOOSECOLOR );
              pstChooseColor->hwndOwner = m_hWnd;
              pstChooseColor->rgbResult = ConfigMgr::Instance().GetBkColor();
              ChooseColor( pstChooseColor );

              called from the DialogProc of PropertyPage

              case WM_COMMAND:
              {
              int nCtrlCode = LOWORD( wParam_i );
              if( IDC_BTN_CHANGE_COLORS == nCtrlCode )
              {
              pDisplaySettingsPage->OnChangeColor();
              }
              }
              break;

              Please help:confused:

              N Offline
              N Offline
              Naveen
              wrote on last edited by
              #7

              The crash occurs because you haven't set value of lpCustColors in the code. COLORREF clrCust[16] = {0}; pstChooseColor->lpCustColors = clrCust; ChooseColor( pstChooseColor );

              Radhakrishnan G. wrote:

              Crash occured while displaying Color Chooser Dialog form a Property Sheet

              1. Why did you say the crash is from property sheet?I think the crash should occur in all cases, not only when called from property sheet

              nave [OpenedFileFinder] [My Blog]

              1 Reply Last reply
              0
              • R Radhakrishnan G

                Here is the code of Dialog Proc

                INT_PTR CALLBACK DisplaySettingsPage::DisplaySettingsPageDlgProc( HWND hWnd_i,
                UINT uMessage_i,
                WPARAM wParam_i,
                LPARAM lParam_i )
                {
                // Get user data from the window.
                DisplaySettingsPage* pDisplaySettingsPage = reinterpret_cast<displaysettingspage*>( GetWindowLong( hWnd_i, GWL_USERDATA ));
                switch (uMessage_i)
                {
                case WM_INITDIALOG:
                {
                pDisplaySettingsPage = reinterpret_cast<displaysettingspage*>( lParam_i );
                if( 0 != pDisplaySettingsPage )
                {
                // Set user data
                SetWindowLong( hWnd_i, GWL_USERDATA, lParam_i );
                pDisplaySettingsPage->m_hWnd = hWnd_i;
                pDisplaySettingsPage->OnInitDialog();
                }
                return TRUE;
                }
                break;
                case WM_CTLCOLORSTATIC:
                {
                if( IDC_STATIC_BKCOLOR == GetDlgCtrlID( (HWND)lParam_i ))
                {
                RECT stRect;
                GetClientRect( (HWND)lParam_i, &stRect );
                FillRect( (HDC)wParam_i, &stRect, pDisplaySettingsPage->m_hBkBrush);
                return (BOOL)GetStockObject(NULL_BRUSH);
                }
                }
                break;
                case WM_NOTIFY:
                {
                NMHDR* pstNMHDR = reinterpret_cast< NMHDR*>( lParam_i );
                if( PSN_APPLY == pstNMHDR->code )
                {
                }
                }
                break;
                case WM_COMMAND:
                {
                int nCtrlCode = LOWORD( wParam_i );
                if( IDC_BTN_CHANGE_COLORS == nCtrlCode )
                {
                pDisplaySettingsPage->OnChangeColor();
                }
                }
                break;
                }
                return DefWindowProc( hWnd_i, uMessage_i, wParam_i, lParam_i );
                }

                Here is the Display setting page class

                class DisplaySettingsPage
                {
                public:
                DisplaySettingsPage();
                ~DisplaySettingsPage();

                    operator LPPROPSHEETPAGE();
                
                    static INT\_PTR CALLBACK DisplaySettingsPageDlgProc( HWND hWnd\_i, UINT uMessage\_i,
                	                                            WPARAM wParam\_i, LPARAM lParam\_i );
                
                void OnInitDialog();
                void OnChangeColor();
                

                private:

                HWND          m\_hWnd; // Handle to the Property page
                HBRUSH        m\_hBkBrush;
                PROPSHEETPAGE m\_stPropertyPage; // Property page information.
                

                };

                Initializing Property page information in constructor

                DisplaySettingsPage::DisplaySettingsPage() : m_hWnd( 0 ),
                m_hBkBrush( 0 )
                {
                ZeroMemory( &m_stPropertyPage, sizeof( PROPSHEETPAGE ));
                m_stPropertyPage.dwSize = sizeof( PROPSHEETPAGE );
                m_st

                J Offline
                J Offline
                Jijo Raj
                wrote on last edited by
                #8

                Radhakrishnan G. wrote:

                DisplaySettingsPage* pDisplaySettingsPage = reinterpret_cast<displaysettingspage*>( GetWindowLong( hWnd_i, GWL_USERDATA ));

                is there two different classes - DisplaySettingsPage & displaysettingspage? Or is it a typo while pasting the source code? Whether DisplaySettingsPage::m_hWnd holds valid handle? Please check by using debugger. If that one doesn't give you any hint, please post code snippet for OnChangeColor(). Regards, Jijo.

                _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

                1 Reply Last reply
                0
                • R Radhakrishnan G

                  Hai All Crash occured while displaying Color Chooser Dialog form a Property Sheet

                  CHOOSECOLOR* pstChooseColor = new CHOOSECOLOR;
                  ZeroMemory( pstChooseColor, sizeof( CHOOSECOLOR ));
                  pstChooseColor->Flags = CC_RGBINIT;
                  pstChooseColor->lStructSize = sizeof( CHOOSECOLOR );
                  pstChooseColor->hwndOwner = m_hWnd;
                  pstChooseColor->rgbResult = ConfigMgr::Instance().GetBkColor();
                  ChooseColor( pstChooseColor );

                  called from the DialogProc of PropertyPage

                  case WM_COMMAND:
                  {
                  int nCtrlCode = LOWORD( wParam_i );
                  if( IDC_BTN_CHANGE_COLORS == nCtrlCode )
                  {
                  pDisplaySettingsPage->OnChangeColor();
                  }
                  }
                  break;

                  Please help:confused:

                  R Offline
                  R Offline
                  Radhakrishnan G
                  wrote on last edited by
                  #9

                  Got the solution code is updated with

                  CHOOSECOLOR\* pstChooseColor = new CHOOSECOLOR;
                  COLORREF     crCustomColorArray\[ 16 \];
                  ZeroMemory( pstChooseColor, sizeof( CHOOSECOLOR ));
                  pstChooseColor->Flags        = CC\_RGBINIT;
                  pstChooseColor->lStructSize  = sizeof( CHOOSECOLOR );
                  pstChooseColor->hwndOwner    = m\_hWnd;
                  **pstChooseColor->lpCustColors = crCustomColorArray;  // Custom color array**
                  pstChooseColor->rgbResult    = ConfigMgr::Instance().GetBkColor();
                  if( FALSE != ChooseColor( pstChooseColor ))
                  {
                      // Update the Background color.
                      ConfigMgr::Instance().SetBkColor( \*pstChooseColor->lpCustColors );
                  }
                  delete pstChooseColor;
                  pstChooseColor = 0;
                  

                  Thanks

                  1 Reply Last reply
                  0
                  • R Radhakrishnan G

                    Hai All Crash occured while displaying Color Chooser Dialog form a Property Sheet

                    CHOOSECOLOR* pstChooseColor = new CHOOSECOLOR;
                    ZeroMemory( pstChooseColor, sizeof( CHOOSECOLOR ));
                    pstChooseColor->Flags = CC_RGBINIT;
                    pstChooseColor->lStructSize = sizeof( CHOOSECOLOR );
                    pstChooseColor->hwndOwner = m_hWnd;
                    pstChooseColor->rgbResult = ConfigMgr::Instance().GetBkColor();
                    ChooseColor( pstChooseColor );

                    called from the DialogProc of PropertyPage

                    case WM_COMMAND:
                    {
                    int nCtrlCode = LOWORD( wParam_i );
                    if( IDC_BTN_CHANGE_COLORS == nCtrlCode )
                    {
                    pDisplaySettingsPage->OnChangeColor();
                    }
                    }
                    break;

                    Please help:confused:

                    S Offline
                    S Offline
                    Stuart Dootson
                    wrote on last edited by
                    #10

                    I know you've fixed your problem - just a comment on style. Why not use a locally declared CHOOSECOLOR rather than one on the heap? That way, you don't need to remember to delete it. Your (fixed) code would look like this:CHOOSECOLOR stChooseColor = { 0 }; COLORREF crCustomColorArray[ 16 ] = { 0 }; stChooseColor.Flags = CC_RGBINIT; stChooseColor.lStructSize = sizeof( CHOOSECOLOR ); stChooseColor.hwndOwner = m_hWnd; stChooseColor.lpCustColors = crCustomColorArray; // Custom color array stChooseColor.rgbResult = ConfigMgr::Instance().GetBkColor(); if( FALSE != ChooseColor( &stChooseColor )) { // Update the Background color. ConfigMgr::Instance().SetBkColor( *stChooseColor.lpCustColors ); }
                    I know it's not a big change, but using the stack for variable storage when possible makes memory management so much easier :-) One other thing - doesn't ChooseColor pass back the user's selected color in the rgbResult member, rather than in lpCustColors[0], as you've used? That's what the documentation[^] says, anyway.

                    R 1 Reply Last reply
                    0
                    • S Stuart Dootson

                      I know you've fixed your problem - just a comment on style. Why not use a locally declared CHOOSECOLOR rather than one on the heap? That way, you don't need to remember to delete it. Your (fixed) code would look like this:CHOOSECOLOR stChooseColor = { 0 }; COLORREF crCustomColorArray[ 16 ] = { 0 }; stChooseColor.Flags = CC_RGBINIT; stChooseColor.lStructSize = sizeof( CHOOSECOLOR ); stChooseColor.hwndOwner = m_hWnd; stChooseColor.lpCustColors = crCustomColorArray; // Custom color array stChooseColor.rgbResult = ConfigMgr::Instance().GetBkColor(); if( FALSE != ChooseColor( &stChooseColor )) { // Update the Background color. ConfigMgr::Instance().SetBkColor( *stChooseColor.lpCustColors ); }
                      I know it's not a big change, but using the stack for variable storage when possible makes memory management so much easier :-) One other thing - doesn't ChooseColor pass back the user's selected color in the rgbResult member, rather than in lpCustColors[0], as you've used? That's what the documentation[^] says, anyway.

                      R Offline
                      R Offline
                      Radhakrishnan G
                      wrote on last edited by
                      #11

                      Yes thats was the Mistake in the code I already corrected that.. Thanks.

                      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