What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [questions] focus to a control + default submit button

[questions] focus to a control + default submit button
Author: Message:
cooldude_i06
Full Member
***

Avatar
I'm so cool I worry myself.

Posts: 272
Reputation: 9
– / Male / –
Joined: Sep 2003
O.P. [questions] focus to a control + default submit button
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
[Image: clb2.jpg]
06-27-2006 03:16 AM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [questions] focus to a control + default submit button
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

This post was edited on 06-27-2006 at 03:57 AM by matty.
06-27-2006 03:54 AM
Profile E-Mail PM Find Quote Report
cooldude_i06
Full Member
***

Avatar
I'm so cool I worry myself.

Posts: 272
Reputation: 9
– / Male / –
Joined: Sep 2003
O.P. RE: [questions] focus to a control + default submit button
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
[Image: clb2.jpg]
06-27-2006 06:43 AM
Profile E-Mail PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: [questions] focus to a control + default submit button
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>&amp;Cancel</Caption>
    //Make this button that is clicked when user presses Enter key
    <Attributes><IsDefault>true</IsDefault></Attributes>

</Control>

This post was edited on 06-27-2006 at 07:26 AM by Eljay.
06-27-2006 07:25 AM
Profile PM Find Quote Report
cooldude_i06
Full Member
***

Avatar
I'm so cool I worry myself.

Posts: 272
Reputation: 9
– / Male / –
Joined: Sep 2003
O.P. RE: [questions] focus to a control + default submit button
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.

This post was edited on 06-27-2006 at 08:22 AM by cooldude_i06.
[Image: clb2.jpg]
06-27-2006 08:21 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On