Jump to content
Sign in to follow this  

Draggable, floating text ... how?

Recommended Posts

I was certain I had seen this basic capability in a simple example.  But, after a day of looking at examples, I've only found text that can march across the screen ... and even fly in different directions.

Can anyone point me to a basic capability? ... one that includes:

►Block with rounded corners

►Block size independent of the text size

►Font specified from the Win font library

►Entire block draggable from its initial position

Attached is an example of the result I'm seeking.

Thanks in advance for any help.



Share this post

Link to post
Share on other sites


The Moving and Resizing PopUp GUIs tutorial in the Wiki shows you several ways to do the "draggable" bit - the "font" and "colour" requirements are done with basic AutoIt GUI functions. And there are umpteen "rounded corner" examples on the forum - use the Search facility to find them. ;)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

Thanks for the nudge.  I found a starting point in an example on rounded-corner GUIs.  Here's what I was able to construct:

;           Simple Floating Text Overlay
#include <GuiConstants.au3>
$sFont = "Comic Sans MS"

$my_gui = GuiCreate("MyGUI", 900, 120, -1, -1, $WS_POPUP)
_GuiRoundCorners($my_gui, 0, 0, 30, 30)
GUICtrlCreateLabel("Floating block of overlaid text ... draggable.", 60, 30, 900, 60, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont(-1, 28, 400, 2, $sFont)

While 1
    $msg = GuiGetMsg()
    Case $msg = $GUI_EVENT_CLOSE
    Case Else

Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
   Dim $pos, $ret, $ret2
   $pos = WinGetPos($h_win)
   $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
   If $ret[0] Then
      $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
      If $ret2[0] Then
         Return 1
         Return 0
      Return 0
EndFunc  ;==>_GuiRoundCorners

Dragging the whole background would be a nice touch, but this method serves my immediate purpose and meets my goal of simplicity.

Thanks, again.

Share this post

Link to post
Share on other sites

Dragging the whole background would be a nice touch


For anyone following this, here's the function—in its simplest form—that makes the block draggable:



Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $my_gui) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION


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