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. C++ CALL CRange's get_shapeRange() triggers an exception

C++ CALL CRange's get_shapeRange() triggers an exception

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
7 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.
  • B Offline
    B Offline
    BCN 163
    wrote on last edited by
    #1

    I construct a CRange object and then call CRange's function get_shapeRange() to get a CShapeRange object. but it triggers an exception. (but it's OK to call another function get_InlineShapes) I have no idea why it triggers an exception. does anyone knows why? thanks. ======================================================== By the way, I call this code in a keyboard hook function.

    _ L 2 Replies Last reply
    0
    • B BCN 163

      I construct a CRange object and then call CRange's function get_shapeRange() to get a CShapeRange object. but it triggers an exception. (but it's OK to call another function get_InlineShapes) I have no idea why it triggers an exception. does anyone knows why? thanks. ======================================================== By the way, I call this code in a keyboard hook function.

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      A question first : Are you using COM Interop? When an exception is triggered, it is indicative that the function cannot be found.

      You talk about Being HUMAN. I have it in my name AnsHUMAN

      B 1 Reply Last reply
      0
      • B BCN 163

        I construct a CRange object and then call CRange's function get_shapeRange() to get a CShapeRange object. but it triggers an exception. (but it's OK to call another function get_InlineShapes) I have no idea why it triggers an exception. does anyone knows why? thanks. ======================================================== By the way, I call this code in a keyboard hook function.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        BianChengNan wrote:

        does anyone knows why?

        There is probably a bug in your code. You need to provide a snippet of the code and full details of the exception if you want a better suggestion.

        One of these days I'm going to think of a really clever signature.

        B 1 Reply Last reply
        0
        • L Lost User

          BianChengNan wrote:

          does anyone knows why?

          There is probably a bug in your code. You need to provide a snippet of the code and full details of the exception if you want a better suggestion.

          One of these days I'm going to think of a really clever signature.

          B Offline
          B Offline
          BCN 163
          wrote on last edited by
          #4

          thanks for your tip. code looks like following.

          bool isRangeShape(__in CRange& oRange)
          {
          // I promise oRange is correct, because I can call
          // like this oRange.get_InlineShapes()

          	AFX\_MANAGE\_STATE(AfxGetStaticModuleState());
          
                      // in word2010 it's ok,but in word2003 triggers an exception
                      // but corresponding VBA code works fun in word2003 **(not fun, I'm sorry)**
                      // word2003 don't support this method, oh my god!!!
          	CShapeRange oShpRange  = oRange.get\_ShapeRange();
          
          	long lCount = oShpRange.get\_Count();
          
          	if (lCount > 0)
          	{
          		return true;
          	}
          
          
          return false;
          

          }

          B 1 Reply Last reply
          0
          • _ _AnsHUMAN_

            A question first : Are you using COM Interop? When an exception is triggered, it is indicative that the function cannot be found.

            You talk about Being HUMAN. I have it in my name AnsHUMAN

            B Offline
            B Offline
            BCN 163
            wrote on last edited by
            #5

            Yes, you are right. but what I can't understand is in VBA corresponding code works fun. VBA code below: selection.range.shaperange works fun ================================================================================= I'm sorry! in word2010 it works fun. in word2003 not fun. oh, my god!!!

            B 1 Reply Last reply
            0
            • B BCN 163

              Yes, you are right. but what I can't understand is in VBA corresponding code works fun. VBA code below: selection.range.shaperange works fun ================================================================================= I'm sorry! in word2010 it works fun. in word2003 not fun. oh, my god!!!

              B Offline
              B Offline
              BCN 163
              wrote on last edited by
              #6

              now it works fun again!!! what have I done!!!!!!

              1 Reply Last reply
              0
              • B BCN 163

                thanks for your tip. code looks like following.

                bool isRangeShape(__in CRange& oRange)
                {
                // I promise oRange is correct, because I can call
                // like this oRange.get_InlineShapes()

                	AFX\_MANAGE\_STATE(AfxGetStaticModuleState());
                
                            // in word2010 it's ok,but in word2003 triggers an exception
                            // but corresponding VBA code works fun in word2003 **(not fun, I'm sorry)**
                            // word2003 don't support this method, oh my god!!!
                	CShapeRange oShpRange  = oRange.get\_ShapeRange();
                
                	long lCount = oShpRange.get\_Count();
                
                	if (lCount > 0)
                	{
                		return true;
                	}
                
                
                return false;
                

                }

                B Offline
                B Offline
                BCN 163
                wrote on last edited by
                #7

                I don't know why it works fun again. (but I think it should work fun!) thanks for your help!

                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