Window refresh After Other Window close - powerbuilder

How can I refresh a window when clicking the close button of a other window?
The other window is a Response Window.
I use PowerBuilder 12.5

The best way is to pass a reference into the response window for the “other window” (if you’re already passing in a parameter, you can pass in multiple parameters in a custom powerobject), store it in an instance variable, then fire off a “refresh” event (iw_OtherWindow.TriggerEvent()) on the other window at an appropriate time during the close logic of your response window.
Good luck.

Try to check the valid status of refresh required window in close query event of that closing window.
If the valid status is true then do the refresh code.
Best of luck.

Related

Simulate window main while in Response - Powerbuilder

Is it possible to simulate window main while window response is active? I want my code in window main running.
It sounds like you need a popup window instead of a response window. Response windows are modal and will halt the execution of any code in your main window.
You can do this by passing a reference to your main window when you open the response window. See the OpenWithParm function in the help. This is not very good from an object-oriented perspective because in PowerBuilder all of the controls and events in the window are public. It would be best to put the code you want to run in a non-visual object that the window uses and pass a reference to that object.

MFC: Best place to prevent a window from re-appearing from a Restore operation

When my application is minimized, and the application programmatically closes a child window, the state of the child window between my framework and MFC goes out of sync because MFC will not send a WM_SHOWWINDOW message when the application is minimized. I noticed that Qt had the same problem: https://codereview.qt-project.org/#/c/93410/
Things that I have tried:
Override OnShowWindow() -- if the states are out of sync, then I alter the BOOL parameter before passing it to the CDialog::OnShowWindow. But doing so does nothing. It is as if the BOOL parameter given to the override is read-only.
Handle WM_SHOWWINDOW in PreTranslateMessage -- this does not work because WM_SHOWWINDOW does not appear here.
I know I can check SW_PARENTOPENING to know when to look for out-of-sync problems and handle it, but I just don't know where is the best place to do it.
My current solution is to override OnShowWindow, check for SW_PARENTOPENING, then post a SW_HIDE. It works, but it feels like a waste because I should be able to prevent it from restoring entirely rather than defer it.
Summary:
Basically, I am just programmatically closing a window, say from a timer call, or user's remote command, or whatever, while the main application is minimized. The dialog will be temporarily hidden when minimized (the MFC framework will automatically call ShowWindow(SW_HIDE) but with an internal flag to re-open when the app is restored). If my program sends ShowWindow(SW_HIDE) now, this call will not be registered, and the window will be re-opened by MFC when the app is maximized. To my user, he/she has closed the window remotely and does not expect the window to re-appear, so I need to re-call my ignored ShowWindow(SW_HIDE) somehow when restoring the main app.

Can't focus from main window after closing dialog from other thread

I create a new CWindThread in CWinApp::InitInstance(). In that thread, I create a dialog (for displaying a progress bar in that dialog).
After finishing InitInstance(), I close the dialog by calling DestroyWindow() from the dialog, but the application is loosing focus from main window.
I used AfxGetMainWnd()->SetActiveWindow(); to set focus for main window but it is not working.
How can I return the focus to the main window after closing the dialog?
There is no real good way to do that. The focus is set per thread. So there is no "focus" over all windows.
The only chance you have is to set the new foreground window, that belongs to the other thread with SetForegorundWindow. From within the same application this should work without restrictions.
If it doesn't work you need to "synch" both message queues. This is done by AttachThreadInput. If both messages queue are already attached, than there is no problem with settings the focus directly. But the behaviour of the application will change... Please read the docs, of the functions I linked too.
When a modal popup window is displayed, the reason a user cannot interact with the owner window is that it is disabled. When the modal window is destroyed, care must be taken to re-enable the owner window BEFORE destroying the popup as windows cannot activate a disabled window. This is the usual cause of popup windows re-activating the wrong window.

tinyMce function to determine if popup is already open

With tinyMce, I've got onclick code to open a plugin using this:
ed.windowManager.open(...)
Right now, it will open a 2nd, 3rd, etc. instance of this plugin window each time I click the target.
Instead, I want the onclick code to ignore the click if the window is already open. How can I detect the open window.
Here's the solution I'm going with:
I seem to have confirmed:
-- that windowManager.open() does not return a reference to the window the same way that window.open() does
-- windowManager does not have a built-in way to limit the number of instances that can be opened.
But it does have a way to add an onClose function to the plugin window:
ed.windowManager.onClose.add(function() {alert('Closing!');});
So I'll be using a variable in the onClick code to keep track of whether the popup window has been opened and closed. The onClose function will mark that variable as closed

How to get the handle of a Vista style Open/SaveDialog?

I'd like to get the window handle of a new vista-style Open/SaveDialog opened by my Delphi application.
It was possible with the old style dialog by parsing OnShow, but with the new style dialog there is no such event.
Is there a possibility maybe to iterate through all window handles in Windows and get it that way?
Thanks!
Edit: I know that OpenDialog.Handle will return the handle, but only when the dialog is visible (otherwise it's 0). I'd need an event to catch the Handle straight after showing the dialog (without any user action, ie.: select an item in the dialog, changing the file type, etc.).
I'd like to get the window handle of a new vista-style Open/SaveDialog opened by my Delphi application.
This is available through the dialog's Handle property.
Probably the easiest way to catch the event of the dialog showing is to use a CBT hook that you set immediately before showing the dialog, and remove as soon as it closes.
TOpenDialog has an OnShow event which fires just after dialog is shown so you can use to get the OpenDialog.Handle since the handle is already set at that time.
EDIT: After some pepole pointed out that using of OnShow event changes the dialogs apperance I tested this out and can confirm that using of OnShow event realy does change the dialogs aperance.

Resources