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

Attemp to make transparent chatbox, help!


Jacquelinett
 Share

Recommended Posts

hey, i was trying to make my chatbox transparent, here is what i have done.

in mod type
```
' AlphaBlend
Public Type BLENDFUNCTION
  BlendOp As Byte
  BlendFlags As Byte
  SourceConstantAlpha As Byte
  AlphaFormat As Byte
End Type
Public Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal BLENDFUNCT As Long) As Long
Public Declare Sub RtlMoveMemory Lib "kernel32.dll" (Destination As Any, Source As Any, ByVal Length As Long)

```
modGameLogic
```
Public Sub ChatBlend()
'AlphaBlend for chatbox
    Dim BF As BLENDFUNCTION, lBF As Long
    'Set the graphics mode to persistent
    frmMain.Picture8.Picture = LoadPicture(App.Path & "\data files\graphics\gui\main\chatbox_text.jpg")
    frmMain.Picture8.AutoRedraw = True
    frmMain.picScreenBuffer.AutoRedraw = True
    'set the parameters
    With BF
        .BlendOp = AC_SRC_OVER
        .BlendFlags = 0
        .SourceConstantAlpha = 128
        .AlphaFormat = 0
    End With
    'copy the BLENDFUNCTION-structure to a Long
    RtlMoveMemory lBF, BF, 4
    ' frmMain.picScreenBuffer.Picture =
    'AlphaBlend the picture from Picture1 over the picture of Picture2
    AlphaBlend frmMain.Picture8.hdc, 0, 0, frmMain.Picture8.ScaleWidth, frmMain.Picture8.ScaleHeight, frmMain.picScreenBuffer.hdc, frmMain.Picture8.Left, frmMain.Picture8.top, frmMain.Picture8.ScaleWidth, frmMain.Picture8.ScaleHeight, lBF
End Sub

```
modConstants:
```
'Declarations/Functions for Transparent Rich Text Boxs
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_TRANSPARENT = &H20&

'Alpha Blend
Public Const AC_SRC_OVER = &H0

```
frmMain, sub formload
```
    Dim TransRichText As Long
    TransRichText = SetWindowLong(txtChat.hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT)

```                  *****************
replace the ** Render graphic ** with this:
                  *****************
```
        Call Render_Graphics
        If Options.ChatBlend = 1 Then
            Call ChatBlend
        End If
        frmMain.txtChat.Refresh
        DoEvents
        frmMain.txtChat.Refresh
        ' Lock fps
        If Not FPS_Lock Then
            Do While GetTickCount < Tick + 15
                DoEvents
                Sleep 1
                frmMain.txtChat.Refresh
            Loop
        End If

        ' Calculate fps
        If TickFPS < Tick Then
            GameFPS = FPS
            TickFPS = Tick + 1000
            FPS = 0
        Else
            FPS = FPS + 1
        End If

    Loop

    frmMain.Visible = False

    If isLogging Then
        isLogging = False
        frmMain.picScreen.Visible = False
        frmMenu.Visible = True
        GettingMap = True
        StopMidi
        PlayMidi Options.MenuMusic
    Else
        ' Shutdown the game
        frmLoad.Visible = True
        Call SetStatus("Destroying game data...")
        Call DestroyGame
    End If

```There…
That what i did, but the chatbox is still not transparent, any idea?

btw, picture 8 is the picture box that contain the chat
Link to comment
Share on other sites

I'm afraid games don't magically get developed because you 'work hard'.

There are 1,000s of examples of how to make an RTB transparent around the web. Take any of them and implement it _properly_ (meaning you don't just copy & paste the code around willy-nilly) and you'll be golden.
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...