Click here to Skip to main content
15,919,778 members
Home / Discussions / C#
   

C#

 
GeneralRe: CPU Usage Monitoring Pin
Luc Pattyn20-Jul-07 3:58
sitebuilderLuc Pattyn20-Jul-07 3:58 
GeneralRe: CPU Usage Monitoring Pin
Malcolm Smart20-Jul-07 4:43
Malcolm Smart20-Jul-07 4:43 
JokeRe: CPU Usage Monitoring Pin
Luc Pattyn20-Jul-07 5:02
sitebuilderLuc Pattyn20-Jul-07 5:02 
JokeRe: CPU Usage Monitoring Pin
Paul Conrad20-Jul-07 5:47
professionalPaul Conrad20-Jul-07 5:47 
JokeRe: CPU Usage Monitoring Pin
Luc Pattyn20-Jul-07 6:02
sitebuilderLuc Pattyn20-Jul-07 6:02 
GeneralRe: CPU Usage Monitoring Pin
Paul Conrad20-Jul-07 6:14
professionalPaul Conrad20-Jul-07 6:14 
QuestionDrag & Drop trouble Pin
eskape1920-Jul-07 3:24
eskape1920-Jul-07 3:24 
AnswerRe: Drag & Drop trouble [modified] Pin
BoneSoft20-Jul-07 4:06
BoneSoft20-Jul-07 4:06 
This might help. First thing I found on programmatically moving the mouse.

http://www.thescripts.com/forum/thread501540.html[^]


-- modified at 10:43 Friday 20th July, 2007

Using the link above, this is an example of how to trap the mouse in a PictureBox, which should be hard to change to only trap while dragging.

private bool trap = false;
private void pictureBox1_MouseMove(object sender,
        System.Windows.Forms.MouseEventArgs e) {
    trap = true;
}

// http://www.thescripts.com/forum/thread501540.html
private void Form1_MouseMove(object sender,
        System.Windows.Forms.MouseEventArgs e) {
    if (trap) {
        if (e.X < pictureBox1.Left) {
            mouse_event(MouseFlags.Move, 1, 0, 0, UIntPtr.Zero);
        }
        if (e.X > pictureBox1.Left + pictureBox1.Width) {
            mouse_event(MouseFlags.Move, -1, 0, 0, UIntPtr.Zero);
        }
        if (e.Y < pictureBox1.Top) {
            mouse_event(MouseFlags.Move, 0, 1, 0, UIntPtr.Zero);
        }
        if (e.Y > pictureBox1.Top + pictureBox1.Height) {
            mouse_event(MouseFlags.Move, 0, -1, 0, UIntPtr.Zero);
        }
    }
}

const int MK_LBUTTON = 0x0001;
enum Messages {
    WM_LBUTTONDOWN = 0x0201,
    WM_LBUTTONUP = 0x0202
}
[Flags]
enum MouseFlags {
    Move = 0x0001,
    LeftDown = 0x0002,
    LeftUp = 0x0004,
    RightDown = 0x0008,
    RightUp = 0x0010,
    Absolute = 0x8000
}
[System.Runtime.InteropServices.DllImport("User32.dll")]
static extern int SendMessage(IntPtr hWnd, Messages uMsg,
                              int wParam, IntPtr lParam);
[System.Runtime.InteropServices.DllImport("User32.dll")] 
static extern void mouse_event(MouseFlags dwFlags, int dx,
                               int dy, int dwData, UIntPtr
                               dwExtraInfo);


Hehe, don't forget about Alt+F4 if you run this.



Try code model generation tools at BoneSoft.com.

AnswerRe: Drag & Drop trouble Pin
BoneSoft20-Jul-07 5:00
BoneSoft20-Jul-07 5:00 
Question(Exit) Not to continue the execution Pin
-spy-20-Jul-07 3:09
-spy-20-Jul-07 3:09 
AnswerRe: (Exit) Not to continue the execution Pin
Pete O'Hanlon20-Jul-07 3:15
mvePete O'Hanlon20-Jul-07 3:15 
AnswerRe: (Exit) Not to continue the execution Pin
Waleed Eissa29-Aug-07 10:15
Waleed Eissa29-Aug-07 10:15 
Questionsubstituting variables [modified] Pin
KPThor20-Jul-07 2:49
KPThor20-Jul-07 2:49 
AnswerRe: substituting variables Pin
Colin Angus Mackay20-Jul-07 2:53
Colin Angus Mackay20-Jul-07 2:53 
GeneralRe: substituting variables Pin
KPThor20-Jul-07 3:27
KPThor20-Jul-07 3:27 
GeneralRe: substituting variables Pin
Colin Angus Mackay20-Jul-07 4:16
Colin Angus Mackay20-Jul-07 4:16 
QuestionConvert Null db field to string Pin
kallileo20-Jul-07 2:44
kallileo20-Jul-07 2:44 
AnswerRe: Convert Null db field to string Pin
Colin Angus Mackay20-Jul-07 2:50
Colin Angus Mackay20-Jul-07 2:50 
AnswerRe: Convert Null db field to string Pin
Le centriste20-Jul-07 2:54
Le centriste20-Jul-07 2:54 
GeneralRe: Convert Null db field to string Pin
Colin Angus Mackay20-Jul-07 2:56
Colin Angus Mackay20-Jul-07 2:56 
GeneralRe: Convert Null db field to string Pin
Le centriste20-Jul-07 2:58
Le centriste20-Jul-07 2:58 
AnswerRe: Convert Null db field to string [modified] Pin
kallileo20-Jul-07 3:02
kallileo20-Jul-07 3:02 
GeneralRe: Convert Null db field to string Pin
Colin Angus Mackay20-Jul-07 3:16
Colin Angus Mackay20-Jul-07 3:16 
GeneralRe: Convert Null db field to string Pin
Le centriste20-Jul-07 3:56
Le centriste20-Jul-07 3:56 
GeneralRe: Convert Null db field to string Pin
m@u20-Jul-07 3:30
m@u20-Jul-07 3:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.