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. [Message Deleted]

[Message Deleted]

Scheduled Pinned Locked Moved C / C++ / MFC
13 Posts 3 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.
  • V Offline
    V Offline
    valerie99
    wrote on last edited by
    #1

    [Message Deleted]

    M 1 Reply Last reply
    0
    • V valerie99

      [Message Deleted]

      M Offline
      M Offline
      MailtoGops
      wrote on last edited by
      #2

      I don't think it is defined two times. Program used reference value. Check other possiblities.. Why do you want to use like this.. --> CWinApp& theApp = (* (static_cast (AfxGetApp()))); use like this.. CWinApp *pApp = AfxGetApp(); ASSERT(pApp != NULL); " Action without vision is only passing time, Vision without action is merely day dreaming, But vision with action can change the world " - Words from Nelson Mandela Thanks & Regards, Gopalakrishnan

      V 1 Reply Last reply
      0
      • M MailtoGops

        I don't think it is defined two times. Program used reference value. Check other possiblities.. Why do you want to use like this.. --> CWinApp& theApp = (* (static_cast (AfxGetApp()))); use like this.. CWinApp *pApp = AfxGetApp(); ASSERT(pApp != NULL); " Action without vision is only passing time, Vision without action is merely day dreaming, But vision with action can change the world " - Words from Nelson Mandela Thanks & Regards, Gopalakrishnan

        V Offline
        V Offline
        valerie99
        wrote on last edited by
        #3

        thanks for your reply, the problem with this app is over here: BOOL CAddSurchrgApp::InitInstance() { #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif CCommandLineInfo CmdLine; CmdLine.setParamsUsed("C"); ParseCommandLine( CmdLine ); strcpy( m_szCycle, CmdLine.getCycle() ); if ( !CmdLine.isOkToProcess() ) //help will always make this call false so app will stop. return FALSE; try { CSurchrgDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); } when it comes to CSurchrgDlg dlg; the dlg get value {CSurchrgDlghWnd=0xccccccccc}, then it would crash at "m_pMainWnd = &dlg;" because of the access violation.....not sure when and where between those line dlg should get the proper value, thanks for your time!

        D 1 Reply Last reply
        0
        • V valerie99

          thanks for your reply, the problem with this app is over here: BOOL CAddSurchrgApp::InitInstance() { #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif CCommandLineInfo CmdLine; CmdLine.setParamsUsed("C"); ParseCommandLine( CmdLine ); strcpy( m_szCycle, CmdLine.getCycle() ); if ( !CmdLine.isOkToProcess() ) //help will always make this call false so app will stop. return FALSE; try { CSurchrgDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); } when it comes to CSurchrgDlg dlg; the dlg get value {CSurchrgDlghWnd=0xccccccccc}, then it would crash at "m_pMainWnd = &dlg;" because of the access violation.....not sure when and where between those line dlg should get the proper value, thanks for your time!

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

          valerie99 wrote: when it comes to CSurchrgDlg dlg; the dlg get value {CSurchrgDlghWnd=0xccccccccc}, We would need to see more of the CSurchrgDlg class in order to give you any helpful solution(s). What you have shown here is fine.


          "One must learn from the bite of the fire to leave it alone." - Native American Proverb

          V 1 Reply Last reply
          0
          • D David Crow

            valerie99 wrote: when it comes to CSurchrgDlg dlg; the dlg get value {CSurchrgDlghWnd=0xccccccccc}, We would need to see more of the CSurchrgDlg class in order to give you any helpful solution(s). What you have shown here is fine.


            "One must learn from the bite of the fire to leave it alone." - Native American Proverb

            V Offline
            V Offline
            valerie99
            wrote on last edited by
            #5

            The dlg info should come from CSurchrgDlg, but when I set breakpoint over CSurchrgDlg, it never stop before it hits the CSurchrgDlg dlg;...so I couldn't figure out where exactly it is from class CAboutDlg : public CDialog { public: CAboutDlg(); enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSurchrgDlg dialog CSurchrgDlg::CSurchrgDlg(CWnd* pParent /*=NULL*/) : CDialog(CSurchrgDlg::IDD, pParent), m_theApp (* static_cast (AfxGetApp())) { //{{AFX_DATA_INIT(CAddSurchrgDlg) m_client_name = _T(""); m_reference = _T(""); m_status_message = _T(""); m_cycle = _T(""); m_percent_complete = _T(""); m_records_changed = _T(""); //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_vecBuffer.reserve (BUFFER_SIZE); } void CSurchrgDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAddSurchrgDlg) DDX_Text(pDX, IDC_CLIENT, m_client_name); DDX_Text(pDX, IDC_REFERENCE, m_reference); DDX_Text(pDX, IDC_STATUSMESSAGE, m_status_message); DDX_Text(pDX, IDC_CYCLE, m_cycle); DDX_Text(pDX, IDC_PERCENT_COMPLETE, m_percent_complete); DDX_Text(pDX, IDC_RECORDS_CHANGED, m_records_changed); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSurchrgDlg, CDialog) //{{AFX_MSG_MAP(CSurchrgDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_OK, OnOk) //}}AFX_MSG_MAP END_MESSAGE_MAP()

            D 1 Reply Last reply
            0
            • V valerie99

              The dlg info should come from CSurchrgDlg, but when I set breakpoint over CSurchrgDlg, it never stop before it hits the CSurchrgDlg dlg;...so I couldn't figure out where exactly it is from class CAboutDlg : public CDialog { public: CAboutDlg(); enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSurchrgDlg dialog CSurchrgDlg::CSurchrgDlg(CWnd* pParent /*=NULL*/) : CDialog(CSurchrgDlg::IDD, pParent), m_theApp (* static_cast (AfxGetApp())) { //{{AFX_DATA_INIT(CAddSurchrgDlg) m_client_name = _T(""); m_reference = _T(""); m_status_message = _T(""); m_cycle = _T(""); m_percent_complete = _T(""); m_records_changed = _T(""); //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_vecBuffer.reserve (BUFFER_SIZE); } void CSurchrgDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAddSurchrgDlg) DDX_Text(pDX, IDC_CLIENT, m_client_name); DDX_Text(pDX, IDC_REFERENCE, m_reference); DDX_Text(pDX, IDC_STATUSMESSAGE, m_status_message); DDX_Text(pDX, IDC_CYCLE, m_cycle); DDX_Text(pDX, IDC_PERCENT_COMPLETE, m_percent_complete); DDX_Text(pDX, IDC_RECORDS_CHANGED, m_records_changed); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSurchrgDlg, CDialog) //{{AFX_MSG_MAP(CSurchrgDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_OK, OnOk) //}}AFX_MSG_MAP END_MESSAGE_MAP()

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

              Is there anything in the OnInitDialog() method? The only "odd" thing I see is this:

              CSurchrgDlg::CSurchrgDlg(CWnd* pParent /*=NULL*/)
              : CDialog(CSurchrgDlg::IDD, pParent),
              m_theApp (* static_cast (AfxGetApp()))

              Try removing the initialization of m_theApp and see what that does. What is m_vecBuffer?


              "One must learn from the bite of the fire to leave it alone." - Native American Proverb

              V 1 Reply Last reply
              0
              • D David Crow

                Is there anything in the OnInitDialog() method? The only "odd" thing I see is this:

                CSurchrgDlg::CSurchrgDlg(CWnd* pParent /*=NULL*/)
                : CDialog(CSurchrgDlg::IDD, pParent),
                m_theApp (* static_cast (AfxGetApp()))

                Try removing the initialization of m_theApp and see what that does. What is m_vecBuffer?


                "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                V Offline
                V Offline
                valerie99
                wrote on last edited by
                #7

                thanks for you reply, I could remove the m_theApp and the app would still crash on the same spot. the m_vecBuffer is defined like this : std::vector m_vecBuffer; in dlg.cpp const std::vector::size_type BUFFER_SIZE = 10000; BOOL CSurchrgDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here CWinApp& theApp = (* (static_cast (AfxGetApp()))); m_bCanceled = false; m_strCycle = ""; //PostMessage( WM_COMMAND, IDC_OK ); m_pThread = AfxBeginThread((AFX_THREADPROC)Run, (LPVOID)this, THREAD_PRIORITY_NORMAL, 0); return TRUE; // return TRUE unless you set the focus to a control } void CSurchrgDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } }

                D 1 Reply Last reply
                0
                • V valerie99

                  thanks for you reply, I could remove the m_theApp and the app would still crash on the same spot. the m_vecBuffer is defined like this : std::vector m_vecBuffer; in dlg.cpp const std::vector::size_type BUFFER_SIZE = 10000; BOOL CSurchrgDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here CWinApp& theApp = (* (static_cast (AfxGetApp()))); m_bCanceled = false; m_strCycle = ""; //PostMessage( WM_COMMAND, IDC_OK ); m_pThread = AfxBeginThread((AFX_THREADPROC)Run, (LPVOID)this, THREAD_PRIORITY_NORMAL, 0); return TRUE; // return TRUE unless you set the focus to a control } void CSurchrgDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } }

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

                  valerie99 wrote: m_pThread = AfxBeginThread((AFX_THREADPROC)Run, (LPVOID)this, THREAD_PRIORITY_NORMAL, 0); Comment this out and see what happens. Does the application crash when it starts or when it is exits?


                  "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                  V 1 Reply Last reply
                  0
                  • D David Crow

                    valerie99 wrote: m_pThread = AfxBeginThread((AFX_THREADPROC)Run, (LPVOID)this, THREAD_PRIORITY_NORMAL, 0); Comment this out and see what happens. Does the application crash when it starts or when it is exits?


                    "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                    V Offline
                    V Offline
                    valerie99
                    wrote on last edited by
                    #9

                    hi, David If I comment the m_pThread out it will hang forever and with no message show on the dialog. this app crash when it exits, but if I run another simular app, the dlg from BOOL CXXXXXDlg::InitInstance() { CXXXXXDlg dlg; would already have the value like {CXXXXXDlghWnd=0x00e90000}, but this one will have {CSurchrgDlghWnd=0xCCCCCCCC} instead, so I think it's because it didn't initialize right, looks like the dlg info is from CDialog, CWnd, but I couldn't find out where exactly it's calling CDialog and getting the info

                    D 1 Reply Last reply
                    0
                    • V valerie99

                      hi, David If I comment the m_pThread out it will hang forever and with no message show on the dialog. this app crash when it exits, but if I run another simular app, the dlg from BOOL CXXXXXDlg::InitInstance() { CXXXXXDlg dlg; would already have the value like {CXXXXXDlghWnd=0x00e90000}, but this one will have {CSurchrgDlghWnd=0xCCCCCCCC} instead, so I think it's because it didn't initialize right, looks like the dlg info is from CDialog, CWnd, but I couldn't find out where exactly it's calling CDialog and getting the info

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

                      valerie99 wrote: ...but this one will have {CSurchrgDlghWnd=0xCCCCCCCC} instead, so I think it's because it didn't initialize right... With the breakpoint on the CSurchrgDlghWnd dlg; statement, CSurchrgDlghWnd.hWnd will likely have a value of 0xcccccccc. This is fine. With the breakpoint on the dlg.DoModal(); statement, CSurchrgDlghWnd.hWnd will likely have a value of 0x00000000. This is fine. The problem at this point is that the secondary thread you are creating is still active when the application is exiting. What does this thread do? Does it communicate with the main thread or any UI component?


                      "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                      V 1 Reply Last reply
                      0
                      • D David Crow

                        valerie99 wrote: ...but this one will have {CSurchrgDlghWnd=0xCCCCCCCC} instead, so I think it's because it didn't initialize right... With the breakpoint on the CSurchrgDlghWnd dlg; statement, CSurchrgDlghWnd.hWnd will likely have a value of 0xcccccccc. This is fine. With the breakpoint on the dlg.DoModal(); statement, CSurchrgDlghWnd.hWnd will likely have a value of 0x00000000. This is fine. The problem at this point is that the secondary thread you are creating is still active when the application is exiting. What does this thread do? Does it communicate with the main thread or any UI component?


                        "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                        V Offline
                        V Offline
                        valerie99
                        wrote on last edited by
                        #11

                        Thanks for following up if I set breakpoint at dlg.DoModal(); { CSurchrgDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); } I will still have &dlg with value 0x0000000, dlg 0x0000000 and m_pMainWnd 0x0000000, that's why I keep thinking it's broken at the beginning I will look more about the secondary thread. thanks! -- modified at 18:31 Tuesday 20th September, 2005

                        D 1 Reply Last reply
                        0
                        • V valerie99

                          Thanks for following up if I set breakpoint at dlg.DoModal(); { CSurchrgDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); } I will still have &dlg with value 0x0000000, dlg 0x0000000 and m_pMainWnd 0x0000000, that's why I keep thinking it's broken at the beginning I will look more about the secondary thread. thanks! -- modified at 18:31 Tuesday 20th September, 2005

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

                          If you don't mind me looking at your code (no proprietary or copyright issues), I would suggest packaging it up into a .zip file and e-mailing it to me and I'll take a look at it. Make sure to include the whole project so that I can just open the .dsw file, compile it, and see the problem.


                          "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                          V 1 Reply Last reply
                          0
                          • D David Crow

                            If you don't mind me looking at your code (no proprietary or copyright issues), I would suggest packaging it up into a .zip file and e-mailing it to me and I'll take a look at it. Make sure to include the whole project so that I can just open the .dsw file, compile it, and see the problem.


                            "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                            V Offline
                            V Offline
                            valerie99
                            wrote on last edited by
                            #13

                            thanks for the offer........but this old app is linking to lot of library files and some of them are from mapping network drive.....:(

                            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