Results 1 to 18 of 18

Thread: Lock the Rich Text Box Control

  1. #1

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Lock the Rich Text Box Control

    If you use RichTextBox1.Locked = True property the RichTextBox is not totally Locked.

    For example i locked the richtextbox with an image inside and i still resized the image and delete it but i couldn't type anything! Is there any way to lock Rich Text Box control in all properties?
    (Text, Images etc)
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465
    I'm not in VB right now, so my info is probably faulty, but have you tried the "Enabled" property?

  3. #3

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    Enable = False property does not allow user to click on Rich Text Box and i don't want something like this! But thanks for help!


    If you find something else then please send it!
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Might not be the best but when you are done with all the adding data, have the exact same text/images in another RTB and in the change event of the main RTB you show, set the data to the data of the hidden RTB... Of course, it's not the best solution and it could have flickering...


    Has someone helped you? Then you can Rate their helpful post.

  5. #5

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Thumbs down

    I wouldn't be a good idea because it would be too slow!

    Any other ideas?
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  6. #6
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    How would LockWindowUpdate work? I don't have VB now to try it...


    Has someone helped you? Then you can Rate their helpful post.

  7. #7

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    I don't have idead for what are you talking about! I don't know this!
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  8. #8
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    VB Code:
    1. Declare Function LockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Long) As Long

    Pass the RTB's hwnd...


    Has someone helped you? Then you can Rate their helpful post.

  9. #9
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    I had a similar problem for a chat program that I was making, and the only solution was to enable = false it.
    Don't Rate my posts.

  10. #10

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    Manavo11, and how to unlock it then?
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  11. #11
    Fanatic Member
    Join Date
    Jul 2002
    Location
    Australia
    Posts
    635
    Originally posted by manavo11
    VB Code:
    1. Declare Function LockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Long) As Long

    Pass the RTB's hwnd...
    Very simple and easy to use code.
    A.A. Fussy
    Babya Software Group

  12. #12
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Originally posted by DarkX_Greece
    Manavo11, and how to unlock it then?
    VB Code:
    1. LockWindowUpdate 0&
    Last edited by manavo11; Apr 3rd, 2004 at 05:00 PM.


    Has someone helped you? Then you can Rate their helpful post.

  13. #13

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    Thanks Manavo11! ( I am not good on API coding)
    I like most the math coding!
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  14. #14
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    No problem So it works?


    Has someone helped you? Then you can Rate their helpful post.

  15. #15

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Unhappy

    No!!!

    I have a code:

    LockWindowUpdate 0& 'This for unlocking the rtb
    'There is some code here...for example....
    RichTextBox.SelRtf = "\b Hello\b0"
    LockWindowUpdate RichTextBox.hWnd 'This for locking the rtb



    But there is nowhere Hello , that it should be in the RTB!

    What is the wrong in the whole thing?
    I can't make it work!
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  16. #16
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Fiddling with the RTF will only end in tears mate.

    Might I suggest instead,

    RTB1.Selstart = whatever
    RtB1.sellength = len(ofword)
    RTB1.SelBold = True
    Don't Rate my posts.

  17. #17
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    You will probably need a DoEvents in there somewhere. As MartinLiss pointed out to me in another post, LockWindowUpdate will store everything that happens to the object, and once you pass 0& to LockWindowUpdate again (to 'unlock' it), all the changes that were stored will take place. Also, with LockWindowUpdate, it will automatically stop when you move the window (application window). You will need something like this:

    You also may want to use UpdateWindow to unlock it, as LockWindowUpdate 0& doesn't seem to work everytime (for me anyway):

    VB Code:
    1. Declare Function UpdateWindow Lib "user32" (ByVal hwnd As Long) As Long


    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  18. #18

    Thread Starter
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315
    Use the UpdateWindow decalere function with LockWindowUpdate declare function! Can i lock a RichTextBox control through UpdateWindow? Or only to unlock it?
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width