2009-09-30 8 views
0

Je crée un programme d'installation de base MSI installshield. Et pour choisir le chemin d'instllation j'appelle FolderBrowserDialog. Tout fonctionne bien, sauf FolderBrowserDialog appers en arrière-plan. Je voudrais le définir comme une fenêtre de premier plan. Ce code renvoie toujours vrai et fonctionne correctement s'il n'y a aucune autre fenêtre ouverte.Définition de FolderBrowserDialog au premier plan

Comment puis-je vérifier si dialogHandle est mon handle de dialogue?

Voici ma méthode:

/// <param name="fPath">INSTALLPATH</param> 
    /// <param name="handle">installshield handle</param> 
    /// <returns></returns> 
    public string NetworkFolderDialog(string sFilePath, IntPtr handle) 
    { 

     FolderBrowserDialog dialog = new FolderBrowserDialog(); 

     IntPtr handle2 = GetDesktopWindow(); 
     IntPtr dialogHandle = GetWindow(handle2, 5); 

     bool set = SetForegroundWindow(dialogHandle); 

     DialogResult result = dialog.ShowDialog(); 

     MessageBox.Show(set.ToString()); 

     if (result == DialogResult.OK) 
      return dialog.SelectedPath; 
     else 
      return sFilePath; 
    } 

Merci pour votre aide.

Répondre

0

Je pense que vous devez supprimer les lignes suivantes de votre code:

IntPtr handle2 = GetDesktopWindow(); 
IntPtr dialogHandle = GetWindow(handle2, 5); 

bool set = SetForegroundWindow(dialogHandle); 
+0

J'ai essayé. Mais ça ne marche pas du tout. FolderBrowserDialog apparaît toujours derrière la fenêtre d'installation. – Nejchy

+0

Pouvez-vous obtenir le handle de la fenêtre d'installation? Si c'est le cas, vous pouvez utiliser la version surchargée de ShowDialog (dialog.ShowDialog (this)). – Anax

Questions connexes