🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.os2.programmer
2 messages
2 total messages Started by Martti Kantola Mon, 06 Aug 1990 19:07
Dragging graphical objects
#1437
Author: Martti Kantola
Date: Mon, 06 Aug 1990 19:07
5 lines
780 bytes
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?

Thanks, Marti Kantola
Re: Dragging graphical objects
#1477
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads