Solved

MFC Modeless Dialog Problem

Posted on 1997-12-03
11
456 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
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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Converting to C# also VS2015 5 127
Would like to move button in a function 3 77
Task manager indicates my c++ program memory consumption is growing? 12 111
Dialogbox API leak? 18 96
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

810 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