Results 1 to 4 of 4

Thread: transparency problem....

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    transparency problem....

    Hey, I'm going to have scrolling text on top of a textured image in my program, so the area where the text is needs to be transparent so you can see through to image. Here's the problem:
    Using the worthless (for scrolling anyway) label control, I get tons of flickering. Someone suggested I use a picture box, but here's the problem with that: If I put the same image as the background image in the picture box, then the patterns don't match up at all (remember, it's a textured image!). And, I didn't see anywhere to set a picturebox background to transparent. Sooo, my question is: What kind of control do I need to use to accomplish this? Is there an activeX control I can d/l to do this? I'd like to stay away from directx as someone before mentioned that would be overkill for my purposes. Any help is appreciated.

  2. #2
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Is the image tiled or not? How is the text scrolled, just from right to left again and again, is it bouncing, etcetera....

    (just trying to collect some info before I start writing code )
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    It's like this!

    text just scrolls from left to right, and, no, the image is not tiled. Thanks for any help you can give.

  4. #4
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    (hopefully the next piece of code is bug-free, no VB here, sorry)



    Drop a picturebox on your form.

    Name: picBackground
    Picture: Your background image
    AutoSize: True
    AutoRedraw: True
    ScaleMode: vbPixels
    Font: Whatever font you want to use


    Also drop a timer on your form:

    Name: tmrScroll
    Interval: 100 (experiment with this, unfortunately, the timer practically won't go lower than 50, or 10 on Windows NT)
    Enabled: True



    In the General -> Declarations of your form:

    VB Code:
    1. Private lXPos As Long
    2. Private Message As String


    Form_Load:

    VB Code:
    1. Sub Form_Load()
    2.   lXPos = picBackground.ScaleWidth
    3.   Message = "Ain't that cute!"
    4. End Sub


    tmrScroll_Timer:

    VB Code:
    1. Sub tmrScroll_Timer()
    2.   ' Move text (change -1 for faster movement)
    3.   lXPos = lXPos - 1
    4.  
    5.   If lXPos < picBackground.TextWidth(Message) Then lXPos = picBackground.ScaleWidth
    6.  
    7.   ' Clear the picturebox
    8.   picBackground.Cls
    9.  
    10.   ' Draw the text
    11.   picBackground.CurrentX = lXPos
    12.   picBackground.CurrentY = (picBackground.ScaleHeight - picBackground.TextHeight(Message)) / 2
    13.   picBackground.Print(Message)
    14.  
    15.   ' Display changes
    16.   picBackground.Refresh
    17. End Sub


    Now that's the non-API way, you could also replace CurrentX, CurrentY and Print with the TextOut API, but I don't know the declaration, and this should also work theoretically

    Note that when you are going to use the API, ScaleMode has to be Pixels, so just in case I already let you set it

    Hope that helps...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

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