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 

%gp and %sp

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
LitusSaxonicum



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

PostPosted: Wed Jan 10, 2007 4:35 pm    Post subject: %gp and %sp Reply with quote

I'm using %gp and %sp to make a window pop up where it was last closed, i.e. so its former position is remembered. Since %gp relates to the position of the next control, the parameters returned from %gp need to be offset before being used in %sp. These offfsets vary according to screen resolution (or aspect ratio) and with the contents of the window, i.e. just how far into the window the next control is, i.e.

i=winio@('%sp&', I, J)
i=winio@('%gp&', I, J)

... this leads to the window "walking" down the screen if it is opened repeatedly, and to make it stick I need:

i=winio@('%sp&', I-I1, J-J1)
i=winio@('%gp&', I, J)

where I1 and J1 are the offsets.

I noticed in the "enhancements" file that there should be a %`gp which returns the window origin coordinates - although I find that it gives me the same answers as plain %gp. I have also tried calling GET_WINDOW_LOCATION@, but the returned parameters simply don't make sense (I don't have a 52 million x 4 million pixel display, for instance!).

Is it that I have simply misunderstood what these format codes do, or can anyone give me some better insight please?

Eddie
Back to top
View user's profile Send private message
JohnHorspool



Joined: 26 Sep 2005
Posts: 270
Location: Gloucestershire UK

PostPosted: Thu Jan 11, 2007 5:20 am    Post subject: Reply with quote

Eddie,

I do exactly what you want, using GET_WINDOW_LOCATION@ to obtain a temporary dialog window's position when the user closes it. Then the next time the window is used I use %sp to place it in the exact position of the previous window. I don't have any offsets or problems with the dialog window "walking".

Have you used the correct window handle ?

cheers
John
Back to top
View user's profile Send private message Visit poster's website
LitusSaxonicum



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

PostPosted: Thu Jan 11, 2007 9:02 am    Post subject: Reply with quote

John,

My reading of the documentation is that what I'm doing should work. Here's my test code:

OPTIONS (INTL)

PROGRAM EDDIE
INCLUDE <WINDOWS.INS>
INTEGER IHAND, I, J, K, L
I=100
J=100

10 CONTINUE
IA=WINIO@ ('%ca[This is a window]%hw&', IHAND)
IA=WINIO@ ('%ww%sp&', I, J)
CALL GET_WINDOW_LOCATION@ (IHAND, I, J, K, L)
WRITE(*,*) IHAND, I, J, K, L
IA=WINIO@ ('%`bt[Quit]')
GO TO 10
END

I just ran it on a machine set to 1280x1024 resolution. The outputs were:

IHAND 12924
I= 538976288
J= 538976288
K=0
L=0

After I pressed Quit, the parameters changed, and the window disappeared (because it was sent to out of view coords). If I use %gp, then at least I get coords that lie within the 1280x1024!

Or am I calling GET_WINDOW_LOCATION@ in the wrong place?

Eddie
Back to top
View user's profile Send private message
IanLambley



Joined: 17 Dec 2006
Posts: 490
Location: Sunderland

PostPosted: Thu Jan 11, 2007 1:51 pm    Post subject: Reply with quote

Hi,
You are callinig it in the wrong place. Because the window does not exist until the last winio@ statement has been executed, then the size and position cannot be detrermined.

Use a %sc to call a function as the window is displayed. See below:


Regards

Ian


OPTIONS (INTL)

PROGRAM EDDIE
INCLUDE <WINDOWS.INS>
INTEGER IHAND, I, J, K, L
common/window_location/IHAND, I, J, K, L
integer get_location
external get_location
I=100
J=100

10 CONTINUE
IA=WINIO@ ('%ca[This is a window]%hw&', IHAND)
IA=WINIO@ ('%ww%sp%sc&', I, J,get_location)
IA=WINIO@ ('%`bt[Quit]')
GO TO 10
END


integer*4 function get_location()
INCLUDE <WINDOWS.INS>
INTEGER IHAND, I, J, K, L
common/window_location/IHAND, I, J, K, L
CALL GET_WINDOW_LOCATION@ (IHAND, I, J, K, L)
WRITE(*,*) IHAND, I, J, K, L
get_location = 1
end
Back to top
View user's profile Send private message Send e-mail
LitusSaxonicum



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

PostPosted: Thu Jan 11, 2007 7:01 pm    Post subject: Reply with quote

Hi Ian,

I just ran your code, and the window doesn't remember where it may have been moved to, but always pops up at 100,100 ... which only needed the %sp. However, armed with the spirit of your answer, I tried it with %cc (instead of %sc) and that gives me what I was looking for (to pop the window up again where it was when it was last closed). I needed to call GET_WINDOW_LOCATION@ immediately before the window was closed. Calling it where I did, the answer was indeterminate, and that is (in effect) what I was getting.

Many Thanks. Now I have to replace a mass of "hacks" ....

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 -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
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