Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 468
  • Last Modified:

MFC Modeless Dialog Problem

In the InitInstance of my app I create a modal dialog, close it, then create a modeless dialog box.  This worked when built using static mfc but when I switched the project to shared MFC and using run time library multithreaded dll, I receive an access violation in the second initdialog.  A getitem for a clistctrl is failing.
0
richp
Asked:
richp
1 Solution
 
alexoCommented:
The source code might help.
0
 
richpAuthor Commented:
CCommonLogin login(m_pMainWnd,login_name,server_name);
if (login.DoModal()!=IDOK)
    return FALSE;

mktSetManager = new CMarketSetManager;
mktSetManager->Create(IDD_MARKETSET_DIALOG, m_pMainWnd);

0
 
Tommy HuiEngineerCommented:
Where in your source code did you get the access violation?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
richpAuthor Commented:
In the InitDialog of the Create(IDD_MARKETSET...
I have a CListCtrl in the dialog and a GetItem fails.
0
 
AlFaCommented:
In the InitDialog of CMarketSetManager you've to call CDialog::OnInitDialog() before triing to access a control either by a control variable or GetDlgItem.
0
 
richpAuthor Commented:
This is already being done...

BOOL CMarketSetManager::OnInitDialog()
{
      CDialog::OnInitDialog();

.....

0
 
anichiniCommented:
Where in InitInstance is the dialog code called? Are you sure that m_pMainWnd has a valid window handle at that point?
0
 
richpAuthor Commented:
The first dialog is called after the:
      CMainFrame* pMainFrame = new CMainFrame;

      if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
            return FALSE;
      m_pMainWnd = pMainFrame;

m_pMainWnd has a valid pointer after that.

0
 
AlFaCommented:
So OnInitDialog() is called before dialog is physiqualy created try to put initialisation in OnShowWindow ( with a flag to ensure one shot).

0
 
richpAuthor Commented:
The problem was a bad text pointer and length in the GetItem.


0
 
RONSLOWCommented:
Please remove this question now that you have answered it (can you submit you own answer?)

Alternatively, reduce the value of the question to 0 points so other experts don't waste thier time reading all this only to discover that you've answered the question yourself.

Thanks

0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now