RichTextBox IgnoreKey?

Discussion in 'Questions (Windows Mobile)' started by RandomCoder, Jun 14, 2009.

  1. RandomCoder

    RandomCoder Well-Known Member Licensed User

    As the RichTextBox has no Events, how to achieve Ignore Key or move Focus.

    I'm already using the door library and so have tried making the RichTextBox.Enabled = False but this greys everything out.

    Ideally what I would like is a RichTetBox that cannot be edited by the user.
    Also, is it possible to set the scrollbars to the top of the document in the event that a really long file has been loaded?

    Regards,
    RandomCoder.
     
  2. RandomCoder

    RandomCoder Well-Known Member Licensed User

    I've found a solution using the control events library.

    Code:
    ...
    CntrlEvent.New1( RichText.ControlRef )
    ...

    Sub CntrlEvent_GotFocus
       FrmObject.Value = TxtTsOrder.ControlRef
       FrmObject.RunMethod( 
    "Focus" )
    End Sub
    This way the richtextbox never gets focus long enough to be able to enter any data :sign0060:

    I'm still struggling with setting the scroll bar position though.
    Plus another slightle improvement has arisen, Is it possible to set the print preview window to maximised?

    Regards,
    RandomCoder
     
  3. agraham

    agraham Expert Licensed User

    ControlEvents is really obsolete now that the Door library supports events. Try this, it also works on a TextBox.

    Obj1.New1(False)
    Obj1.Value = RTD.ControlRef
    Obj1.SetProperty("ReadOnly", True)


    Try this, the RTD must have the focus so move the focus to it then move it away after if necessary.

    Obj1.New1(False)
    Obj1.Value = RTD.ControlRef
    Obj1.RunMethod("Focus")
    Obj1.SetProperty("SelectionStart", 0)
    Obj1.SetProperty("SelectionLength", 0) ' may not need this
    Obj1.RunMethod("ScrollToCaret", 0) ' probably will need this

    It's already there, RTD.PrintPreviewState = 2
     
  4. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Thanks AGraham, I'll try tomorrow as its late now.

    Note to myself... read the help files more thoroughly :sign0013:

    Regards,
    RandomCoder
     
  5. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Just for completenes, and for anyone else that may have been following this thread.

    This works but still greys out the RichTextBox, much the same as setting the enable property to False.

    This didn't work and also produces an error with this line Obj1.RunMethod("ScrollToCaret", 0), removing the ",0" got rid of the error but still did not move the scorll bar to the top of the page.

    However! By moving the focus away from the RichTextBox as soon as it gets Focus, a side effect is that the scrollbars remain at the top of the page and the background is still white :cool:

    Problem solved. I'll now remove the ControlEvents library and instead use the door library to catch the GotFocus event thus removing the need for an extra library. I think I'm nearly done now, thanks for all the help.

    Regards,
    RandomCoder
     
  6. agraham

    agraham Expert Licensed User

    Really? I just tried this on my RichTextBox demo and it doesn't gray out there but does stop user editing.

    :signOops::sign0013: I normally try code before I post but, to quote Erel "It wasn't tested and therefore doesn't work". It should be

    Code:
    Obj1.RunMethod2("ScrollToCaret"0"System.String"' probably will need this
    Actually I still haven't tested it but it should be OK now! :)
     
  7. RandomCoder

    RandomCoder Well-Known Member Licensed User

    @AGraham, By moving the Focus it now does everything that I need.

    But now a new problem has arisen :sign0013:
    A while ago you created me a FolderDialogDesktop.dll which basically works like the OpenDialog in B4PPC but returns the folder path instead of a file path.
    The problem is that I get this error message when attempting to at the component....
    Other components I already have installed are FormExesktop, ControlsExDesktop, SerialEx, and BinaryFile.

    Regards,
    RandomCoder
     
  8. agraham

    agraham Expert Licensed User

    Actually it wasn't, too much speed without checking. I've just checked putting the code into my RichTextDemo program and your original amendment was correct and should have worked!

    That's because FolderDialog is now included in ControlsExDesktop, as from version 1.4, so you don't need a separate library.
     
    Last edited: Jun 17, 2009
  9. RandomCoder

    RandomCoder Well-Known Member Licensed User

    I can not emphasise this enough... your a star :sign0188:

    Thanks,
    RandomCoder
     
  10. Zenerdiode

    Zenerdiode Active Member Licensed User

    I have a RichTextBox that is populated by incoming data from Serial Ports. I was wanting similar control of the RichTextBox to RandomCoder; however I wanted the box to scroll to the end of the data each time. I placed this at the end of my OnCom event Sub and I confirm it works;

    Code:
    Obj1.Value=RichText.ControlRef
    Obj1.RunMethod(
    "Focus")
    RichText.SelectionStart=StrLength(RichText.Rtf)
    RichText.SelectionLength=
    0
    Obj1.RunMethod(
    "ScrollToCaret")
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice