|
Thanks for the prompt reply.
>> setting the right Scrollbar.MaxValue should do it.
I don't think so.
Scrollbar.MaxValue is decided automatically according to the size of form and the panel. Since I am not changing the panel/form size. Scrollbar.MaxValue has nothing to do with it.
Also while changing the Scrollbar's value, the code is taking care not to let it go beyond it's Min/Max limits.
>> scrolling panel's Top is anywhere between Panel.Height-Form.ClientSize.Height and zero.
scrolling panel's Location is fixed at (0,0).
modified 8-Oct-11 12:37pm.
|
|
|
|
|
Hi again,
I created a project and discovered how the AutoScroll works (hadn't used it in ages). I got it working just fine, assuming the Panel only holds disabled Controls (so MouseDown and MouseMove are sure to fire). This is the relevant code:
private int clickX;
private int clickY;
private void panel1_MouseDown(object sender, MouseEventArgs e) {
clickX=e.X+panel1.HorizontalScroll.Value;
clickY=e.Y+panel1.VerticalScroll.Value;
}
private void panel1_MouseMove(object sender, MouseEventArgs e) {
if (e.Button==MouseButtons.Left) {
int x=clickX-e.X;
if (x<panel1.HorizontalScroll.Minimum) x=panel1.HorizontalScroll.Minimum;
if (x>panel1.HorizontalScroll.Maximum) x=panel1.HorizontalScroll.Maximum;
panel1.HorizontalScroll.Value=x;
int y=clickY-e.Y;
if (y<panel1.VerticalScroll.Minimum) y=panel1.VerticalScroll.Minimum;
if (y>panel1.VerticalScroll.Maximum) y=panel1.VerticalScroll.Maximum;
panel1.VerticalScroll.Value=y;
}
}
It looks very much the same as yours, except for two things:
1. I don't like Math.Min/Math.Max much;
2. I'm not accumulating diff all the time, which you did.
Test: move the mouse over a significant distance, the panel should track that; then (button still down) follow a small circle, this should not do much at all.
[ADDED] I've created this little article[^] on the subject.[/ADDED]
modified 8-Oct-11 16:31pm.
|
|
|
|
|
Hello Luc
Thanks a lot for the explanation, the reference code and detailed article.
However, sadly this does not solve my problem.
In my case, Scrollbars are not associated with the panel. Infact, Panel does not have Scroll bars.
Since the size of the panel is already larger than the Form itself, Form's scrollbars (not Panel's) need to be manipulated.
See this : http://img824.imageshack.us/img824/1388/panelv.png
So, to get the clickX value, you dont need to add panel1.HorizontalScroll.Value to e.X .
In this case e.X itself will be clickX .
Can you please help some more to deal this problem ?
|
|
|
|
|
Abhshake wrote: Can you please help some more to deal this problem ?
I will investigate (Form too small is a particular case I will add to my article). However not right away, except for this:
my Panel is your Form, my content of the Panel (all the Labels) is your Panel.
The one difference is I click/drag the Panel (the outer, smaller thing), you click the Panel (the inner, large thing).
Therefore, yes, you need a different translation of the coordinates.
But then again, make sure not to accumulate changes, always compare with the start of the drag, not the previous moved position.
|
|
|
|
|
I have updated my article[^] to include a second major situation, which probably is what you need.
|
|
|
|
|
Ofcourse the absolute coordinates (MousePosition) !
I was stuck with this problem for a couple of days.
Thanks a lot Luc, you saved me.
|
|
|
|
|
You're welcome.
|
|
|
|
|
Can i have textfile templetes for Captcha with Random numbers
|
|
|
|
|
I suppose you can, but I'm guessing you don't.
|
|
|
|
|
Greetings Gurus,
Could you help please?
I am querying the registry to get a list of installed programs, this works.
I am trying to locate a value in the list of returned items, this doesn't work.
e.g.
RegistryKey rk = Registry.LocalMachine;
RegistryKey rkprograms = rk.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
foreach (string s in rkprograms.GetSubKeyNames())
{
int idx;
idx = s.IndexOf(".NET");
Console.WriteLine(idx);
{
Console.WriteLine(s);
}
Console.ReadKey(true);
}
but all "idx" values return "-1" i.e. not found.
Is my method faulty?
|
|
|
|
|
That looks OK, try stepping through it in debug and see what the values are.
|
|
|
|
|
I just ran your code on my XP machine and it works.
This to obvious, but I will ask it anyway.
Did you check the registry manually to see whether any .NET entries are present?
Also note that your code will not work on XP x64 and Vista (and higher).
I read about it here[^]. But your code would have crashed if this was the case.
0100000101101110011001000111001011101001
|
|
|
|
|
Your method of looking at the Uninstall keys is flawed. It is NOT a list of everything installed on the machine, 'cause, lets face it, not everything is uninstallable/repairable.
Use WMI and the System.Management namespace to query for all instances of the Win32_Product class. This will show you everything that's installed on the machine, not including patches. Those are listed under the Win32_QuickFixEngineering class.
|
|
|
|
|
Bad luck, he's the no-WMI-for-me guy you have encountered not so long ago!
|
|
|
|
|
Ah, sucks to be him then. I'd rather use the stuff that works and is easy to code up instead of blowing half my project time working on something that is very complex to replace it.
|
|
|
|
|
@ PIEBALD - Will do (again), maybe looking at it with fresh eyes will reveal something
@ André - There are quite a few .NET entries in the registry "Microsoft .NET Framework 4 Client Profile", "Microsoft .NET Compact Framework 1.0 SP3 Developer"
@ Dave - http://stackoverflow.com/questions/673233/wmi-installed-query-different-from-add-remove-programs-list[^],
http://stackoverflow.com/questions/2246768/finding-all-installed-applications-with-powershell[^], http://www.techmumbojumblog.com/?p=39[^]and personal experience have proved that WMI only finds instances installed through MSI. If you are trying to catch an app that hasn't used MSI (Google Chrome for e.g.)the RegKey "Uninstall" is better. I also know that it won't find eveything, but it will find everything that Windows knows about.
@ Luc - I am not a "not-WMI-for-me" guy and already have WMI code in app. I prefer to only use WMI when it is more efficient than any other method. WMI is an inefficient method compared to using (for e.g.) System.Environment, System.Net.NetworkInformation etc.
@ Dave - I'd also rather use the stuff that works, but I would be even happier to use stuff that works efficiently. If that means that I have to write a few more lines of code so that there is less impact on the system's resources then that is what I'll do.
Thanks to all for your replies.
|
|
|
|
|
Yeah, you'll find stuff all over the registry. There isn't going ot be one method that returns everything that's installed on the machine. I've seen setups out there (.EXE-based) that don't show up in the resigtry at all.
|
|
|
|
|
A quick look at the subkey names in the registry will show you why.
|
|
|
|
|
|
Again, not the proper forum for this.
|
|
|
|
|
|
12.No advertising or soliciting.
|
|
|
|
|
Advertising, false advertising at that. Those keys are crackable. ECC isn't magic.
|
|
|
|
|
Greetings Gurus,
Without using another language, is there a C# way to convert the Windows install date to yyyymmdd ?
RegistryKey RegKeyIN = Registry.LocalMachine;
RegKeyIN = RegKeyIN.OpenSubKey("SOFTWARE\\MICROSOFT\\WINDOWS NT\\CURRENTVERSION");
Object Date = RegKeyIN.GetValue("InstallDate");
|
|
|
|
|
I'm no expert, but that appears to be the number of seconds since 1970-01-01.
System.DateTime dt = new System.DateTime ( 1970 , 1 , 1 ).AddSeconds ( seconds ) ;
|
|
|
|