منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : ScreenToClient(PictureBox1 .Handle, mPos)
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
استعمل SetParent لاظهار Notepad فى PictureBox1 اريد عند الضغط على ال PictureBox1 يضغط فى notepad استعمل هذا الكود

كود :
ScreenToClient(PictureBox1 .Handle, zPos)

يظهر هذا الخطاء
إقتباس :Additional information: A call to PInvoke function 'WindowsApplication1!WindowsApplication1.Form1::ScreenToClient' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

If there is a handler for this exception, the program may be safely continued.
تم الحل الحمد الله
Dim mPos As POINTAPI
Dim PosX As Long
Dim PosY As Long

' The position in picture box you want to click
PosX = 50 ' 50 pix from left
PosY = 100 ' 100 from top

' find X Y of picture box
ScreenToClient(PictureBox1.Handle.ToInt32, mPos)

' move cursor
SetCursorPos(PosX + Abs(mPos.x), PosY + Abs(mPos.y))


'Click
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)