473,382 Members | 1,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Forms and Label

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
8 1583
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
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
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
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
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
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
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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
by: Zak McGregor | last post by:
Hi all Are there any good solutions to aligning form field names and input boxes without resorting to tables? I am struggling to do this nicely at the moment. Thanks Ciao Zak
0
by: Tim Haughton | last post by:
I've just released an article on using Test Driven Development with C# and Windows Forms. GUI's are often difficult to test, so I thought it might be of interest. The article along with the...
3
by: Joshua Russell | last post by:
Hi, Both the methods below open up a windows form called MasterForm. However, one works better than the other. Method 1 opens the form correctly but I don't have any reference to the instance of...
3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
1
by: Sunil Sabir | last post by:
Dear All, I have 4 web ASP.net Forms. I use a image control to move between these forms.The problem I am facing is that I cannot preserve the state of the form when moving between different...
7
by: Mike Bulava | last post by:
I have created a base form that I plan to use throughout my application let call the form form1. I have Built the project then add another form that inherits from form1, I add a few panel controls...
15
by: Joshua Kendall | last post by:
I have a script in which it keeps opening the same form instead of only one instance. I also need help with a form that has a password. Where do I put the actual password? can I use a database for...
3
by: Geraldine Hobley | last post by:
Hello, In my project I am inheriting several forms. However when I inherit from a form and add additional subroutines and methods to my inherited form I get all sorts of problems. e.g. I sometimes...
1
by: Dawoodmm | last post by:
Hi i have a sight problem with detecting the mouse up in a drag-drop outside a form what i have on my hands is an mdi form with 2 child forms: form1 and form2, both containing a label each. i also...
0
by: Sergio E. | last post by:
Hello, I have a problem with masterpages and forms security. I made a new Web site, in which I have my page login.aspx as the homepage , a master page with only a sitemappath object in it, the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.