KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Restore Size, Location and WindowState on next run ...

 
Post new topic   Reply to topic    KiXforms Forum Index -> Script Archive
View previous topic :: View next topic  
Author Message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Dec 30, 2005 1:18 pm    Post subject: Restore Size, Location and WindowState on next run ... Reply with quote

Here's a sample of how to make your gui more comfortable to improve your users experience.

I use an ini file here, because I don't want to poke around in your Registry only for demonstration purposes, but it should be no problem to convert this for registry use.

Code:
break on

$ini = @scriptdir + '\test.ini'
if not exist($ini)
    $_ = writeprofilestring($ini,"Default","Size","300,400")
    $_ = writeprofilestring($ini,"Default","Location","100,100")
    $_ = writeprofilestring($ini,"Default","Maximised","0")
endif

$system = createobject("KiXtart.System")

$form               = $system.Form()
$form.SizeGripStyle = 1
$form.Text          = "Restorable Form"
$form.Location      = val(split(readprofilestring($ini,"Default","Location"),',')[0]),
                      val(split(readprofilestring($ini,"Default","Location"),',')[1])
$form.Size          = val(split(readprofilestring($ini,"Default","Size"),',')[0]),
                      val(split(readprofilestring($ini,"Default","Size"),',')[1])
$form.OnResize      = "form_Resize"
$form.OnMove        = "form_Move"

if val(readprofilestring($ini,"Default","Maximised"))
    $form.WindowState = 2
endif

$form.Show

while $form.Visible
    $_ = execute($form.DoEvents)
loop

if $form.WindowState = 2
    $_ = writeprofilestring($ini,"Default","Maximised","1")
else
    if not $form.Windowstate
        $_ = writeprofilestring($ini,"Default","Maximised","0")
        $_ = writeprofilestring($ini,"Default","Location", '' + $form.Left + ',' + $form.Top)
        $_ = writeprofilestring($ini,"Default","Size", '' + $form.Width + ',' + $form.Height)
    else
        $_ = writeprofilestring($ini,"Default","Maximised","0")
    endif
endif

exit 0

function form_Move ; to safe location before maximising
    if not $form.WindowState
        $_ = writeprofilestring($ini,"Default","Location", '' + $form.Left + ',' + $form.Top)
    endif
endfunction

function form_Resize ;to safe size before maximising
    if not $form.WindowState
        $_ = writeprofilestring($ini,"Default","Size", '' + $form.Width + ',' + $form.Height)
    endif
endfunction

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Wed Jan 11, 2006 2:36 pm    Post subject: Reply with quote

Updated above code to catch some misbehaviour when closing in minimized state Rolling Eyes
_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Wed Jan 11, 2006 9:04 pm    Post subject: Reply with quote

Quote:

misbehaviour when closing in minimized state


lol, been there too my brother. its not fun.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Script Archive All times are GMT
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
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group