|
There are a couple of ways of doing this, the easiest/most reliable I've found is to recreate the submission form with the same target and fill the fields there, and then autosubmit the form. This can be totally invisible to the user I've never done this using .NET but it can be done with static HTML and some basic javascript so doing it with .NET should be a doddle.
I have come across a couple of secure sites that wouldn't play ball with this but they're rare.
|
|
|
|
|
can u help me out with the java scripts for it????
|
|
|
|
|
This is a very simple example...
Notice there is only one inline javascript function that submits the form, the rest is plain html.
<html>
<head>
</head>
<body>
<!--
<form name="elementNameForm" action="targetPage.html" method="post">
<input type="hidden" name="elementNameUserName" value="userName" />
<input type="hidden" name="elementNamePassword" value="password" />
<!--
<input type="hidden" name="elementNameSubmitButton" value="submitText" />
</form>
<script language="javascript" type="text/javascript">
<!--
document.forms[0].submit();
</script>
</body>
</html>
|
|
|
|
|
I have a panel (win forms) that has scroll bars, the problem is that when the scroll button on the mouse is scrolled it is meant to just execute x, instead it is executing x and scrolling vertically!
How do I disable mouse scrolling only for the scroll panel and still capture the mouse scroll?
If I have confused you:
I would like the following:
1:Execute x command when mouse is scrolled
What it is doing (the problem):
1:Execute x command when mouse is scrolled
2:Scrolling vertically (DO NOT WANT)
Thanks
|
|
|
|
|
This works to disable mousewheel scroll for a listbox, so I'm guessing it may work for a panel as well.
listBox1.MouseWheel += new MouseEventHandler(listBox1_MouseWheel);
...
void listBox1_MouseWheel(object sender, MouseEventArgs e)
{
(e as HandledMouseEventArgs).Handled = true;
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks, I tried it but it did help
Still scrolls + executes instead of just execute.
MapRender.MouseWheel += MapRender_MouseWheel;
...
void MapRender_MouseWheel(object sender, MouseEventArgs e)
{
if (e.Delta > 0)
_presenter.IncreaseTileSize();
else _presenter.DecreaseTileSize();
(e as HandledMouseEventArgs).Handled = true;
}
|
|
|
|
|
To avoid confusing the user, you should not do that... The best thing to do would be to uses a modifier key (like Shift + Mouse wheel) for your action.
Anyway, you would need to mark the event as handled to avoid default execution. For that, you probably have to handle to WM_MOUSEWHEEL message... or uses something else than a scrollable panel.
One possibility would be have have a regular panel and scrollbar controls and handle yourself the scrollbar.
Another possibility might be to have a control that handle the mouse wheel inside the panel and require the user to be over that control for you special function. It could then works similary to nested panel inside Internet Explorer... The inner most one would handle the event.
Philippe Mori
|
|
|
|
|
Thanks for the reply, I have already tried handling WM_MOUSEWHEEL messages but does not work...
Philippe Mori wrote: The best thing to do would be to uses a modifier key (like Shift + Mouse wheel) for your action.
This scenario seems like it would also fit the same problem im currently facing?
I would still have to sent the MouseWheel event and then check...
Such as:
MapRender.MouseWheel += MapRender_MouseWheel;
MapRender.KeyDown += MapRender_KeyDown;
MapRender.KeyUp += MapRender_KeyUp;
...
void MapRender_KeyUp(object sender, KeyEventArgs e)
{
if(_current == e.KeyCode)
{
_current = Keys.None;
}
}
private Keys _current = Keys.None;
void MapRender_KeyDown(object sender, KeyEventArgs e)
{
_current = e.KeyCode;
}
void MapRender_MouseWheel(object sender, MouseEventArgs e)
{
if(_current != Keys.ControlKey) return;
if (e.Delta > 0)
_presenter.IncreaseTileSize();
else _presenter.DecreaseTileSize();
}
Still have to pass through the same event handler which calls the scroll bar to change...?
|
|
|
|
|
You don't really have to hook keyboard events as it it possible to check the current keyboard state at the time MouseWheel is called.
But effectively, you still have to prevent the event...
Maybe one possibility would be to derive a control from the panel and override OnMouseWheel method.
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onmousewheel.aspx
Otherwise, the trick to uses a non scrollable panel and manual scrollbar controls would works...
Also, you have to be carefull about which control has the focus... Typically the inner control (the one inside the scrollable panel) should be focusable and handle the mouse wheel.
Philippe Mori
|
|
|
|
|
Thanks for your help Gave me a dirty idea...
I have solved my problem in the form of (what I call) a hack
The main form receives and handles the "MouseScroll" so the map render panel does not need to.
Now for the hack part:
void MapRender_MouseEnter(object sender, EventArgs e)
{
this.ActiveControl = null;
}
When the map is entered instead of it becoming the focused form (thus any scroll will screw up the vertical scroll), nothing is - yet the scroll behaviour still works!
Thanks for your help, I know my solution sucks but the map render is too tightly coupled for me to apply any radical changes to the control
|
|
|
|
|
I think you should keep in mind what one of the other posters said, Users expect the default behavior of a mouse wheel to handle a scroll in any application they use. Taking that away to make the worldwide default behavior do something different is annoying and can put users off especially if you do more things of that nature.
Users as a rule do NOT like to relearn how things work.
Programming is a race between programmers trying to build bigger and better idiot proof programs, and the universe trying to build bigger and better idiots, so far... the universe is winning.
|
|
|
|
|
Good advice and I would generally follow such advice however I am quite familiar with accessibility, the app is just a small tool for me and a friend
We needed a quick way to change the selection size fast, the mouse scroll felt like the best candidate for such operation.
Otherwise key presses or other controls will be used for the same affect, but surely wont be as seamless?
|
|
|
|
|
hello guys... I want to learn the basics of WCF apps. Just to host a small service in localhost (IIS) and then want to consume that service in client. I am still unable to find the right tutorial. Any help? thnx
|
|
|
|
|
Some reading here[^] should help you out.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Why do I feel that beginners are Slaughtered at msdn?
|
|
|
|
|
Try the second and third links here[^].
Always: Google first
CodeProject next
MSDN - when all else fails.
The best things in life are not things.
|
|
|
|
|
That's because MSDN is reference material, and not learning material
Very good for finding out the specifics of a function; not so good for learning about the function.
|
|
|
|
|
See this[^] introductory article.
/ravi
|
|
|
|
|
I'm using StrCmpLogicalW to logically compare strings. My signature is:
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
public static extern int StrCmpLogicalW(string x, string y);
seems like its kind of working, but I see that its giving me random results when trying to sort doubles (as strings).
1 ===> 0.883266340175621 <-> 0.842264196854649
that seems like its right, but then a second later I get:
1 ===> 0.842264196854649 <-> 0.91145355364217
that seems wrong. Obviously 0.91 is greater then 0.84. I'm thinking StrCmpLogicalW isn't liking that the 2nd string is shorter.
Can't really special case this since its in generic code that uses LINQ expression trees to get property "x" from objects and then does .ToString() on them for passing into StrCmpLogicalW.
Any ideas?
-- Modified Friday, June 3, 2011 5:05 PM
|
|
|
|
|
Seems like the second comparison is failing because the string is shorter... thats a stupid bug in StrCmpLogicalW :p.
|
|
|
|
|
I agree, as a number obiously we would expect .91 to be larger than .84. but as a string the shorter one is smaller.
That being said I'm not sure the best way for you to fix it
Programming is a race between programmers trying to build bigger and better idiot proof programs, and the universe trying to build bigger and better idiots, so far... the universe is winning.
|
|
|
|
|
just shooting in the dark and could be WAAY off base here, but could you maybe trim the strings to be the same length? or would that hurt your comparison to much due to loss of data?
Programming is a race between programmers trying to build bigger and better idiot proof programs, and the universe trying to build bigger and better idiots, so far... the universe is winning.
|
|
|
|
|
Well, I was originally thinking of trimming the strings to the same length, but that would screw things up because I could get something like 0.5 and then I don't want to trim 0.92323923423 to 0.9. I could go the other way and pad out the 0.5 to 0.500000000, but I don't want to display it like that .
My list control was doing sorting generically by property name. I.e. column1 sorts on "Name", column2 sorts on "Age", etc. So I just added a "custom sort callback" property to the column and
if it has one specified, it calls that instead of StrCmpLogicalW with raw object(s) instead of the ToString()'ed version and the implementer of the callback can decide how to compare them. In this case, I just typecast to doubles and use the <, == and > operators.
Still, the StrCmpLogicalW thing irks me because the whole point of that function is to take numbers into account .
|
|
|
|
|
StrCmpLogicalW() is what Windows Explorer uses to sort file names in the "logical" order, i.e. it gives
a1a, a2a, a3a, ..., a9a, a10a, a11a, ...
so it looks at a string as containing digits and non-digits; in scans left-to-rigth; for the non-digits it compares a character at a time, by char value; for digits, it calculates the integer value and compares that. It does not know about decimal points, thousand separators, minus signs, etc.
As a result 0.842264196854649 is the number zero, a period, and the number 842264196854649, and the latter one is larger than 91145355364217 by about a factor of 9.
You should not use StrCmpLogicalW() here; why don't you just use string.Compare() (OK for positive numbers only!)? and of course, the clean approach would be using numbers, not strings.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Yeah, I have filenames, so thats why my control defaults to using StrCmpLogicalW as the default sorter. As I mentioned in another post, I added support for a custom comparer for each column, so what I'm thinking is that I should default to string.compare() and the user (of the control) can override for the filename columns or other columns they want logical sorting on. That should improve sorting performance since I'm thinking string.compare() is faster then StrCmpLogicalW() .
But great explanation on why it works how it does. I gave up trying to figure that out and just implemented the custom callback so they can sort as doubles or whatever if they wish.
|
|
|
|