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 / A question about creating a modal window

Author
Message
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 3rd Aug 2010 02:22
Hi Guys,

I'm trying to create some custom requesters for an application I'm developing.

I have created a window, a panel and some gadgets using BlueGUI and made myself a halfway decent looking requester; but it's not modal.

I did a search for "Modal" (some of the results made me chuckle, lol) and found this helpful snippet from RobK



But sadly, it's not "modal" enough, it still allows for Tabs and Menu's of the main window to operate. With a proper modal dialogue box, any clicking of the main window just results in a windows ding and a little flash of the dialogue border.

Does anyone have any other suggestions as to what I should try?

Thanks in advance

=PRoF=

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Aug 2010 11:05
Have you tried using "SetGadgetEnabled"?

=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 3rd Aug 2010 11:54 Edited at: 3rd Aug 2010 12:22
Hmm, I've had some success with that Baxslash.



and then



Makes the requester window act exactly as I want it too, but

(and I feel it is quite a big but)

when I createGadgetFromWindow() it stops the drop down menu's from working.

Altho I quite possibly have missed something somewhere.


>EDIT<

N3wton also seemed to have the same problem with making a gadget from the DBP window stopping the menus working, in >this< thread, to which humanoid (somewhat mystically) replied...

Quote: "@N3wton: menu to close focus for some reason ... I try to explain the problem"


Which doesn't help me much tbh, lol

I shall continue searching

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Aug 2010 12:32
Maybe you could use "SET ACTIVE WINDOW Window Handle" from IanM's Matrix Utils?

=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 3rd Aug 2010 13:06 Edited at: 3rd Aug 2010 13:06
I think I've sorted it! (Although have prolly just jinxed myself :/)

If you don't use the createGadgetFromWindow() command, then you must check evenType() against 0x400+1 for a menuClick, where as if you have gadgetified the DBPro window, then menuClick register as 0x111

Ok, so Modal requesters are go! Just need to work out how to accept input from them now

Mugen Wizardry
User Banned
Posted: 3rd Aug 2010 19:18
If is maximised(GET DBPRO WINDOW()) or is fullscreen()=0
set active window GET DBPRO WINDOW()
Endif

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 3rd Aug 2010 20:06
*sigh*

I spoke to soon

Although it made Modal windows possible, using makeGadgetFromWindow() and changing the value of menu_click has broken the way the interface works.

Sometimes when you click on the buttons, it registers as a menu item being selected. This isn't v.helpful at all, lol.



Here is my BlueGUI control code, which I've pretty much copy and pasted from the help files; but If I'm doing something wrong can someone please give me a poke in the right direction?

Thanks again

tiresius
23
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 3rd Aug 2010 20:59 Edited at: 3rd Aug 2010 21:00
I have modal windows in my editor and I'll try to find out how I do it and post some snippets. I think I just use it for an "About" popup now but I'll look into it.

It has to do with filtering out events that are outside the popup when my editor is in a "modal state". I haven't worked in that area of the code for a while so I don't have pseudo code off the top of my head.

I know I don't have a ding and a flash of the border.


A 3D marble platformer using Newton physics.
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 3rd Aug 2010 21:15
@Tiresius:

Thank you, I'm interested to see how you have done it.

I have got a Modal window running successfully now (with ding & flash ) but my new problem is that in doing so I have broken the UI controls (as detailed above)

Have you ever managed to get buttons/menu's working in conjunction to using the makeGadgetFromWindow() command? The more I mess with this, the more I think its the same problem that stops me completing *any* project I start using BlueGUI.

tiresius
23
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 4th Aug 2010 07:02 Edited at: 4th Aug 2010 07:11
I checked and while I do have modal popup, the user is able to click menus and see them, but they do nothing. User can also minimize the main window, but can't close it until the modal is closed.

And I do use createGadgetFromWindow() this way without menu/gadget problems:
resetMainWindow
WinGadgets.mainWin = createGadgetFromWindow(mainWindow())

Warning: I'm going to throw a lot of code at you, sorry.

My main loop once all the gadgets are set up:


My process event function with lots of code removed:


My processMenuClick function with lots of code removed:


And some modal functions...


Hope this helps!


A 3D marble platformer using Newton physics.
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 4th Aug 2010 13:30
You can disable the main window without turning it into a gadget



[b]
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 4th Aug 2010 14:26
@Diggsey:
I am blown away by the simple elegance of that snippet, lol; It works perfectly. Thank you ever so much

@Tiresius:
Thank you for the code, I'm going to try and adapt some of it to improve upon mine. I use the simpler gadgetClicked() method for all but the menu section, but I can see how your method would work better for larger projects.


I'm well impressed at the fact that I now have an almost 100% functional windows UI The only thing I need to be able to do is to "catch" the WM_CLOSE thing, so I can put in a "Are you sure?" requester before exiting the program.

(Although without using the createGadgetFromWindow command)

I have a snippet to try using IanM's set message callback command from the Matrix1.

Wish me luck, lol; and thanks again for the help guys

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Aug 2010 14:30
Quote: "The only thing I need to be able to do is to "catch" the WM_CLOSE thing, so I can put in a "Are you sure?" requester before exiting the program."

Why not use "questionmessage"?

=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 4th Aug 2010 14:48
@Baxslash:
No no, I mean so when someone presses the "X" in the top right corner of the window; I can pop up a requester asking if they're sure, and allowing me to clean up properly rather than just closing the program.

Mugen Wizardry
User Banned
Posted: 4th Aug 2010 14:50
use exit prompt

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 4th Aug 2010 15:03
@Mugen Wizardry:

Maybe I made too much of an emphasis on the requester, what I am trying to do is something along the lines of this...



=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 4th Aug 2010 15:20
@Everyone who helped:

I've done it It's all working so far, now all I need to do is finish the layout of the UI and tie all the gadgets up to the various things they are supposed to do.

For those who are interested, This is the code snippet from the Matrix1 board exampling the use of set message callback to catch WM_Close messages.



Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 4th Aug 2010 15:30
Btw, if you are running in windowed mode you may find this code snippet helpful:



It will prevent any stretching caused by resizing the window, and it won't even cause flicker when resizing

[b]
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Aug 2010 15:36
Compiler doesn't recognise "set message callback"...

=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 4th Aug 2010 15:54 Edited at: 4th Aug 2010 15:57
@Baxslash
Its a newer command from IanM's Matrix1 plugin set

@Diggsey:
I've disabled resizing and the maximise button using the BlueGUI commands added by Humanoid. but thank you

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Aug 2010 15:59
Quote: "Its a newer command from IanM's Matrix1 plugin set"

...oooh, didn't realise I was out of date!!

Cool!!

Login to post a reply

Server time is: 2026-07-25 08:29:37
Your offset time is: 2026-07-25 08:29:37