Sign in to follow this  
Followers 0
qwert

Draggable, floating text ... how?

4 posts in this topic

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.

 

post-29172-0-68976600-1400466146_thumb.p

Share this post


Link to post
Share on other sites



qwert,

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

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)
GUISetBkColor(0x990000)
GUICtrlSetDefColor(0xFFFFFF)
GUICtrlCreateLabel("Floating block of overlaid text ... draggable.", 60, 30, 900, 60, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont(-1, 28, 400, 2, $sFont)
GuiSetState()

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
;
    EndSelect
WEnd
Exit

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
      Else
         Return 0
      EndIf
   Else
      Return 0
   EndIf
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:

:
:
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")

:
:

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

:

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  
Followers 0