Sorry Riccardo, I do not understand your reply.
I had tried with empty as well as non-empty dialogs.
Still with these 4 combinations I do not get appropriate values for the global position.
Bool res = GeDialog::CreateLayout();
GroupBegin(0, BFH_SCALEFIT | BFV_SCALEFIT, 2, 0, ""_s, 0);
AddButton(ACTION_1, BFH_CENTER | BFV_CENTER, 200, 10, "button A"_s);
AddButton(ACTION_2, BFH_CENTER | BFV_CENTER, 300, 10, "button B"_s);
AddEditText(ACTION_3, BFH_CENTER | BFV_CENTER, 500, 10);
Bool MyCommand::Execute(BaseDocument* doc)
if (GetInputState(BFM_INPUT_MOUSE, BFM_INPUT_MOUSELEFT, bc))
const Int32 mx = bc.GetInt32(BFM_INPUT_X);
const Int32 my = bc.GetInt32(BFM_INPUT_Y);
const Int32 w = 50;
const Int32 h = 50;
mDlg.Open(DLG_TYPE::ASYNC /*ASYNC_POPUPEDIT*/, TEST_COMMAND_PLUGIN_ID, mx, my, w, h, 0);
ApplicationOutput("Mouse cursor at @, @", mx, my);
Int32 dlgX = 0;
Int32 dlgY = 0;
ApplicationOutput("Dialog created at @, @ (screen)", dlgX, dlgY);
dlgX = 0;
dlgY = 0;
ApplicationOutput("Dialog created at @, @ (global)", dlgX, dlgY);
Additionally, when activating the plugin when Cinema4D is fullscreen, the dialog gets positioned at the expected coordinates. But the position of the dialog is nowhere near the expected position if the plugin is activated when the Cinema4D window is not full screen.
It seems as if the mouse coordinates relative to the application window are applied relative to the screen origin.
Which means that if:
1 Cinema4D is not full screen
2 and offset from the top left corner of the screen by an amount X
3 assuming the mouse position is at coordinate mx from the Cinema4D's main window's top left corner
The dialog ends up at mx from the screen's top left corner, instead of the expected X + mx.
(All the above was tested with R20 only, since I have refrained from further R21 development)
Unfortunately, I have moved on and am currently not focused on this particular plugin anymore. As such, I may have missed some details. I will need to find the time to pick up where I had left.