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.
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 interceptWM_BEGINDRAG/WM_ENDDRAGand forward them to the dialog as user messages (UM_BEGINDRAG,UM_ENDDRAG). - Capture the mouse with
WinSetCaptureso that pointer events are delivered to the dialog even when the mouse moves over other windows. - Use
WinWindowFromPointto identify the window under the pointer, andWinSetWindowTextto 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_ESCby releasing the capture and restoring the original pointer.
| 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 |
- 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
├── 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
compile-gcc.cmd
Or invoke make directly:
make -f makefile-gcc
Output: bin-gcc\DROPTEXT.exe
compile-ow.cmd
Or invoke wmake directly:
wmake -f makefile-ow
Output: bin-ow\DROPTEXT.exe
make -f makefile-gcc clean
wmake -f makefile-ow clean
bldlevel DROPTEXT.exe
-
Header files — use the kLIBC headers from
libc-devel. Verifyconfig.syscontainsSET INCLUDE=C:\usr\include. -
Resource and linker tools —
wrcandwl.exe(Watcom tools) are used. Add toconfig.sys:SET EMXOMFLD_LINKER=wl.exe SET EMXOMFLD_TYPE=WLINK SET EMXOMFLD_RC_TYPE=WRC SET EMXOMFLD_RC=wrc.execompile-gcc.cmdsets these automatically for the build session. -
Dialog resource —
DROPTEXT.RCusesrcinclude DROPTEXT.DLGto include the dialog template. Both files must be insrc/.
-
1.02 — 2026-07-25
- Reorganised directory structure (source files in
src/, build outputs inbin-gcc/andbin-ow/) - Added OpenWatcom build support (
makefile-ow,compile-ow.cmd,droptext-ow.lnk) - Improved README documentation
- Added
.gitignore
- Reorganised directory structure (source files in
-
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.
BSD 3-Clause License — see LICENSE file for details.
- Joe DiAdamo / IBM Corp. (original, 1993)
- Martin Iturbide / OS2World (GCC port and reorganisation, 2026)
