Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi Everyone!
I'm am developing a mouse App and need to change the mouse settings for the user using my own App. I have designed the Interface(GUI) same as "default mouse properties" interface(have a look: http://img192.imageshack.us/img192/1494/cap1e.png[^])

My Idea:
When the user performs an action on my App,say checks the "switch primary and secondary buttons" checkbox.Then the effect will be same as checking the same box in default mouse properties form,i.e.,change the content of "main.cpl"(well,so far I found mouse settings are stored in "main.cpl" in system32) manually through my App.

My Problem:
I'm "completely naive" to C# (in terms to adding control actions and coding,but can design the Windows Form App) and I've no idea how to achieve it.I mean the C# mouse classes and all...and also the corresponding changes in "OK", "Cancel" and "Apply" buttons.

Also I want to know which "tool" from "toolbox" have been used to make "Customize:" section under "Pointer Options" tab.Please let me know(I've implemented using TableLayoutPanel and its not same as default one).

My Software:
OS: Windows 7 Ultimate 64-bit
Visual Studio 2010 Ultimate
.NET4.0
[extras:OpenCv,OpenCvSharp,for Back end,no need to consider for above problems I think]
I basically needs code snippet help or related links or finally anything You can come up with.I got only 2-3 weeks left to finish the project.

Please help!
Thanks for Your help in Advance.
Posted
Updated 27-Apr-11 12:06pm
v4
Comments
walterhevedeich 27-Apr-11 17:59pm    
never post your email in public sites unless you want to invite spams. If someone knows the problem, he will reply on this post.

1 solution

C#
[DllImport("user32.dll")]
        public static extern Int32 SwapMouseButton(Int32 bSwap);
        private void button1_Click(object sender, EventArgs e)
        {
            // swap mouse buttons 1= swapped 0 = normal
            SwapMouseButton(1);
            SwapMouseButton(0);
        }
 
Share this answer
 
Comments
AmarjeetAlien 27-Apr-11 19:20pm    
Thanks for the reply....but it didn't work :(
To let You know...I haven't added any mouse handler in my program....I've only created the check box which when selected should invert(in this case) mouse selection....this is how I used your code:
[DllImport("user32.dll")]
public static extern Int32 SwapMouseButton(Int32 bSwap);

private void BtnChkBoxBC_CheckedChanged(object sender, EventArgs e)
{
SwapMouseButton(1);
SwapMouseButton(0);
ApplyEnable();

}
charles henington 27-Apr-11 19:22pm    
apply only one that is calling both and setting back to normal
AmarjeetAlien 27-Apr-11 19:27pm    
ApplyEnable() is for enabling "Apply" button(I hope the image link is working,let me know) which is desabled by default....I even don't have any code for "Apply" button action.
private void ApplyEnable()
{
Apply.Enabled = true;
}
charles henington 27-Apr-11 19:24pm    
if (!BtnChkBoxBC.Checked)
{
SwapMouseButton(1);
}
else
{
SwapMouseButton(0);
}
AmarjeetAlien 27-Apr-11 19:34pm    
Thanks it worked fine:
private void BtnChkBoxBC_CheckedChanged(object sender, EventArgs e)
{
if (!BtnChkBoxBC.Checked)
{
SwapMouseButton(0);
}
else
{
SwapMouseButton(1);
}
ApplyEnable();

}

Thanks a lot!
Can you please let me know the name of other mouse setting...like "pointer speed","click lock",etc....in fact I'm implementing all mouse properties in my App.

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