Creating a sub window
BlitzMax Forums/Brucey's Modules/Creating a sub window
| ||
As the title says, I want to create a sub window under the main window, to add a 'pos' after you push a button in the tool bar it'll pop up.. heres my code so far... after i push the button nothing happens though... any ideas? heres the chunk of code in question... |
| ||
A wxDialog might be a better choice? You might have to also pass wxSTAY_ON_TOP in the dialog styles. |
| ||
Arent dialog boxes those little notifiers that give you Yes, No, or Cancel, Retry ect? I'm looking for like a sub window. There is mini window things, i saw the example, looks like what i might need. But wouldnt I at least get an error with the above code? I think i'm connecting the clicking event wrong? But I cant find a list of event commands, Button clicked seems the closest i can find for the tool bar.. Any ideas? |
| ||
I'm not clear as to what your intention is. What do you mean by "pop up"? Do you want the parent window to lose focus and stop responding to input while the child is in play? |
| ||
"Do you want the parent window to lose focus and stop responding to input while the child is in play?" Yes, like a little control window, try this: open any options panel on your internet browser; notice how a sub window comes up with all the additional options ect.. (If your using IE go tools -> internet options) I want a "Sub window" (just what i call them) to pop up after you hit the 'add POS' button, that sub window will have some fields and options on it, then a 'OK' button. After you hit OK that window will close and the info you provided will be applied somewhere on the main window. make sense? |
| ||
Sounds like a modal wxDialog to me :-) Perhaps connect to wxEVT_COMMAND_TOOL_CLICKED? |
| ||
that'll do it, thanks, now just to implement the dialog box... :) |
| ||
Hmm this is creating an error...Function CreateAddPOSWindow(event:wxEvent) Local Addpos:wxDialog = New wxDialog.Create_(Self, , "Add POS", , , 500, 300) End Function Saying the my WxFrame is not a WxWindow... Any ideas? |
| ||
My guess it's the "Self". You need to pass a correct parent handle. If you posted code I could run it'd be easier ;-) |
| ||
complete code: Giving me a compilation error, and I know why: It wants wxwindow not wxframe, but i don't know how to fix that. |
| ||
Local Addpos:wxDialog = New wxDialog.Create_(Null,wxID_ANY , "Add POS",200,200 , 500, 300, wxSTAY_ON_TOP| wxDEFAULT_DIALOG_STYLE) Addpos.ShowModal() ? |
| ||
I don't know what you did, but it works now, thanks. |
| ||
That was a bit of a cheat. You could have created the dialog within myFrame's OnInit() - passing Self as the parent window and then just called ShowModal() on the button click. [edit] Sorry, long overdue for lunch :-) Local Addpos:wxDialog = New wxDialog.Create_(myFrame(event.parent),wxID_ANY , "Add POS",200,200 , 500, 300, wxDEFAULT_DIALOG_STYLE) Addpos.ShowModal() Is the more standard alternative |
| ||
How would i create it in the Oninit() then ShowModal it on the CreateAddPOSWindow function? because i tried it and it doesnt work. I'd like to be able to do this so i can just end it from a different function, called by a button click on the window.. code: Thanks for all the help so far. |
| ||
If you create a default wxOK button, EndModal() is called implicitly. |
| ||
Hey... toolbars and dialogs in your first attempt ;-) After creating the "Addpos" dialog, you might find this is useful too: Addpos.Center(wxBOTH) It centers the dialog nicely. Remember too, that if your dialog is going to be reasonably complicated, you could Extend from wxDialog with your own Type, and add control creation into its own OnInit() method. Otherwise you end up with lots of control creation in one place - I'm for keeping things grouped together :-p |
| ||
Thanks for the help, couple more questions: 1)I'm confused, about connections. For ID's I can take any number and my my own ID correct? Then why are there wxID's ? if you have more then one button with a WX id won't it get them mixed up? Also, if i replace wxID_ok with something else, it won't close the dialog... odd. 2)do you know if WxWidgets takes XP style manifests? so I can make the application look windows XP ish? 3) Does this have group boxes? for an example, fire up IE, and go to tools -> internet options -> security and look at the little box with the label "Security level for this zone", thats what I'm looking for. |
| ||
1)Yes you can use your own ID, however if your also using wxID's best make sure none of your ID's are the same as any wxID's that your using. EDIT: make sure you change the id on both the create function for the object and the connect function. 2)You should just be able to put it in the .exe with Resource Hacker (wxWidgets might have it built in, not sure.) 3)not sure |
| ||
1) If you are worried about number clashes, start yours from wxID_HIGHEST. wxID_xxxx's are special-case id's that when used trigger certain functionality. It might be to tell Mac to put a menu in a platform-specific place, or to make a button work in a certain way. 2) According to http://www.wxwidgets.org/docs/faqmsw.htm#winxp yes. But I dunno much about Windows and manifests and such like so you might have to experiment a bit with it. 3) there's a wxStaticBox and wxStaticBoxSizer. The sizer is probably the best to work with, as it takes care of a lot of the niggly stuff. For example, wxStaticBox isn't meant to be used as a parent/container. |
| ||
@Also, if i replace wxID_ok with something else, it won't close the dialog... odd. In that case, you can use SetAffirmativeId() for OK and SetEscapeId() for CANCEL on your custom buttons. |
| ||
Edit: Ignore me i'm an idiot.. :D forgot to import the mods.. |
| ||
Alright, now i'm trying to add tabbers, based on the basic_notebook example. Now i'm not 100% of this but i think a notebook is a tabber? (for an example on what i call a tabber see your Bmax IDE and see the top "Help" tabber + whatever files you have open) anyways, here's my code, i see no tabber at the moment.. trying to figure this out. see " 'body " under the MainWindow type, thats where i'm trying.. Thanks in advance |
| ||
You've got no positioning code for the notebook in there. I can see it in osx - it's in the top left corner. Yes notebook is a tabber. You may want to put a large base panel on your window as your very first object. wxWidgets manuals often recommend this as a way of avoiding object positioning issues. |
| ||
but what do i change position on? the notebook or the panel? also the basic_notebook example doesnt include position code. and it looks fine |
| ||
Method Create:wxNotebook(parent:wxWindow, id:Int, x:Int = -1, y:Int = -1, w:Int = -1, h:Int = -1, style:Int = 0) Try filling in x,y,w,h The sample is probably using sizers. |
| ||
Thanks |