Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CHALLENGE: Make a better drag and drop to a form.
#1
Okay, this only works for Windows systems, and since I only run Windows, I'll have to take your word for a Mac or Linux version.

1) Open a form, or use this forum (use an input box, the URL input line, etc.) or just open notepad.

2) Move whatever you opened to the right side of the screen, and make it about 1/2 the screen width with the form space accessible.

3) Run the code.

4) Drag the contents in the QB64 window into the form space (or anywhere in notepad) and release the mouse button to drop it there.

It's a bit jittery, and I don't know if that will vary from system to system.

Code: (Select All)
text$ = "Pete's tremendous!"
$Color:32
Const VK_CONTROL = &H11 ' Ctrl key
Const KEYEVENTF_KEYUP = &H2
Type POINTAPI
    X_Pos As Long
    Y_Pos As Long
End Type
Dim WinMse As POINTAPI
Declare Dynamic Library "User32"
    Function GetAsyncKeyState% (ByVal vkey As Long)
    Function GetCursorPos (lpPoint As POINTAPI)
    Sub SENDKEYS Alias keybd_event (ByVal bVk As Long, ByVal bScan As Long, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
End Declare
Dim As Integer fw, fh, WinX, WinY, lb
Width 80, 25
_ScreenMove 50, 200
_Delay .5
Color 15, 0: Cls
WinX = 30: WinY = 12
Locate WinY, WinX, 0
Print text$;
t& = _NewImage(200, 15, 32)
_Dest t&
Color _RGBA32(190, 190, 190, 128), _RGBA32(0, 0, 0, 0)
_PrintString (0, 0), text$
_Clipboard$ = text$
win& = _CopyImage(t&, 33)
_FreeImage (t&)
_Dest 0
Do
    _Limit 60
    If onetime Then _PutImage (0, 0), imgdesk&
    While _MouseInput: Wend
    mx = _MouseX
    my = _MouseY
    lb = _MouseButton(1)
    If lb Then
        If Drag Then
            WinX = mx - Drag: WinY = my
            _PutImage ((WinX - 1) * fw, (WinY - 1) * fh), win&
        Else ' Set drag cursor position in title bar.
            If onetime = 0 Then
                y1 = _ScreenY: x1 = _ScreenX: fw = _FontWidth: fh = _FontHeight
                WinY = WinY + 1 + y1 \ fh: WinX = WinX + 1 + x1 \ fw
                tmp& = _ScreenImage
                imgdesk& = _CopyImage(tmp&, 33)
                _FreeImage tmp&
                Width _DesktopWidth \ 8 + 8, _DesktopHeight \ 16 - 2: _Font 16
                _ScreenMove -16, -32
                onetime = 1
            End If
            If mx >= WinX And mx <= WinX + Len(text$) And my >= WinY And my <= WinY + 1 Then
                Drag = mx - WinX
            End If
        End If
    Else
        If Drag Then
            z& = GetCursorPos(WinMse)
            y = WinMse.Y_Pos: x = WinMse.X_Pos
            Drag = 0
            Width 80, 25: _Display
            _ScreenMove x1, y1: _Delay .5
            lb = 0
            _ScreenClick x, y ' IT MAKES A SCREEN CLICK, SO DON'T RELEASE THE MOUSE ON SOMETHING YOU DON'T WANT CLICKED.
            _Delay .5
            SENDKEYS VK_CONTROL, 0, 0, 0 ' SENDKEYS ROUTINE PASTES THE DRAGGED QB64 TEXT INTO THE OTHER APP.
            _Delay .1
            SENDKEYS &H56, 0, 0, 0 ' V
            _Delay .1
            SENDKEYS &H56, 0, KEYEVENTF_KEYUP, 0
            _Delay .1
            SENDKEYS VK_CONTROL, 0, KEYEVENTF_KEYUP, 0
            Exit Do
        End If
    End If
    If Len(InKey$) Then _Delay .5: System
    Rem If Drag Then _MouseMove WinX + Drag, WinY
    _Display
Loop


Have a better way? Post your code today!

Kidding aside, an all Win API method, that would carry the shadow of the characters across the screen, would be preferable.

Pete
Reply


Messages In This Thread
CHALLENGE: Make a better drag and drop to a form. - by Pete - 12-20-2025, 08:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Flaming Text (let's make it a challenge) SMcNeill 7 378 01-31-2026, 08:31 AM
Last Post: bplus
  Clouds? for 100 Lines or Less Challenge bplus 12 1,046 10-27-2025, 08:23 AM
Last Post: bplus
  Peek-a-boo Hardware Form Concept Pete 14 2,017 04-10-2025, 09:49 PM
Last Post: Pete
  Writing on hardware form by switching display order. Pete 0 444 04-09-2025, 03:00 AM
Last Post: Pete
  Screw Peek-a-boo. Write on a hardware image form. Pete 0 443 04-08-2025, 11:28 PM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)