CDialog::DoModal returns -1

Overview:
I have 2 utilities and both have same common interface i.e. open a dialog box to "request for username".
The code for "requesting username" is written in different library and both these utilities call that library .

ISSUE:

In 1 utility it works fine and I got this this dialog box which request username but in other utility it doesn't come up.

MY Investigation:
ON deeper investigation I found that both these utilities call CDialog::DoModal() which in turns call onCreate() . In my other utility breakpoint never hits onCreate function . Any idea why ?

sample code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// IN actual Utility
//somewhere in code 

Dialog_for_common_interface dlg( message.c_str(), "Please enter username:" );

        CString username;

        bool is_correct = ( dlg.DoModal(username) == IDOK )

// IN Dialog_for_common_interface

int  Dialog_for_common_interface::DoModal ( CString &_reply_c )
{
    int result_i = CDialog::DoModal(); // break point hits this but value of result_i = -1;

    if ( result_i == IDOK )
    {
        _reply_c = reply_c;
    }

    return result_i;
}

// Breakpoint nver hits the below function

int Dialog_for_common_interface::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
    if (CDialog::OnCreate(lpCreateStruct) == -1)
        return -1;

    SetWindowText( title_c );

    return 0;
}
Last edited on
Topic archived. No new replies allowed.