Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Cant get a variable from my pop up dialog.

FlackFlack Member Posts: 88
Hello,

I have a main dialog app (created with MFC App Wizard, VC++). When the user hits a button, a new dialog app comes up. Im having trouble returning a variable that the new pop up dialog calculates.

Here is the problem:
The original dialog app is created from BF1942Dlg.cpp. The new dialog that pops up uses TestDialog.cpp. Now, I call the dialog like this: TestDialog dlg(NULL,Source). Source is a CString indicating the exe I am going to extract an icon from. Now, the TestDialog dialog has a list box. The list box lists all of the icon ids and whenver the user single clicks an id the icon is drawn on the TestDialog window. What I want is that when the user double clicks on an id the pop up dialog closes and the icon handle is returned to my main app. I can easily get the icon handle but I do not know how to return this handle to my main app.

In my OnSelchangeList1() method I calculate an icon handle and store it in HICON icon, a member of TestDialog. In my OnDblclkList1() I want to somehow get the var icon back to the dialog that created the popup and then exit (by calling OnOK()).

Any suggestion on how to do this?

Thanx for the help,
-Flack

Comments

  • stoberstober Member Posts: 9,765 ✭✭✭
    [blue]That is a pretty common thing to do. Store the HICON in a public variale in TestDialog. Then after the Ok button is clicked in the TestDialog control returns to the calling dialog. The calling dialog just extracts it from TestDialog[/blue]
    [code]
    int BF1942Dlg::GetIcon()
    {
    HICON icon;
    CTestDialog dlg(NULL,"...");
    if( dlg.DoModal() == IDOK)
    {
    // TestDialog saved the icon in a public member
    // variable m_icon.
    icon = dlg.m_icon;

    }

    }
    [/code]

    : Hello,
    :
    : I have a main dialog app (created with MFC App Wizard, VC++). When the user hits a button, a new dialog app comes up. Im having trouble returning a variable that the new pop up dialog calculates.
    :
    : Here is the problem:
    : The original dialog app is created from BF1942Dlg.cpp. The new dialog that pops up uses TestDialog.cpp. Now, I call the dialog like this: TestDialog dlg(NULL,Source). Source is a CString indicating the exe I am going to extract an icon from. Now, the TestDialog dialog has a list box. The list box lists all of the icon ids and whenver the user single clicks an id the icon is drawn on the TestDialog window. What I want is that when the user double clicks on an id the pop up dialog closes and the icon handle is returned to my main app. I can easily get the icon handle but I do not know how to return this handle to my main app.
    :
    : In my OnSelchangeList1() method I calculate an icon handle and store it in HICON icon, a member of TestDialog. In my OnDblclkList1() I want to somehow get the var icon back to the dialog that created the popup and then exit (by calling OnOK()).
    :
    : Any suggestion on how to do this?
    :
    : Thanx for the help,
    : -Flack
    :

Sign In or Register to comment.