Frage

How can I properly set the starting screen for a specific form in Managed C++/cli?

The idea is to use the form_Load event, detect if a secondary screen is present and set the starting position.

I've seen some examples in C# but I can't use the Screen class in the same way, ie

This

Screen.AllScreens[1].WorkingArea.Location;

cannot be translated to this in c++

Screen::AllScreens[1]->WorkingArea->Location;
War es hilfreich?

Lösung

WorkingArea returns a Rectangle, which is a struct. Structs are value types, not reference types, therefore you use ., not ->.

int main(array<System::String ^> ^args)
{
    Debug::WriteLine(Screen::AllScreens[1]->WorkingArea.Location);
    //                                                 ^
    return 0;
}

Output:

{X=0,Y=0}

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top