Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Is it possible to capture the event for a close window?

Author
Message
Scraggle
Moderator
23
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 28th Aug 2010 14:56
I'm sure I could have answered this myself a while ago but having been away from DBP for 2 years I am a bit rusty.
I have created a software tool and I want to be able to write to a file when the user exits so that I can store the positions of windows, panels etc.

If the user selects File->Exit then I can do what I want.
I know I can also disable the escape key then react when the user presses the escape key.
However, if the user clicks the close button there is nothing I can do about it.
I know I could get around the issue completely by making the software full screen but I would really rather keep it windowed.

Any suggestions?



Blobby 101
20
Years of Service
User Offline
Joined: 17th Jun 2006
Location: England, UK
Posted: 28th Aug 2010 16:45
I had this problem with a chat program release I was working on - The only solution I found was to disable the window borders (including the close button) and just add sort of "fake" close and minimise buttons and to the application and make my own titlebar then handel it all manually in the program.

Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 28th Aug 2010 18:13
Alternatively you could use BBB GUI and turn control over the window to it. It has a very easy way to detect if the window was closed.


Guns, cinematics, stealth, items and more!
Thebeely
21
Years of Service
User Offline
Joined: 4th May 2005
Location: Croatia
Posted: 29th Aug 2010 14:48
Or BlueGUI.
Scraggle
Moderator
23
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 29th Aug 2010 19:14
Actually, I am using BlueGui but I don't see how I can use that to capture the close event of the DBP window ... prey tell.



Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 29th Aug 2010 21:03
IanM's plugins let you hook into the windows message loop directly so you can catch and filter WM_CLOSE messages, and I think with BlueGUI you can turn the main window into a gadget which will have a similar effect.

[b]
Scraggle
Moderator
23
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 29th Aug 2010 23:26
Cheers, Disggsey, I'll give both methods a try



=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 29th Aug 2010 23:49
I prefer the IanM Matrix 1 plug in method.

I have had issues using main=createGadgetFromWindow(mainWindow()) method, It changes something about the way BlueGUI handles events, particually drop down menus.

BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 30th Aug 2010 00:03
You could also just save the data periodically, or whenever the user moves windows around, which would take care of any type of exit, even crashes, Alt+F4, or shutdown.


Latest progress: Fog of War implemented; frustrated by pathfinding >.>
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 30th Aug 2010 14:04
I haven't done this kind of thing for a while so the details are a bit sketchy in my mind but you could subclass the window using a dll; passing the information back and forth through memblock pointers.

You set up your own wndproc in the dll, and capture the close event from there.

Another way, and to avoid the subclassing, is to create a dll that doesn't necessarily do anything (it can if you want) accept maybe record the window information you want to save, and in DLLMain, you can use a switch case to DLL_PROCESS_DETACH when the window closes and have your info write to disk or run any other close down routines.

Enjoy your day.

Login to post a reply

Server time is: 2026-07-23 12:09:54
Your offset time is: 2026-07-23 12:09:54