Board index » Visual Studio » How to reuse the dialog?

How to reuse the dialog?

Visual Studio232
Hi, there,



I am using a dialog based class to get all needed

information, then process them in the app class. So I put

my bulk code in the CApp class as in following:

BOOL CTransApp::InitInstance()

{

...

if (nResponse == IDOK)

Process_File((LPCTSTR) dlg.m_str, ......);

else if (nResponse == IDCANCEL)

.....

return FALSE;

}

It works well in this way. However, each time when I

porcessed those files, the dialog disappears. How can I

reuse the dialog, and let the user enter information again?

Can I implement the same function without moving my bulk

code to the dialog class?



Thanks.



Gary


-
 

Re:How to reuse the dialog?

You can use modeless dialog, When you process_file,you can hide the dialog,

after it, you show it again

"Gary" <anonymous@discussions.microsoft.com>дÈëÏûÏ¢ÐÂÎÅ

:075f01c39dc4$f2950870$a301280a@phx.gbl...

Quote
Hi, there,



I am using a dialog based class to get all needed

information, then process them in the app class. So I put

my bulk code in the CApp class as in following:

BOOL CTransApp::InitInstance()

{

...

if (nResponse == IDOK)

Process_File((LPCTSTR) dlg.m_str, ......);

else if (nResponse == IDCANCEL)

.....

return FALSE;

}

It works well in this way. However, each time when I

porcessed those files, the dialog disappears. How can I

reuse the dialog, and let the user enter information again?

Can I implement the same function without moving my bulk

code to the dialog class?



Thanks.



Gary







-

Re:How to reuse the dialog?

Quote
However, each time when I porcessed those files, the dialog disappears.

Not only does your dialog disappear but your application ends



Quote
Can I implement the same function without moving my bulk

code to the dialog class?



Yes but you would have to redisplay the dialog which is rubbish ...



while ( myDialog.DoModal() == IDOK )

{

ProcessFile(...)

}



return FALSE





How can I reuse the dialog, and let the user enter information again?

Ideally you would label your OK button as 'Process' and handle OnOK



void CMyDialog::OnOK()

{

UpdateData(TRUE);

ProcessFile(...)

return;

}



your Cancel button would still mean dismiss the dialog and exit the application

-