I'm constructing a UI using wxWidgets.
In my GUI, I generate a window (wxFrame class) which is accessible through pushing a bitmap button. In that window, I also perform some tasks, again pushing some bitmap buttons and diabling them etc. But I can't close and reopen that window with the state saved. I always have to re-initialize it, and this is very impractical.
How can I save the state of my window? I checked the internet, it's suggested to use wxPersistent class but this class is missing in my wxWidgets.
Thank you for any help,
Best Regards.
Instead of destroying the window every time, you can just hide it with the wxWindow::Show() member function, passing false as the argument, when you receive a wxCloseEvent. You then veto the wxCloseEvent to prevent WxWidgets from destroying your window:
// In your close handler:
if(evt.CanVeto()) // Where evt is a wxCloseEvent
{
Show(false); // Hide window
evt.Veto(); // Prevent window destruction
}
This should remove it from the screen, but all the initialized parts should still be there. If you need to show it again, call the Show() method again with true.
Related
I am new to coded UI, is it good practice to initialize Browser Window in each method of test case. For example i have two methods in my test case, I am trying to find control in each method, for that i write browser window in each method, can i write like that.
I don't see an issue with that approach.
Are you trying to reduce code/setup statements?
It really depends, you could have a test class with many test methods. however have a method attributed with ClassInitialize to launch the browser one time (and set the option to not destroy the window after each test) and keep reusing the same window. Then, possibly, have a method to close the window attributed with ClassCleanup.
Then in a test, you should only potentially need to use the NavigateTo method at the start of your tests to be on the right page.
Do you have test requirements dealing with sessions or saved data?
You may need to actively close down a window after a test and programmatically empty caches. Then in this aspect, I would be using BrowserWindow.Launch typically and letting CodedUi automatically destroy the window if i forgot to call close on the window.
I have a TreeViewer inside a jface Dialog window.
The treeViewer needs to be populated with a large number of items with the setInput().And so it takes quite a bit of time for the tree to show, each time the dialog window is opened.
I want to know if there is any way to instantiate and save the treeViewer beforehand, so that the when the dialog window is opened, the treeViewer is just added to the dialog window and it is instantly visible.
I don't recall ever seeing anything try to do this. Creating the tree has to be done in the UI thread so this would still be difficult to do without stalling the UI.
There are various things you can do:
The model objects that the content provider provides can be built at any time since they are not UI objects. So you could get these in the background before the dialog is displayed.
You can use a virtual tree using the SWT.VIRTUAL style and an ILazyTreeContentProvider to delay building parts of the tree until they are needed.
If the code is in an Eclipse plugin you can use org.eclipse.ui.progress.DeferredTreeContentManager to defer building parts of the tree (there isn't much documentation on this method).
In my application there are a lots of dialogs being opened and closed all the time. The dialogs are non-modal.
In order to save some performace, we are "recycling" some of the more complicated controls. When one dialog is closed, the controls are not destroyed, but their pointers are stored in an array so that they can be reused when another dialog is opened.
The problem is that after the control is positioned in the new dialog, it does not receive all the messages. For instance the message WM_DRAWITEM (the control is derived from CListCtrl) is not being sent anymore. The WM_LBUTTONDOWN on the other hand is still arriving. It is as if the control does not know its class anymore. The NC area (border and list header) is being painted correctly.
Did anyone have similar problems? What could be wrong? Can the controls be "detached" and "reattached" in this way at all?
For CListCtrl to respond to WM_DRAWITEM image it is needed it has the LVS_OWNERDRAWFIXED style. Are you sure you have it set?
And from http://msdn.microsoft.com/en-us/library/windows/desktop/bb774739(v=vs.85).aspx , it seems it only occurs if it is in Report view (Seems strange to me!).
I have a bunch of control objects (TextBoxes, to be precise) that get injected into my code using the #FXML annotation during the FXML load.
I would like to save the states of these controls, specifically the text values, when the user closes the Scene by clicking the close box on the title bar.
However, when I trap the CloseRequest event in an OnCloseRequest handler I find that the values of the control variables are null (the original injection works, so this is something that happens in between the loading of the FXML and the calling of OnCloseRequest).
Can anyone explain this behavior and/or suggest how I can get the functionality that I want?
TIA
onCloseRequest is
Called when there is an external request to close this Window. ...
(from Javadoc). One of the meanings of "external request" is when you close the window through OS native window close button. The closeRequest event is not triggered through the programmatic stage.close() or stage.hide() calls. So consider to handle onHiding or onHidden events.
Otherwise post your OnCloseRequest handler code.
I load a single instance of a window on php-gtk, I have a button named "Cancel" that hide(); the window, so when the window is needed again I just show();.
But when I click on the close button instead of the cancel button the window is destroyed. Even when I redirect the event (I'm not sure if i'm doing it right) it calls the first(just hide() function) and then the destroy method.
Any idea?
PD: I wouldn't want to destroy and recreate the windows because of php's crappy garbage collector and to be able to maintain previous data without having to refill the whole window(after all is supposed to be a desktop app).
Following the advice here: delete-event.
I changed my code to return TRUE:
function on_multipleCancelButton_activate()
{
global $GladeMultiple;
$MultipleWindow = $GladeMultiple->get_widget('multipleWindow');
$MultipleWindow->hide();
return TRUE;
}
On the GTK designer I linked the delete-event to this function.