🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #1477

Re: Dragging graphical objects

#1477
From: ie15
Date: Sat, 01 Sep 1990 15:53
50 lines
3055 bytes
In article <1990Aug6.190714.5592@cs.uoregon.edu>, martti@spencer.cs.uoregon.edu (Martti Kantola) writes:
> I need to drag graphical objects around on the screen using the mouse but can't
> figure out how to do it. What I think I need is something similar to the Mac's
> DragGrayRgn-function. Is there a PM counterpart for this function, anyone?
> 

What I have been doing to is to change the mouse pointer to the new object,
a file folder for instance, then I capture all the mouse messages and wait for
a button1 up, asuming this function was initiated from some menu selection as
opposed to some "pick-up-and-drop". When I get the mouse button up message I
unset the pointer, un capture the mouse mesassages, find out where the mouse
pointer is pointing at, and take apprpriate steps. Pseudo-C-Code looks like:

   wpMain( HWND   hwnd...)
   {static HPOINTER   hptr;

      WM_COMMAND: * The users selections some sort of initial function that
                  we know means the user wants to manipulate his document
                  hptr =WinLoadPointer( HWND_DESKTOP, NULL, ID_PTR_DOC);
                  WinSetCapture( HWND_DESKTOP, hwnd, TRUE);
                  WinSetPointer( HWND_DESKTOP, hptr);
                  * any other internal flags settings, processing
                  return( 0);
     WM_MOUSEMOVE: We need to set the mouse pointer to OUR document pointer
                   every time the mouse moves because PM will change it back
                   to the default pointer every mousemove
                  WinSetPointer( HWND_DESKTOP, hptr);
                  return( 1); * returning a 1 is important

     WM_MOUSEBUTTON1_DOWN:
                  * The user has clicked on a spot where he wants the document
                    dropped. The pointer position comes in as a message param
                    one. Check it and see if it's a valid spot. If it is then
                    do the proper manipulations
                  * And now WinDestroyPointer( hptr) to free up the mouse
                    pointer's resources 
                  * WinSetCapture( HWND_DESKTOP, hwnd, FALSE) to set capturing
                    off
                  return( 0);

When the mouse capturing is on it is impossible for the user to click another
window since our window procedure gets all the mouse button downs. Also,
strange X & Y coordinates may come in since all clicks are related to our
window and our window doesn't necessarily cover the entire window. So a click
to the left or under our window will return negative values. As expected,
really, considering the Cartesian coordinate system

Good luck,
Ken Tabor
UNT
Technical Details
Message-ID: <33585.26dfd97f@vaxb.acs.unt.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!cs.utexas.edu!ntvaxb!ie15
References: <1990Aug6.190714.5592@cs.uoregon.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!cs.utexas.edu!ntvaxb!ie15
From: ie15@vaxb.acs.unt.edu
Newsgroups: comp.os.os2.programmer
Subject: Re: Dragging graphical objects
Message-ID: <33585.26dfd97f@vaxb.acs.unt.edu>
Date: 1 Sep 90 15:53:35 GMT
References: <1990Aug6.190714.5592@cs.uoregon.edu>
Distribution: na
Lines: 50