Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Show text after press a button

Show text after press a button

Scheduled Pinned Locked Moved C / C++ / MFC
comhelptutorialquestiondiscussion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    antonio343
    wrote on last edited by
    #1

    hi, I have an aplication whose view is based in TabControl. It has three tab and one of them have a Edit control. I'd like show text in this edit control when I press a button. I thought do a global variable that keep a valor, for example 1, and in the method, to do a control that show text only if the variable have valor 1. But my problem is after press button, don't happen something. I think that I must to update the view with the method onUpdate or something like that.. but I dont know how. What do you think? This is my aplication: http://i54.tinypic.com/1e9qtx.png This is code : http://www.megaupload.com/?d=1QT43LOQ\[^\]

    A 1 Reply Last reply
    0
    • A antonio343

      hi, I have an aplication whose view is based in TabControl. It has three tab and one of them have a Edit control. I'd like show text in this edit control when I press a button. I thought do a global variable that keep a valor, for example 1, and in the method, to do a control that show text only if the variable have valor 1. But my problem is after press button, don't happen something. I think that I must to update the view with the method onUpdate or something like that.. but I dont know how. What do you think? This is my aplication: http://i54.tinypic.com/1e9qtx.png This is code : http://www.megaupload.com/?d=1QT43LOQ\[^\]

      A Offline
      A Offline
      Albert Holguin
      wrote on last edited by
      #2

      Global variables are usually not a good answer to anything. What you should do is post a message to the view and tell it to update the control whenever you need a value displayed or updated (use SendMessage() or PostMessage()). You should not access the control directly from any window that does not own the control. In the future, try and post applicable code in your question.

      A 1 Reply Last reply
      0
      • A Albert Holguin

        Global variables are usually not a good answer to anything. What you should do is post a message to the view and tell it to update the control whenever you need a value displayed or updated (use SendMessage() or PostMessage()). You should not access the control directly from any window that does not own the control. In the future, try and post applicable code in your question.

        A Offline
        A Offline
        antonio343
        wrote on last edited by
        #3

        Ok, but I dont know how to update the control so that when I press the button show a message

        A 1 Reply Last reply
        0
        • A antonio343

          Ok, but I dont know how to update the control so that when I press the button show a message

          A Offline
          A Offline
          Albert Holguin
          wrote on last edited by
          #4

          Well, there's a number of steps: 1. To get notification of a button press, make sure the button control owner is catching the notification message. 2. To alert the other control's owner of the button press, the message handler of the button press should SendMessage() or PostMessage() to the edit control owner window requesting he make the change. The owner window needs a message defined and appropriate message handler. 3. Within the owner of the edit control, the message handler for changes to the edit control should take the parameters passed to it, then set the window text. Which step do you not understand? As you can see, this is a somewhat complex process if you don't know how messaging works. You need to do a bit of research.

          A 1 Reply Last reply
          0
          • A Albert Holguin

            Well, there's a number of steps: 1. To get notification of a button press, make sure the button control owner is catching the notification message. 2. To alert the other control's owner of the button press, the message handler of the button press should SendMessage() or PostMessage() to the edit control owner window requesting he make the change. The owner window needs a message defined and appropriate message handler. 3. Within the owner of the edit control, the message handler for changes to the edit control should take the parameters passed to it, then set the window text. Which step do you not understand? As you can see, this is a somewhat complex process if you don't know how messaging works. You need to do a bit of research.

            A Offline
            A Offline
            antonio343
            wrote on last edited by
            #5

            I don't have idea about messaging works, can you give me information? any page or something like that?

            A 1 Reply Last reply
            0
            • A antonio343

              I don't have idea about messaging works, can you give me information? any page or something like that?

              A Offline
              A Offline
              Albert Holguin
              wrote on last edited by
              #6

              Look up Windows message handling... here's a few articles to get you started: Windows Message Handling - Part 1[^] Windows Message Handling - Part 2[^] Windows Message Handling - Part 3[^] Windows Message Handling - Part 4[^] http://msdn.microsoft.com/en-us/library/0x0cx6b1.aspx[^]

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups