bucz

I want one window to be drawn always over other window, but not over all windows (something like some small window with additional properties for main application). How to check / get / set windows drawing order I think that I could capture main's window drawing order and then change small windows d. o. but how to do that Is there a property responsible for that



Re: Visual C++ General Forms drawing order

Bite Qiu - MSFT

bucz wrote:
I want one window to be drawn always over other window, but not over all windows (something like some small window with additional properties for main application). How to check / get / set windows drawing order I think that I could capture main's window drawing order and then change small windows d. o. but how to do that Is there a property responsible for that

You can use System::Windows::Forms::Control::ControlCollection::GetChildIndex and SetChildIndex to switch the z-order of controls, like:

Code Snippet

void SwitchZOrder(Form^ form, Control^ control1, Control^ control2){
int index1, index2;
index1 = form->Controls->GetChildIndex(control1);
index2 = form->Controls->GetChildIndex(control2);

form->Controls->SetChildIndex(control1,index2);
form->Controls->SetChildIndex(control2,index1);
}

hope it helps

rico






Re: Visual C++ General Forms drawing order

bucz

But how to gets windows z-index

I tried to captuer Activated event in main form and then set z-index of the small window, but I didnt succeed. GetChildIndex get z-order of Controls, not Forms, right And I am interested in forms this time.
tried something like this:

this->Owner->Controls->SetChildIndex( smallWindow, 0)

But it desn't work






Re: Visual C++ General Forms drawing order

bucz

I handled it this way:

Code Snippet

private: System::Void Form1_Activated(System::Object^ sender, System::EventArgs^ e) {
if (formInfo->TopMost != true) formInfo->TopMost = true;
}
private: System::Void Form1_Deactivate(System::Object^ sender, System::EventArgs^ e) {
if (formInfo->TopMost != false) formInfo->TopMost = false;
}



Those conditions are needed. Without them it just behaves improperly - check.

It is also worth looking at BringToFront() method.





Re: Visual C++ General Forms drawing order

bucz

Well, a problem again.

Ithe code I pased works almost good - It doesnt work when I open small window at first time (it hides behing main form when I clikc main form), but when I bring it back to front, then it works as it should. It hides only at first time. Have an idea

My goal is to make kind of TopMost window, that wouldn't be over all windows abut only over my main form.




Re: Visual C++ General Forms drawing order

bucz

private: System::Void Form1_Activated(System:Surprisebject^ sender, System::EventArgs^ e) {
if (formInfo->TopMost != true) formInfo->TopMost = true;
}
private: System::Void Form1_Deactivate(System:Surprisebject^ sender, System::EventArgs^ e) {
// (formInfo->Visible == true) - BUGFIX : hiding form on first time
if ((formInfo->TopMost != false) && (formInfo->Visible == true)) formInfo->TopMost = false;
}


that doest he thing - checking visibility