Click here to Skip to main content
15,885,127 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to stop run of a program after a message display Pin
Luc Pattyn19-May-10 9:39
sitebuilderLuc Pattyn19-May-10 9:39 
GeneralRe: how to stop run of a program after a message display Pin
mrby12319-May-10 10:40
mrby12319-May-10 10:40 
GeneralRe: how to stop run of a program after a message display Pin
«_Superman_»19-May-10 10:46
professional«_Superman_»19-May-10 10:46 
GeneralRe: how to stop run of a program after a message display Pin
Luc Pattyn19-May-10 11:19
sitebuilderLuc Pattyn19-May-10 11:19 
GeneralRe: how to stop run of a program after a message display Pin
mrby12319-May-10 12:12
mrby12319-May-10 12:12 
AnswerRe: how to stop run of a program after a message display Pin
Maximilien19-May-10 8:43
Maximilien19-May-10 8:43 
GeneralRe: how to stop run of a program after a message display Pin
mrby12319-May-10 9:15
mrby12319-May-10 9:15 
AnswerRe: how to stop run of a program after a message display Pin
Aescleal19-May-10 12:53
Aescleal19-May-10 12:53 
Hi,

As you're using an MFC app look up Dialog Data Exchange (DDX) and Dialog Data Validation (DDV). Between the pair of them you can specify allowed ranges for field in a dialog box and give the user a message if they enter something that's out of the range. Out of the box it's a bit clunky but works okay with a bit of tender loving care.

So if you've got an edit control with the sampling interval in milliseconds (IDC_SAMPLE_INTERVAL) and you want the user to be able to enter something between 10 and 1000ms, you overide DoDataExchange in your dialogue box class as something like:

void CSampleDlg::DoDataExchange( CDataExchange *pDX )
{
    CDialog::DoDataExchange( pDX );

    DDX_Text( pDX, IDC_SAMPLE_INTERVAL, sample_interval_ );
    DDV_MinMaxInt( pDX, sample_interval_, 10, 1000 ); 
}


where sample_interval_ is the data member containing your er, sample interval.

If the entered interval isn't between 10 and 1000 MFC displays an message box and lets the user choose to abandon the edit or try again.

Cheers,

Ash

PS: Using exit() in a C++ program can be a bad idea one main reason - destructors aren't run for any objects. If those objects are managing a system global resource then that resource can leak. It can also mean that files aren't flushed and closed properly and may not have the contents you expect.

On the other hand exit() can be a quick way to bail out of a misbehaving program with a long shutdown time if that shutdown time is due to a large number of or slow destructors. This is generally regarded as being pretty vile by most C++ experts and only used as a desperate measure.
AnswerRe: how to stop run of a program after a message display Pin
KarstenK19-May-10 21:10
mveKarstenK19-May-10 21:10 
QuestionNeed to change the main icon of an SDI app with the new ribbon interface (with a transparent icon) Pin
sashoalm19-May-10 3:45
sashoalm19-May-10 3:45 
AnswerRe: Need to change the main icon of an SDI app with the new ribbon interface (with a transparent icon) Pin
Code-o-mat19-May-10 3:51
Code-o-mat19-May-10 3:51 
GeneralRe: Need to change the main icon of an SDI app with the new ribbon interface (with a transparent icon) Pin
sashoalm19-May-10 4:03
sashoalm19-May-10 4:03 
GeneralRe: Need to change the main icon of an SDI app with the new ribbon interface (with a transparent icon) Pin
Code-o-mat19-May-10 4:05
Code-o-mat19-May-10 4:05 
GeneralRe: Need to change the main icon of an SDI app with the new ribbon interface (with a transparent icon) Pin
sashoalm19-May-10 4:28
sashoalm19-May-10 4:28 
Questionhow do I create a process dump file in WinXP and Win7? Pin
Dave Calkins19-May-10 3:28
Dave Calkins19-May-10 3:28 
AnswerRe: how do I create a process dump file in WinXP and Win7? Pin
Code-o-mat19-May-10 3:47
Code-o-mat19-May-10 3:47 
GeneralRe: how do I create a process dump file in WinXP and Win7? Pin
Dave Calkins19-May-10 4:38
Dave Calkins19-May-10 4:38 
QuestionWinInet Pin
Rajmohan SK19-May-10 1:30
Rajmohan SK19-May-10 1:30 
AnswerRe: WinInet Pin
«_Superman_»19-May-10 11:03
professional«_Superman_»19-May-10 11:03 
QuestionRe: WinInet Pin
Rajmohan SK19-May-10 18:29
Rajmohan SK19-May-10 18:29 
QuestionPNG Image Pin
AbhiHcl18-May-10 23:59
AbhiHcl18-May-10 23:59 
AnswerRe: PNG Image Pin
sashoalm19-May-10 0:31
sashoalm19-May-10 0:31 
AnswerRe: PNG Image Pin
EmoBemo19-May-10 3:26
EmoBemo19-May-10 3:26 
Questionimage color depth Pin
john563218-May-10 23:21
john563218-May-10 23:21 
AnswerRe: image color depth Pin
Code-o-mat19-May-10 4:03
Code-o-mat19-May-10 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.