Display message box while closing the window by using closing option (X) of the window - flex3

Can anyone help me how to display message/alert box when user clicks Close option (X) of the window in flex ?
Like in html we can handle it by using,
window.onbeforeunload = function(){return "Are you sure you want to Exit";}
Is there anything in Flex similar to "window.onbeforeunload" of HTML which can handle Close option (X) of the window ?
If not, can anyone help me to handle this with sample code.?
In my mxml i have not used any kind of , etc.
My flex screen is opened from a jsp page through a hyper link and i dont want to use any window related tags. It is normal screen with min, max and close option.
Thanks,
Anand.

Use ExternalInterface.addCallback and from JavaScript call the AS function you want to run on close.
However I do not think you can block the browser from closing this way as it would be a security hole.
Another thing to note here is that the code in the function should run fast or you may risk not having it all done before the browser closes.
All clients work should be done before close so a method like this wouldn't be needed.
A more appropriate method would be to create some kind of session for the user and store the data server side as the client works.
Unless of course your are just trying to make some kind of hack app.

Related

How to force a dialog to front?

I would like to display a modal JDialog OVER all standing dialogs
when it is invoked (say) by a function key.
This way I want to display a status of my application regardless
of the pile of dialogs and pop-up's already 'on the air'.
I tried to have the dialog in question 'owned' by the mainframe
and to (Frame)null without success.
The method 'this.toFront()' just before 'this.setVisible(true)'is also without effect.
What am I doing wrong?
Thanks for reading.
;JOOP!
It appears to be: [code]window.setAlwaysOnTop(true)[/code]
;JOOP!

Prevent window from being captured

I'm solving this problem so long an i can't find solution.
I would like to capture a screen but i want to exclude a specific window.
Like capture whole screen but remove an window from it.
Or what i have to set to notepad like styles or something to being captured ?
Thanks
Regarding screen capture, you could hide window/capture/show window using windows api calls. Second question I did not understand.

How to simulate mouse clicks?

I was wondering how to create a sort of auto clicker using VB.NET.
I would basicly have the click coordinates pre-defined and the clicks, which would have to be separated by delays I guess since I want more than one to happen periodically, would happen outside of the application window (I read this envolves extra system hooks?).
The only code I have been able to find is related to clicks on the application window, which is not what I am looking for.
In short: I want to click a button on the app window, which would initiate a number of clicks on certain pre-defined screen coordinates.
Thanks in advance :)
See this discussion on social.msdn: Simulate a mouse click in a program.
Uses winapi: SetCursorPos, GetCursorPos and mouse_event.
I believe you need to P/Invoke into Windows to accomplish this.
Have a look at the SendInput function.
If you are using automate the program,that program have some tabindex in order to relevant control.then you can use;
SendKeys.Send("{TAB}");
SendKeys.Send("{ENTER}");
it is more accurate on desktop application

Show webpage with no URL bar, navigation bar, etc

I'm working on a vb.net web application and want to make it to where when someone puts in a url into the browser or when someone clicks on a shortcut, a new browser window is opened but there is no back or forward, no refresh, no navigation bar, etc. Does anyone know how to do this or if it's even possible? I just want the browser shell essentially. Thanks.
I would advice against this - the browser is the users domain, don't mess with it. Are there any particular reasons for your choice of functionality?
Any ways to make this possible will be based on Javascript, and this can always be disabled by the user.
You can do this in javascript code behind cannot open new browser windows. Take a look here.
you can do this with javascript using the window.open() method.

How can I navigate to different webpages in the same MSIE window in VB.NET

I have code that opens a new window but I want to be able to edit the same one.
System.Diagnostics.Process.Start("iexplore.exe", "http://www.live.com")
I'm not sure exactly but a good pointer to start off might be to get the handle of the window you're interested in:
http://www.pocketpcdn.com/articles/dotnetcf_hwnd.html
And then separately investigate what interop messages you can send to IE to change the URL in tab X
In order of increasing difficulty and increased control/power:
Send input text to your IE process. Alt-D to focus on the navigation bar, then the URL, then ENTER.
Use MSAA to find the navigation bar and send it text, as above.
Use MSAA to get IHTMLDocument access to the browser, and then programmatically drive the browser with that, and the related interfaces.
I don't know your exact scenario, but if you can host your own instance of MSHTML, or a WebBrowser control, it will make it a lot easier to get the interfaces and do the manipulations mentioned in #3 above; doing that stuff cross-process is fraught with peril.
I just did a web search and turned up a WatiN tool that apparently wraps a lot of this work; perhaps it would be useful for you.
If you are using 2008 there is a feature where you could create a second form and then add a Webbrowser control
the page could then be called by
myForm.show
The page could then be changed with the
Webbrowser1.Url = New Uri("http://www.google.com")
Use the following code:
System.Diagnostics.Process.Start("http://www.live.com")
That is: do not invoke iexplore.exe directly – just let the system figure out which default browser to open.
This may yield two behaviours:
Either it opens a new tab in an existing Internet Explorer window,
or it creates a new window.
The important point is that this depends on a preference that can be controlled within the Internet Explorer application. If a new window opens, then this is the setting chosen by the user – do not try to override it: overriding the user’s preferences is considered bad manners.
If the users don’t want a new window opened, they can simply change that in their Internet Explorer preferences.