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. what is wrong in this code

what is wrong in this code

Scheduled Pinned Locked Moved C / C++ / MFC
question
13 Posts 7 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 Offline
    P Offline
    prathuraj
    wrote on last edited by
    #1

    CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically

    C C H P S 6 Replies Last reply
    0
    • P prathuraj

      CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      What is the problem ? Did you check with your debugger that ip is a valid pointer before calling GetAddress ?


      Cédric Moonen Software developer
      Charting control [v1.2]

      1 Reply Last reply
      0
      • P prathuraj

        CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        Check if the control identifier (13) was already assigned by AppWizard to any other control.:)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

        1 Reply Last reply
        0
        • P prathuraj

          CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically

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

          Whats return value in ip ?


          WhiteSky


          P 1 Reply Last reply
          0
          • H Hamid Taebi

            Whats return value in ip ?


            WhiteSky


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

            I want to get a value from dynamic ip address control for that purpose i wrote this code CIPAddressCtrl* ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dword);

            H 1 Reply Last reply
            0
            • P prathuraj

              CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically

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

              prathuraj wrote:

              CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13);

              Unless , you are having the control with id 13, nothing wrong with code. Though, I would have used dynamic_cast , instead of c-style cast.

              prathuraj wrote:

              ip->GetAddress(dwIPAddress);

              If ip is non-null and controll retunrned in previous statement is of type CIPAddressCtrl, there should not be any problem. Can you specify, what problem you are facing.


              Prasad MS MVP -  VC++

              P 1 Reply Last reply
              0
              • P prasad_som

                prathuraj wrote:

                CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13);

                Unless , you are having the control with id 13, nothing wrong with code. Though, I would have used dynamic_cast , instead of c-style cast.

                prathuraj wrote:

                ip->GetAddress(dwIPAddress);

                If ip is non-null and controll retunrned in previous statement is of type CIPAddressCtrl, there should not be any problem. Can you specify, what problem you are facing.


                Prasad MS MVP -  VC++

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

                ip->GetAddress(dword); Access violation error occured at this line

                P H 2 Replies Last reply
                0
                • P prathuraj

                  ip->GetAddress(dword); Access violation error occured at this line

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

                  As sated in one of previous post, make sure, id 13 is assigned to control you are talking about.


                  Prasad MS MVP -  VC++

                  P 1 Reply Last reply
                  0
                  • P prathuraj

                    ip->GetAddress(dword); Access violation error occured at this line

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

                    prathuraj wrote:

                    Access violation error occured at this line

                    Because ip is invalid.


                    WhiteSky


                    1 Reply Last reply
                    0
                    • P prasad_som

                      As sated in one of previous post, make sure, id 13 is assigned to control you are talking about.


                      Prasad MS MVP -  VC++

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

                      control id is correct.but pointer is null.what i do further

                      1 Reply Last reply
                      0
                      • P prathuraj

                        I want to get a value from dynamic ip address control for that purpose i wrote this code CIPAddressCtrl* ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dword);

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

                        How do you make this control?


                        WhiteSky


                        1 Reply Last reply
                        0
                        • P prathuraj

                          CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically

                          S Offline
                          S Offline
                          Stephen Hewitt
                          wrote on last edited by
                          #12

                          Try this code instead (run in a debug build):

                          CWnd *pWnd = GetDlgItem(13);
                          ASSERT(pWnd != NULL);
                          ASSERT(dynamic_cast<CIPAddressCtrl*>(pWnd) != NULL);
                          CIPAddressCtrl *ip = static_cast<CIPAddressCtrl*>(pWnd);

                          If the second line asserts in a debug build the id is wrong. If the third line asserts in a debug build the CWnd returned was not a CIPAddressCtrl and your cast is in error. Try adding a member variable (using ClassWizard in MSVC6); this step makes calling GetDlgItem unnecessary. If this line fails to compile enable RTTI (just in the debug build) and try again. If the fourth line fails to compile CIPAddressCtrl is not derived from CWnd. Don't use C-style casts!

                          Steve

                          1 Reply Last reply
                          0
                          • P prathuraj

                            CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically

                            K Offline
                            K Offline
                            krmed
                            wrote on last edited by
                            #13

                            Typically, the wizards assign control IDs starting at 1000 - perhaps the ID you chose (13) is actually some other control that has been assigned by Microsoft. It could be that by simply changing your ID (perhaps to something like above 1000, you may be ok as long as that ID isn't used elsewhere in your project. Hope that helps.

                            Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

                            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