Kent Dong 1191810 Posted December 7, 2011 at 11:58 AM Posted December 7, 2011 at 11:58 AM I'm new to ES plugin development. Now I'm having a problem with OnMoveScreenObject. First I move a screenobject on the radar screen. Then I hold the left mouse button on a blank area and move the cursor. The previous moved object suddenly appears under the cursor and moves. Does anyone have a clue about how to fix this? Below is the code snippet which I think is related to the issue. Hope it is helpful for you to understand the issue. void CHelloWorldScreen::OnRefresh(HDC hDC, int phase) { if (phase != REFRESH_PHASE_AFTER_LISTS) { return; } char * text = "Hello World"; Rectangle(hDC, m_Rect.left, m_Rect.top, m_Rect.right, m_Rect.bottom); AddScreenObject(12345, "Hello World", m_Rect, true, "Yes, this is a test object."); } void CHelloWorldScreen::OnMoveScreenObject(int ObjectType, const char * sObjectId, POINT Pt, RECT Area, bool Released) { m_Rect = Area; RequestRefresh(); } Thanks. Link to comment Share on other sites More sharing options...
Todor Atanasov 878664 Posted December 7, 2011 at 12:06 PM Posted December 7, 2011 at 12:06 PM Well that is what you wrote In the OnMoveScreenObject add if(strcmp(sObjectId,"Hello World") == 0){ m_Rect = Area; RequestRefresh(); } That will update your m_Rect only when you have clicked over it, and not just when you click on the screen. EuroScope BETA Tester/Board of Designers Link to comment Share on other sites More sharing options...
Kent Dong 1191810 Posted December 7, 2011 at 12:14 PM Author Posted December 7, 2011 at 12:14 PM Well that is what you wrote In the OnMoveScreenObject add if(strcmp(sObjectId,"Hello World") == 0){ m_Rect = Area; RequestRefresh(); } That will update your m_Rect only when you have clicked over it, and not just when you click on the screen. Thank you for the reply. I update the code as this, but the issue is still there....... Link to comment Share on other sites More sharing options...
Todor Atanasov 878664 Posted December 7, 2011 at 12:50 PM Posted December 7, 2011 at 12:50 PM Oh now I got your problem Try this (doing by memory as I'm not at home right now): void CHelloWorldScreen::OnMoveScreenObject(int ObjectType, const char * sObjectId, POINT Pt, RECT Area, bool Released) { m_Rect_Move = Area; m_Move_Str_temp = sObjectId; if(Released) m_Rect = Area; RequestRefresh(); } On the function you are using to draw your rectangle add this if(strcmp(text,m_Move_Str_temp) == 0) Rectangle(hDC, m_Rect_Move.left, m_Rect_Move.top, m_Rect_Move.right, m_Rect_Move.bottom); else Rectangle(hDC, m_Rect.left, m_Rect.top, m_Rect.right, m_Rect.bottom); EuroScope BETA Tester/Board of Designers Link to comment Share on other sites More sharing options...
Kent Dong 1191810 Posted December 7, 2011 at 01:37 PM Author Posted December 7, 2011 at 01:37 PM I made changes following your instruction. But it's still not working. Here is the latest code. void CHelloWorldScreen::OnRefresh(HDC hDC, int phase) { if (phase != REFRESH_PHASE_AFTER_LISTS) { return; } if (strcmp(m_MovingObject, OBJECT_NAME)) { Rectangle(hDC, m_Rect.left, m_Rect.top, m_Rect.right, m_Rect.bottom); } else { Rectangle(hDC, m_RectMove.left, m_RectMove.top, m_RectMove.right, m_RectMove.bottom); } AddScreenObject(1, OBJECT_NAME, m_Rect, true, "Yes, this is a test object."); } void CHelloWorldScreen::OnMoveScreenObject(int ObjectType, const char * sObjectId, POINT Pt, RECT Area, bool Released) { if (strcmp(sObjectId, OBJECT_NAME)) { return; } if (!Released) { strcpy(m_MovingObject, sObjectId); m_RectMove = Area; } else { m_MovingObject[0] = 0; m_Rect = Area; } RequestRefresh(); } Link to comment Share on other sites More sharing options...
Gergely Csernak Posted December 11, 2011 at 08:16 PM Posted December 11, 2011 at 08:16 PM Well that is what you wrote In the OnMoveScreenObject add if(strcmp(sObjectId,"Hello World") == 0){ m_Rect = Area; RequestRefresh(); } That will update your m_Rect only when you have clicked over it, and not just when you click on the screen. Thank you for the reply. I update the code as this, but the issue is still there....... This version works for me fine. Gergely. EuroScope developer Link to comment Share on other sites More sharing options...
Kent Dong 1191810 Posted December 12, 2011 at 10:40 AM Author Posted December 12, 2011 at 10:40 AM Sadly, it still doesn't work for me. Maybe I make a mistake elsewhere. A complete sourcecode package can be downloaded from here http://realch3cho.com/temp/HelloWorldPlugIn.zip. Could you take a look and help me out, please? Thanks. Link to comment Share on other sites More sharing options...
Todor Atanasov 878664 Posted December 12, 2011 at 10:52 AM Posted December 12, 2011 at 10:52 AM Just tested it and it is working without any modifications.... EuroScope BETA Tester/Board of Designers Link to comment Share on other sites More sharing options...
Kent Dong 1191810 Posted February 11, 2012 at 02:19 AM Author Posted February 11, 2012 at 02:19 AM Hi guys, Sorry, the issue still exists on my side. Some more information can be downloaded via this link, including a screen video showing how this issue looks like, the complete source code of this test plugin (a VS2005 solution), a release dll built from the source code, and the corresponding VC++ Redistributable Package. http://realch3cho.com/temp/OnMoveScreenObject%20Issue.zip Could anyone help me out, please? Thanks Link to comment Share on other sites More sharing options...
Joao Pereira 1256632 Posted April 30, 2014 at 01:30 AM Posted April 30, 2014 at 01:30 AM Sorry to revive this thread after so much time but I'm having the exact same problem. Did you manage to solve it Kent Dong? Here's my code: void CNew::ONREFRESH(...) { if(strcmp("Closebutton",m_MoveObjectId) == 0){ Rectangle(*dc, m_MoveArea.left, m_MoveArea.top, m_MoveArea.right, m_MoveArea.bottom); dc->DrawFrameControl(&m_MoveArea,DFC_CAPTION,DFCS_CAPTIONCLOSE); AddScreenObject(WINDOW_OBJ,"Closebutton",m_MoveArea,true,NULL); } else{ dc->DrawFrameControl(&rect3,DFC_CAPTION,DFCS_CAPTIONCLOSE); AddScreenObject(WINDOW_OBJ,"Closebutton",rect3,true,NULL); } } void CNew::OnMoveScreenObject(...) { if(strcmp(sObjectId,"Closebutton")==0){ m_MoveObjectType=Released ? 0 : ObjectType; m_MoveObjectId=sObjectId; m_MoveArea=Area; RequestRefresh(); } } Can anyone help me solve this please? Link to comment Share on other sites More sharing options...
Joao Pereira 1256632 Posted May 1, 2014 at 06:54 PM Posted May 1, 2014 at 06:54 PM So, I found out the problem but don't know how to solve it. The problem is that sObjectId still points to "Closebutton" even after Released. So when i press the left button of the mouse anywhere on the screen it still thinks I'm trying to move the Close button. I noticed this while debugging because if i move the Close button and then click on another screen object this problem does not happen (because sObjectId points at something else now) How do i clean sObjectId after Released? More scpecifically, where is this sObjectId initialized?because I can't find it anywhere Link to comment Share on other sites More sharing options...
Recommended Posts