Skip to content

Latest commit

 

History

History
144 lines (108 loc) · 5.37 KB

File metadata and controls

144 lines (108 loc) · 5.37 KB

DEV-SAMPLES-C-PM-DragInfo

OS/2 Presentation Manager sample for testing and debugging drag-and-drop applications. The program acts as a drag source — when the user drags from its window, it logs every DM_* message received from the drop target in a scrollable list. All DRAGINFO/DRAGITEM parameters and the drag API (DrgDrag or DrgDragFiles) are fully configurable at runtime.

DragInfo Screenshot

Description

DragInfo creates a standard PM frame window containing a listbox. The listbox is subclassed so it intercepts WM_BEGINDRAG and initiates a drag. Every drag message (DM_DRAGOVER, DM_DROP, DM_RENDER, DM_ENDCONVERSATION, etc.) received by either the client or the listbox is appended to the list, making it easy to see exactly what a target application sends back.

Two configuration dialogs let you change:

  • DrgDrag parameters — drag operation (DO_DEFAULT/DO_COPY/…), drag type (DRT_TEXT/DRT_BITMAP/…), RMF string (mechanism + format), control flags (DC_OPEN/DC_REF/…), container path, filename, and the return value used for DM_PRINTOBJECT/DM_DISCARDOBJECT.
  • DrgDragFiles parameters — full file path and whether the source or target renders.

This program was derived from the DROPINFO sample from the IBM OS/2 Developer's Toolkit Redbook Vol. 4. Both programs complement each other.

OS/2 APIs Used

API Purpose
WinInitialize / WinTerminate Initialize and terminate the PM anchor block
WinCreateMsgQueue / WinDestroyMsgQueue Create and destroy the message queue
WinRegisterClass Register the main window class
WinCreateStdWindow / WinDestroyWindow Create and destroy the frame window
WinGetMsg / WinDispatchMsg Main message loop
WinSubclassWindow Subclass the listbox to intercept WM_BEGINDRAG
WinSetWindowPos Position and size the frame window on startup
WinLoadPointer Load the drag cursor from resources
WinCreateWindow Create the listbox child window
WinCheckMenuItem Reflect DrgDrag/DrgDragFiles selection in the menu
WinDlgBox Display the configuration dialog
WinSendMsg / WinPostMsg Communicate with controls and queue
WinMessageBox Display the "Do Something" confirmation box
WinDefWindowProc / WinDefDlgProc Default message handling
DrgAllocDraginfo / DrgFreeDraginfo Allocate and free the DRAGINFO structure
DrgSetDragitem Set a DRAGITEM inside DRAGINFO
DrgAddStrHandle / DrgDeleteDraginfoStrHandles Manage drag string handles
DrgDrag Initiate a drag using the DRAGINFO/DRAGITEM API
DrgDragFiles Initiate a drag using the file-list API

Directory Structure

DEV-SAMPLES-C-PM-DragInfo/
├── src/
│   ├── DRAGINFO.C          Main application and window procedures
│   ├── DRAGDLG.C           Configuration dialog procedures and drag globals
│   ├── DRAGINFO.H          Shared application header (IDs, extern decls, prototypes)
│   ├── DRGCONFG.H          Dialog control IDs
│   ├── DRAGINFO.DEF        Module definition file (OpenWatcom)
│   ├── draginfo-gcc.def    Module definition file (GCC — no STUB/PROTMODE)
│   ├── DRAGINFO.RC         Resource script (icons, menu, accelerator)
│   ├── DRAGINFO.DLG        Dialog templates (IDD_CONFIG1, IDD_CONFIG2)
│   ├── DRAGINFO.ICO        Application icon
│   ├── DRGDRAG.ICO         Drag cursor icon
│   └── draginfo-ow.lnk     OpenWatcom linker script
├── makefile-gcc            GCC 9.2 (bitwiseworks) makefile
├── makefile-ow             OpenWatcom 2.0 makefile
├── compile-gcc.cmd         GCC build script
├── compile-ow.cmd          OpenWatcom build script
├── .gitignore
├── LICENSE
└── README.md

Build Requirements

GCC (bitwiseworks):

  • GCC 9.2 (bitwiseworks) — gcc.exe
  • GNU make — make.exe
  • Watcom Resource Compiler — wrc.exe
  • Watcom Linker — wl.exe (used via EMXOMFLD env vars)
yum install gcc make watcom-wrc watcom-wlink-hll

OpenWatcom:

  • OpenWatcom 2.0 — wcc386.exe, wlink.exe, wrc.exe, wmake.exe
yum install watcom-wcc watcom-wlink-hll watcom-wrc

Build Instructions

GCC

compile-gcc.cmd

Or manually:

set EMXOMFLD_TYPE=WLINK
set EMXOMFLD_LINKER=wl.exe
set EMXOMFLD_PRELINK=0
make -f makefile-gcc

OpenWatcom

compile-ow.cmd

Or manually:

wmake -f makefile-ow

Output goes to bin-gcc\DRAGINFO.EXE or bin-ow\DRAGINFO.EXE.

Usage

  1. Run DRAGINFO.EXE.
  2. Use Options → Configure parameters to set the drag type, RMF, operation, control flags, and file paths.
  3. Use Options → Use DrgDrag or Use DrgDragFiles to select the drag API.
  4. Click and drag from the listbox area to any drop target.
  5. The listbox shows every DM_* message received during and after the drag.
  6. Use Options → Clear Listbox to reset the log.

Version History

Version Date Notes
1.0 1993 Original — Christian Sell
1.01 2026-07-27 Directory reorganization, GCC and OpenWatcom dual-build support

License

See LICENSE.

Authors

  • Christian Sell (1993) — original sample
  • Martin Iturbide (2026) — build modernization and reorganization

Links