Scroll the document window to a specified graphic object

Hi,
anyone knows  a way to scroll the document window to a specified graphic object?
I've tried with F_ApiScrollToText() function, but it works only with object containing text, and a graphic object ( like a line) doesn't contain text...
Thanks in advance.

Hi Stemen82,
I have dealt with this in the past and found it to be a bit complex. I've pasted below the functions I came up with to do it. Note that:
- I'm not sure that it works in all cases. Because there is no direct FDK function to do this, you really have to monkey around with things to get it done.
- The code I've pasted should handle both anchored frames and graphic objects, including "floating" graphics. Anchored frames are actually a bit more straightforward because you can get the text location of the anchor.
- All the comments in the code are "notes to self." That is, I didn't write them for you   However, they should be of some use to you.
- There may be plenty of other, better ways to do this... this is just what I slapped together to get the basic functionality to work.
Russ
//THIS IS REALLY ONLY GOOD FOR ONE LEVEL OF NESTING,
// ie, one graphic in one anchored frame, in a text frame.
// No testing or implementation for anything else at this point.
//If you don't know whether the object is a graphic or an anchored
//frame, you can send it as the graphic ID and the function will
//figure it out.
// So, either send a graphic ID as graphicId,
// a frame ID as graphicId, or both graphic and frame IDs.
// Don't sent just a frame ID as frameID.
VoidT ws_SelectAndScrollToGraphic(F_ObjHandleT docId,
                                  F_ObjHandleT graphicId,
                                  F_ObjHandleT frameId)
  F_ObjHandleT aFrameId = 0,
    textFrameId,
    graphicPageId,
    currentPageId,
    tempGraphicId;
  IntT objectType,
    alreadySelected = False;
  F_TextRangeT tr;
  if(!docId || (!graphicId && !frameId)) return;
  //let's get the page. We might need it for scrolling and
  //maybe to switch to the correct page type
  graphicPageId = ws_GetPageForGraphic(docId, graphicId);
  //So far, two possibilities here, either an anchored frame somewhere in the object hierarchy or not.
  //If there is no anchored frame, we have to guess based on pages and paragraps.  If there is one,
  //we can jump to the anchor.
  //let's start by looking for an anchored frame if one was not sent
  if(graphicId && !frameId)
    objectType = F_ApiGetObjectType(docId, graphicId);
    //if we actually got an anchored frame, we will store the ID.
    if(objectType == FO_AFrame)
      aFrameId = graphicId;
    //otherwise, let's look above to see if there is an anchored frame
    else
      aFrameId = F_ApiGetId(docId, graphicId, FP_FrameParent);
      objectType = F_ApiGetObjectType(docId, aFrameId);
      if(objectType != FO_AFrame)
        aFrameId = 0;
  //at this point, if we have an anchored frame, scroll to it
  if(aFrameId)
    //let's switch to the appropriate page type, only if necessary
    //we'll do that by simply switching to the first page of that
    //type in the doc before the scroll action
    currentPageId = F_ApiGetId(FV_SessionId, docId, FP_CurrentPage);
    if(F_ApiGetObjectType(docId, graphicPageId) != F_ApiGetObjectType(docId, currentPageId))
      if(F_ApiGetObjectType(docId, graphicPageId) == FO_MasterPage)
        currentPageId = F_ApiGetId(FV_SessionId, docId, FP_FirstMasterPageInDoc);
      else if(F_ApiGetObjectType(docId, graphicPageId) == FO_RefPage)
        currentPageId = F_ApiGetId(FV_SessionId, docId, FP_FirstRefPageInDoc);
      else
        currentPageId = F_ApiGetId(FV_SessionId, docId, FP_FirstBodyPageInDoc);
      F_ApiSetId(FV_SessionId, docId, FP_CurrentPage, currentPageId);
    tr.beg = tr.end = F_ApiGetTextLoc(docId, aFrameId, FP_TextLoc);
    F_ApiScrollToText(docId, &tr);
  //if no anchored frame (ie, just a floating graphic),
  //let's finangle with some paragraphs and pages and try our
  //best. There might be a better way.
  else
    // We have the page that the graphic is on, let's at least jump
    // to that page, maybe we can get a little closer later
    F_ApiSetId(FV_SessionId, docId, FP_CurrentPage, graphicPageId);
    //get the parent frame of the graphic which is hopefully a text frame
    textFrameId = F_ApiGetId(docId, graphicId, FP_FrameParent);
    //let's see if we can find a paragraph and scroll to it.
    tr.beg.objId = tr.end.objId =
      F_ApiGetId(docId, textFrameId, FP_FirstPgf);
    F_ApiScrollToText(docId, &tr);
  //now, let's do the selection. We'll unselect everything
  //that is selected, unless our graphic is already selected.
  tempGraphicId = F_ApiGetId(FV_SessionId, docId, FP_FirstSelectedGraphicInDoc);
  while(tempGraphicId)
    if(tempGraphicId == graphicId || tempGraphicId == frameId)
      alreadySelected = True;
    else
      F_ApiSetInt(docId, tempGraphicId, FP_GraphicIsSelected, False);
    tempGraphicId = F_ApiGetId(docId, tempGraphicId, FP_NextSelectedGraphicInDoc);
  if(!alreadySelected)
    if(graphicId)
      F_ApiSetInt(docId, graphicId, FP_GraphicIsSelected, True);
    else
      F_ApiSetInt(docId, frameId, FP_GraphicIsSelected, True);
