Results 1 to 10 of 10

Thread: Background images on richtextboxes!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    23

    Question

    I need to make a richtextbox either transparent to see an image behind it, or able to have an image be painted on the background of the control... is this possible? In AoE, they do that for listboxes...
    -_=Progrium=_-

  2. #2
    Guest
    This will only work in VB5 and 6.

    Code:
    Option Explicit
    Private Const WS_EX_TRANSPARENT = &H20&
    Private Const GWL_EXSTYLE = (-20)
    
    Private Declare Function SetWindowLong Lib "user32" _
      Alias "SetWindowLongA" (ByVal hwnd As Long, _
      ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    
    
    
    Public Function MakeRTBTransparent(RTBCtl As Object) As Boolean
    
    On Error Resume Next
    RTBCtl.BackColor = RTBCtl.Parent.BackColor
    SetWindowLong RTBCtl.hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT
    MakeRTBTransparent = Err.LastDllError = 0
    
    End Function
    
    Usage:
    
    MakeRTBTransparent RichTextBox1

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    23

    Question Cool...

    Wow, thanks! But it now it just makes it show the form's color, but if I put I but an image/picture box or just make the form's background picture, it doesn't show the picture in the rich text box like I want it to... there is a way to do this right?
    -_=Progrium=_-

  4. #4
    Guest
    Do you mean show the picture over the RichTextBox?

    Use the ZOrder method.

    Code:
    Private Sub Command1_Click()
    RichTextBox1.ZOrder vbSendToBack
    Picture1.ZOrder vbBringToFront
    End Sub
    Use a Picturebox and set the Border style to 0-None, I don't think the Imagebox will go on top of the RichTextBox when using the ZOrder method.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    23
    Ummm, no. My goal is to have a background image for the RTB, but I figured it out. I'm using another form in place of the RTB and using the print function and stuff... it works well and solves my problem, but thanks for your help!
    -_=Progrium=_-

  6. #6
    Guest
    Can you show me the code you've got?

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    23
    Well, in my situation, the program will be full screen and what takes up the screen is the main form (Form1 say). Where I was going to have the RichTextBox (as a log for my program) was going to take up all of the screen except for a bit of the top and bottom of the screen (for a menu bar and status bar) and I wanted the RichTextBox to have a faded image in the background to make the log a bit nicer looking. But now, instead of a RichTextBox, I have a form (Form2) that has no border, no caption, and all that with a picture loaded onto it (the faded picture background).

    When the prog starts, I show Form2 with Form1 as it's owner and place it where I want it through the code (Form2.Top = bla bla bla). That's basically it. Then to add entries to my log I use Form2.Print (Form2.AutoRedraw needs to be on). And to change font, just Form2.ForeColor or Form.FontBold etc etc, you get the point. There's not much code at all...

    Does that help? Heh...
    -_=Progrium=_-

  8. #8
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225

    Angry not getting transparent first time

    i just wanted the same thing to do rich text box transparent to what ever is on form.i load then and rich text box is not transparent till ths time.I have one button and click it and make it transparent from above code. but on the same time it doesnt get transparent but when i get focus again on form it becomes transparent i can see the prev image or form what ever it is.problem seems that it doesnt get refresh or have to paint form again. i did that also but it doesnt work. how i can make it transparent at first time . though i find just temp. solution for it.I am just making richtext box unvisible and then visible , then it shows the background first time just on click .

    but ne other logical way to do it ?

    regds
    Chander
    Email:[email protected]

  9. #9
    Fanatic Member
    Join Date
    Jan 2001
    Posts
    574

    MakeRTBTransparent for Treeview

    Is there a code like MakeRTBTransparent for a Treeview like:
    MakeTreeviewTransparent. Cause I know how to get a picture behind a Treeview only it's a little complicated.

  10. #10
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225
    i think u can .. rich text box is made transparent from setwindow API passing rich text box handle .. try passing treeview handle to it and making it transparent ...

    i will try i success will paste code here ....
    Chander
    Email:[email protected]

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