forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Image Bar (%ib) buttons.
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Suggestions
View previous topic :: View next topic  
Author Message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6159
Location: Salford, UK

PostPosted: Mon Feb 04, 2008 11:24 pm    Post subject: Reply with quote

OK thanks.
Back to top
View user's profile Send private message
IanLambley



Joined: 17 Dec 2006
Posts: 472
Location: Sunderland

PostPosted: Sun May 04, 2008 12:15 pm    Post subject: Reply with quote

Eddie,

I have recently had a battle with the positioning of window controls and so I've modified Paul's code a little to show positioning of %ib controls using
GET_WINDOW_LOCATION@ & MOVE_WINDOW@.

A couple of problems to overcome first. The get_window_location@ actually returns the position of a control relative to the top left corner of the window, but the move_window@ is relative to the first pixel under the caption bar and to the right of the LH border. These of course vary with text size and windows style (standard or XP for example). It there is a %mn then it is the first pixel below the menu.

What I did, and there is probably a better way was to construct a dummy window on startup, which places a caption and a menu, followed by an %rd control. Using a %sc callback, which returns 0, closing the dummy window, I position the %rd to 0,0 and get its position. Add 1 to the x & y positions and use this as the offset from the top of the overall window. Subsequently the get_real_control_location routine simply subtracts these from the get_window_location@ positions to get a location relative to the first usable space. This can then be used to set the %ib or any other control to a new location. After a window resize, the overall window size could be adjusted to account for any dramatic repositioning of controls that you have carried out.

I know it is a bit long winded, but it might help.

Paul,
Is there any way to get the locations relative to the same point that move_window@ uses?

Regards

Ian

[code:1:f7b7436803]
WINAPP
include <windows.ins>

INTEGER i,iresize,iget_offsets,imove_ib2
external iresize,iget_offsets,imove_ib2
common/window_things/ihandle_window,ihandle_ib1,ihandle_ib2,ihandle_tt
common/window_offset/ixoffset,iyoffset
!dummy window
i=winio@('%ca[dummy]&')
i=winio@('%mn[File[Exit]]&','EXIT') !include this line only if real window is to contain a menu
i=winio@('%rd%lc%sc',i,ihandle_window,iget_offsets)

! real window
i=winio@('%ca[Image bar]%ww%bg[btnface]%hw&',ihandle_window)
i=winio@('%bd&',0.0D0,0.0D0,0.5D0,1.0D0)
i=winio@('%mn[File[Exit]]&','EXIT')
i=winio@('%3ib[flat]&','cut/Cut',4,'CONTINUE','copy/Copy',4,'CONTINUE','paste/Paste',4,'CONTINUE')
i=winio@('%lc&',ihandle_ib1)
i=winio@('%se&',0.0D0)
i=winio@('%3ib[flat]&','cut/Cut',4,'CONTINUE','copy/Copy',4,'CONTINUE', 'paste/Paste',4,'CONTINUE')
i=winio@('%lc&',ihandle_ib2)
i=winio@('%ff%^tt[Move IB2]&',imove_ib2)
i=winio@('%lc&',ihandle_tt)
i=winio@('%ff%pv%^gr[black,user_resize]',300,200,iresize)

END


integer*4 function iresize()
include <windows.ins>
common/window_things/ihandle_window,ihandle_ib1,ihandle_ib2,ihandle_tt
! get new position & size of overall window
call get_real_control_location(ihandle_window,ix,iy,iw,ih)
print *,'window',ix,iy,iw,ih
! get new position & size of first ib block
call get_real_control_location(ihandle_ib1,ix,iy,iw,ih)
print *,'ib 1 ',ix,iy,iw,ih
! get new position & size of second ib block
call get_real_control_location(ihandle_ib2,ix,iy,iw,ih)
print *,'ib 2 ',ix,iy,iw,ih
! get new position & size of text button
call get_real_control_location(ihandle_tt,ix,iy,iw,ih)
print *,'tt ',ix,iy,iw,ih

iresize = 1
end

! get initial offsets using dummy window
integer*4 function iget_offsets()
include <windows.ins>
common/window_things/ihandle_window,ihandle_ib1,ihandle_ib2,ihandle_tt
common/window_offset/ixoffset,iyoffset
! set the %rd pixel location to zero,zero
call MOVE_WINDOW@( ihandle_window, 0,0)

call GET_WINDOW_LOCATION@( ihandle_window, ixoffset, iyoffset, iw, ih)
ixoffse
Back to top
View user's profile Send private message Send e-mail
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2068
Location: Yateley, Hants, UK

PostPosted: Mon May 12, 2008 2:10 pm    Post subject: Reply with quote

Hi Ian,

A very elegant solution, and very timely because of the post by Catherine Rees Lay in the other forum. Your code there isn't truncated.

I eventually discovered %bx, which locks the second %ib into a fixed position. If one puts i=winio@('%ib&',0.0D0) into your code, for instance, the coords of ib2 don't alter when the window is resized.

As written, if one resizes the window, so that ib2 scoots off behind ib1, so too does the %se separator, so presumably that needs to be resurrected in the right position too.

Regards

Eddie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Suggestions All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group