[questions] focus to a control + default submit button - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [questions] focus to a control + default submit button (/showthread.php?tid=61695)
[questions] focus to a control + default submit button by cooldude_i06 on 06-27-2006 at 03:16 AM
I have two questions:
1. Is there a way (perhaps using the windows API) to give a particular control focus. I want a certain EditControl to have the cursor after a window loads.
2. Is there a way to have it so that if you press enter when a window has focus, that a default submit button is automatically pressed, kind of like a submit button on a form.
Thanks
CD
RE: [questions] focus to a control + default submit button by matty on 06-27-2006 at 03:54 AM
code: /*
Create the Window
*/
var Wnd = MsgPlus.CreateWnd('xmlfile.xml', 'WindowId');
/*
Click Default Button
*/
Wnd.SendControlMessage('sControlId', 256 , 32, 0); // WM_KEYDOWN = 256
Wnd.SendControlMessage('sControlId', 257 , 32, 0); // WM_KEYUP = 257
RE: [questions] focus to a control + default submit button by cooldude_i06 on 06-27-2006 at 06:43 AM
To give an editcontrol focus by default I had to use
code: Wnd.SendControlMessage('sControlId', 513, 0, 0); //WM_LBUTTONDOWN = 513
Wnd.SendControlMessage('sControlId', 514, 0, 0); //WM_LBUTTONUP = 514
But, thanks for pointing me in the right direction. As for making a default button, so that if a user presses enter after typing stuff in an editcontrol, it clicks the button, "sendControlMessage" can be used to click the button. But I am still stumped on how to detect if the user has pressed enter...
Thanks
CD
RE: [questions] focus to a control + default submit button by Eljay on 06-27-2006 at 07:25 AM
1:
code: //7 = WM_SETFOCUS
PlusWnd.SendControlMessage('ControlId', 7, 0, 0);
2:
code: <Control xsi:type="ButtonControl" Id="BtnCancel">
<Position Top="0" Width="50" Left="0"/>
<Caption>&Cancel</Caption>
//Make this button that is clicked when user presses Enter key
<Attributes><IsDefault>true</IsDefault></Attributes>
</Control>
RE: [questions] focus to a control + default submit button by cooldude_i06 on 06-27-2006 at 08:21 AM
Thank you Eljay for solution #2, that was exactly what I needed.
As for #1, WM_SETFOCUS gave me a very weird result. The cursor did move to the specified EditControl, but when I typed something, it appeared in the default (first) EditControl and the cursor in the specified EditControl also moved to the left. It gives a wierd result. Anyways, WM_LBUTTONDOWN and WM_LBUTTONUP gave me the result I wanted.
Thanks guys for helping me out.
|