Click here to Skip to main content
15,899,126 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Cannot hook FindNextFile Pin
gamitech8-Dec-05 8:46
gamitech8-Dec-05 8:46 
GeneralRe: Cannot hook FindNextFile Pin
Chris Losinger8-Dec-05 8:56
professionalChris Losinger8-Dec-05 8:56 
GeneralRe: Cannot hook FindNextFile Pin
ThatsAlok8-Dec-05 20:06
ThatsAlok8-Dec-05 20:06 
GeneralRe: Cannot hook FindNextFile Pin
gamitech10-Dec-05 4:27
gamitech10-Dec-05 4:27 
GeneralRe: Cannot hook FindNextFile Pin
ThatsAlok11-Dec-05 19:27
ThatsAlok11-Dec-05 19:27 
GeneralRe: Cannot hook FindNextFile Pin
gamitech15-Dec-05 3:16
gamitech15-Dec-05 3:16 
GeneralRe: Cannot hook FindNextFile Pin
ThatsAlok15-Dec-05 17:11
ThatsAlok15-Dec-05 17:11 
QuestionHalt processing until button is clicked Pin
Simon Cornish8-Dec-05 5:40
Simon Cornish8-Dec-05 5:40 
I am new to windows programming, and am using Visual Studio .Net 2003.

I have a standard managed form which contains a number of data entry fields (textboxes, radio buttons etc), and a couple of buttons.

One of the buttons (labelled Save) activates an event handler that calls two functions. The first function will perform some validation on the data entered in the form, and then displays a message on a second smaller form with an OK button. This OK button closes the form. The second function then formats some of the data, and will eventually write it to a file.

How do I stop the second function running until after the OK button on the form displayed by the first function is clicked ? Or, in other words, how do I stop the 2nd function from running until the first is complete.

The program so far is listed below, and the event handler concerned is called collegeForm::buttonSave.

Many thanks

#using <mscorlib.dll>
#using <system.dll>
#using <system.drawing.dll>
#using <system.windows.forms.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

__gc class collegeForm : public Form
{
public :
collegeForm();

private :
Label *labelSurname;
Label *labelForename;
Label *labelGender;
Label *labelDateOfBirth;
Label *labelAccomodation;
Label *labelSupportCode;
Label *labelCourseCode;

TextBox *surname;
TextBox *forename;
TextBox *courseCode;
TextBox *dateOfBirth;

ComboBox *supportCode;

GroupBox *gender;
RadioButton *male;
RadioButton *female;

GroupBox *accomodation;
RadioButton *parentalHome;
RadioButton *lodgings;
RadioButton *hallsOfResidence;

Button *save;
Button *clear;

MainMenu * mainMenu;

void buttonSave(Object *Sender, EventArgs *Args);
void buttonClear(Object *Sender, EventArgs *Args);
Int32 validateForm(void);
void formatNames(void);
};

__gc class errorMessage : public Form
{
public :
errorMessage();
errorMessage(String *);

private :
Label *message;
Button *ok;

void buttonOK(Object *Sender, EventArgs *Args);
};

errorMessage::errorMessage()
{
}

errorMessage::errorMessage(String * errorMessage)
{
this->Text = S"Error Message";
message = new Label;
message->Text = errorMessage;
message->Location = Point(25,100);
this->Controls->Add(message);

ok = new Button;
ok->Location = Point(180,120);
ok->Text = "OK";
ok->Click += new EventHandler(this,buttonOK);
this->Controls->Add(ok);
}

void errorMessage::buttonOK(Object *Sender, EventArgs *Args)
{
Close();
}


