1. Win32lib System Metrics

I need to make a window of precise dimensions. How do I find the width of
borders and title bars ( as in getsystemmetrics),please?
Regards
Bob

new topic     » topic index » view message » categorize

2. Re: Win32lib System Metrics

On Thu, 17 Aug 2000 22:34:11 +0200, bobspringett wrote:

>I need to make a window of precise dimensions. How do I find the width of
borders and title bars ( as in getsystemmetrics),please?
>Regards
>Bob

You could go through the trouble of using getsystemmetrics but you don't
have to.  Feel free to use the setClientRect procedure in the example
below.  It simply uses what Win32Lib already offers:

-- setClientRect Demo
-- by Brian Broker
-- click in window to use 'setClientRect'

-- file: setClient.exw
include win32lib.ew

constant
  Win = create( Window, "Test Win", 0, Default, Default, 200, 200, 0 ),
  Txt = create( LText, "", Win, 5, 5, 100, 20, 0 )
------------------------------
procedure setClientRect( integer id, integer width, integer height )
  sequence extent, client, diff

  -- get current client size
  client = getClientRect( id )
  -- get current window size
  extent = getExtent( id )
  -- get current window size and subtract client size
  diff = extent - client[3..4]
  -- add difference to specified window size
  setSize( id, width+diff[1], height+diff[2] )
end procedure
------------------------------
procedure onClick_Win()
  sequence client

  -- specify client size
  setClientRect( Win, 200, 200 )
  -- get current client size
  client = getClientRect( Win )
  -- display in window
  setText( Txt, sprintf( "Client: %d x %d", client[3..4] ) )
end procedure
onClick[Win] = routine_id( "onClick_Win" )
------------------------------
procedure onOpen_Win()
  sequence client

  -- get current client size
  client = getClientRect( Win )
  -- display in window
  setText( Txt, sprintf( "Client: %d x %d", client[3..4] ) )
end procedure
onOpen[Win] = routine_id( "onOpen_Win" )
------------------------------
WinMain( Win, Normal )
------------------------------

-- Brian

new topic     » goto parent     » topic index » view message » categorize

3. Re: Win32lib System Metrics

On Thu, 17 Aug 2000 19:20:12 -0400, Brian Broker wrote:

>-- setClientRect Demo
>-- by Brian Broker
>-- click in window to use 'setClientRect'

Sorry, I didn't finish 'optimizing' setClientRect().  You can even shorten
it up a bit:

------------------------------
procedure setClientRect( integer id, integer width, integer height )
  sequence client, diff

  -- get current client size
  client = getClientRect( id )
  -- get current window size and subtract client size
  diff = getExtent( id ) - client[3..4]
  -- add difference to specified window size
  setSize( id, width+diff[1], height+diff[2] )
end procedure
------------------------------

new topic     » goto parent     » topic index » view message » categorize

4. Re: Win32lib System Metrics

Hi Brian (Broker)
can I add your setClientRect to the standard win32lib? I've also reduced it
by another line.

>------------------------------
>procedure setClientRect( integer id, integer width, integer height )
>  sequence diff
>
>  -- get current window size and subtract client size
>  diff = getSize( id ) - getClientRect( id )
>  -- add difference to specified window size
>  setSize( id, width+diff[3], height+diff[4] )
>end procedure

