Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEV-SAMPLES-C-PM-DropText

An OS/2 Presentation Manager sample that demonstrates how to drag and drop text from an entry field onto any window that has a textual component.

DropText Screenshot

Description

Type a line of text in the entry field, then drag it over any window — title bar, push button, another entry field, or any other window with a textual component — and release the mouse button to replace that window's text.

The sample demonstrates a pattern of entry field subclassing and mouse capture to implement drag-and-drop without using the OS/2 Direct Manipulation API (INCL_WINSTDDRAG). Key techniques:

  • Subclass the entry field (WinSubclassWindow) to intercept WM_BEGINDRAG / WM_ENDDRAG and forward them to the dialog as user messages (UM_BEGINDRAG, UM_ENDDRAG).
  • Capture the mouse with WinSetCapture so that pointer events are delivered to the dialog even when the mouse moves over other windows.
  • Use WinWindowFromPoint to identify the window under the pointer, and WinSetWindowText to perform the drop.
  • Swap the pointer between a "drop allowed" pointer (DROPTEXT.PTR) and a "no drop" pointer (NODROP.PTR) to give the user visual feedback.
  • Cancel the drag on VK_ESC by releasing the capture and restoring the original pointer.

Key PM APIs demonstrated

API Purpose
WinSubclassWindow Replace the entry field's window procedure
WinSetCapture / WinQueryPointerPos Capture the mouse during drag
WinWindowFromPoint Find the window under the mouse pointer
WinSetWindowText Drop the text onto the target window
WinLoadPointer / WinSetPointer Custom drag pointer feedback
WinQueryWindow(QW_OWNER) Walk the window hierarchy to exclude own children

Requirements

  • OS/2 Warp 4.5x or later (including ArcaOS)
  • GCC 9.2 (bitwiseworks / kLIBC) or OpenWatcom 2.0 C compiler

Install build tools on ArcaOS:

yum install git gcc make libc-devel binutils watcom-wrc watcom-wlink-hll

Directory Structure

├── src/                    Source files
│   ├── DROPTEXT.C          Main source — main(), dialog proc, EF subclass proc
│   ├── DROPTEXT.H          Data structures, constants, and function prototypes
│   ├── DROPTEXT.DEF        Module definition file (BLDLEVEL)
│   ├── DROPTEXT.RC         Resource script (icon, pointers, dialog include)
│   ├── DROPTEXT.DLG        Dialog template
│   ├── DROPTEXT.ICO        Application icon
│   ├── DROPTEXT.PTR        "Drop allowed" mouse pointer
│   ├── NODROP.PTR          "Drop not allowed" mouse pointer
│   └── droptext-ow.lnk     OpenWatcom wlink response file
├── bin-gcc/                GCC build output (created by build)
├── bin-ow/                 OpenWatcom build output (created by build)
├── wiki/                   Screenshots
│   └── DROPTEXT_001.png    Application screenshot
├── compile-gcc.cmd         GCC build script
├── compile-ow.cmd          OpenWatcom build script
├── makefile-gcc            GCC makefile
├── makefile-ow             OpenWatcom makefile
├── DROPTEXT.TXT            Original IBM sample notes
├── .gitignore              Git ignore rules
├── LICENSE                 BSD 3-Clause License
└── README.md               This file

Building

Using GCC

compile-gcc.cmd

Or invoke make directly:

make -f makefile-gcc

Output: bin-gcc\DROPTEXT.exe

Using OpenWatcom

compile-ow.cmd

Or invoke wmake directly:

wmake -f makefile-ow

Output: bin-ow\DROPTEXT.exe

Cleaning build artifacts

make -f makefile-gcc clean
wmake -f makefile-ow clean

BLDLEVEL Information

bldlevel DROPTEXT.exe

Compile Notes

  1. Header files — use the kLIBC headers from libc-devel. Verify config.sys contains SET INCLUDE=C:\usr\include.

  2. Resource and linker toolswrc and wl.exe (Watcom tools) are used. Add to config.sys:

    SET EMXOMFLD_LINKER=wl.exe
    SET EMXOMFLD_TYPE=WLINK
    SET EMXOMFLD_RC_TYPE=WRC
    SET EMXOMFLD_RC=wrc.exe
    

    compile-gcc.cmd sets these automatically for the build session.

  3. Dialog resourceDROPTEXT.RC uses rcinclude DROPTEXT.DLG to include the dialog template. Both files must be in src/.

Version History

  • 1.02 — 2026-07-25

    • Reorganised directory structure (source files in src/, build outputs in bin-gcc/ and bin-ow/)
    • Added OpenWatcom build support (makefile-ow, compile-ow.cmd, droptext-ow.lnk)
    • Improved README documentation
    • Added .gitignore
  • 1.01 — 2026-05-25

    • Adapted to compile with GCC 9.2 on ArcaOS 5.1.1
  • 1.0 — May 7, 1993

    • Original version by Joe DiAdamo / IBM Corp.

License

BSD 3-Clause License — see LICENSE file for details.

Authors

  • Joe DiAdamo / IBM Corp. (original, 1993)
  • Martin Iturbide / OS2World (GCC port and reorganisation, 2026)

Links

About

Using this program you can type a line of text, drag it over a window and drop it thus changing its text.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages