Ver Mensaje Individual
  #17  
Antiguo 18-10-2012
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Reputación: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Mejorando el código para el caso de tener mas de dos formularios abiertos y sólo uno sea TopMost:
Código:
void ReDrawWindow(HWND hWnd)
{
  TRect cr;
  ::GetClientRect(hWnd, &cr);
  InvalidateRect(hWnd, &cr, true);
  SendMessage(hWnd, WM_NCPAINT, 0, 0);
  RedrawWindow(hWnd, &cr, 0, RDW_FRAME|RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);
}

void  __fastcall TForm2::WndProc(Messages::TMessage& Message)
{
  if(Visible && Message.Msg == WM_WINDOWPOSCHANGING)
    SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);

  if(Visible && Message.Msg == WM_ACTIVATE && Message.WParam != 0){
    SetWindowPos(Application->MainForm->Handle, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
    for(int i = 0; i<Application->ComponentCount; i++){
      TForm *F = static_cast<TForm*>(Application->Components[i]);
      if (F) ReDrawWindow(F->Handle);
    }
  }

  TForm::WndProc(Message);
}

Saludos.
Responder Con Cita