NO

Author Topic: Invisible Dialog/Button or retrieving mouseclick  (Read 9340 times)

ml1969

  • Guest
Re: Invisible Dialog/Button or retrieving mouseclick
« Reply #15 on: July 21, 2009, 05:12:41 PM »
Oh sorry John  ::),

but I want to say thanks all of you, who helps me here....

Ok,
I tried this code, but the same as the getcursorpos....... then I have changed a litte bit, to see what happens:
Code: [Select]
    while (GetMessage(&msg, NULL, 0, 0))
    {
//        GetCursorPos(&p);

GetCursorPosWinCE(&p);
GetAsyncKeyState(VK_LBUTTON);   // for first time, clear buffer
if (GetAsyncKeyState(VK_LBUTTON) & 0x8000)
{


        if (p.x > -1 && p.x < 480 && p.y > -1 && p.y < 272)
          {
break;
}
    }

        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    //MessageBeep(16);
swprintf(hStr1, L"%d %d", p.x , p.y );
MessageBox(NULL, hStr1, L"B2", MB_TOPMOST|MB_YESNO);

    KillTimer(hwnd, 1);
    DestroyWindow(hwnd);
    return msg.wParam;
}

Now I see the MessageBox and it shows me for p.x = 0  und p.y = 0 (that´s wy I changed the if statement from 0 to -1)
Ok , now I took the break statement out, to get an endless loop,
the first time the messagebox comes up it shows me 0/0  for x and y, ....
I clicked OK and the next time it shows me the coordinates where i clicked the button   NOT where I clicked on the screen.

I can reproduce it... it only shows me the point from the messagebox where I cleick YES or NO.
I hoped I would see the coordinates from that point I cleicked the screen....

Perhaps the code only works when a real notification was send???

Ok now I have a big unvisible button  ;D,


Why will the GetCursorPos  and GetCursorPosCe  will not worl like you think?  ???


Michael

JohnF

  • Guest
Re: Invisible Dialog/Button or retrieving mouseclick
« Reply #16 on: July 21, 2009, 05:31:05 PM »
The idea behind the code is that a Timer message comes every 0.1 of a second so when a message (Timer) is received the click will give you the position.

I have no idea why those two API's appear not to be working and I can't test it on your platform.

John

ml1969

  • Guest
Re: Invisible Dialog/Button or retrieving mouseclick
« Reply #17 on: July 21, 2009, 06:42:37 PM »
mhhh  perhaps cause there no visible cursor?  ???

in an other try, I used the WM_LBUTTONDOWN with a peekmessage loop,
I could get the coordinates with the
xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam);

But only I created a "visible" window.....


Michael

ml1969

  • Guest
Re: Invisible Dialog/Button or retrieving mouseclick
« Reply #18 on: July 22, 2009, 06:14:05 AM »
Hello,

an other thought...

Could this work.... no real code

I register a hotkey using....  RegisterHotKey(hwnd, (UINT) 0x0001, 0, (UINT) VK_LBUTTON)

now I enter a message loop   while (GetMessage(&msg, NULL, 0, 0) != 0)

       switch (msg.wParam)
      {
         case 0x0001:

                        xPos = GET_X_LPARAM(msg.lParam);
                        yPos = GET_Y_LPARAM(msg.lParam);

                       if (xPos  > 0 && xPos  < 50 && yPos > 0 && yPos < 50) {
                       do what I want;
                       }
                       else {
                       generate org. click with mouse_event


I thought on that, cause I wrote a litte " hotkey" program to use the 4 hardware-buttons (VK_F6 ..VK_F9 of the PNA) with my own user- code


Can I use VK_LBUTTON as a "Hotkey" ?


Michael

ml1969

  • Guest
Re: Invisible Dialog/Button or retrieving mouseclick
« Reply #19 on: July 25, 2009, 12:11:59 PM »
Hi,,

also do not work :-(


is there no other possibility?



Michael

ml1969

  • Guest
Re: Invisible Dialog/Button or retrieving mouseclick
« Reply #20 on: July 25, 2009, 05:36:00 PM »
Ok

I think the manufactor has disabled this function like it is discribe on the msdn website :-(,

cause the code above works on an other pna from an othe manufactor..



Thanks alot, an is there an other way to retrive the mouse position I will be glad....


Michael

JohnF

  • Guest
Re: Invisible Dialog/Button or retrieving mouseclick
« Reply #21 on: July 25, 2009, 09:47:34 PM »
This is my last suggestion - make a transparent window always on top at the top left of the screen and pick up WM_LBUTTONDOWN.

John

ml1969

  • Guest
Re: Invisible Dialog/Button or retrieving mouseclick
« Reply #22 on: July 26, 2009, 10:10:50 AM »
Hello Johm

this was my thought at first, but I can create a window that receives the WM_LBUTTONDOWN, then the window ist visible or if I create a non-visible window I did not receive the command :-(
Ok I think I do a mistake here, but I`m a beginner and try alot :-)

WS_EX_TRANSPARENT is an undeclared identifier :-( on a wince system

for me it would be OK if the titlebar is visible (I set the position of the window outside the desktop)
and if the white region of the window could be transparent......

I used at least  SetWindowPos(hwnd, HWND_TOPMOST, -25, -25, 65,65,SWP_NOOWNERZORDER| SWP_SHOWWINDOW);

so the window is almost on top, bu the white region is visible..... :-(

I saw something about SetWindowRgn .... but I dont understand the right way to use it :-(


Michael

JohnF

  • Guest
Re: Invisible Dialog/Button or retrieving mouseclick
« Reply #23 on: July 26, 2009, 11:00:21 AM »
// WS_EX_TRANSPARENT is an undeclared identifier :-( on a wince system

Sorry I can't help.

Search the web and see if anyone else has done this.

John

ml1969

  • Guest
Re: Invisible Dialog/Button or retrieving mouseclick
« Reply #24 on: July 29, 2009, 05:32:25 PM »
Hi JOHN

so I tried your code with the GetCursorPosCe()  AND made the window visible.

Even when the window is visible, I mean it is OnTop  your Code works fine and I got the correct coordinates of the cursor, ok it is interessting but helps me not really....

One thought....
I wait for the VK_LBUTTON with the with the AsyncKeyState.
Show for a real short time the window, get the cursorposition an hide the window....

I hope this will not take to much process-power.....


Michael

JohnF

  • Guest
Re: Invisible Dialog/Button or retrieving mouseclick
« Reply #25 on: July 29, 2009, 06:35:08 PM »
//I hope this will not take to much process-power.....

Use Sleep(20) in the loop.

John