|
Using spy++ I find a window.
But, I need to get the screen coords for the window so I can place a the mouse there. Can anyone tell me how or what API function I can use to get the actual screen coordinates of the window.
Please
this is what I currently have
RECT myRect2 = new RECT();
GetWindowRect(hwnd, out myRect2);
int posx = (myRect2.right - myRect2.left) / 2;
int posy = (myRect2.bottom - myRect2.top) / 2;
where hwnd is the handle of the wind returned from EnumChildWindows
Is this right or wrong? My SendInput doesn't appear to be working correctly.
1 line of code equals many bugs. So don't write any!!
-- modified at 14:50 Wednesday 31st May, 2006
|
|
|
|
|
Ista wrote: Is this right or wrong?
It's not the most efficient, nor is it syntactically correct. Try:
RECT myRect2;
GetWindowRect(hwnd, &myRect2);
Ista wrote: int posx = (myRect2.right - myRect2.left) / 2;
int posy = (myRect2.bottom - myRect2.top) / 2;
This finds the center of the window. Is this what you want?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
heres what i have. and yes its ugly.
( this is c# callung user32.dll ) I asked in here, think the C++ gurus would have an easier time with this.
RECT myRect2 = new RECT();
GetWindowRect(hwnd, out myRect2);
int posx = (myRect2.right - myRect2.left) / 2;
int posy = (myRect2.bottom - myRect2.top) / 2;
MOUSEINPUT mi = new MOUSEINPUT();
mi.dx = posx + myRect2.left;
mi.dy = posy + myRect2.top;
mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
mi.mouseData = INPUT_MOUSE;
int cb = Marshal.SizeOf(mi);
SendInput(INPUT_MOUSE, ref mi, cb);
This window is a button I have created in another application.
SO what I want is to click the left button of the mouse anywhere in the button.
But when I run it, I don't think its working because the button event isn't firing. Although if I use PostMessage, it works fine.
I think im just getting coords relative to the window and not the screen.
Please help.
Thanks, Nick
1 line of code equals many bugs. So don't write any!!
-- modified at 15:21 Wednesday 31st May, 2006
|
|
|
|
|
If you are just trying to cause the message handler for your button click to get called, just use Send/PostMessage with your window handle for the button (which you will still have to obtain, but you already have the app window handle, so it won't be too hard from there).
If you actually want to move the mouse there, try setting the focus to either the app or to the button before calling SendInput. You will also have to call SendInput 2 different times: once to move the mouse to the correct position and once to simulate the button press.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I'm trying to write a program with an interface similar to a disc defrag. It needs to show 10,000 boxs, 100x100 pixs each. The boxs will show a sequence of colors 1 at a time. I'm switching from VB6 to VC++ and I can't figure out how to create 10,000 images that I can access individually with a index. I'm so lost, can anyone help me?
Overwelmed++
-- modified at 15:49 Wednesday 31st May, 2006
|
|
|
|
|
hiho
cause i'm much more working on unix systems
i just don't know how i can connect and do some SQL statements to a database like postgresql or mysql?
for example, using linux i use libpq API with funktions like PQconnectdb or PQexec to connect or execute a query
but how does this work under windows?
can i use the same API on windows systems?
i'm sure there are many guys here who know how this stuff works, but since i work most time with linux i just have no idea on how to do database programming on windows
any articles or hints would be great
thx@ll
|
|
|
|
|
ThinkingPrometheus wrote: but how does this work under windows?
See here.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
that seems a good resource
but, just cause of interest:
is there only odbc on windows?
and for better understanding:
is odbc just a API which is able to "talk" to databases?
or can odbc do much more than just manage sql and its results? (i'm not sure about what i'm expecting, that's why i ask )
|
|
|
|
|
ThinkingPrometheus wrote: is there only odbc on windows?
No. See here.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
|
|
Hi, everybody
I need a POP3 server code in C or C++. Could you please suggest me where I can find such code?
Thanks in advance
-- modified at 14:33 Wednesday 31st May, 2006
|
|
|
|
|
hahayk wrote: Could you please suggest me where I can find such code?
In a file ending with .c or .cpp.
|
|
|
|
|
leppie wrote: In a file ending with .c or .cpp.
These days even .cs, .vb
Regards,
Nish
|
|
|
|
|
leppie wrote: In a file ending with .c or .cpp.
opps, i have seen same code in hpp file
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
|
Check sourceforge.net.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
Jon Sagara wrote: You tool.[^]
He has posted the same question twice in the lounge. Clearly he didn't suffer enough abuse the first time.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
My suggestion is to use google, but you need to pull your head out of your ass first so you can see what you're doing.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
What is the best way to update a view after opening a file from the document class? I am working with OpenGL and NTGraph and I have read data from a file to an array in OnOpenDocument and I need to automatically update the view. In the past I have added a menu item called Refresh Graph and when I select it, I assign the appropriate data and then call Invalidate to update the graph. It works, but it is not automatic and I know there has to be a better way to do it. Thank you.
CWB
|
|
|
|
|
|
When you are initially opening the file, you just need to override the view's OnInitialUpdate method. Calling UpdateAllViews from your document's initialization process can lead to double-drawing the view at startup (which you may or may not mind depending on how performance hungry your app is).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Help me! i am learning about Client-Server modern.
i want to write a program that server manages the music web
(upload and download songs). Client can upload or download songs if it's a member of webpage. Client can only delete the songs that it uploaded....
thanks!Sao
|
|
|
|