Re: How to set the width of a browse, and keep it set.
Searching for this thread reveals that this problem has been an issue for a long time! Getting a saved browse to retain its width and height set in design mode does not work in the OnInit event for the browse - but does in the OnFetch event. However the trick is to only do this once else it will resize on every record change. But since the OnFetch follows the OnInit event when the browse is loaded, a global flag can be set to .t. in the OnInit event and set to .f. by a UDF that actually resizes the browse.
Here are my steps:
First create the UDF below: brw_size() and save it
Open the saved browse in design mode and make it the size you want
Open the IW and check its width and height properties
?your_browse_name.width
?your_browse_name.height
Open the OnInit and OnFetch events for the browse in the editor
Type this line in the OnInit event and save to the Code Library
dim global brw_flag as L = .t.
In the OnFetch use the function to set the size from the IW
brw_size(360,600)
I am working on a form to keep track of my development notes and wanted to be able to pop up a layout, script, table or udf to see its detail. And the browses were the most annoying when I wanted to see one or two at the same time.
Searching for this thread reveals that this problem has been an issue for a long time! Getting a saved browse to retain its width and height set in design mode does not work in the OnInit event for the browse - but does in the OnFetch event. However the trick is to only do this once else it will resize on every record change. But since the OnFetch follows the OnInit event when the browse is loaded, a global flag can be set to .t. in the OnInit event and set to .f. by a UDF that actually resizes the browse.
Here are my steps:
First create the UDF below: brw_size() and save it
Open the saved browse in design mode and make it the size you want
Open the IW and check its width and height properties
?your_browse_name.width
?your_browse_name.height
Open the OnInit and OnFetch events for the browse in the editor
Type this line in the OnInit event and save to the Code Library
dim global brw_flag as L = .t.
In the OnFetch use the function to set the size from the IW
brw_size(360,600)
Code:
FUNCTION brw_size AS L (xwidth AS N, yheight AS N ) 'use in OnFetch event for browse to resize one time only 'set the global brw_flag to .t. in OnInit event topparent.window_position("Left","Top") 'this is my preference DIM GLOBAL BRW_FLAG AS L if brw_flag then topparent.width = xwidth topparent.height = yheight BRW_FLAG = .f. end if brw_size = brw_flag END FUNCTION
Comment