Changing text from within CommandBarKeyDown() |
Post Reply |
Author | |
DDTech
Groupie Joined: 10 October 2007 Status: Offline Points: 23 |
Post Options
Thanks(0)
Posted: 26 December 2008 at 12:13pm |
Hi,
I am trying to change an edit- or comboBoxControl's text from within the CommandbarKeyDown() - event. The control shows a datevalue and I would like to allow the user to also change the date with the up and down keys. the event fires nicely and I am updating a second control on the form with no problem. The text of the control however does not change at all. I do something like do case case CommandBar.BarID=1094 and CommandBar.SelectedControl.ID=1101 do case case KeyCode = 38 && UpArrow CommandBar.SelectedControl.Text = ... case KeyCode = 40 && DnArrow CommandBar.SelectedControl.Text = ... ... I also tried to employ external timers as well as the update() event but it seems that changing the text is not possible as long as the control has the focus. Any Tips? thanks in advance Frank |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Yes Text property is locked when user edit item. :( You can replace text with SetWindowText API + CommandBar.SelectedControl.Hwnd.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
DDTech
Groupie Joined: 10 October 2007 Status: Offline Points: 23 |
Post Options
Thanks(0)
|
Oleg,
Great, thanks a lot. In my case it's a ComboBox that does not have the hWnd-Property but it works with .EditHandle. This is the way it works for me; in case someone else needs something alike (Code is VFP9 SP2). There is an additional text-control on the form that is the reference for the current date and performing several tasks. This of course is not needed for the functionality itself. PROCEDURE CommandBarKeyDown(CommandBar as object, KeyCode as Long, shift as Integer) as VOID LOCAL ldX, lnID lnID = Commandbar.BarID *================================================* * Das funktioniert leider nicht so, wie ich es * * mir vorstelle. Die TextBox wird aktualisiert * * aber Text des Datums-Controls bleibt gleich * *================================================* do case case lnID == 1094 && Planung if Commandbar.SelectedControl.ID = 1101 && Datum ldX = {//} do case case KeyCode = 38 && Up ldX = thisform.txtDatum.Value - 1 case KeyCode = 40 && down ldX = thisform.txtDatum.Value + 1 case Keycode = 33 && pgUp ldX = goMonth(thisform.txtDatum.Value, -1) case Keycode = 34 && pgDown ldX = goMonth(thisform.txtDatum.Value, +1) other *DEBUGOUT keycode endcase if ! empty(ldX) *-- Control's Text is locked. So I can't set *-- CommandBar.SelectedControl.Text= dtoc(ldX) *-- but it works with SetWindowText() declare integer SetWindowText in User32.dll AS SWT long hWnd, string Text SWT(CommandBar.SelectedControl.EditHandle, dtoc(ldX)) thisform.txtDatum.Value = ldX clear Dlls SWT endif endif other endcase ENDPROC Regards from Berlin Frank |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Thanks for share this :)
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
DDTech
Groupie Joined: 10 October 2007 Status: Offline Points: 23 |
Post Options
Thanks(0)
|
My pleasure. Thank You for the hint regards Frank |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |