Jump to content

_winapi_drawtext


Recommended Posts

In this script, I have successfully got it to display the text on screen. The only thing I cannot get it to do is remove the text. The text remains onscreen after the script exits. It does not disappear until I refresh the screen or open a new window. I thought the Redraw line would do this for me but is not working. I hope someone can tell me how to remove the text from the screen without having to refresh or open a new window.

Thanks.

#Include<StructureConstants.au3>

#Include <WinAPI.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#include <FontConstants.au3>

$hDC = _WinAPI_GetDC(0);Gets handle of entire screen

_WinAPI_SetTextColor($hDC, "0x0000FF");Sets color of text

$bkmode = DllCall("GDI32.dll", "int", "SetBkMode", "hwnd", $hDC, "int", "TRANSPARENT");Sets background of text to Transparent

$font = _WinAPI_CreateFont(50,15);Creates a font 50 pixels high and 15 pixels/character wide

_WinAPI_SelectObject($hDC, $font);Selects newly created font

$sText = "Hello world, this is my test message!";Sets actual message to be displayed.

$rect = DllStructCreate($tagRECT);Creates region where text is to be displayed.

DllStructSetData($rect,1,0)

DllStructSetData($rect,2,0)

DllStructSetData($rect,3,1280)

DllStructSetData($rect,4,50)

$iFlags = "$DT_CENTER";Sets how text is positioned in region.

_WinAPI_DrawText($hDC, $sText, $rect, $DT_RIGHT);Draws the text

sleep(1000);Waits 1 second

_WinAPI_RedrawWindow("","","",$RDW_UPDATENOW);Should repaint the entire screen to remove the text but does not work.

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...