Solved

MFC Modeless Dialog Problem

Posted on 1997-12-03
11
465 Views
Last Modified: 2008-02-01
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
Comment
Question by:richp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1174721
The source code might help.
0
 

Author Comment

by:richp
ID: 1174722
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
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1174723
Where in your source code did you get the access violation?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:richp
ID: 1174724
In the InitDialog of the Create(IDD_MARKETSET...
I have a CListCtrl in the dialog and a GetItem fails.
0
 
LVL 2

Expert Comment

by:AlFa
ID: 1174725
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
 

Author Comment

by:richp
ID: 1174726
This is already being done...

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

.....

0
 
LVL 2

Expert Comment

by:anichini
ID: 1174727
Where in InitInstance is the dialog code called? Are you sure that m_pMainWnd has a valid window handle at that point?
0
 

Author Comment

by:richp
ID: 1174728
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
 
LVL 2

Expert Comment

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

0
 

Author Comment

by:richp
ID: 1174730
The problem was a bad text pointer and length in the GetItem.


0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 200 total points
ID: 1174731
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question