Putting ModalPopupExtender in a constant location - c#

I've got a series of ModalPopupExtenders that I'm using to implement popup dialogs on an ASP.NET 2.0 page.
When they popup it's fairly easy to specify the location where they appear using the constructor using X and Y coordinates but I'm unsure how to deal with changes of window size which alters where they should be in cartesian space. I need them to appear relative to some other elements on the page.
I've tried hooking into the onresize javascript function in IE but this is broken and fires whenever a div changes size (problematic really given that i have lots of CollapsiblePanelExtenders in the UI.
Anybody ever done this and have any suggestions how i can get this working?
Edit : This code helps no end in capturing the resize event...
http://blog.stchur.com/2006/09/06/the-ie-resize-bug-revisited/

I've figured out how to do this.
I use onClickClick to display the modal popup after figuring out where to put them by getting the x + y coordinates from a known control from the DOM. Upon resize (from http://blog.stchur.com/2006/09/06/the-ie-resize-bug-revisited/) i've decided to just hide the popups

ModalPopupExtender has a property called RepositionMode for exactly this purpose

Related

Center form during runtime

I've been developing a game. As such, I need to be able to display information that are group accordingly. I've been using a menu system that allows me to utilize 1 form to display different bits of grouped information using the panel control. Using a timer on the form, it automatically changes in size depending on just how much information is displayed, using the currently visible panel as a guide for dimensions.
I have the form's screen position behavior set to Center Screen. This works great.
However, there is a problem. The form is only truly centered when it is the size of the biggest panel - the log in screen - is active, being that it is the first menu a user sees.
My question is, using code, could I get the form to be re-centered during runtime? If so, how would I go about doing so?
You can call the method Form.CenterToScreen
or follow this answer!
StartPosition is set to CenterPosition but my form is not centered

How do I disable user input on a WebView?

I'm having tons of issues trying to integrate Microsoft's WebView in my WinRT application and one of them is the following. I want to display the WebView and its content (which comes from a local offline server but that works like a charm) and I don't want the user to be able to click around ; basically completely disable user input on this WebView.
There is no IsEnabled property on this control so I tried:
Catching the many Pressed-like events and setting the Handled property of the event object to false in each one of the handlers
Catching the GotFocus event of the WebView to set the focus on another control immediately
Putting the WebView in a ContentControl, then set the IsEnabled property of the ContentControl to false
Obviously, none of these workarounds did work so I'm facing a brickwall here. Maybe some of you can help find a solution?
More details if that can help: the web page that is loaded contains an HTML5 canvas where the user can draw things (like in Microsoft Paint). There are also links (ahref). I dont want the user to be able to draw on this canvas, and I don't want them to be able to click on these links as well!
Thanks
Hi you can use a if the content is not animated then you can use a Rectangle instead of the WebView and in the rectangle you use a WebViewBrush, this actually take the webview and render it's content as an image on the rectangle. since it is an image no interaction is available on the rectangle, but if you have animation then you will lose them.
Generally this trick is used to show content onto the webview.

How do i stop the blurring when zooming in on a UIScrollView?

I have been trying to find out how to redraw a view when i have zoomed in on it, i have looked at many examples (mainly native code) but am still struggling to get it fully working.
So let me try and explain what i am attempting....
I have a UIScrollView With a UIView(container) in it this in turn has many views within it each with UITextFields inside, the functionality i am looking for is when a user clicks on any of the view it is zoomed in on and then goes back into place when the user is finished with it which does all actually work fine except for the quality of the zoomed in view is terrible.
I am using a UIScrollViewDelegate but not really sure what to put in the ZoomedEnded function to handle the redraw, I have tried using the CATiledLayer but am not really sure how this is used and i always just end up with a black screen.
There is not much code to show as
svCertScroller.SetZoomScale(2.34f, true);
Works fine and in the UIScrollDelegate event ViewForZoomingInScrollView just returns the view i want zoom in on but i don't have anything in ZoomingEnded event at the moment I have tried loads but nothing even seems to get close.
So any help on what to put inside this event to sharpen up the zoomed in view would be great.
Thanks in advance.
Make the scroll canvas larger and plot the contents at a higher resolution.

Graphical hiccups in C# User Control - Resize obscures components

I'm experiencing difficulty with a custom-made User Control, and my searching on Stack Overflow, MSDN, and Google didn't pop up any troubles quite like the one I'm experiencing.
I have a very simple User Control: It's a label, a text box, and a button, with a SaveFileDialog and a FolderSelectDialog available. The text box and button are anchored Left,Right and Right respectively, with the intent that if the control is resized larger, the text box will enlarge to fill the gap, and the button will stay on the right edge of the control.
The problem I am encountering is that when the control is enlarged, the area to the right of the default width of the control becomes blank space when the project is built and run. The pictures here will illustrate what I mean:
In editor:
Running:
The control is smallish in its design window, but when I add it to a form and widen it, it behaves as intended. However, when I run the form the control was added to, half the control isn't visible.
I suspect that I'm overlooking something fairly straightforward, but I wasn't able to find anything addressing this point in my search. Help would be much appreciated.
My guess is that there is a panel or something that is added to your control and will be brought to front somehow runtime.
from property window's top there's a combo from which you can select all the controls in your User Control.
check if all the controls are what you want.
if you find that panel or anything delete it :)
EDIT:
alright this was not your problem.
now I can only assume that you have set some manual sizes to your user control, i.e. in its constructor. in that case designer will show the correct size of you user control,
now some other place in your code, you have set the user controls size manually again. if the layout is suspended and size changes, I think that the anchored controls' size will not change automatically.
if this is your problem, it is probably hard to find.

