Jump to content

You're browsing the 2004-2023 VATSIM Forums archive. All content is preserved in a read-only fashion.
For the latest forum posts, please visit https://forum.vatsim.net.

Need to find something? Use the Google search below.

Euroscope Plugin - OnMoveScreenObject Question


Kent Dong 1191810
 Share

Recommended Posts

Kent Dong 1191810
Posted
Posted

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

Todor Atanasov 878664
Posted
Posted

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.

Link to comment
Share on other sites

Kent Dong 1191810
Posted
Posted
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

Todor Atanasov 878664
Posted
Posted

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);

Link to comment
Share on other sites

Kent Dong 1191810
Posted
Posted

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

Gergely Csernak
Posted
Posted
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

Kent Dong 1191810
Posted
Posted

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

Todor Atanasov 878664
Posted
Posted

Just tested it and it is working without any modifications....

Link to comment
Share on other sites

  • 1 month later...
Kent Dong 1191810
Posted
Posted

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

  • 2 years later...
Joao Pereira 1256632
Posted
Posted

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

Joao Pereira 1256632
Posted
Posted

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

 Share