Jump to content
Sign in to follow this  

Floating Text (With Transparent Background)

Recommended Posts

Yes, I know, another Transparent Background thing, the topics are everywhere! lolz.

So I am trying to display text in the middle of the screen. I am currently using a couple different methods, but nothing looks good. So I will begin by describing what I am doing, then what I am achieving.

I used lod3n's technique for a .PNG overlay (http://www.autoitscript.com/forum/index.php?showtopic=47651)

Here is the PNG for reference: post-909-1191864656_thumb.png

Those labels are static, they will not change, however, you can see that i left room for statistics.

I want another .au3 to read from an ini, values into those spots, which is easy, but the labels themselves are the problem i am having.

I have tried using this method: http://www.autoitscript.com/forum/index.php?showtopic=43180 - but it doesnt display the text well. It is choppy, it isnt actually size 11, like i used in the PNG, and it isnt readable!

Do I have any other options? What can be done to make this work?

The labels have to be able to be changed frequently and limitlessly...

Edited by PreludeOfDeath

Share this post

Link to post
Share on other sites

The DC isnt working.... Still is choppy and crappy looking... lolz

Drawing text on DC is a good method and it works good.

If it doesn't work for you, post the example how you are using it, so we can maybe fix it.

I just copied the main code and did some slight edits....

#include <GUIConstants.au3>

$font = "Tahoma"

$hwnd = GUICreate("Text Region",400,50,405,85,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))

$rgn = CreateTextRgn($hwnd,"100%",13,$font)



Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)

;Func CombineRgn(ByRef $rgn1, ByRef $rgn2)
;   DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 2)

Func CreateTextRgn(ByRef $CTR_hwnd,$CTR_Text,$CTR_height,$CTR_font="Microsoft Sans Serif",$CTR_weight=1000)
    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 $CTR_font = "" Then $CTR_font = "Microsoft Sans Serif"
    If $CTR_weight = -1 Then $CTR_weight = 1000
    Local $gdi_dll = DLLOpen("gdi32.dll")
    Local $CTR_hDC= DLLCall("user32.dll","int","GetDC","hwnd",$CTR_hwnd)
    Local $CTR_hMyFont = DLLCall($gdi_dll,"hwnd","CreateFont","int",$CTR_height,"int",0,"int",0,"int",0, _
                "int",$CTR_weight,"int",0,"int",0,"int",0,"int",$ANSI_CHARSET,"int",$OUT_CHARACTER_PRECIS, _
                "int",$CLIP_DEFAULT_PRECIS,"int",$PROOF_QUALITY,"int",$FIXED_PITCH,"str",$CTR_font )
    Local $CTR_hOldFont = DLLCall($gdi_dll,"hwnd","SelectObject","int",$CTR_hDC[0],"hwnd",$CTR_hMyFont[0])
    Local $CTR_hRgn1 = DLLCall($gdi_dll,"hwnd","PathToRegion","int",$CTR_hDC[0])
    Local $CTR_rc = DLLStructCreate("int;int;int;int")
    Local $CTR_hRgn2 = DLLCall($gdi_dll,"hwnd","CreateRectRgnIndirect","ptr",DllStructGetPtr($CTR_rc))
    Return $CTR_hRgn2[0]
Edited by PreludeOfDeath

Share this post

Link to post
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
Sign in to follow this  

  • Create New...