How to change position of caret in MSHTML during mouse click?

I have a MSHTML-based control embedded in an application and the ContentEditable mode is used to edit documents inside it. The body of the HTML document initially contains the following lines:
<div></div>
<div id="signature"></div>
The caret is placed at the beginning of the document, that is inside the first DIV element. Now when user clicks with mouse inside the control in a place below the last line, the caret is moved into the second DIV element, as it's the closest one to the point where the user clicked.
I want to move the pointer to the end of the first DIV on the mouse click. Now I have the code to calculate the intended position of the caret as IMarkupPointer and IDisplayPointer. What I need to know is where to intercept the MSHTML event pipeline to do the actual caret move.
I've written code that implements IHTMLEditDesigner and moves the caret using IHTMLCaret.MoveCaretToPointer to the intended position. The problem is that no matter where I intercept the event (PreHandleEvent, PostHandleEvent or PostEditorEventNotify) the caret position is eventually reverted to the default one on single click (but it is not reverted if I hold the left mouse button pressed for a while or if I click with right mouse button).
Use jscript inside of the HTML that you load into the IE control. If you do not know HTML and jscript very well you will find this task very painful.
See these questions for my experience when I tried do so something like this.
Risk of using contentEditable in
IE
Why is ContentEditable
removing “ID” from div
I also had lots of other problem, including have to write resize logic in jscript to get the HTML editor to size along with the WinForm form and having to pass the default form/coontrol colours into the HTML editor so that it looked write then users changed colour schemes on Windows.
Even better just find a HTML editor and load it into the IE control, you will still have to code with standard window colours etc yourself.
There are also 3rd party winforms HTML editors you can use. If possible I think you should buy in a solution as ContentEditable is a lot harder in real life then it look.
A quick google found.
Writer by Lutz Roeder (of Reflector fame)
NetRix by netrixcomponent
Html Editor by Carl Nolan
HTML viewing and editing component for WinForms apps
Have you tried using a winforms timer with a timeout of 0?
When you get the mouse down event start the timer.
Then the MSHTML control will process the event
You will then go back to the windows message loop
All other messages in the message queue will then be process before the timer
Hopefully by now MSHTML has set the default caret position on single click
You can then move the caret position yourself when the timer fires
Have a look with Spy++ to see what events are being sent between the diffent windows in the MSHTML control to get other ideals. The MSHTML control is like no other winforms control and you have to go back to all the trick you used in the days of C and Win32 programming.
Maybe there are separate events for mouseDown mouseUp and mouseClick.
You intercept mouseClick but default behavior gets executed on mouseUp.
Have you tied setting the "focus" to the first div by finding the dom item for it, and calling the setFocus (or whatever it is called) dom method? The caret should move to where the fosus is.
(There are interfaces that MSHTML expose to find dom items and call methods on them. Sorry I don't recall the details of how to do this)
I believe you need to change the SelectStart property and leave the SelectionLength = 0. That will move the caret to a new position.

Categories