By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,852 Members | 2,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,852 IT Pros & Developers. It's quick & easy.

Forms and Label

P: n/a
I wonder if you could help.

The event handler code below, will allow the user to change the phone number
and write it on a label of a message box. I want to replace the message box
with a dialog box.

Can anybody help me replace the message box below to a dialog box. In other
words. I want to write the new phone number on a label (named "labe1")of a
dialog box (named "dialog2),instead of writing the new phone number on the
label of a message box.

private: System::Void dialogBtnItem_Click(System::Object * sender,
System::EventArgs * e)

{

// Create the dialog

MyDialog* box = new MyDialog();
//Fill in the initial data

box->Phone = S"(650)123-3456)"; // <------ This is the phone number to be
changed

//Show dialog

if (box->ShowDialog() == DialogResult::OK)

{

MessageBox::Show(box->Phone); //<-----I tried to change this line
}

}
Apr 23 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
You will need a dialog with a label whose ID is different than IDC_STATIC,
because this ID is generic.

Suposing you have something like a CMyMsgBox class with a IDC_STATIC1 label,
try this:

CMyMsgBox mymsgbox;
CWnd *plabel;

plabel=mymsgbox->GetDlgItem(IDC_STATIC1);
plabel->SetWindowText(box->Phone);
mymsgbox.DoModal();

Regards
--
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:la*@pulsoinformatica.es

"Allen Maki" wrote:
I wonder if you could help.

The event handler code below, will allow the user to change the phone number
and write it on a label of a message box. I want to replace the message box
with a dialog box.

Can anybody help me replace the message box below to a dialog box. In other
words. I want to write the new phone number on a label (named "labe1")of a
dialog box (named "dialog2),instead of writing the new phone number on the
label of a message box.

private: System::Void dialogBtnItem_Click(System::Object * sender,
System::EventArgs * e)

{

// Create the dialog

MyDialog* box = new MyDialog();
//Fill in the initial data

box->Phone = S"(650)123-3456)"; // <------ This is the phone number to be
changed

//Show dialog

if (box->ShowDialog() == DialogResult::OK)

{

MessageBox::Show(box->Phone); //<-----I tried to change this line
}

}
Apr 25 '07 #2

P: n/a
Hi Luis,

I thank you a lot for trying to help, but you may be so fluent in the
language, that I can not catch up with you or you are speaking different
language. Make it easy for me please.

"Luis Antonio Rosello Garcia" <la*@pulsoinformatica.eswrote in message
news:EB**********************************@microsof t.com...
You will need a dialog with a label whose ID is different than IDC_STATIC,
because this ID is generic.

Suposing you have something like a CMyMsgBox class with a IDC_STATIC1
label,
try this:

CMyMsgBox mymsgbox;
CWnd *plabel;

plabel=mymsgbox->GetDlgItem(IDC_STATIC1);
plabel->SetWindowText(box->Phone);
mymsgbox.DoModal();

Regards
--
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:la*@pulsoinformatica.es

"Allen Maki" wrote:
>I wonder if you could help.

The event handler code below, will allow the user to change the phone
number
and write it on a label of a message box. I want to replace the message
box
with a dialog box.

Can anybody help me replace the message box below to a dialog box. In
other
words. I want to write the new phone number on a label (named "labe1")of
a
dialog box (named "dialog2),instead of writing the new phone number on
the
label of a message box.

private: System::Void dialogBtnItem_Click(System::Object * sender,
System::EventArgs * e)

{

// Create the dialog

MyDialog* box = new MyDialog();
//Fill in the initial data

box->Phone = S"(650)123-3456)"; // <------ This is the phone number to be
changed

//Show dialog

if (box->ShowDialog() == DialogResult::OK)

{

MessageBox::Show(box->Phone); //<-----I tried to change this line
}

}

Apr 26 '07 #3

P: n/a
Hi Allen,
I'm sorry because you didn't understood me, certanly my english is a little
poor and the Google translator is not as good as I want.
What I want to say is that you need to make a new dialog from the
ResourceView. That dialog must have an Static Text resource. When you place
it, then Visual C++ asigns a default id: IDC_STATIC. You can't use this
default id in order to get the CWnd object associated to it.
Also you must create a new class associated to the dialog resource. I
usually double click on the Ok button, and Visual C++ ask me if I want that
Visual C++ environment create that class automatically, and I answer yes.
In the example I proposed to you, you must change the id of the static text
from IDC_STATIC to IDC_STATIC1, and you must create a class CMyMsgBox
associated to the dialog.
On your main program, or the function you use to show the new dialog, you
must add the lines I wrote.
CMyMsgBox mymsgbox; // this line defines a variable mymsgbox and calls the
dialog class constructor for that new variable
CWnd *plabel; // this variable is needed in order to get the CWnd pointer
associated to the static text in the new dialog
plabel=mymsgbox->GetDlgItem(IDC_STATIC1); // getting the CWnd pointer to the
label
plabel->SetWindowText(box->Phone); // setting the text you want to the label
mymsgbox.DoModal(); // showing the dialog
I hope that this explanation will be enough for you.
Good luck and regards,
--
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:la*@pulsoinformatica.es

"Allen Maki" wrote:
Hi Luis,

I thank you a lot for trying to help, but you may be so fluent in the
language, that I can not catch up with you or you are speaking different
language. Make it easy for me please.

"Luis Antonio Rosello Garcia" <la*@pulsoinformatica.eswrote in message
news:EB**********************************@microsof t.com...
You will need a dialog with a label whose ID is different than IDC_STATIC,
because this ID is generic.

Suposing you have something like a CMyMsgBox class with a IDC_STATIC1
label,
try this:

CMyMsgBox mymsgbox;
CWnd *plabel;

plabel=mymsgbox->GetDlgItem(IDC_STATIC1);
plabel->SetWindowText(box->Phone);
mymsgbox.DoModal();

Regards
--
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:la*@pulsoinformatica.es

"Allen Maki" wrote:
I wonder if you could help.

The event handler code below, will allow the user to change the phone
number
and write it on a label of a message box. I want to replace the message
box
with a dialog box.

Can anybody help me replace the message box below to a dialog box. In
other
words. I want to write the new phone number on a label (named "labe1")of
a
dialog box (named "dialog2),instead of writing the new phone number on
the
label of a message box.

private: System::Void dialogBtnItem_Click(System::Object * sender,
System::EventArgs * e)

{

// Create the dialog

MyDialog* box = new MyDialog();
//Fill in the initial data

box->Phone = S"(650)123-3456)"; // <------ This is the phone number to be
changed

//Show dialog

if (box->ShowDialog() == DialogResult::OK)

{

MessageBox::Show(box->Phone); //<-----I tried to change this line
}

}


Apr 26 '07 #4

P: n/a
Luis Antonio Rosello Garcia wrote:
You will need a dialog with a label whose ID is different than IDC_STATIC,
because this ID is generic.

Suposing you have something like a CMyMsgBox class with a IDC_STATIC1 label,
try this:

CMyMsgBox mymsgbox;
CWnd *plabel;

plabel=mymsgbox->GetDlgItem(IDC_STATIC1);
plabel->SetWindowText(box->Phone);
mymsgbox.DoModal();
Luis: Isn't the OP using Managed C++?

Allen: If you want to use .NET framework I would strongly advise
updating to VS2005 (or VS2007 hopefully out this later year), because
the syntax for managed code is completely different/much improved.

--
David Wilkinson
Visual C++ MVP
Apr 26 '07 #5

P: n/a
Hi Luis,

I hope you knew that when I referred to language I was not referring to
English. I was referring to- the programming language- Visual C++ .NET
2003. The reason I said that, is because you might be using different
language such as Visual basic. If you were using the same programming
language, you may be so fluent that I could not catch up with you. I will
try to understand what you wrote and thank you very much for all of your
helps


"Allen Maki" <al*******@sbcglobal.netwrote in message
news:Ea***************@newssvr23.news.prodigy.net. ..
Hi Luis,

I thank you a lot for trying to help, but you may be so fluent in the
language, that I can not catch up with you or you are speaking different
language. Make it easy for me please.

"Luis Antonio Rosello Garcia" <la*@pulsoinformatica.eswrote in message
news:EB**********************************@microsof t.com...
>You will need a dialog with a label whose ID is different than
IDC_STATIC,
because this ID is generic.

Suposing you have something like a CMyMsgBox class with a IDC_STATIC1
label,
try this:

CMyMsgBox mymsgbox;
CWnd *plabel;

plabel=mymsgbox->GetDlgItem(IDC_STATIC1);
plabel->SetWindowText(box->Phone);
mymsgbox.DoModal();

Regards
--
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:la*@pulsoinformatica.es

"Allen Maki" wrote:
>>I wonder if you could help.

The event handler code below, will allow the user to change the phone
number
and write it on a label of a message box. I want to replace the message
box
with a dialog box.

Can anybody help me replace the message box below to a dialog box. In
other
words. I want to write the new phone number on a label (named "labe1")of
a
dialog box (named "dialog2),instead of writing the new phone number on
the
label of a message box.

private: System::Void dialogBtnItem_Click(System::Object * sender,
System::EventArgs * e)

{

// Create the dialog

MyDialog* box = new MyDialog();
//Fill in the initial data

box->Phone = S"(650)123-3456)"; // <------ This is the phone number to
be
changed

//Show dialog

if (box->ShowDialog() == DialogResult::OK)

{

MessageBox::Show(box->Phone); //<-----I tried to change this line
}

}


Apr 27 '07 #6

P: n/a
Hi David,

I am working, now, with Visual C++ .NET 2003. I have MS visual C++ 2005.
Thanks .

Allen.
"David Wilkinson" <no******@effisols.comwrote in message
news:ee**************@TK2MSFTNGP06.phx.gbl...
Luis Antonio Rosello Garcia wrote:
>You will need a dialog with a label whose ID is different than
IDC_STATIC, because this ID is generic.

Suposing you have something like a CMyMsgBox class with a IDC_STATIC1
label, try this:

CMyMsgBox mymsgbox;
CWnd *plabel;

plabel=mymsgbox->GetDlgItem(IDC_STATIC1);
plabel->SetWindowText(box->Phone);
mymsgbox.DoModal();

Luis: Isn't the OP using Managed C++?

Allen: If you want to use .NET framework I would strongly advise updating
to VS2005 (or VS2007 hopefully out this later year), because the syntax
for managed code is completely different/much improved.

--
David Wilkinson
Visual C++ MVP

Apr 27 '07 #7

P: n/a
Hi Allen,
The code I wrote was in Visual C++ 6.0. I don't use Visual C++ .NET because
I write Pro*C programs in order to connect to Oracle 8i databases, and there
is no Visual C++ .NET libraries for Oracle 8i Pro*C.
I thought that the only difference between .NET and 6.0 was the namespaces.
The C++ language is the same, and also you have a lot of advantages in the
Visual Studio 2003 .NET environment.
In response to David Wilkinson comments, I'll tell that of course Visual
Studio 2005 .NET is better than 2003, 2005 is the best because is the last
version and has still more advantages than 2003, but this is another theme.
Regards
--
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:la*@pulsoinformatica.es

"Allen Maki" wrote:
Hi David,

I am working, now, with Visual C++ .NET 2003. I have MS visual C++ 2005.
Thanks .

Allen.
"David Wilkinson" <no******@effisols.comwrote in message
news:ee**************@TK2MSFTNGP06.phx.gbl...
Luis Antonio Rosello Garcia wrote:
You will need a dialog with a label whose ID is different than
IDC_STATIC, because this ID is generic.

Suposing you have something like a CMyMsgBox class with a IDC_STATIC1
label, try this:

CMyMsgBox mymsgbox;
CWnd *plabel;

plabel=mymsgbox->GetDlgItem(IDC_STATIC1);
plabel->SetWindowText(box->Phone);
mymsgbox.DoModal();
Luis: Isn't the OP using Managed C++?

Allen: If you want to use .NET framework I would strongly advise updating
to VS2005 (or VS2007 hopefully out this later year), because the syntax
for managed code is completely different/much improved.

--
David Wilkinson
Visual C++ MVP


May 2 '07 #8

P: n/a

"Luis Antonio Rosello Garcia" <la*@pulsoinformatica.eswrote in message
news:A6**********************************@microsof t.com...
Hi Allen,
The code I wrote was in Visual C++ 6.0. I don't use Visual C++ .NET
because
I write Pro*C programs in order to connect to Oracle 8i databases, and
there
is no Visual C++ .NET libraries for Oracle 8i Pro*C.
I thought that the only difference between .NET and 6.0 was the
namespaces.
The C++ language is the same, and also you have a lot of advantages in the
Visual Studio 2003 .NET environment.
In response to David Wilkinson comments, I'll tell that of course Visual
Studio 2005 .NET is better than 2003, 2005 is the best because is the last
version and has still more advantages than 2003, but this is another
theme.
If you haven't used .NET, you can't begin to imagine the ways in which
2005's C++/CLI language beats the abortive attempt that was 2003's Managed
Extensions for C++.

If you're talking only native code, then there are just a few new features
from 2002 -2003 -2005 (although all are much better than 6.0 as far as
support for ISO C++). But the .NET side took a huge leap forward with 2005.
Regards
--
Luis Antonio Rosello Garcia
Pulso Informatica, S.L.
mailto:la*@pulsoinformatica.es

"Allen Maki" wrote:
>Hi David,

I am working, now, with Visual C++ .NET 2003. I have MS visual C++
2005.
Thanks .

Allen.
"David Wilkinson" <no******@effisols.comwrote in message
news:ee**************@TK2MSFTNGP06.phx.gbl...
Luis Antonio Rosello Garcia wrote:
You will need a dialog with a label whose ID is different than
IDC_STATIC, because this ID is generic.

Suposing you have something like a CMyMsgBox class with a IDC_STATIC1
label, try this:

CMyMsgBox mymsgbox;
CWnd *plabel;

plabel=mymsgbox->GetDlgItem(IDC_STATIC1);
plabel->SetWindowText(box->Phone);
mymsgbox.DoModal();

Luis: Isn't the OP using Managed C++?

Allen: If you want to use .NET framework I would strongly advise
updating
to VS2005 (or VS2007 hopefully out this later year), because the syntax
for managed code is completely different/much improved.

--
David Wilkinson
Visual C++ MVP



Jun 6 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.