Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Changing text from within CommandBarKeyDown()
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Changing text from within CommandBarKeyDown()

 Post Reply Post Reply
Author
Message
DDTech View Drop Down
Groupie
Groupie


Joined: 10 October 2007
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDTech Quote  Post ReplyReply Direct Link To This Post Topic: Changing text from within CommandBarKeyDown()
    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


Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 26 December 2008 at 4:27pm
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
Back to Top
DDTech View Drop Down
Groupie
Groupie


Joined: 10 October 2007
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDTech Quote  Post ReplyReply Direct Link To This Post Posted: 27 December 2008 at 9:28am
Oleg,

Originally posted by oleg oleg wrote:

Yes Text property is locked when user edit item. :( You can replace text with SetWindowText API + CommandBar.SelectedControl.Hwnd.


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


Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 05 January 2009 at 2:53am
Hi,
Thanks for share this :)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
DDTech View Drop Down
Groupie
Groupie


Joined: 10 October 2007
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDTech Quote  Post ReplyReply Direct Link To This Post Posted: 06 January 2009 at 2:22pm
Originally posted by oleg oleg wrote:

Thanks for share this :)


My pleasure. Thank You for the hint

regards

Frank
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.