Thanks for the answer. I could use one more hint. To modify the mouse data with let's say WH_MOUSE_LL I have to use my own custom CallBack function and modify the POINT pt of the MSLLHOOKSTRUCT pointed to by lParam, which has been passed to the CallBack function, right? Or did I get something wrong about how to restrict the movement correctly?
3Dizard
Posts
-
completely restrict mouse movement (including raw data) -
completely restrict mouse movement (including raw data)Hi, I want to confine mouse movement. Let's say I want to confine mouse movement to x-direction (so only horizontal movement is possible) when pressing a certain button. This should work globally. What I mean with that is, that I want to use this in any windows program. Let's take MS Paint as an example: When my program runs and I press the certain button, the movement of the mouse should be restricted to horizontal movement. So when drawing a straight horizontal line should be the result. My research so far led me to ClipCursor, but ClipCursor seems to only affect the mousecursor, not the raw data. So returning to the example of MS Paint the following happens: The cursor moves on the horizontal line, but the mouse data received by paint is different: So if you move the mouse slightly in y-direction this still affects the line drawn, also the mouse cursor itself does not indicate that (stays on the straight line). So the result is not a straight line as expected. Does anybody know how to solve that problem ? (as ClipCursor does not confine the raw data sent to an application, it seems to be the wrong routine for doing that) Thanks in advance.
-
CreateProcess doesn't start specific executableThanks for the answer, but running the program as administrator doesn't change anything. This is what I expected, because nvcplui.exe doesn't need admin rights to be executed.
-
CreateProcess doesn't start specific executableHi, I want to start a certain process called nvcplui.exe within my application. That process is the Nvidia Control Panel process. To do so I use the CreateProcess function. Here is my short code:
if( !CreateProcess( NULL, // No module name (use command line) "C:\\\\Windows\\\\System32\\\\nvcplui.exe", // Command line NULL, // Process handle not inheritable NULL, // Thread handle not inheritable FALSE, // Set handle inheritance to FALSE 0, // No creation flags NULL, // Use parent's environment block NULL, // Use parent's starting directory &si, // Pointer to STARTUPINFO structure &processinfo ) // Pointer to PROCESS\_INFORMATION structure ) { printf( "CreateProcess failed (%d)\\n", GetLastError() ); return; }
As you might guess that doesn't work for me. If I use another application instead, let's say notepad (just replacing nvcplui.exe with notepad.exe), the code just works fine. These are my investigations so far: - Using GetLastError delivers: "Create Process failed (2)". That, as far as I know, means file not found. But the file is there for sure. - Starting the process via command line manually (not via code) just works fine. No additional account privileges needed (was one of my first thoughts, but doesn't seem to be the case). - As already said starting another program using the above method seems to work just fine. - Using .net Process Class works fine with nvcplui.exe:
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "C:\\windows\\system32\\nvcplui.exe";
process.Start();Important notes: I'm running windows vista 64bit and unfortunately can't test the whole thing on a 32bit system, because I have none with an nvidia graphics card (for the nvidia control panel) available. I'm using UAC, but as stated above, this shouldn't be the problem. I'm grateful for any hints. Thanks in advance.
-
How to make an number only text box?Greeeg is definitely right, but I'd prefer a slightly different way than using exception. Here's the code:
private void AmountBox_KeyPress(object sender, KeyPressEventArgs e) { switch (e.KeyChar) { case '0': break; case '1': break; case '2': break; case '3': break; case '4': break; case '5': break; case '6': break; case '7': break; case '8': break; case '9': break; default: e.Handled = true; break; } }
Setting Handled to true prevents the input from being processed further and that is exactly what you want for anything else than numbers. BTW: This is a function for the KeyPress event. Greetings -
remote application: problem with modal dialogFound the problem: I used SendMessage instead of SendNotifyMessage.
-
remote application: problem with modal dialogHi, I'm developing a remote application, which means a windows application that controls an existing windows application by using the Win32 API (SendMessage, FindWindow, etc.). Problem is the following: The other application, which already runs and has to be controlled, has a button, that opens an OpenFileDialog, when being clicked. My remote application does so by sending the appropriate message to the other form. The OpenFileDialog is shown, but my remote application stops processing its code, it doesn't continue working (easy to see in debugger: code is executed till button click command is sent, then everything stops. If I manually cancel the OpenFileDialog, rest of the code is executed)! This is a situation that I want to avoid, I want the application to work on. Any ideas how to circumvent that? Greetings working in visual c# express 2005 developing usual windows application
-
problems using System.Diagnosics.Process.Start to start ProcessThank you all guys. @Mike Bluett: You're right, that really helped me out. Setting the working directory for the process tells it where to look for the additional files. Thanks.
-
problems using System.Diagnosics.Process.Start to start ProcessThat is already the default. Setting it to false also doesn't solve.
-
problems using System.Diagnosics.Process.Start to start ProcessNo, it is not. BTW: I'm developing a usual c# windows application.
-
problems using System.Diagnosics.Process.Start to start ProcessIf I run AutoGK.exe from command line it starts fine. No problems.
-
problems using System.Diagnosics.Process.Start to start ProcessHi, sorry for posting again, but problem hasn't been solved jet. I know this might be difficult, but perhaps somebody knows: my starting routine looks like this: private void StartProcess() { System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "C:\\Programme\\AutoGK\\AutoGK.exe"; p.Start(); } When I run the code everything is executed fine except that the application to be started shows me an error: "Installation is corrupted. Please reinstall the application." BTW: The code works with any ohter application I have tested so far. But starting the app (AutoGK) manually (in windows explorer via double click, etc.) causes no errors and the application starts fine. The program I want to start is AutoGordianKnot, which probably was written in Qt. Any suggestions? Greetings
-
problems starting application with System.Diagnostics.ProcessThought of that, too, but it is not!
-
problems starting application with System.Diagnostics.ProcessHi, my starting routine looks like this:
private void StartProcess() { System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "C:\\Programme\\AutoGK\\AutoGK.exe"; p.Start(); }
When I run the code everything is executed fine except that the application to be started shows me an error: "Installation is corrupted. Please reinstall the application." But starting the app manually (in windows explorer, etc.) causes no errors and the application starts fine, so the problem is in the code I use. The program I want to start is AutoGordianKnot, which probably was written in Qt. Any suggestions or any other ways to start this app? Greetings -
Inheriting System.Windows.Forms.ButtonIt's not exactly what you wan't, but it might help you out a little bit because it enables you to use at least some designer abilities. To outwit the designer do the following: Let's say you have a class
MyButton
derived fromButton
. To place an instance, first place a usual Button Control on your form by using the designer (let's name it myButton1). In your code replace the designer generated codeprivate System.Windows.Forms.Button myButton1;
withprivate MyButton myButton1;
and inInitializeComponent()
use your own class, which results in replacingthis.myButton1 = new System.Windows.Forms.Button();
withthis.myButton1 = new MyButton();
. This should make the designer switch to your own data type permanently and your own properties and events should also be listed by the designer. Hope this helps. -
XMLSerialize and Microsoft ControlsSorry for posting this again. What I want to do is save the state of my windows form. What I heard so far XMLSerializing is a good way to go. If I got it right: Due to containing interfaces many classes can't be serialized. So the Form itself can't be serialized. So I need to serialize elements of this form. These are Controls (Labels and UserControls). If the above applies, I see no way doing so, except serializing lets say the Text of a Label and then later deserialize the string, create a new Label and set the Text to the deserialized string, which is a really bad situation. Is there any better way? Thanks for helping me out.
-
Saving the current state of a formIf I got that right: Due to containing interfaces many classes can't be serialized. I want to save the state of my windows form. So I need to serialize elements of this form. These are Controls (Labels and UserControls). If the above applies, I see no way doing so, except serializing lets say the Text of a Label and then later deserialize the string, create a new Label and set the Text to the deserialized string, which is a really bad situation. Is there any better way?
-
Saving the current state of a formWell, as the title says I want to save the current state of a Windows.Form object. I'm currently investigating on doing this with xml-serialization, but I don't know if this is the way to go. I don't need a complete essay about that (I would take that, too) but a hint that points me into the right direction. So, can someone help me out please? Greetings
-
bug in HScrollBar control objectThank you, didn't guess this is intended behaviour.
-
bug in HScrollBar control objectI setup an HScrollBar as part of a panel. Let's call this ScrollBar MyScrollBar. Now to the problem: When a user scrolls (dragging the slider) the maximum value that can be reached is not the MyScrollBar.Maximum value but the value (MyScrollBar.Maximum - 9). This occured for any MyScrollBar.Maximum value I specified. Anyone having this bug, too? Anyone know, how to fix this? Greetings