Click here to Skip to main content
15,897,891 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CListCtrl - disable an item Pin
Nishad S30-May-06 0:55
Nishad S30-May-06 0:55 
GeneralRe: CListCtrl - disable an item Pin
YaronNir30-May-06 0:56
YaronNir30-May-06 0:56 
GeneralRe: CListCtrl - disable an item Pin
Nishad S30-May-06 1:02
Nishad S30-May-06 1:02 
GeneralRe: CListCtrl - disable an item Pin
YaronNir30-May-06 1:05
YaronNir30-May-06 1:05 
GeneralRe: CListCtrl - disable an item Pin
Nishad S30-May-06 1:17
Nishad S30-May-06 1:17 
JokeRe: CListCtrl - disable an item Pin
Sarath C30-May-06 0:35
Sarath C30-May-06 0:35 
GeneralRe: CListCtrl - disable an item Pin
YaronNir30-May-06 8:25
YaronNir30-May-06 8:25 
QuestionProblems sending mouse inputs using SendInput Pin
kumar_subrahmanya29-May-06 23:13
kumar_subrahmanya29-May-06 23:13 
Hi,
I am facing problems in sending mouse clicks via SendInput API.

Mouse clicks are being sent but at the X,Y co-ordinates.

I am mapping my monitor to the (0,0,65535,65535) virtual monitor as needed by the SendInput. But the mouse clicks are always reported at the "current cursor location" (I am testing it with the notepad) irrespective of the X,Y co-ordinates specified.

Here is the code.


void SendMouseInput(unsigned int iX,unsigned int iY)
{
MOUSEINPUT mousei={0};
INPUT Input={0};
BlockInput(true);
::ZeroMemory(&Input,sizeof(INPUT));
::ZeroMemory(&mousei,sizeof(MOUSEINPUT));
mousei.dx=VirtualXFromAbsoluteX(iX);
mousei.dy=VirtualYFromAbsoluteY(iY);
mousei.dwFlags=MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_LEFTDOWN;
Input.type = INPUT_MOUSE;
Input.mi = mousei;

if(::SendInput(1,&Input,sizeof(Input))==0)
ShowError("SendMouseInput");


mousei.dwFlags=MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_LEFTUP;
Input.type = INPUT_MOUSE;
Input.mi = mousei;

if(::SendInput(1,&Input,sizeof(Input))==0)
ShowError("SendMouseInput");
BlockInput(false);
Sleep(1000);

}
static int VirtualXFromAbsoluteX ( int iX )
{

double Width = GetSystemMetrics ( SM_CXSCREEN ) ;
double Val = ( ((double)iX/Width) * (double)(65535) ) ;

double Ceil = ceil ( Val ) ;
double Floor = floor ( Val ) ;

if ( Ceil > Floor )
{
iX = (int)Ceil ;
}
else
{
iX = (int)Floor ;
}
return ( iX ) ;
}
static int VirtualYFromAbsoluteY ( int iY )
{

double Height = GetSystemMetrics ( SM_CYSCREEN ) ;
double Val = ( ((double)iY/Height) * (double)(65535) ) ;

double Ceil = ceil ( Val ) ;
double Floor = floor ( Val ) ;

if ( Ceil > Floor )
{
iY = (int)Ceil ;
}
else
{
iY = (int)Floor ;
}
return ( iY ) ;
}

void ShowError(LPTSTR lpszFunction)
{
TCHAR szBuf[80];
LPVOID lpMsgBuf;
DWORD dw = GetLastError();

FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );

wsprintf(szBuf,
"%s failed with error %d: %s",
lpszFunction, dw, lpMsgBuf);

::MessageBox(NULL, szBuf, "Error", MB_OK);

LocalFree(lpMsgBuf);
}

Am I doing something wrong?

PS: I am able to send key board events using SendInput.

Thanks a load in advance.

Subra

AnswerRe: Problems sending mouse inputs using SendInput Pin
NiceNaidu30-May-06 0:36
NiceNaidu30-May-06 0:36 
GeneralRe: Problems sending mouse inputs using SendInput Pin
kumar_subrahmanya31-May-06 2:43
kumar_subrahmanya31-May-06 2:43 
QuestionProblem on load file Pin
Immunity1829-May-06 22:53
Immunity1829-May-06 22:53 
QuestionRe: Problem on load file Pin
NiceNaidu30-May-06 0:48
NiceNaidu30-May-06 0:48 
AnswerRe: Problem on load file Pin
Hamid_RT30-May-06 3:31
Hamid_RT30-May-06 3:31 
Questionproblem in multi splitting a window Pin
sahaja_p29-May-06 22:38
sahaja_p29-May-06 22:38 
AnswerRe: problem in multi splitting a window [modified] Pin
_anil_30-May-06 0:34
_anil_30-May-06 0:34 
GeneralRe: problem in multi splitting a window [modified] Pin
sahaja_p30-May-06 1:33
sahaja_p30-May-06 1:33 
GeneralRe: problem in multi splitting a window [modified] Pin
_anil_30-May-06 1:56
_anil_30-May-06 1:56 
QuestionLoad/Store a TreeView in database (Visual C++) Pin
karlheinzsteinhart29-May-06 22:35
karlheinzsteinhart29-May-06 22:35 
QuestionMulti Threading in MFC Pin
Scorpio29-May-06 22:04
Scorpio29-May-06 22:04 
AnswerRe: Multi Threading in MFC Pin
_AnsHUMAN_ 29-May-06 22:21
_AnsHUMAN_ 29-May-06 22:21 
AnswerRe: Multi Threading in MFC Pin
Ganesh_T29-May-06 22:30
Ganesh_T29-May-06 22:30 
AnswerRe: Multi Threading in MFC Pin
Roger Stoltz29-May-06 22:35
Roger Stoltz29-May-06 22:35 
AnswerRe: Multi Threading in MFC Pin
Hamid_RT30-May-06 3:22
Hamid_RT30-May-06 3:22 
Questionwinapi & mfc Pin
blue_rabbit29-May-06 21:54
blue_rabbit29-May-06 21:54 
AnswerRe: winapi & mfc Pin
Hamid_RT30-May-06 3:32
Hamid_RT30-May-06 3:32 

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.