collegeForm::collegeForm()
{
this->Text = S"College Enrollment Database";

labelSurname = new Label;
labelSurname->Text = S"Surname";
labelSurname->Location = Point(25,100);
this->Controls->Add(labelSurname);

labelForename = new Label;
labelForename->Text = S"Forename";
labelForename->Location = Point(25,150);
this->Controls->Add(labelForename);

labelGender = new Label;
labelGender->Text = S"Gender";
labelGender->Location = Point(25,200);
this->Controls->Add(labelGender);

labelDateOfBirth = new Label;
labelDateOfBirth->Text = S"Date Of Birth";
labelDateOfBirth->Location = Point(25,250);
this->Controls->Add(labelDateOfBirth);

labelAccomodation = new Label;
labelAccomodation->Text = S"Accomodation";
labelAccomodation->Location = Point(25,300);
this->Controls->Add(labelAccomodation);

labelSupportCode = new Label;
labelSupportCode->Text = S"Support Code";
labelSupportCode->Location = Point(25,350);
this->Controls->Add(labelSupportCode);

labelCourseCode = new Label;
labelCourseCode->Text = S"Course Code";
labelCourseCode->Location = Point(25,400);
this->Controls->Add(labelCourseCode);

surname = new TextBox;
surname->Location = Point(125,100);
surname->Width = 200;
this->Controls->Add(surname);

forename = new TextBox;
forename->Location = Point(125,150);
forename->Width = 200;
this->Controls->Add(forename);

courseCode = new TextBox;
courseCode->Location = Point(125,400);
courseCode->Width = 100;
this->Controls->Add(courseCode);

dateOfBirth = new TextBox;
dateOfBirth->Location = Point(125,250);
dateOfBirth->Width = 200;
this->Controls->Add(dateOfBirth);

supportCode = new ComboBox;
supportCode->Location = Point(125,350);
supportCode->Width = 230;
supportCode->Items->Add(S"No Known Disability");
supportCode->Items->Add(S"Dyslexia");
supportCode->Items->Add(S"Blind or Partially Sighted");
supportCode->Items->Add(S"Deaf or Impaired Hearing");
supportCode->Items->Add(S"Mobility Difficulties or Wheelchair User");
supportCode->Items->Add(S"Personal Care Support Required");
supportCode->Items->Add(S"Mental Health Difficulties");
supportCode->Items->Add(S"Unseen Disability - Diabetes, Asthma");
supportCode->Items->Add(S"Two Or More Of The Above");
supportCode->Items->Add(S"Other Disability Not Listed");
supportCode->Text = S"No Known Disability";
this->Controls->Add(supportCode);

gender = new GroupBox;
gender->Location = Point(125,175);
gender->Size = Drawing::Size(300,55);
Controls->Add(gender);

male = new RadioButton;
male->Location = Point(25,20); // These are coords in group box
male->Text = S"Male";
gender->Controls->Add(male);

female = new RadioButton;
female->Location = Point(150,20);
female->Text = S"Female";
gender->Controls->Add(female);

accomodation = new GroupBox;
accomodation->Location = Point(125,275);
accomodation->Size = Drawing::Size(450,55);
Controls->Add(accomodation);

parentalHome = new RadioButton;
parentalHome->Location = Point(25,20);
parentalHome->Text = S"&Parental Home";
accomodation->Controls->Add(parentalHome);

lodgings = new RadioButton;
lodgings->Location = Point(150,20);
lodgings->Text = S"Lodgings";
accomodation->Controls->Add(lodgings);

hallsOfResidence = new RadioButton;
hallsOfResidence->Location = Point(275,20);
hallsOfResidence->Text = S"&Halls Of Residence";
accomodation->Controls->Add(hallsOfResidence);

save = new Button;
save->Location = Point(175,500);
save->Text = S"&Save";
save->Click += new EventHandler(this,buttonSave);
this->Controls->Add(save);

clear = new Button;
clear->Location = Point(350,500);
clear->Text = S"&Clear";
clear->Click += new EventHandler(this,buttonClear);
this->Controls->Add(clear);

mainMenu = new MainMenu();
MenuItem *menuFile = mainMenu->MenuItems->Add("&File");
menuFile->MenuItems->Add("&Validate");
menuFile->MenuItems->Add("&Save");
menuFile->MenuItems->Add("&Clear");
menuFile->MenuItems->Add("-");
menuFile->MenuItems->Add("&Exit");

MenuItem *menuHelp = mainMenu->MenuItems->Add("&Help");
menuHelp->MenuItems->Add("&About");

Menu = mainMenu;

}

