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. Event Handler -Please help me

Event Handler -Please help me

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
11 Posts 3 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.
  • P prathuraj

    I have created a IP address control dynamically. How to add a event handler for those controls. How to use event handlers with dynamically created control.

    A Offline
    A Offline
    Arman S
    wrote on last edited by
    #2

    Generally, three things to be done; *) decide which exact command to handle *) prepare the handler function [whose prtototype is influenced by the cammand to be handled] *) map the command to the handler As for ip control, I guess you are trying to handle the IPN_FIELDCHANGED notifycation. So you would have a handler like this;

    void CMyDialog::OnFieldChangedIpAddress(NMHDR *pNMHDR, LRESULT *pResult)
    {
    LPNMIPADDRESS pIPAddr = reinterpret_cast(pNMHDR);
    // your code here ...
    *pResult = 0;
    }

    And map it to the notifycation inside BEGIN_MESSAGE_MAP/END_MESSAGE_MAP pair like so;

    ON_NOTIFY(IPN_FIELDCHANGED, IDC_MYIPADDRESS, OnFieldChangedIpAddress)

    -- ===== Arman

    P 1 Reply Last reply
    0
    • A Arman S

      Generally, three things to be done; *) decide which exact command to handle *) prepare the handler function [whose prtototype is influenced by the cammand to be handled] *) map the command to the handler As for ip control, I guess you are trying to handle the IPN_FIELDCHANGED notifycation. So you would have a handler like this;

      void CMyDialog::OnFieldChangedIpAddress(NMHDR *pNMHDR, LRESULT *pResult)
      {
      LPNMIPADDRESS pIPAddr = reinterpret_cast(pNMHDR);
      // your code here ...
      *pResult = 0;
      }

      And map it to the notifycation inside BEGIN_MESSAGE_MAP/END_MESSAGE_MAP pair like so;

      ON_NOTIFY(IPN_FIELDCHANGED, IDC_MYIPADDRESS, OnFieldChangedIpAddress)

      -- ===== Arman

      P Offline
      P Offline
      prathuraj
      wrote on last edited by
      #3

      ON_NOTIFY(IPN_FIELDCHANGED, IDC_MYIPADDRESS, OnFieldChangedIpAddress) I cant use the control id directly because i created control dynamically. How to add On_notify for dynamically created one

      A H 2 Replies Last reply
      0
      • P prathuraj

        ON_NOTIFY(IPN_FIELDCHANGED, IDC_MYIPADDRESS, OnFieldChangedIpAddress) I cant use the control id directly because i created control dynamically. How to add On_notify for dynamically created one

        A Offline
        A Offline
        Arman S
        wrote on last edited by
        #4

        You can and hou have to. The last parameter of CIPAddressCtrl::Create takes the id of the newly creating control. So define an id inside resource.h file and pass it to the Create method. PS. To define an id, go to menu option Edit\Resource Synbols... and then choose New... .

        -- ===== Arman

        P 1 Reply Last reply
        0
        • P prathuraj

          ON_NOTIFY(IPN_FIELDCHANGED, IDC_MYIPADDRESS, OnFieldChangedIpAddress) I cant use the control id directly because i created control dynamically. How to add On_notify for dynamically created one

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #5

          prathuraj wrote:

          I cant use the control id

          How do you make IP address control ? CIPAddressCtrl::Create(....,UINT nID); or CIPAddressCtrl::CreateEx(...,UINT nID);


          WhiteSky


          P 1 Reply Last reply
          0
          • A Arman S

            You can and hou have to. The last parameter of CIPAddressCtrl::Create takes the id of the newly creating control. So define an id inside resource.h file and pass it to the Create method. PS. To define an id, go to menu option Edit\Resource Synbols... and then choose New... .

            -- ===== Arman

            P Offline
            P Offline
            prathuraj
            wrote on last edited by
            #6

            how to use this id to call notify event

            A 1 Reply Last reply
            0
            • P prathuraj

              how to use this id to call notify event

              A Offline
              A Offline
              Arman S
              wrote on last edited by
              #7

              You should not bother about calling notify events. This is done by the system. So your job is to handle the notifyfication only. See my first post; it describes what you need to do.

              -- ===== Arman

              1 Reply Last reply
              0
              • H Hamid Taebi

                prathuraj wrote:

                I cant use the control id

                How do you make IP address control ? CIPAddressCtrl::Create(....,UINT nID); or CIPAddressCtrl::CreateEx(...,UINT nID);


                WhiteSky


                P Offline
                P Offline
                prathuraj
                wrote on last edited by
                #8

                CIPAddressCtrl* pIPAdd = new CIPAddressCtrl; pIPAdd->Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER|ES_AUTOHSCROLL, CRect(x,y,x+sz.cx,y+sz.cy),this,nID);

                H 1 Reply Last reply
                0
                • P prathuraj

                  CIPAddressCtrl* pIPAdd = new CIPAddressCtrl; pIPAdd->Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER|ES_AUTOHSCROLL, CRect(x,y,x+sz.cx,y+sz.cy),this,nID);

                  H Offline
                  H Offline
                  Hamid Taebi
                  wrote on last edited by
                  #9

                  You used of nID whats problem?


                  WhiteSky


                  P 1 Reply Last reply
                  0
                  • H Hamid Taebi

                    You used of nID whats problem?


                    WhiteSky


                    P Offline
                    P Offline
                    prathuraj
                    wrote on last edited by
                    #10

                    how to call on_notify for OnFieldchangedIpaddress1 using this id

                    H 1 Reply Last reply
                    0
                    • P prathuraj

                      how to call on_notify for OnFieldchangedIpaddress1 using this id

                      H Offline
                      H Offline
                      Hamid Taebi
                      wrote on last edited by
                      #11

                      Did you try with Arman Z. Sahakyan's answer anyway see this[^] thread.


                      WhiteSky


                      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