Print Page | Close Window

Changing text from within CommandBarKeyDown()

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=13018
Printed Date: 07 October 2024 at 8:34am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Changing text from within CommandBarKeyDown()
Posted By: DDTech
Subject: Changing text from within CommandBarKeyDown()
Date 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





Replies:
Posted By: Oleg
Date 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


Posted By: DDTech
Date 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




Posted By: Oleg
Date Posted: 05 January 2009 at 2:53am
Hi,
Thanks for share this :)


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: DDTech
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net