Forms and Label

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Allen Maki

    #1

    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),inste ad of writing the new phone number on the
    label of a message box.

    private: System::Void dialogBtnItem_C lick(System::Ob ject * sender,
    System::EventAr gs * 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::O K)

    {

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


    }

    }


  • =?Utf-8?B?THVpcyBBbnRvbmlvIFJvc2VsbG8gR2FyY2lh?=

    #2
    RE: Forms and Label

    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.DoModa l();

    Regards
    --
    Luis Antonio Rosello Garcia
    Pulso Informatica, S.L.
    mailto:lar@puls oinformatica.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),inste ad of writing the new phone number on the
    label of a message box.
    >
    private: System::Void dialogBtnItem_C lick(System::Ob ject * sender,
    System::EventAr gs * 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::O K)
    >
    {
    >
    MessageBox::Sho w(box->Phone); //<-----I tried to change this line
    >
    >
    }
    >
    }
    >
    >
    >

    Comment

    • Allen Maki

      #3
      Re: Forms and Label

      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" <lar@pulsoinfor matica.eswrote in message
      news:EB04A03C-A178-45D9-9E4E-CA9B98C63EDD@mi crosoft.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.DoModa l();
      >
      Regards
      --
      Luis Antonio Rosello Garcia
      Pulso Informatica, S.L.
      mailto:lar@puls oinformatica.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),inste ad of writing the new phone number on
      >the
      >label of a message box.
      >>
      >private: System::Void dialogBtnItem_C lick(System::Ob ject * sender,
      >System::EventA rgs * 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::O K)
      >>
      >{
      >>
      >MessageBox::Sh ow(box->Phone); //<-----I tried to change this line
      >>
      >>
      >}
      >>
      >}
      >>
      >>
      >>

      Comment

      • =?Utf-8?B?THVpcyBBbnRvbmlvIFJvc2VsbG8gR2FyY2lh?=

        #4
        Re: Forms and Label

        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.DoModa l(); // 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:lar@puls oinformatica.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" <lar@pulsoinfor matica.eswrote in message
        news:EB04A03C-A178-45D9-9E4E-CA9B98C63EDD@mi crosoft.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.DoModa l();

        Regards
        --
        Luis Antonio Rosello Garcia
        Pulso Informatica, S.L.
        mailto:lar@puls oinformatica.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),inste ad of writing the new phone number on
        the
        label of a message box.
        >
        private: System::Void dialogBtnItem_C lick(System::Ob ject * sender,
        System::EventAr gs * 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::O K)
        >
        {
        >
        MessageBox::Sho w(box->Phone); //<-----I tried to change this line
        >
        >
        }
        >
        }
        >
        >
        >
        >
        >
        >

        Comment

        • David Wilkinson

          #5
          Re: Forms and Label

          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.DoModa l();
          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

          Comment

          • Allen Maki

            #6
            Re: Forms and Label

            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" <allenmaki@sbcg lobal.netwrote in message
            news:EaTXh.744$ tp5.622@newssvr 23.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" <lar@pulsoinfor matica.eswrote in message
            news:EB04A03C-A178-45D9-9E4E-CA9B98C63EDD@mi crosoft.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=mymsgbo x->GetDlgItem(IDC _STATIC1);
            >plabel->SetWindowText( box->Phone);
            >mymsgbox.DoMod al();
            >>
            >Regards
            >--
            >Luis Antonio Rosello Garcia
            >Pulso Informatica, S.L.
            >mailto:lar@pul soinformatica.e s
            >>
            >>
            >>
            >"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),inste ad of writing the new phone number on
            >>the
            >>label of a message box.
            >>>
            >>private: System::Void dialogBtnItem_C lick(System::Ob ject * sender,
            >>System::Event Args * 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::O K)
            >>>
            >>{
            >>>
            >>MessageBox::S how(box->Phone); //<-----I tried to change this line
            >>>
            >>>
            >>}
            >>>
            >>}
            >>>
            >>>
            >>>
            >
            >

            Comment

            • Allen Maki

              #7
              Re: Forms and Label

              Hi David,

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

              Allen.


              "David Wilkinson" <no-reply@effisols. comwrote in message
              news:eecrUp$hHH A.4076@TK2MSFTN GP06.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=mymsgbo x->GetDlgItem(IDC _STATIC1);
              >plabel->SetWindowText( box->Phone);
              >mymsgbox.DoMod al();
              >
              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

              Comment

              • =?Utf-8?B?THVpcyBBbnRvbmlvIFJvc2VsbG8gR2FyY2lh?=

                #8
                Re: Forms and Label

                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:lar@puls oinformatica.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-reply@effisols. comwrote in message
                news:eecrUp$hHH A.4076@TK2MSFTN GP06.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.DoModa l();
                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
                >
                >
                >

                Comment

                • Ben Voigt [C++ MVP]

                  #9
                  Re: Forms and Label


                  "Luis Antonio Rosello Garcia" <lar@pulsoinfor matica.eswrote in message
                  news:A6409A18-3857-4289-8CAA-DB3453E111A1@mi crosoft.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:lar@puls oinformatica.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-reply@effisols. comwrote in message
                  >news:eecrUp$hH HA.4076@TK2MSFT NGP06.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=mymsgbo x->GetDlgItem(IDC _STATIC1);
                  >plabel->SetWindowText( box->Phone);
                  >mymsgbox.DoMod al();
                  >
                  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
                  >>
                  >>
                  >>

                  Comment

                  Working...