Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi my application is of type Silverlight. i want to trigger when user clicks on the border of the browser. for this purpose, i used this method:
C#
public MainPage()
{
    InitializeComponent();
    bool bResult = System.Windows.Browser.HtmlPage.Window.AttachEvent("onmousedown", new EventHandler(this.eventHandler));
}

private void eventHandler(object sender, EventArgs e)
{
    ...
}

but the eventHandler is not called. why?
ps1. if i change "onmousedown" to "onresize" it's called.
ps2. bResult is true in both cases.
Posted
Updated 30-Apr-12 1:40am
v2
Comments
Sergey Alexandrovich Kryukov 30-Apr-12 18:37pm    
Why would you contaminate the site with all those numbers in the question titles? If you want, leave them in your own records, with your questions' URLs.
--SA

1 solution

Clicking on the border will not generate an onmousedown event. The border does not belong to browser windows client area so no event will be generated. If you resize the window though, the client area will also change and thus the container for the root element resizes which triggers an onresize event.

Hope that clears it up a bit!

Cheers!
 
Share this answer
 
Comments
ilostmyid2 30-Apr-12 8:20am    
so how can i grab the mouse events belong to the non-client area parts of the browser?
indeed i need to know when use release the left mouse button (mouse up). by this method i want to know when resize is done.
Manfred Rudolf Bihy 30-Apr-12 11:58am    
1. Grabbing non client area mouseevents is IMHO impossible for browser based applications.
2. I'm not sure when a resize event is acutally fired. If the resize is only fired after the mouse button has been released then you'd also have the end of your resize operation. If the resize is being fired continually there is no way I know of to tell that the user finally stopped resizing the window by releasing the mouse button.
ilostmyid2 1-May-12 2:56am    
thank u for ur answer
resize is continually generated.
the fact is that the event might be raised, because we've ResizeEnd in a form application and essentially all windows receive WM_EXITSIZEMOVE and this could not be neglected. this is the fault of MS that it doesn't capture the message and dispatch it throw Silverlight.
but, since the message EXISTS, there must be a way or workaround to write an unmanaged code to capture it.
any suggestion?
Sergey Alexandrovich Kryukov 30-Apr-12 18:35pm    
That is correct, a 5.
--SA
Manfred Rudolf Bihy 2-May-12 7:00am    
Thanks SA!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900