Remembering window position and size from last run

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Remembering window position and size from last run

Postby tashimaya » Fri Oct 10, 2014 10:25 am

I want cefclient.exe to remember its position and size from the last time it was shown. Do I have to do extra stuff to make this work in CEF?
tashimaya
Techie
 
Posts: 36
Joined: Fri Oct 10, 2014 7:18 am

Re: Remembering window position and size from last run

Postby magreenblatt » Fri Oct 10, 2014 10:36 am

This is something that you need to do in your application. See https://social.msdn.microsoft.com/Forum ... =vcgeneral
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Remembering window position and size from last run

Postby tashimaya » Fri Oct 10, 2014 10:41 am

Isn't this kind of information saved in the user profile folder? (viewtopic.php?f=10&t=1047)
tashimaya
Techie
 
Posts: 36
Joined: Fri Oct 10, 2014 7:18 am

Re: Remembering window position and size from last run

Postby magreenblatt » Fri Oct 10, 2014 10:44 am

tashimaya wrote:Isn't this kind of information saved in the user profile folder? (http://www.magpcss.org/ceforum/viewtopi ... =10&t=1047)

No. Your application creates the windows and is responsible for remembering/restoring the position if desired.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Remembering window position and size from last run

Postby Mayhew » Fri Oct 10, 2014 2:16 pm

It is different for each platform
On Win if you are using straight win32 APIS you can use GetWindowPlacement and/or GetWindowRect in your apps WM_DESTROY handler and store the values in the registry. On launch when you call CreateWindow() to create your new main window you can read those reg entries and call SetWindowPlacement() to restore the position

On Mac, assuming you are a Cocoa app, the OS can just handle this for you. Check out the setFrameAutosaveName API.

On Linux, it depends on your UI framework. For GTK its a similar procedure to Win. In your configure-event signal handler you can call gtk_window_get_position and gtk_window_get_size to get the new position and store it somewhere like your apps preferences. To restore it on launch, you can retrieve them after you create your main window in your main() method and use gtk_window_resize and gtk_window_move to restore the position and size.

I hope that helps.
Mayhew
Expert
 
Posts: 303
Joined: Mon Apr 18, 2011 8:02 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 40 guests