This appears to be a problem with calling SetCursorPos inside your hook proceedure. I guess this is explicitly prohibted in Vista/Windows 7, but I couldn't find any documentation to confirm that. I modified your code slightly to post a thread message when it wants to move the cursor, and do the actual SetCursorPos inside your message proceedure. It works fine once this is done.
In your hook procedure:
if (pMouseStruct->pt.x < -1900)
{
PostThreadMessage( GetCurrentThreadId(), WM_USER, 0, 0 );
printf("Trigger %d. Response %d", pMouseStruct->pt.x, r);
}
In your message loop:
while (GetMessage(&message,NULL,0,0)) {
if( message.hwnd == NULL ) {
if( message.message == WM_USER ) {
SetWindowPos( 500, 500 );
}
} else {
TranslateMessage( &message );
DispatchMessage( &message );
}
}
(Note this is just a demonstration, not an actual fix.)
That being said, there are numerous, serious problems with your code. I don't think it's appropriate to go into all of them here, but I recommend you post it on https://codereview.stackexchange.com/.