-----
cheers,
Derek Parnell
derekp at solace.com.au
Solace Limited ( http://www.solace.com.au )
Melbourne, Australia
+61 3 9291 7557

new topic     » goto parent     » topic index » view message » categorize

5. Re: Win32lib System Metrics

On Fri, 18 Aug 2000 09:57:34 +1000, Derek Parnell wrote:

>Hi Brian (Broker)
>can I add your setClientRect to the standard win32lib? I've also reduced it
>by another line.
>
>>------------------------------
>>procedure setClientRect( integer id, integer width, integer height )
>>  sequence diff
>>
>>  -- get current window size and subtract client size
>>  diff = getSize( id ) - getClientRect( id )
>>  -- add difference to specified window size
>>  setSize( id, width+diff[3], height+diff[4] )
>>end procedure

Right on... I think it would be a good addition.  Since there's
a 'getClientRect' I think there should be a 'setClientRect'.  And this
isn't the first time that someone's asked about doing something like this...

-- Brian

new topic     » goto parent     » topic index » view message » categorize

6. Re: Win32lib System Metrics

On Thu, 17 Aug 2000 20:18:46 -0400, Brian Broker wrote:

>On Fri, 18 Aug 2000 09:57:34 +1000, Derek Parnell wrote:
>
>>Hi Brian (Broker)
>>can I add your setClientRect to the standard win32lib? I've also reduced
it
>>by another line.
>>
>>>------------------------------
>>>procedure setClientRect( integer id, integer width, integer height )
>>>  sequence diff
>>>
>>>  -- get current window size and subtract client size
>>>  diff = getSize( id ) - getClientRect( id )
>>>  -- add difference to specified window size
>>>  setSize( id, width+diff[3], height+diff[4] )
>>>end procedure
>
>Right on... I think it would be a good addition.  Since there's
>a 'getClientRect' I think there should be a 'setClientRect'.  And this
>isn't the first time that someone's asked about doing something like
this...
>
>-- Brian

Except you'll have to change it back to my last version since the 3rd and
4th elements returned by getSize is not the same as the extent...

-- Brian

new topic     » goto parent     » topic index » view message » categorize

7. Re: Win32lib System Metrics

I believe that is a bug in getSize. If the object was a window it returned
{top, left, right, bottom}, but for all other objects it returned {top,
left, width, height}. If your window was positioned at (0,0) then this is
equivalent. I've "fixed" this bug in my copy of win32lib and I'd like to
hear if this is going to break any existing code. My opinion is that the
function should return {top,  left, width, height} for all objects and not
make a window an exception.

-----
cheers,
Derek Parnell
derekp at solace.com.au
Solace Limited ( http://www.solace.com.au )
Melbourne, Australia
+61 3 9291 7557

new topic     » goto parent     » topic index » view message » categorize

8. Re: Win32lib System Metrics

On Fri, 18 Aug 2000 11:34:52 +1000, Derek Parnell wrote:

>I believe that is a bug in getSize. If the object was a window it returned
>{top, left, right, bottom}, but for all other objects it returned {top,
>left, width, height}. If your window was positioned at (0,0) then this is
>equivalent. I've "fixed" this bug in my copy of win32lib and I'd like to
>hear if this is going to break any existing code. My opinion is that the
>function should return {top,  left, width, height} for all objects and not
>make a window an exception.

Well then, I guess that would deprecate 'getExtent'...

Another thing that always bothered me was the 'getClientRect' function.  As
far as I can tell, the first two elements will always be zero, so why are
they returned?  (or could somebody give me an example where the first two
elements are not zero?)  I guess this one doesn't matter so much since
changing this might break too much code...

-- Brian

new topic     » goto parent     » topic index » view message » categorize

9. Re: Win32lib System Metrics

Many thanks Brian.
I had located getClientRect() but could nowhere find the corresponding 'set'
function. I know why now.
Regards
Bob
----- Original Message -----
From: Brian Broker <bkb at CNW.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Friday, August 18, 2000 1:27 AM
Subject: Re: Win32lib System Metrics


> On Thu, 17 Aug 2000 19:20:12 -0400, Brian Broker wrote:
>
> >-- setClientRect Demo
> >-- by Brian Broker
> >-- click in window to use 'setClientRect'
>
> Sorry, I didn't finish 'optimizing' setClientRect().  You can even shorten
> it up a bit:
>
> ------------------------------
> procedure setClientRect( integer id, integer width, integer height )
>   sequence client, diff
>
>   -- get current client size
>   client = getClientRect( id )
>   -- get current window size and subtract client size
>   diff = getExtent( id ) - client[3..4]
>   -- add difference to specified window size
>   setSize( id, width+diff[1], height+diff[2] )
> end procedure
> ------------------------------

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu