2010-01-01 4 views
1

Я работаю над комплектом заставки C# XNA, и до сих пор все на месте, за исключением диалогового окна конфигурации, которое должно быть модальным для Настройки заставки диалог, предоставляемый окнами ("/ c: < hwnd>" аргумент).C# screensaver: диалог конфигурации модальный к предоставленному HWND

Мой тестом является Vistas встроенного 3D Text заставки - мой код обеспечивает ту же функцию и о диалоге конфигурации, 3D Text отображает полностью модальный к Screen Saver Settings диалога и при нажатии Screen Saver Settings Диалог, диалоги мигают без принятия щелчка.

Я попробовал метод обертывания HWND с IWin32Window как предложил Ryan Farley, но даже если мои диалоговые отображается на верхней части Параметры экранной заставки диалога элементы управления в настройках Экономии диалога экрана все еще может быть щелкнул.

Мне нужны некоторые экзотические вызовы Win32API, чтобы сообщить родительскому диалогу о том, что он был модализован или существует более чистое решение?

ответ

0

На самом деле, оказалось, что HWND обеспечивается окнами на заставке ребенок диалога настроек, так что, вызвав GetParent на HWND, я получаю HWND, которая представляет диалог.

Сегодня день, когда я написал свой первый вопрос на stackoverflow.com и ответил на первый вопрос.

0

Попробуйте вызвать функцию API SetParent.

+0

Я уже пользуюсь SetParent, но теперь я обнаружил, что HWND-провайдер ed by windows на заставку является дочерним элементом диалогового окна настроек, поэтому, вызывая GetParent на HWND, я получаю HWND, который представляет диалог. –

+0

Итак, это работает? – SLaks

+0

Да, да. Диалоговое окно конфигурации полностью модально к диалоговому окну настроек заставки Windows. –

0

У меня была та же проблема. Кроме того, я не смог напрямую подключить диалог к ​​внешнему окну с .NET. Поэтому я поставляю работу вокруг зацепить диалог с родителем данного окна ручки:

// ------------------------------------------------------------------------ 
public class CHelpWindow : Form 
{ // this class hooks to a foreign window handle and then it starts a 
    // modal dialog to this form; .NET seems not to be able to hook a dialog 
    // to a foreign window directly: therefore this solution 

    // retrievs the parent window of the passed child 
    [DllImport("user32.dll")] 
    private static extern IntPtr GetParent (IntPtr hWndChild); 

    // changes the parent window of the passed child 
    [DllImport("user32.dll")] 
    private static extern IntPtr SetParent (IntPtr hWndChild, IntPtr hWndNewParent); 

    // -------------------------------------------------------------------- 
    public CHelpWindow (long liHandle) 
    // this constructor initializes this form and positions itself outside 
    // the client area; then it prepares the call to create the dialog after 
    // the form is first shown in the window 
    { 
     // suppressing multiple layout events 
     SuspendLayout(); 
     // positioning the windoe outside the parent area 
     ClientSize = new Size (1, 1); 
     Location = new Point (-1, -1); 
     // the dialog will be created when this form is first shown 
     Shown += new EventHandler (HelpWindow_Shown); 
     // resuming layout events without executing pending layout requests 
     ResumeLayout (false); 

     // hooking to the parent of the passed handle: that is the control, not 
     // the tab of the screen saver dialog 
     IntPtr oParent = GetParent (new IntPtr (liHandle)); 
     SetParent (Handle, oParent); 
    } 

    // -------------------------------------------------------------------- 
    private void HelpWindow_Shown (object oSender, EventArgs oEventArgs) 
    // this function is called when the form is first shown; now is the right 
    // time to start our configuration dialog 
    { 
     // now creating the dialog 
     CKonfiguration oConfiguration = new CKonfiguration(); 
     // starting this dialog with the owner of this object; because this 
     // form is hooked to the screen saver dialog, the startet dialog is 
     // then indirectly hooked to that dialog 
     oConfiguration.ShowDialog (this); 
     // we don not need this object any longer 
     Close(); 
    } 
} 

После извлечения парашюта из командной строки

/c:#### 

создать свой диалог по

CHelpWindow oHelpWindow = new CHelpWindow (liHandle); 
oHelpWindow.ShowDialog(); 

Reimer

 Смежные вопросы

  • Нет связанных вопросов^_^