Author Topic: Behavior of _MDIChildSetWindow  (Read 6193 times)

jporkka

  • Senior Community Member
  • Posts: 140
  • Hero Points: 6
Behavior of _MDIChildSetWindow
« on: July 07, 2008, 08:48:52 PM »
Just upgraded to 13.0.1 (windows)
I've got some old macros that rearrange my document windows.
Now instead of moving the document windows they appear to simply move the document itself inside the document window (as if inside the document window there is a nested window that the document is really rendered into).

I was using this statement:
   winID._move_window(xx,yy,ww,hh,'N');
to move the document window.
If I change this to:
   int save = p_window_id;
   p_window_id = winID;
   _MDIChildSetWindow(xx,yy,ww,hh);
   p_window_id = save;
I get the behavior I want...the entire document window gets moved correctly.

Also I cannot get _MDIClientGetWindow to tell the truth about the window size...or more likely I don't know how to correctly use it to request information about a specific window.

Questions:
In 13.0.1 what changed WRT document windows?
What is the correct way to move document windows around in script?
Is there a notification sent when the MDI child window resizes? (Such as when toolbar dock or undock or the main slick edit program window resizes).

Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 798
  • Hero Points: 54
Re: Behavior of _MDIChildSetWindow
« Reply #1 on: July 07, 2008, 10:54:52 PM »
Yes, you are correct. In 13.0.1 we changed our MDI child window architecture a bit in order to support future features. It is exactly as you say: the editor window is now inside an MDI child form. _mdi.p_child still gets you the window id of the editor control. The code you want is:

   int xx, yy, ww, hh;
   // Get current MDI child window geometry in pixels
   _mdi.p_child._MDIChildGetWindow(xx,yy,ww,hh);
   // Move current MDI child window by 10 pixels across and down
   _mdi.p_child._MDIChildSetWindow(xx+10,yy+10,ww,hh);

Note that all geometry for an MDI child window is in pixels (not twips like most everything else). Origin (xx, yy) is relative to the MDI frame.

Quote
Is there a notification sent when the MDI child window resizes? (Such as when toolbar dock or undock or the main slick edit program window resizes).

There is currently no facility to provide this type of notification. Sorry.

One way you could get notified when the application window was resized would be to hook into the call_list that gets called when the dock channel gets resized (the dock channel is where autohidden tool windows get minimized to). You would have to have at least one autohidden tool window for this scheme to work (otherwise there is no dock channel). Your callback would have to start with _dockchan_resize_. It would be called whenever the application window is resized (not moved). Look at _dockchan_resize_toolbars() in tbdockchannel.e for an example. This does not help you with MDI child windows (unless your MDI child is maximized in which case it would also be a notification that the MDI child had been resized ).

--rodney

jporkka

  • Senior Community Member
  • Posts: 140
  • Hero Points: 6
Re: Behavior of _MDIChildSetWindow
« Reply #2 on: July 08, 2008, 05:31:56 PM »
Thanks....but how do I call MDIChildSetWindow for a specific window ID?
I create an array of window IDs by recording p_window_id, then calling _next_window

What is the difference between
         WindowIDs[index++] = p_window_id;
and
         WindowIDs[index++] = _mdi.p_child;
?

Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 798
  • Hero Points: 54
Re: Behavior of _MDIChildSetWindow
« Reply #3 on: July 08, 2008, 06:03:22 PM »
p_window_id is SlickEdit's idea of the active window. The active window is what is affected if you call functions to insert text, move the cursor, etc.. This is almost always the same window that has keyboard focus because the functions/commands that SE ships with call _set_focus() after using p_window_id=... (or activate_window) to set the window active.

_mdi.p_child is the current MDI child editor window (not the MDI child form parent). If the SE application gets focus back from the operating system, or a tool window is dismissed, then _mdi.p_child is how we find our way back to the active MDI child.

If you are running a Slick-C function that accumulates window ids (as in your example), and you start your function in the active MDI child editor window (_mdi.p_child), then there is no difference between p_window_id and _mdi.p_child. I hope that is clearer.

Quote
....but how do I call MDIChildSetWindow for a specific window ID?

You prefix the call with the window id you want affected:

int wid = WindowIDs[ii];
wid._MDIChildSetWindow(...);

--rodney

jporkka

  • Senior Community Member
  • Posts: 140
  • Hero Points: 6
Re: Behavior of _MDIChildSetWindow
« Reply #4 on: July 08, 2008, 07:16:33 PM »
OK, it is getting clearer...but I'm not there yet.
You posted:
    // Get current MDI child window geometry in pixels
   _mdi.p_child._MDIChildGetWindow(xx,yy,ww,hh);

If I try that, I get a Slick-C error "This property or method is not allowed on this object"
Yet, the same line of code works fine if I change "Get" to "Set".
So, I have code like this:
   int save2 = p_window_id;
   p_window_id = winID;
   _mdi._MDIClientGetWindow(x, y, width, height);
   p_window_id = save2;
but that doesn't report the same numbers as I set with MDIChildSetWindow.
In the example below I have 3 windows.
I set the size of each and immediately try to read the size with MDIChildGetWindow, and then print the results
0 WID=346, BufID=30
1 WID=324, BufID=28
2 WID=372, BufID=29
_MDIChildSetWindow:(336,287) (336,287)
_MDIClientGetWindow says (211,2) (671,574)
_MDIChildSetWindow:(336,0) (336,287)
_MDIClientGetWindow says (211,2) (671,574)
X: _MDIChildSetWindow:(0,0) (336,574)
X: _MDIClientGetWindow says (211,2) (671,574)

Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 798
  • Hero Points: 54
Re: Behavior of _MDIChildSetWindow
« Reply #5 on: July 08, 2008, 07:58:53 PM »
I think you've made a mistake somewhere.

_MDIClientGetWindow gets geometry for the MDI client window the parent of all MDI children windows (e.g. editor windows). It is the gray area behind the MDI child windows when they are not maximized.

_MDIChildGetWindow gets the geometry for an MDI child window.

Calling _mdi.p_child._MDIClientGetWindow(...) will definitely give the exact Slick-C error you mentioned. Yes, I know that is not what you posted in your reply, but it is the only explanation I can think of, since the example code I posted works perfectly in 13.0.0 and 13.0.1:

_mdi.p_child._MDIChildGetWindow(xx,yy,ww,hh);

--rodney