On 23/07/2014 at 19:30, xxxxxxxx wrote:
Hi All,
Bare with me on this one, I'm in need of some clear clarification.
1. When can we poll the mouse, and when can't we?
2. What is KillEvents() for, and when should we use it?
3. How do we properly handle a mouse drag?
4. Is there a clean example of mouse dragging somewhere I can look at?
5. Point 5 below..
The docs are really unhelpful with all of this. I'll put forward an example of the way I'm currently going about it. The following is a stripped version of what I have when going from one user area to another:
// USER AREA 1 - DRAG STARTER - fired from user area's InputEvent()
while(GetInputState(BFM_INPUT_MOUSE,BFM_INPUT_MOUSELEFT,MB))
{
if(MB.GetLong(BFM_INPUT_VALUE) == 0)
{
return TRUE;
}
// (GET MOUSE COORDS HERE..)
// IF MOUSE LEAVES USER AREA,
// OPEN A HandleMouseDrag()
if((MouseX < 0 || MouseX > Width) || (MouseY < 0 || MouseY > Height))
{
HandleMouseDrag(..);
}
Redraw(FALSE);
}
//--------------------------------------------------------------
// USER AREA 2 - DRAG RECEIVER
Message(const BaseContainer &msg;,BaseContainer &result;)
{
//...
case BFM_DRAGRECEIVE:
{
InputEvent(msg); // second user area does nothing without this
break;
}
//...
}
InputEvent(const BaseContainer &msg;)
{
//...
case BFM_DRAGRECEIVE:
{
while(GetInputState(BFM_INPUT_MOUSE,BFM_INPUT_MOUSELEFT,LMB))
{
if(LMB.GetBool(BFM_INPUT_VALUE) == 0)
{
return TRUE;
}
// do something.. get mouse coords..
Redraw(FALSE);
}
return TRUE;
}
//...
}
In the above example, I'm polling the mouse in the first user area's InputEvent() and calling HandleMouseDrag() when the mouse leaves the area. I'm then waiting for the second user area to receive the BFM_DRAGRECEIVE message, and are initiating the second user areas InputEvent() from the message case. The above example 'works', but the problem is that the second user area is filling up memory with what's probably messages (is this assumption right?). Using KillEvents() fixes the window from greying out, but it does not fix the memory build up. I'm not talking a few megabytes either, I'm talking gigabytes - several gigabytes in a few seconds.
The other thing also is the mouse cursor. Without polling the mouse in the second user area, the cursor does not stay to what I set it too. It just flickers between two cursor icons.
5. Are we meant to/allowed to poll, or not?
Would really appreciate a working example of how to properly handle a mouse drag from one user area to another. Searching the forum only brings up topics with similar queries and incomplete answers.
Cheers,
WP.
P.s. how do we get rid of this rubbish double-line spacing in the code brackets too?