Re: Win32lib System Metrics

new topic     » goto parent     » topic index » view thread      » older message » newer message

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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu