06-05-2020 07:10 AM
As many people nowadays, I have a two monitor setup.
My main monitor (#1) is usually on my front, the secondary one (#2) is on the right side of the main one.
This way the coordinates top left angle for #1 of are (0,0) and (1920,0) for #2.
I have noticed that setting the ATTR_LEFT attribute for a panel, when it is only loaded, but not displayed has the very odd effect when the value is 8 (eight). The attribute, read immediately after, becomes 1928, and the panel jumps in the secondary monitor when displayed.
Any other value for ATTR_LEFT behaves correctly.
My bet is that 8 is the value returned for the panel ATTR_FRAME_ACTUAL_WIDTH, so there is some special but my guess end here.
The code works perfectly when the panel is displayed before setting the position, and it works in any condition for single monitor system and when I swap the #2 monitor position on the other side (when it assumes negative coordinates).
I'm attaching here a minimal project that can be used to demonstrate this.
06-08-2020 04:03 AM
Hi,
I observe the same odd behaviour but are not sure that it has anything to do with CVI.
If you use the window function SetWindowPos() with left value set to 0, the panel appears on the wrong monitor. Any other left value work as expected.
Jan
06-08-2020 05:35 AM
Hello, in my demo program if I change the couple of SetPanelAttribute with SetPanelPos, I obtain the same result.
Just to do some further investigation I tried this snippet of code, always before DisplayPanel(), trying a full coverage for left coordinates.
int left;
for (int i=-10000; i<10000; i++) {
SetPanelPos(hPanel, 100, i);
GetPanelAttribute(hPanel, ATTR_LEFT, &left);
if (left != i) {
DebugPrintf("i=%d left=%d\n", i, left);
}
}
The result is:
i=8 left=1928
i=1508 left=1928
So there is another "magic number" 😒. "1508" is nothing representative on my system, my monitors are 1920 or 1280 pixels wide.
Being involved only the setting of an attribute for a CVI panel, I am very dubious that this behavior depends from something outside CVI.
I was just there, writing this message, and I wonder if there is something strange for the TOP position, too.
The result is still very confusing:
i=31 top=36
i=814 top=819
i=854 top=859
This case there is nothing related to multi-monitor system. I have verified that top coordinate is really changed with this 5 pixel, almost unnoticeable, shift to the bottom of the screen.
Frankly speaking, I'm very confused about what the (beep) reason is behind this behavior.
And no, this cannot be related to anything outside CVI. 😀
May be some NI member could give an hint on this.