cancel
Showing results for 
Search instead for 
Did you mean: 

UserObject change the size

Former Member
0 Kudos

Hello, some example of how to change the size of a UserObject?

Thanks.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks

ricardojasso
Participant
0 Kudos

Beto,

What a coincidence. I just finished refactoring a window from one of our applications by extracting a tab control with many embedded controls (tabpages, datawindows, buttons) to a user object which now I use inside the window as one control.

The size of the control within the window can be set as usual in the resize event of the window itself. The resizing of all the controls within the user object could be also set in the same window resize event. There is nothing that prevents this but since these controls are contained inside the user object their workspace is the user object itself so it makes sense to create a function in the user object to resize all its controls and then call this function from the resize event of the window.

Example:


(Window resize event):

// TAB DE SOLICITUD

uo_tab_solicitud.x = 1

uo_tab_solicitud.y = this.workspaceheight() * ( 1 - 0.45)

uo_tab_solicitud.width = this.workspacewidth()

uo_tab_solicitud.height = this.workspaceheight() * 0.45 - cb_agregar_solicitud.height

uo_tab_solicitud.of_resize()

(Object function of_resize in tab user object):

// DW DE SOLICITUD

idw_solicitud.x = 1

idw_solicitud.y = 1

idw_solicitud.width = this.tabpage_solicitud.width

idw_solicitud.height = this.tabpage_solicitud.height - icb_solicitud.height

Regards,

Ricardo

Former Member
0 Kudos

Hi Ricardo;

  The only fault with your approach is that it is not encapsulated. While this will initially work - this also means that every time you refactor a UO you would have to refactor your Windows Resize event code. This could create a long term maintenance challenge - especially, if this Window also becomes used as an ancestor for other Window descendants.

  In a proper OO design approach, the resize code in the Window would never know how, why or when the resizing was implemented in a UO, its nested children or its descendants. 

Food for thought.

Regards .. Chris

ricardojasso
Participant
0 Kudos

Chris,

I don't follow. The resize instructions for the objects within the user object are encapsulated in the mentioned user object. The window doesn't have to know how to resize the objects that are inside the user object. It just needs to resize the user object that is inside the window itself and then call the function of_resize of the user object.

Regards,

Ricardo

Former Member
0 Kudos

<my bad> I missed the call to your "of_resize()" method when I read your script. I assume that the resize operations are carried out in there similar to my "oe_resize" event.


FWIW: I use event for this as they are easier to extend or over-ride in PB objects vs functions. Also, events are for notifications vs functions which are specific units of work. Thus, my event is a message that can be routed from many objects - not just the parent Window. The event is just a notification. What the child object(s) do with that is up to them. Maybe I'm too picky - LOL! 

Former Member
0 Kudos

Hi Beto;

  The UO can be resized like any other control. However, UO's within UO's, Controls within UO's and Tab Pages (which are really User Objects) will have the resizing challenge as the objects inside a UO class do not have the Resize Event!

  What I would like to suggest is to have a look at my Integrated frame and its example OrderEntry application. You will see that the OE application uses a lot of UO's and because the UO's are inherited from my framework base class - they all have an oe_resize user event that synthesizes the normal Window or Control class's current Resize event provided by the PB System Classes.

  You are most welcome to either use my Integrated Framework or borrow the code you see around the "oe_resize" event to implement something similar in your PB application(s). The nice thing I like about my implementation is that it is well encapsulated. Food for thought.

HTH

Regards ... Chris