//Returns the ID of the page that the graphic is on.
F_ObjHandleT ws_GetPageForGraphic(F_ObjHandleT docId,
                                  F_ObjHandleT graphicId)
  F_ObjHandleT tempGraphicId = 0,
    pageId = 0;
  while(graphicId)
    tempGraphicId = graphicId;
    graphicId = F_ApiGetId(docId, graphicId, FP_FrameParent);
  if(tempGraphicId)
    pageId = F_ApiGetId(docId, tempGraphicId, FP_PageFramePage);
  return pageId;

Similar Messages

  • How to trap the document window activate event?

    Hi All,
    I am working with a plugin development application. My requirement is, at any time I may have more than one document opened. The plugin window what I have designed gets populated with data from the xml file attached with the current document. Therefore whenever I switch between the document window, I need the plugin window to be refreshed so that it will load/display the contents from the current xml file.
    For this I need to trap the activate document window event. So whenever a window is selected from the current list of opened windows, then the plugin should get refreshed automatically.
    Actually, I tried inheriting the CWindowEH class and I used the kDocWindowBoss class for the same. But the event is not firing as expected. Help/tips from anyone could be appreciated.
    Thanks in advance.
    JR.

    Hi, <br /><br />I don't think having observers on kDocBoss and kDocumentListBoss should be a problem. We do exactly that.<br /><br />Just running with a couple of break points in your code, do you hit the DocListObserver::AutoAttach and not the Update().<br /><br />If you don't hit the AutoAttach breakpoint then it's probably the resource is not set up right. Ours is like this..<br /><br />/** Observes document list actions.<br /> */<br />AddIn<br />{<br />     kDocumentListBoss,<br />     kInvalidClass,<br />     {<br />      IID_IMYDOCLISTOBSERVER, kMyDocListObserverImpl,<br />     }<br />},<br /><br />If you're getting to the AutoAttach but not the Update then it may be that you're not specifying what notifications you wish to receive.<br /><br />Our AutoAttach is like this..<br /><br />     do<br />     {<br />          InterfacePtr<ISubject> subject( this, UseDefaultIID());<br />          if (subject != nil)<br />          {<br />               if ( subject->IsAttached(this, IID_IDOCUMENTLIST, IID_IMYDOCLISTOBSERVER) == kFalse )<br />                    subject->AttachObserver(this, IID_IDOCUMENTLIST, IID_IMYDOCLISTOBSERVER);<br />          }<br />     }<br />     while ( kFalse );<br /><br />with equivalent DetachObserver code in the AutoDetach of course.

  • Drawing directly in the document window

    Can anybody provide sample code showing the basics of drawing directly in the document window? I'm thinking of something along the lines of the measure tool (pardon the pun).
    It looks like I'm supposed to use either the Annotator Suite or the Document View Suite to "invalidate" a rectangle in the document, followed by doing the actual drawing with the ADMDrawer Suite. But the documentation in this area is pretty sparse (for example GetDocumentViewInvalidRect and SetDocumentViewInvalidRect refer to a "fudged" invalid rect without explaining what that is) and I don't see anything in the Sample Code folder that explains this feature.
    Are the little text annotations ("path" "anchor") that pop up when using Smart Guides done using this method?
    Thanks,
    John

    (Sound of crickets chirping...)
    Boy, this forum is awfully dead in comparison to the InDesign SDK forum. Is no one writing Illustrator plug-ins anymore?
    But hey, I'll keep posting, if only for my own amusement, about my saga of writing a plug-in.
    I figured out some of the annotation stuff, but I'm still puzzled by some things.
    I started by simply trying to create a tool which would carry a 100x100 box around with it when moved on the screen -- no clicking or dragging yet -- much as the symbol sprayer, for example, has a nice circle (albeit of varying size) around it. I created the tool and added it as an annotator. When it receives a kSelectorAITrackToolCursor message, it simply captures the cursor location in a global and sets the PlatformCursor. When the tool receives a kCallerAIAnnotation message, I have this code:
    extern AIErr toolAnnotate( AIAnnotatorMessage *message ) {
        AIErr error = kNoErr;
        error = sView->ArtworkPointToViewPoint( message->view, &g->cursorPoint, &g->cursorPointScreen );
        g->annoBoundsScreen.top = g->cursorPointScreen.v - 50;
        g->annoBoundsScreen.bottom = g->cursorPointScreen.v + 50;
        g->annoBoundsScreen.left = g->cursorPointScreen.h - 50;
        g->annoBoundsScreen.right = g->cursorPointScreen.h + 50;
        ADMDrawerRef dr = sADMDrawer->Create(message->port, &g->annoBoundsScreen, kADMPaletteFont);
        ASRect myRect;
        myRect.top = 0;
        myRect.bottom = 100;
        myRect.left = 0;
        myRect.right = 100;
        sADMDrawer->SetDrawMode( dr, kADMXORMode );
        sADMDrawer->SetADMColor( dr, kADMBlackColor );
        sADMDrawer->DrawRect( dr, &myRect );
        sADMDrawer->Destroy( dr );
        sAnnotator->InvalAnnotationRect ( message->view, &g->annoBoundsScreen );
    This (should) convert the cursor location (in artwork coordinates) to screen coordinates, set the annotation boundaries based on this location, create the drawer reference, and draw the 100x100 rectangle within this reference. Finally, it invalidates this rectangle as per the Annotation suite documentation.
    I fired up the tool in Illy 10 and saw a single box created down at the 0, 0 point on the page. No box followed the cursor. Hmm. I added an sADMBasic->Beep() to the annotation code and realized what was happening -- my tool was getting an annotation message when first selected, but none when it was merely moved around the screen.
    After some futzing around I discovered that if I added a call to sView->SetDocumentViewInvalidDocumentRect in the TrackToolCursor code, I got an annotate message every time the mouse was moved! I captured the previous cursor position and invalidated the rectangle 50 points on all sides from it. and tried again. Success -- partially.
    At this point, the cursor could be moved around with the box following it. It suffers, however, from the following bugs:
    1) The SetDocumentViewInvalidDocumentRect is in artwork coordinates and so only works at 100% or greater. If I zoom out, my little box leaves trails all over the screen. In addition, if I zoom in, the cursor stutters noticeably -- I assume because Illustrator is forcing a redraw on large portions of the document. I think I can fix both these bugs by recalculating the SetDocumentViewInvalidDocumentRect into screen coordinates. However I note that the circle of the symbol sprayer can be made huge -- as large as the screen -- and it still moves smoothly. So maybe calling sView->SetDocumentViewInvalidDocumentRect is not the way to force annotations. But I haven't been able to discover another way.
    2) When the mouse moves into a palette, the square remains "hung up" at the last position where the cursor was in the document window. I think I can fix this by utilizing the Suspend and Resume notifiers and doing one last InvalAnnotationRect when I get the Suspend notification.
    3) For fun I tried clicking and dragging. Bad news. If I do this, thereafter the entire Illustrator window only redraws iself in the small rectangle that was set when I created the drawer port. By chance I found that if I use another tool that annotates such as the pencil *before* I use my tool, then everything is fine (although of course the box doesn't follow the cursor around anymore because my toolMouseDrag code is empty). How is using a previous tool "fixing" my code? I don't understand this one at all.
    Anyway, I suppose I could fork over a wad of cash and join the ADN and purchase a support case -- but hey, I'm just a hobbyist messing around at this point and facing some rather crappy documentation. Any tips will be much appreciated.
    John

  • Why does the document window in illustrator cs6 move to the far left when I reopen the file?

    why does the document window in illustrator cs6 move to the far left when I reopen the file?

    Hi John,
    thanks for the fast response.  cs5 remembered the window position.  I like having the window in the middle as I have a 27" monitor.  I just upgraded to cs6 yesterday and I'm sure it was remembering the window document position.  I think.  If i find out how to fix this, I'll post it here.
    And while I'm on the subject of cs6, why the f*** did adobe combine the stroke and swatches pallettes?  Now I forever have to click stroke and swatch tabs all day.  And I love the army and navy file icons of photoshop and illustrator.  I won't comment on Acrobat X.  ; (

  • Expand the Document Window's Page Name Area

    In FW CS4, the area for the page name is too small.  It truncates my page names so that I can't tell them apart like this:
    Is there any way to expand that are where the page name shows up on the right of the document window toolbar?
    Thanks!

    That won't work if other users are to recognize what the pages are designed to do.

  • Why doesn't the image show in the document window?

    I am a Photoshop CS5 begI have tried to look for what button I need to click. I can see the document name in the window but there is no image showing in the window. Getting bit frustrated. Please help.
    Thank you.

    Here's the shot of what I get.
    It will show in the layers. But nothing in the document window.

  • Is it possible to make the document window not to hide behind the palettes?

    Is it possible to make the document window not to hide behind the palettes (layers, paths etc) like in CS5? For instance if I want to make a correction in the right part of the image and zoom in, the window expand under the different palettes and I can no longer see the area which I want to correct without change the document window size. I don't want to use the Photoshop application fram because then I can't see stuff in other applications ID, mail an so on. 

    I have written about how to control various font sizes in Thunderbird here:
    http://www.ramsden.org.uk/9_Type_sizes.html
    Generally, you shouldn't need to zoom; you can pre-set the display of message text.
    To get straight to the point, you should probably try the https://addons.mozilla.org/en-us/thunderbird/addon/theme-font-size-changer/ add-on to address issues with the size of the message list font.

  • Is there any way to bring back the Documents window? [Android]

    I liked the Documents window in the previous version where all the PDFs of the phone was shown, plus theor source folder was indicated. Now, it's somehow troublesome to go through my phone's folders just to look for a certain file.

    Hi Leslie,
        Are you using an Android device or an iOS device? My understanding is that you are able to find local files on your device but it is painful without a consolidated list of PDF's. In addition, if you are using an Android device can you please share your Android OS version (Settings-> About Phone) with us.
    -Rahul

  • Can only see the first page of document and when I scroll the document is cut off.

    I was sent some notes from my professor but I am only able to see the first page and when I scroll, it shows the document cut off.

    Thank you so much!! So simple, yet so effective! Am happy!

  • Resizing the Document window to predetermined size

    Hopefully this is just a quickie... Have just defined a site
    and am about to start afresh and wanted to change the page size to
    760 x 420 as reccomended. However, have gone to change this in the
    pop-up menu at the bottom and all the sizes are greyed-out (have
    even tried to determine my own size - but that's greyed out too.
    I am stuck on one size only (1018 x 497) Is this due to my
    own screen size??? Should I just continue working to the parameters
    I have set with guides?

    1. You cannot change those items at the bottom of the page
    until you have
    unmaximized the document pane in DW. But don't bother
    because,
    2. Changing that value does nothing to your page other than
    to show it in a
    reduced size window. It adds no code to the page.
    If you want your page to be 760px wide, then that's how wide
    you make the
    widest element on the page. Don't worry about trying to
    control the
    height - you cannot conveniently or reliably do that anyhow.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "mccoole1" <[email protected]> wrote in
    message
    news:g16l5k$28r$[email protected]..
    > Hopefully this is just a quickie... Have just defined a
    site and am about
    > to
    > start afresh and wanted to change the page size to 760 x
    420 as
    > reccomended.
    > However, have gone to change this in the pop-up menu at
    the bottom and all
    > the
    > sizes are greyed-out (have even tried to determine my
    own size - but
    > that's
    > greyed out too.
    > I am stuck on one size only (1018 x 497) Is this due to
    my own screen
    > size???
    > Should I just continue working to the parameters I have
    set with guides?
    >

  • VSTO: Add Custom Control in Word Document, When I scroll the Document, the Control is missing.

    Hi All,
    I faced an issue regarding insert custom control in Word Document via VSTO. And then I scroll down/up the Word Document. The control which I added is missing.
    I used the code below to AddControl in Word Document, 
    var shape = Globals.Factory.GetVstoObject(_doc).Controls.AddControl(myControl, range, width, height, shapeName).InlineShape.ConvertToShape();
    shape.WrapFormat.Type = Word.WdWrapType.wdWrapInline;
    I test this on Word 2007 and Word 2013. Both of them have the same result.
    Please help me! Thanks a lot!
    Ricky!

    Hi Ricky,
    I failed to reproduce your issue on my test environment (Office 2013).
    Here is the sample project:
    # WordAddCustomControlIssue on OneDrive
    Would you mind sharing a sample project through OneDrive to help us reproduce this issue?
    Regards,
    Jeffrey
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • The document window in Dreamweaver does not match the tutorial.

    There is no Document title box.

    I don't use the Extract workspace.  Have you tried changing to Code or Design workspace (upper right corner)?  In addition, you can create a custom workspace and save it. 
    Nancy O.

  • Switch between views in the Document window

    This question was posted in response to the following article: http://help.adobe.com/en_US/dreamweaver/cs/using/WScbb6b82af5544594822510a94ae8d65-7fb6a.h tml

    When using the Code/Design view, I am Unable to Split View vertically or change the design view to the left, as the options are greyed out on my version of CS5.5 Dreamweaver.
    I would be grateful if anybody has any suggestions.

  • How can I open a document with applescript without the doc. window opening.

    How can I open a document with applescript without opening the document window and speak the text of the document?  I can get it to open the file but the doc window always opens up. 

    try
              set pathToMyFolderOnDesktop to ("Macintosh HD:Users:jodyconnor:Desktop:") & "Dsource:" as alias
              set rnd to (random number from 1 to 6)
              set rndFileName to (rnd as text) & ".scpt"
              set FullPath to pathToMyFolderOnDesktop & rndFileName as text
              set myScript to load script (FullPath as alias)
      run script myScript
    on error the error_message number the error_number
              display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1
              return
    end try
    This code answered my question:  Hats off to Digimonk from stackoverflow and Darrick Herewe from stackoverflow.

  • Maximizing a floating document window makes the entire UI inaccessible

    On Windows 7, with Photoshop CS6, if you drag a document tab out of the main application window, it becomes a floating document with its own window controls for minimize, maximize, and close just like a normal Windows OS document should.  However, if you click the maximize window button, instead of maximizing within the primary application window like document windows are supposed to... the Photoshop document window expands to the full screen and covers up all user interface elements of the primary Photoshop application window.  This makes all user interface elements completely inaccessible.  Pressing the tab key will not show your tools like you'd expect, though shortcut keys still work. 
    The only way to get the user interface back is to restore the document window to a smaller size.  If this is a feature, what would it be used for?  Why do document windows in CS6 need to behave differently from the normal behavior of application and document windows on the Windows operating system?

    If Adobe were to make the document "maximize" into the application window, there would no doubt be people who want to see it on the whole screen and are used to the way it works in Photoshop CS5 who would be upset.  Plus, that's just not what the Maximize button on a window is supposed to do.
    Your workaround is to avoid the Maximize button entirely and use the right-click Fit on Screen function (which really fits to document to the application window) or the keyboard equivalent - Control 0.
    -Noel

Maybe you are looking for

  • BI Publisher Template Builder for Word 10.1.3.4.1 and Creating Pivot Table

    I'm new to BI (XML) Publisher and Pivot Tables.  I have XDO Engine version 5.6.3 and Template builder 10.1.3.4.1.  I creates a Word 2010 RTF template containing a pivot table.  When I preview in Word, it displays.  When I execute the Concurrent Reque

  • Disk repair utilities, etc.

    There seem to be mixed messages around here regarding running any sort of disk repair utilities on Pods. But since there are a couple of products on the market designed just for this purpose...might there be information that relates, a bit more defin

  • How do I configure a Pioneer DVR-XD10 external dvd writer to my macbook pro laptop?

    How do I configure a Pioneer DVR-XD10 external dvd writer to my macbook pro laptop? I read online that you could use an external dvd writer on a macbook pro when the internal dvd writer died. Please help? It shows power running through the external d

  • The Sims 2 vs Leopard

    Hello, Can someone please point me regarding patch for Leopard? Sims 2 and EP (Open for Business/Nighlife/Pets/etc) can't be launched on Leopard... Is there any estimate date we can expect patch? Process: The Sims 2 [80008] Path: /The Sims 2.localize

  • Where are the settings to make Acrobat software recognize my scanner?

    Where are the settings to make Acrobat software recognize my scanner?  I've had my computer on a road trip.  When I returned to the home office, I can't get Adobe Acrobat 10 Pro software to recognize my scanner, which is a 4-in-one printer.  Acrobat