void collegeForm::buttonSave(Object *Sender, EventArgs *Args)
{
validateForm();
formatNames();
}

void collegeForm::buttonClear(Object *Sender, EventArgs *Args)
{
surname->Text = S"";
forename->Text = S"";
courseCode->Text = S"";
dateOfBirth->Text = S"";
supportCode->Text = S"";
male->Checked = false;
female->Checked = false;
parentalHome->Checked = false;
lodgings->Checked = false;
hallsOfResidence->Checked = false;
}

Int32 collegeForm::validateForm(void)
{
errorMessage * em = new errorMessage("This is a test");
em->Size = System::Drawing::Size(400,200);
em->Show();
return(1);
}

void collegeForm::formatNames(void)
{
String * left;
String * right;
String * temp;

if (surname->Text->Length > 1)
{
temp = surname->Text;
left = temp->Substring(0,1);
right = temp->Substring(1,temp->Length-1);
left = left->ToUpper();
right = right->ToLower();
temp = String::Concat(left,right);
surname->Text = temp;
}

if (forename->Text->Length > 1)
{
temp = forename->Text;
left = temp->Substring(0,1);
right = temp->Substring(1,temp->Length-1);
left = left->ToUpper();
right = right->ToLower();
temp = String::Concat(left,right);
forename->Text = temp;
}
}

int __stdcall WinMain()
{
collegeForm *cf = new collegeForm();
cf->Size = System::Drawing::Size(600,600);
Application::Run(cf);
return 0;
}

Simon Cornish
AnswerRe: Halt processing until button is clicked Pin
toxcct8-Dec-05 5:55
toxcct8-Dec-05 5:55 
GeneralRe: Halt processing until button is clicked Pin
Simon Cornish8-Dec-05 6:40
Simon Cornish8-Dec-05 6:40 
GeneralRe: Halt processing until button is clicked Pin
toxcct8-Dec-05 21:09
toxcct8-Dec-05 21:09 
QuestionON_WM_MOUSEMOVE() in a ActiveX Pin
sweep1238-Dec-05 4:45
sweep1238-Dec-05 4:45 
QuestionVisual C++ compiler error C2143 Pin
Emb_Emb8-Dec-05 4:44
Emb_Emb8-Dec-05 4:44 
AnswerRe: Visual C++ compiler error C2143 Pin
toxcct8-Dec-05 5:03
toxcct8-Dec-05 5:03 
Questionstd::vector - issues Pin
ddmcr8-Dec-05 4:24
ddmcr8-Dec-05 4:24 
AnswerRe: std::vector - issues Pin
toxcct8-Dec-05 4:53
toxcct8-Dec-05 4:53 
GeneralRe: std::vector - issues Pin
ddmcr8-Dec-05 5:01
ddmcr8-Dec-05 5:01 
GeneralRe: std::vector - issues Pin
toxcct8-Dec-05 5:06
toxcct8-Dec-05 5:06 
QuestionFile locking problems?? Pin
chilituna8-Dec-05 3:05
chilituna8-Dec-05 3:05 
AnswerRe: File locking problems?? Pin
David Crow8-Dec-05 3:20
David Crow8-Dec-05 3:20 
QuestionAdd Picturebox into the Form Pin
JanakKoshia8-Dec-05 2:51
JanakKoshia8-Dec-05 2:51 
AnswerRe: Add Picturebox into the Form Pin
BlackDice8-Dec-05 6:09
BlackDice8-Dec-05 6:09 
QuestionNetworking Pin
Girish6018-Dec-05 1:41
Girish6018-Dec-05 1:41 
QuestionHow to get the real parent of a service process Pin
Vaskoder8-Dec-05 0:23
Vaskoder8-Dec-05 0:23 
AnswerRe: How to get the real parent of a service process Pin
Blake Miller8-Dec-05 10:12
Blake Miller8-Dec-05 10:12 

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.