RE: XControls
- Posted by Andy Serpa <ac at onehorseshy.com> Feb 12, 2004
- 527 views
Don Phillips wrote: > > > > to Don Philips: > > > > I've downloaded xControls to see how it runs with the > > soon-to-be-released win32lib. Everything seems to be going fine except > > that you are using getClientRect() and expecting a 6-element sequence to > > > > be returned. But the getClientRect() in win32lib has only ever returned > > a 4-element sequence. What am I missing here? > > > > > > -- > > Derek > > You know Derek, I am not really positive I can answer your question with > > any certainty. > > I do know for a fact that (in the very least) that your last Win32Lib > version did indeed return a six element sequence. I am not positive > about any previous version before this however. I am sure that if I was > > wrong people would have complained about the code not working before > this. > > Its been awile before I looked at that particular piece of code, but if > memory serves it went like this... > > If the window was a child located at 0, 0 with a width height of 50 each > > then the sequence would be: { 0, 0, 50, 50, 50, 50 }. > > But if the child window was not started at 0, 0 it was slightly > different. If (for example) it started at 20, 20 and w/h was 50 each it > > would return { 20, 20, 70, 70, 50, 50 }. > > The first four numbers were the absolute window coordinates and numbers > 5 and 6 respectively were the width and height (as I recall). > > I knew from you pre-sending me the beta that this was broken/ removed. > I probably shouldnt have used them to begin with but I just couldnt help > > myself =) The fix was/ is quite easy so I was not worried about it at > the moment. I am waiting for the official new release before I make any > > fixes or changes to the code. > In an old version of win32lib, getClientRect does in fact return 6 elements: global function getClientRect( integer id ) -- returns rectangle of the client area, accounting for -- the toolbar and status bar. integer x, y, cx, cy, toolbar, statusbar atom ptrRect, hdc sequence rect, size rect = repeat( 0, 6 ) if id = Screen or id = Printer then hdc = getDC( id ) -- screen size --rect[1] = 0 --rect[2] = 0 rect[3] = w32Func( xGetDeviceCaps, {hdc, HORZRES} ) rect[4] = w32Func( xGetDeviceCaps, {hdc, VERTRES} ) releaseDC( id ) else -- Allocate a rectangle structure ptrRect = acquire_mem( 0, SIZEOF_RECT ) -- get client rectangle size if not w32Func( xGetClientRect, {getHandle(id), ptrRect} ) then warnErr( Err_GCRGETCLIENTRECT ) end if rect[1..4] = peek4u({ptrRect,4}) --rect[1] = fetch( ptrRect, rectLeft ) --rect[2] = fetch( ptrRect, rectTop ) --rect[3] = fetch( ptrRect, rectRight ) --rect[4] = fetch( ptrRect, rectBottom ) -- Free the structure release_mem( ptrRect ) end if -- fetch the values -- is there a toolbar? toolbar = window_toolbar[ id ] if toolbar and ((vWinMainState = kNotStarted) or (call_func(r_isVisible, {toolbar}))) then -- get the size of the toolbar size = getCtlSize( toolbar ) -- add height to the y value rect[2] += size[2] rect[4] -= size[2] end if -- is there a statusbar? statusbar = window_statusbar[ id ] if statusbar and ((vWinMainState = kNotStarted) or (call_func(r_isVisible, {statusbar}))) then -- get the size of the toolbar size = getCtlSize( statusbar ) -- subtract height from the y value rect[4] -= size[2] end if rect[5] = rect[3] rect[6] = rect[4] return rect end function r_getClientRect = routine_id("getClientRect")