User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Control WindowProc not firing events

  1. #1
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2006
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Control WindowProc not firing events

    Hi,

    I am trying to get to grips with the SDK after being away from Fusion for a long time.

    I am trying to adapt the SimpleControl example to a TreeView. I cannot get it to fire events, however. This is my WindowProc. Can anyone point out what I am doing wrong?

    Code:
    LRESULT CALLBACK DLLExport WindowProc(fprh rhPtr, HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
    {
    	LPRDATA rdPtr = NULL;
    
    	switch (nMsg) {
    
    	case WM_NOTIFY:
    
    		if (((LPNMHDR)lParam)->code == NM_RCLICK)
    		{
    			// Is it this edit control?
    			if (((rdPtr = GetRdPtr((HWND)lParam, rhPtr)) != NULL) && (IDENTIFIER == rdPtr->rHo.hoIdentifier))
    			{
    				// Yes => set flag to trigger a CND_CHANGED condition in the next call to HandleRunObject
    				rdPtr->dwLastRightClickedLoopNumber = rhPtr->rh4.rh4EventCount;
    				rdPtr->dwEvtFlags |= EVTFLAG_RIGHTCLICK;
    			}
    		}
    		break;
    
    	default:
    		return 0;
    	}
    
    	return 0;
    }

  2. #2
    Clickteam Clickteam

    Join Date
    Jun 2006
    Location
    France
    Posts
    14,640
    Mentioned
    279 Post(s)
    Tagged
    3 Thread(s)
    Something is wrong, you do both (LPNMHDR)lParam and (HWND)lParam. I suppose you should replace (HWND)lParam by ((LPNMHDR)lParam)->hwndFrom

  3. #3
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2006
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup, that fixed it. Thanks, Yves! I did not realise there was a difference between WM_COMMAND and WM_NOTIFY when retrieving the hWnd.

  4. #4
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2006
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm experiencing a new problem. The right-click event never fires...when I test for it in the event editor, it thinks the other two events are firing. What am I doing wrong?
    Code:
    LRESULT CALLBACK DLLExport WindowProc(fprh rhPtr, HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
    {
    	LPRDATA rdPtr = NULL;
    
    	switch (nMsg) {
    
    		case WM_NOTIFY:
    
    			switch (((LPNMHDR)lParam)->code) {
    
    				case TVN_SELCHANGED:
    					if (((rdPtr = GetRdPtr(((LPNMHDR)lParam)->hwndFrom, rhPtr)) != NULL) && (IDENTIFIER == rdPtr->rHo.hoIdentifier))
    					{
    						//rdPtr->dwLastSelChangedLoopNumber = rhPtr->rh4.rh4EventCount;
    						rdPtr->dwEvtFlags |= EVTFLAG_ONSELCHANGED;
    						return REFLAG_MSGHANDLED;
    					}
    
    				case NM_DBLCLK:
    					if (((rdPtr = GetRdPtr(((LPNMHDR)lParam)->hwndFrom, rhPtr)) != NULL) && (IDENTIFIER == rdPtr->rHo.hoIdentifier))
    					{
    						//rdPtr->dwLastDoubleClickedLoopNumber = rhPtr->rh4.rh4EventCount;
    						rdPtr->dwEvtFlags |= EVTFLAG_ONDOUBLECLICKED;
    						return REFLAG_MSGHANDLED;
    					}
    
    				case NM_RCLICK:
    					if (((rdPtr = GetRdPtr(((LPNMHDR)lParam)->hwndFrom, rhPtr)) != NULL) && (IDENTIFIER == rdPtr->rHo.hoIdentifier))
    					{
    						POINT sMouse;
    						TVHITTESTINFO hTest;
    						HTREEITEM hItem;
    						GetCursorPos(&sMouse);
    						ScreenToClient(rdPtr->hWnd, &sMouse);
    						hTest.pt.x = sMouse.x;
    						hTest.pt.y = sMouse.y;
    						hTest.flags = TVHT_ONITEMRIGHT;
    						hItem = TreeView_HitTest(rdPtr->hWnd, &hTest);
    						if (hItem != NULL)
    							TreeView_SelectItem(rdPtr->hWnd, hItem);
    
    						rdPtr->dwEvtFlags |= EVTFLAG_ONRIGHTCLICKED;
    						return REFLAG_MSGHANDLED;
    					}
    
    				default:
    					break;
    			}
    
    		default:
    			break;
    	}
    
    	return 0;
    }

  5. #5
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Mac Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    Phi's Avatar
    Join Date
    Jan 2010
    Location
    England
    Posts
    2,074
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by waffles View Post
    I'm experiencing a new problem. The right-click event never fires... when I test for it in the event editor, it thinks the other two events are firing.
    So the case NM_RCLICK never runs?

    Also, you should put a break; after the if, like if(...){...} break;
    In C/C++, if you don't break for a match, the code will "fall through" and run the next case, as if the condition matches the next case.

  6. #6
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2006
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    NM_RCLICK does run...for example, if I put MessageBox in there, the dialog appears upon a right-click. The event just doesn't run, so nothing in the event editor runs upon a right-click. Adding the breaks doesn't fix it, but thank you for the information about that.

    Maybe I'm doing something wrong elsewhere? This is my HandleRunObject function:
    Code:
    short WINAPI DLLExport HandleRunObject(LPRDATA rdPtr)
    {
    	if ((rdPtr->dwEvtFlags & EVTFLAG_ONSELCHANGED) != 0)
    	{
    		callRunTimeFunction(rdPtr, RFUNCTION_PUSHEVENTSTOP, CND_ONSELCHANGED, 0);
    		rdPtr->dwEvtFlags &= ~EVTFLAG_ONSELCHANGED;
    	}
    	
    	if ((rdPtr->dwEvtFlags & EVTFLAG_ONDOUBLECLICKED) != 0)
    	{
    		callRunTimeFunction(rdPtr, RFUNCTION_PUSHEVENTSTOP, CND_ONDOUBLECLICKED, 0);
    		rdPtr->dwEvtFlags &= ~EVTFLAG_ONDOUBLECLICKED;
    	}
    	
    	if ((rdPtr->dwEvtFlags & EVTFLAG_ONRIGHTCLICKED) != 0)
    	{
    		callRunTimeFunction(rdPtr, RFUNCTION_PUSHEVENTSTOP, CND_ONRIGHTCLICKED, 0);
    		rdPtr->dwEvtFlags &= ~EVTFLAG_ONRIGHTCLICKED;
    	}
    	return 0;
    }

  7. #7
    Clickteam Clickteam

    Join Date
    Jun 2006
    Location
    France
    Posts
    14,640
    Mentioned
    279 Post(s)
    Tagged
    3 Thread(s)
    Could you show the source code of the On Right Click condition?

  8. #8
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2006
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    long WINAPI DLLExport CndOnRightClicked(LPRDATA rdPtr, long param1, long param2)
    {
    	// Always TRUE if first condition
    	if (rdPtr->rHo.hoFlags & HOF_TRUEEVENT)
    		return TRUE;
    
    	return rdPtr->dwEvtFlags & EVTFLAG_ONRIGHTCLICKED;
    }

  9. #9
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2006
    Posts
    271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for the double post. I still can't get this to work. Does anyone have any idea what I'm doing wrong? Thanks.

  10. #10
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Mac Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    Phi's Avatar
    Join Date
    Jan 2010
    Location
    England
    Posts
    2,074
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)
    Typically, I would use GenerateEvent, not PushEvent, particularly if modifying internal ext data then firing events inside HandleRunObject based on it. I have yet to have a need to use PushEventStop.
    In the WindowProc part, take out the PushEvent lines entirely, and in HandleRunObject, switch to GenerateEvent.

    I would also recommend using an Edif-based SDK.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 19th April 2016, 09:27 PM
  2. Replies: 6
    Last Post: 19th March 2015, 11:29 PM
  3. Extension SDK - Can't make WindowProc interception work
    By GrayFace in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 6th November 2012, 09:09 PM
  4. control of events at the microphone
    By daniele in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 25th May 2011, 09:35 PM
  5. [Help] Get rdPtr from WindowProc function
    By Sphax in forum Extension Developers Lobby
    Replies: 11
    Last Post: 18th July 2007, 07:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •