Resizing header graphic

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Resizing header graphic

Post by jalz » Tue May 01, 2012 11:46 pm

Hi all,
I've created a header for my card by placing a blank button and filling it with the background of the image. Seems to work well, however I would like the header to stretch horizontally along if the user decides to stretch the window. Is there a way I can create a header graphic that stretches an shrinks horizonrally according to the size if the window?

Many thanks

Jalz

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Resizing header graphic

Post by mwieder » Tue May 01, 2012 11:59 pm

Try something like this in the script of the first card of the stack:

Code: Select all

on resizestack
    lock screen
    set the width of image 1 to the width of me
    set the top of image 1 to the top of me
    set the left of image 1 to the left of me
    unlock screen
end resizestack
But note that images don't scale very quickly, so this may appear a bit jerky.

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: Resizing header graphic

Post by jalz » Wed May 02, 2012 8:26 pm

Thanks mweider for starting me off.
After a little trial and error and looking at the dictionary to find out how things work - the following code seems to work quite nicely.

Code: Select all

on resizestack
   lock screen
   set the width of button "button 1" to the width of me
   set the top of button "button 1" to 0
   set the left of button "button 1" to 0
   unlock screen
end resizestack

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Resizing header graphic

Post by jacque » Thu May 03, 2012 4:28 pm

The resizeStack message also includes two parameters which are the width and height of the stack. So an alternate way to do this would be:

on resizestack x,y -- these params are sent by the engine
lock screen
set the width of button "button 1" to x
set the topleft of button "button 1" to 0,0
unlock screen
end resizestack
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply