Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Initial mouse pointer positioning on a dialog control
#1
Is there a simple - smart way to position mouse pointer to a dialog control when starting the dialog.

Thanks in advance
#2
Under WM_INITDIALOG:
GetWinXY or GetWindowRect
mou
#3
Dear Gintaras,

Many thanks indeed.

Regards
Simos
#4
In the example it follows, I try to position the cursor at a certain point on the dialog window, for example (10, 10), when the dialog starts. I am afraid it fails. No problem if the dialog is already visible. Any advice is mostly welcome and appreciated. Best regards.

Function Dialog55
Code:
Copy      Help
;Dialog to test Dlg_GoToCtrl



str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Edit 0x54030080 0x200 21 5 96 12 ""
;4 Edit 0x54030080 0x200 21 30 96 12 ""
;5 SysDateTimePick32 0x54030000 0x200 21 50 96 12 ""
;6 Edit 0x54030080 0x200 21 72 96 12 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040800 "*" "" "" ""

str controls = "3 4 6"
str e3 e4 e6
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
;,Initial mouse pointer positioning on a dialog control MF
;,www.quickmacros.com/forum/showthread.php?tid=3606&highlight=init*+mous*+dialog*
,mou 10 10 hDlg
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
;OutWinMsg message wParam lParam
sel wParam
,case IDOK
,case IDCANCEL
,
,case [EN_CHANGE<<16|4]
,mou 10 10 hDlg
,
ret 1

Nevertheless, it works if mou is set under WM_PAINT
    case WM_PAINT
    mou 10 10 hDlg
#5
Here works. Windows 10. Not tested on XP. If dialog is in wrong position when it receives WM_INITDIALOG, other good message for it is WM_SHOWWINDOW with wParam 1:
case WM_SHOWWINDOW if(wParam=1) mou 10 10 hDlg
Or use timer.
#6
Many thanks , indeed!
#7
Let me report my last findings. I am using XP.

(i) WM_PAINT should not be used, inasmuch as it may be called several times during a dialog session. It is implied ttat an additional control could solve this problem.

(ii) WM_SHOWWINDOW although it is triggered it does not position the cursor (mou does not work).

(iii) Timer is working perfectly.

Best regards.


Forum Jump:


Users browsing this thread: 1 Guest(s)