Jump to content

Text on top of everything


jimmer
 Share

Recommended Posts

  • 1 month later...

Just a question, is there anyway to update the text without deleting the gui and making a new one? I made a small script to display the current song playing in winamp, for when im playing games, but one of my games has an opengl crash whenever a new window is created and the game is fullscreen,

All in all it is a great script

Link to comment
Share on other sites

heres my result, although it probly has alot of excess code

Func UpdateTextWindow($hwnd,$zText,$width,$height,$font="Microsoft Sans Serif",$weight=1000,$x=-1,$y=-1,$color=-1)
    Local Const $ANSI_CHARSET = 0
    Local Const $OUT_CHARACTER_PRECIS = 2
    Local Const $CLIP_DEFAULT_PRECIS = 0
    Local Const $PROOF_QUALITY = 2
    Local Const $FIXED_PITCH = 1
    Local Const $RGN_XOR = 3
    
    If $font = "" Then $font = "Microsoft Sans Serif"
    If $weight = -1 Then $weight = 1000
    
    If $color <> -1 Then GUISetBkColor($color)
    Local $hDC= DLLCall("user32.dll","int","GetDC","hwnd",$hwnd)
    Local $hMyFont = DLLCall("gdi32.dll","hwnd","CreateFont","int",$height, _
                    "int",0,"int",0,"int",0,"int",1000,"int",0, _
                    "int",0,"int",0,"int",$ANSI_CHARSET, _
                    "int",$OUT_CHARACTER_PRECIS,"int",$CLIP_DEFAULT_PRECIS, _
                    "int",$PROOF_QUALITY,"int",$FIXED_PITCH,"str",$font )
    Local $hOldFont = DLLCall("gdi32.dll","hwnd","SelectObject","int",$hDC[0], _
                    "hwnd",$hMyFont[0])
    DLLCall("gdi32.dll","int","BeginPath","int",$hDC[0])
    DLLCall("gdi32.dll","int","TextOut","int",$hDC[0],"int",0,"int",0, _
                    "str",$zText,"int",StringLen($zText))
    DLLCall("gdi32.dll","int","EndPath","int",$hDC[0])
    Local $hRgn1 = DLLCall("gdi32.dll","hwnd","PathToRegion","int",$hDC[0])
    Local $rc = DLLStructCreate("int;int;int;int")
    DLLCall("gdi32.dll","int","GetRgnBox","hwnd",$hRgn1[0], _
                    "ptr",DllStructGetPtr($rc))
    Local $hRgn2 = DLLCall("gdi32.dll","hwnd","CreateRectRgnIndirect", _
                    "ptr",DllStructGetPtr($rc))
    DLLCall("gdi32.dll","int","CombineRgn","hwnd",$hRgn2[0],"hwnd",$hRgn2[0], _
                    "hwnd",$hRgn1[0],"int",$RGN_XOR)
    DLLCall("gdi32.dll","int","DeleteObject","hwnd",$hRgn1[0])
    DLLCall("user32.dll","int","ReleaseDC","hwnd",$hwnd,"int",$hDC[0])
    DLLCall("user32.dll","int","SetWindowRgn","hwnd",$hwnd,"hwnd",$hRgn2[0],"int",1)
    DLLCall("gdi32.dll","int","SelectObject","int",$hDC[0],"hwnd",$hOldFont[0])
EndFunc

all i really did was pass on the hwnd of a previously created window, rather than creating it in-script

It works well enough for my purpose anyway

Edited by death pax
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...