I'm updating my "resize" macro to use the _MDIChildGetWindow method to set the size of the windows (buffers). This works if I enter the command manually, or if I double click a file that is opened in SE. But when I open a project (via the Project menu) I get the following error;
This property or method is not allowed on this object
resize.ex 774 resize_window() p_window_id: 5 p_object: OI_FORM p_name:
resize.ex 1071 _buffer_add_resize(31,D:\xxxxxxx\Data\SlickEdit\macros\resize.e,0) p_window_id: 202 p_object: OI_EDITOR p_name:
files.ex 10172 call_list(_buffer_add_,31,D:\xxxxxxx\Data\SlickEdit\macros\resize.e,0) p_window_id: 202 p_object: OI_EDITOR p_name:
files.ex 4161 files:edit_status(0,0,31 5,32,) p_window_id: 202 p_object: OI_EDITOR p_name:
files.ex 3221 files:edit2(-w +ftext "D:\xxxxxxx\Data\SlickEdit\macros\resize.e",32,0) p_window_id: 202 p_object: OI_EDITOR p_name:
files.ex 392 edit(-w +ftext "D:\xxxxxxx\Data\SlickEdit\macros\resize.e",32,0) p_window_id: 202 p_object: OI_EDITOR p_name:
restore.ex 4023 restore:process_buffer(BN="\xxxxxxx\Data\SlickEdit\macros\resize.e",,
3: MA=1 74 1 TABS=1 4 WWS=1 IWT=0 ST=0 IN=2 BW=0 US=32000 RO=0 SE=0 SN=0 BIN=0 MN=Slick-C HM=0 MF=2293856 TL=0 MLL=0 ASE=0 LNL=6 LCF=0 CAPS=0 E=0 ESBU2=0 CL="" SC="" SCE= SCU=
4: D:\dev\ccm\projects\
5: 0
p_window_id: 5
p_object: OI_FORM
p_name:
restore.ex 1062 restore:restore2(,D:\dev\ccm\projects\,1,1) p_window_id: 5 p_object: OI_FORM p_name:
restore.ex 435 restore(,202,D:\dev\ccm\projects\,1,1) p_window_id: 5 p_object: OI_FORM p_name:
wkspace.ex 4874 workspace_open(D:\dev\ccm\projects\DBB0001.vpw,,,1,1) p_window_id: 200 (invalid)
Adding "say" statements to the code shows that it's the _MDIChildGetWindow call that's failing. So, my question is; at what point is it OK to use that method on the _mdi.p_child object?
This is my resize.e
#include "slick.sh"
/* Macro that will automatically set all files that are opened to a specified size (see command "_buffer_add_resize()" comments for manual option.).
To use this macro:
1) the user can specify a window width, using the "Vertical line column" on the "Tools | Configuration | General", "General" tab.
-- OR --
2) the user can specify a window size for "_mdi.pchild.p_width" : please note that "Vertical line column" value must be zero (0) in order to use this option
-----------------
To change the window height, specify a different value for "_mdi.p_child.p_height" below.
Also, to specify a different location for opening the window, in the editor, change the values of "_mdi.p_child.p_x" and "_mdi.p_child.p_y" below.
To load the 'resize.e' macro file:
* Select "Macro | Load Module"
* Choose the 'resize.e' macro file from the browse.
* Click on the "Open" button
* You will see the message "Module(s) loaded" on the editor's message line.
*/
int windowIDs[];
void Trace( _str saystring )
{
say( saystring );
}
_command resize_window( _str doall = "" ) name_info(',' VSARG2_MACRO | VSARG2_REQUIRES_EDITORCTL | VSARG2_MARK | VSARG2_READ_ONLY)
{
int numWindows = 0;
int winWidthAdj = 55;
int winOffsetX = 20;
int newHeight = 0;
int newWidth = 0;
if ( p_window_state :== 'M' )
{
p_window_state = 'N';
}
Trace( "*** Begin " :+ _date( 'I' ) :+ ' ' :+ _time( 'L' ) :+ " ***" );
Trace( "Parameter DOALL<" :+ doall :+ ">" );
Trace( "p_window_id<" :+ p_window_id :+ ">" );
//
// If the ALL paramter was passed on the command (entered manually) get the number of
// windows (buffers). Otherwise process just the window being opened.
//
if ( "ALL" == upcase( doall ) )
{
GetListOfWindows( numWindows );
}
else
{
windowIDs[0] = _mdi.p_child;
numWindows = 1;
}
//
// Establish the new window height.
//
int height = _default_option( VSOPTION_NEW_WINDOW_HEIGHT );
if ( height < 1 )
{
typeless junk = 0;
int mdiclient_width = 0, mdiclient_height = 0;
_mdi._MDIClientGetWindow( junk, junk, mdiclient_width, mdiclient_height );
Trace("_MDIClientGetWindow() width<" :+ mdiclient_width :+ "> height<" :+ mdiclient_height :+ ">");
newHeight = mdiclient_height;
}
else
{
newHeight = height;
}
//int startWindowID = p_window_id;
int i;
for ( i = 0; i < numWindows; i++ )
{
int curChild = windowIDs[i];
_str bufName = curChild.p_buf_name;
Trace( "curChild<" :+ curChild :+ ">" );
int ftpSys = pos( '\ftp\', bufName );
if ( ftpSys )
{
parse bufName with drv ':\' . '\ftp\' sys '\' q1 '.' q2 '.' q3 '\' mbr
bufName = drv :+ ":\\" :+ q1 :+ "\\" :+ q2 :+ "\\" :+ q3 :+ "\\" :+ mbr :+ ".mf"
}
int lastDot = lastpos( '.', bufName );
boolean fAdjust = true;
if ( lastDot )
{
Trace( "bufName<" :+ bufName :+ ">" );
_str ext = substr( bufName, lastDot + 1 );
int width=_default_option('R');
//
// Check if the extension is one we want to set a Vertical Line Column for.
//
switch ( ext ) {
case "c" :
case "e" :
case "h" :
case "cpp" :
case "xml" :
case "xsd" :
_default_option('R', 100);
width=_default_option('R');
newWidth = 760;
break;
case "mf" : // mainframe file
case "asm" :
case "mac" :
case "gml" :
case "exec" :
case "gmlinc" :
case "inc" :
case "pasm" :
case "pc" :
case "pcc" :
_default_option('R', 80);
width=_default_option('R');
break;
default:
fAdjust = false;
Trace("Unknown extension<" :+ ext :+ ">");
}
if ( fAdjust ) //&& curChild > 100 )
{
int curX = 0, curY = 0, curWidth = 0, curHeight = 0;
Trace( "Prior to _MDIChildGetWindow call" );
curChild._MDIChildGetWindow( curX, curY, curWidth, curHeight );
Trace( "curX<" :+ curX :+ "> curY<" :+ curY :+ "> curWidth<" :+ curWidth :+ "> curHeight<" :+ curHeight :+ '>' );
if ( width )
{
message( "Resizing file " :+ bufName );
newWidth = width * curChild.p_font_width + winWidthAdj;
Trace("newWidth<" :+ newWidth :+ ">");
curChild._MDIChildSetWindow( curX, curY, newWidth, newHeight );
}
}
}
}
Trace( "*** End " :+ _date( 'I' ) :+ ' ' :+ _time( 'L' ) :+ " ***" );
}
void GetListOfWindows( int &numwins )
{
int StartWindowID = p_window_id;
int lastwindow_id;
int done = 0;
int index = 0;
numwins = 0;
_prev_window 'HF';
lastwindow_id = p_window_id;
_next_window 'HF'
for ( ;; )
{
if ( p_window_id == lastwindow_id )
{
done=1;
}
if ( !(p_window_flags & (HIDE_WINDOW_OVERLAP) ) || arg(3) != '' )
{
windowIDs[index++] = p_window_id;
}
_next_window 'HR';
if ( done )
{
break;
}
}
numwins = index;
p_window_id = StartWindowID;
Trace( "numwins<" :+ numwins :+ '>' );
}
/* "#if 1" -- will run this each time a file is opened
"#if 0" -- will require user to run the command "_buffer_add_resize" manually
(ie. bind to a key or from the Visual SlickEdit command line)
*/
#if 1
void _buffer_add_resize()
{
if ( def_one_file != '' ) {
resize_window();
}
}
#endif