Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Transperent chatbox script


turbocookie
 Share

Recommended Posts

This is obviously a source question as scripting can't get this done. So I'm escalating this thread to the Source Questions board.

The only ways to get a transparent textbox is via GDI, GDI+ or DirectX. As GDI and GDI+ aren't suitable for games actually, it's recommended to do it through DirectX, in which case you're basically enforced to use Direct3D instead of DirectDraw since the alpha channel isn't common in DirectDraw.

Regards,
  Godlord.
Link to comment
Share on other sites

@turbocookie:

> hahaha godlord you are very technical you know, us noobs (me) dont understand too much of it =]

Then do some research. You have Google, Wikipedia, MSDN, etc. at your disposal and yet you don't do anything with that. We're not here to provide you a detailed guide on how to add feature X to your game.

Regards,
  Godlord.
Link to comment
Share on other sites

@turbocookie:

> trust me i am using them except the MSDN i didnt install it xD

The MSDN is available online, if you Googled a bit, you would have known that. [Visual Basic 6.0 Resource Centre](http://msdn.microsoft.com/en-us/vbrun/default.aspx).

Regards,
  Godlord.
Link to comment
Share on other sites

As Dmitry said, you can use alpha blending in Direct3D. Eclipse uses DirectDraw7, however, which doesn't natively support it.

The only ways to do this is to have a D3D and DD7 hybrid (Which is beyond you) or to steal the current night rendering system and lock the DC every loop, use some sort of C++ library to alpha blend (vbDabl does something like this, but only with 16bit? I think), then unlock the DC.

Slow, but the only way you're going to do it.
Link to comment
Share on other sites

I try..
I found [this](http://www.vbforums.com/showthread.php?t=438895&highlight=transparent+TextBox).

I report a portion of that code only for a question of speed.
I repeat, it's not a my own code\work.

```
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" ( _
    ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_TRANSPARENT = &H20&

Private Sub Form_Load()
    SetWindowLong RichTextBox1.hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT
End Sub

```
You just need only of a [ RichTextBox1 ].
I test it and the result is cool. :D

It can resolve your problem, for a part.
Lemme know please.

–-update

Whoa.. I'm a bit surprised.
See, test [this](http://www.a1vbcode.com/app-2467.asp).

Yeahyeah, now I will resolve a few of things.
Link to comment
Share on other sites

About transparent PictureBox.

This is a way to get a transparent background. Pay attention, it's the first time you will use a User Control - I guess. An User Control permits you to create your own controls. In this case it will permit you to unite an image with a color mask. Think, in this way you can stuck and delete the background color (that you wish) from the image.

So, test this.
Create a new project in VB6\. "Menu > Project > Add User Control". Don't care to rename the [ User Control ], it's called [ User Control 1 ] by default. - From now I will work only in [ User Control ].

In "Properties" of [ User Control ], set [ BackStyle ] to [ 0 - Transparent ] . Now, add a new [ Picture Box ] and, in "Properties", set [ Visible ] to [ False ] - don't care about the sizes of [ Picture Box ].

Double click on [ User Control ] - you enter in code mode. Add this:
```
Public Property Set Pic(ByVal vNewValue As Variant)
  Picture1.Height = UserControl.Height
  Picture1.Width = UserControl.Width
  Set Picture1.Picture = vNewValue
  Set UserControl.Picture = Picture1.Image
  Set UserControl.MaskPicture = Picture1.Image
End Property

Public Property Get MaskColor() As Long
  MaskColor = UserControl.MaskColor
End Property

Public Property Let MaskColor(ByVal vNewValue As Long)
  UserControl.MaskColor = vbNewValue
End Property
```
Shortly. [ Public Pic ] permits to load an image, it will be masked.
[ MaskColor ] permits to cut off the background color of the image loaded by [ Public Pic ].

Now, close the [ User Control ] window. Back to [ Form1 ].
*If you won't close [ User Control ] window, you can't use it anywhere*.

Look your "Tool Box", a new component is present. It's the [ User Control ] created, before. Drag the component in [ Form1 ].

Add a new [ PictureBox ] and import an image with a monocromatic background - look for an example\make an your own image -.

Add this in [ Form1 ] code:
```
Private Sub Form_Load()
UserControl11.Top = Picture1.Top
UserControl11.Left = Picture1.Left
UserControl11.Height = Picture1.Height
UserControl11.Width = Picture1.Width
UserControl11.MaskColor = &H80000005
Set UserControl11.Pic = Picture1.Picture
Picture1.Visible = False
End Sub
```

* Black = &H00000000(&)
* White = &H80000005(&)
* Red = &H000000FF(&)
* Fuxia = &H00FF00FF(&)
* Green = &H0000FF00(&)
Link to comment
Share on other sites

Making a user control is completely over the top.

If you want a transparent RTB, just use the age-old method of doing so.

It's not hard to create a rendered chat box, however. You just need to create a self-managed string array, a render procedure, a text wrapper and the user's input on the scrollbar.
Link to comment
Share on other sites

> @Robin -Making a user control is completely over the top.

Well, this topic makes me interested and that was my first answer.

> @Robin -self-managed string array, a render procedure, a text wrapper and the user's input on the scrollbar.

Sorry but at this point I'm curious. I come from Java, where an array must have a length fixed\declared. I dunno in VB, but in Java if you increase the length of an array, you need to declare a new array with a function and blablabla.
So, -example- in which way do I use an array? Is VB able to increase the length of the array automatically everytime? And the array should save what players write\tell, right?

About scrollbars there're not problems, I guess. I can take inspiration from "scrollbars" buttons of the old standard inventory.

I'm really tring to understand it, but I get some difficulties to image the function of array and how it should run. Please, give me also some suggestions.

Thanks.
Link to comment
Share on other sites

> @Robin

Whoa… You gained 100 points of esteem.
Just at the begginning I though "Redim = Reorganize" .. So I had doubts. So, before to post I wanted to catch the essence of your post. I'm not so expert to.. understand.. an entire concept from a command.

Ahahah.
You gave me the answer more precise I could get - thanks.

Really, a short example - please confirm it:
```
Redim Array(n)
```So if I want to increase it I need simply to write [ Redim Array(n+X) ] ?

I have just noticed a function to preserve the datas already in the array.

Small doubt - so I return in theme of this topic -: I won't to overload Client\Server connection in this way, right? I'm just thinking what can happen with the management of more links (bah.. 200-300). Eh.. the Array have to be read and reload again in every Client but it's located only in Server.. This just is only a thought..
Awaiting for your answer about it.

Anyway now I think to understand how to code, I would need to try.

Thanks again.
Link to comment
Share on other sites

Yessum, thanks.

Eheh, I noticed that, as I wrote in my previous post.
Good, I will try to use this new strument. Mh.. It could be useful for me to update my multiple system of èrivate chat(s).

- Oook, I'm OT now. Let's skip it, thanks! :D
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...