получить хэндл диалогового окна

Тема в разделе "WASM.BEGINNERS", создана пользователем zxcc, 24 янв 2007.

  1. zxcc

    zxcc New Member

    Публикаций:
    0
    Регистрация:
    21 окт 2006
    Сообщения:
    172
    Как получить хэндл диалогового окна DialogBoxParam
     
  2. Asterix

    Asterix New Member

    Публикаций:
    0
    Регистрация:
    25 фев 2003
    Сообщения:
    3.576
    конкретнее
     
  3. nitrotoluol

    nitrotoluol New Member

    Публикаций:
    0
    Регистрация:
    5 сен 2006
    Сообщения:
    848
    zxcc
    1. Получаешь хендл модального окна (он хранится в переменных winmain)
    либо просто
    GetModuleHandle(0);

    2 Затем нужно перечислить все дочерние окна, сравнить название с искомым.
    Если совпадет, значит это и есть твое окно.

    Вот процедура для перечисления:


    Код (Text):
    1. The FindWindowEx function retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the specified child window. This function does not perform a case-sensitive search.
    2.  
    3. Syntax
    4.  
    5. HWND FindWindowEx(          HWND hwndParent,
    6.     HWND hwndChildAfter,
    7.     LPCTSTR lpszClass,
    8.     LPCTSTR lpszWindow
    9. );
    10. Parameters
    11.  
    12. hwndParent
    13. [in] Handle to the parent window whose child windows are to be searched.
    14. If hwndParent is NULL, the function uses the desktop window as the parent window. The function searches among windows that are child windows of the desktop.
    15.  
    16. Microsoft® Windows® 2000 and Windows XP: If hwndParent is HWND_MESSAGE, the function searches all message-only windows.
    17.  
    18. hwndChildAfter
    19. [in] Handle to a child window. The search begins with the next child window in the Z order. The child window must be a direct child window of hwndParent, not just a descendant window.
    20. If hwndChildAfter is NULL, the search begins with the first child window of hwndParent.
    21.  
    22. Note that if both hwndParent and hwndChildAfter are NULL, the function searches all top-level and message-only windows.
    23.  
    24. lpszClass
    25. [in]
    26. Pointer to a null-terminated string that specifies the class name or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be placed in the low-order word of lpszClass; the high-order word must be zero.
    27.  
    28. If lpszClass is a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, or any of the predefined control-class names, or it can be MAKEINTATOM(0x800). In this latter case, 0x8000 is the atom for a menu class. For more information, see the Remarks section of this topic.
    29.  
    30. lpszWindow
    31. [in] Pointer to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match.
    32. Return Value
    33.  
    34. If the function succeeds, the return value is a handle to the window that has the specified class and window names.
    35.  
    36. If the function fails, the return value is NULL. To get extended error information, call GetLastError.
    37.  
    38.  
    39.  
    40.  
    41. Remarks
    42.  
    43. If the lpszWindow parameter is not NULL, FindWindowEx calls the GetWindowText function to retrieve the window name for comparison. For a description of a potential problem that can arise, see the Remarks section of GetWindowText.
    44.  
    45. An application can call this function in the following way.
    46.  
    47. FindWindowEx( NULL, NULL, MAKEINTATOM(0x8000), NULL );  
    48. 0x8000 is the atom for a menu class. When an application calls this function, the function checks whether a context menu is being displayed that the application created.
    49.  
    50. Windows 95 or later: FindWindowExW is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.
     
  4. zxcc

    zxcc New Member

    Публикаций:
    0
    Регистрация:
    21 окт 2006
    Сообщения:
    172
    При создании дочернего окна CreateWindow,в параметре WndParent нужно указать окно владельца.Окном владельцем является окно созданное DialogBoxParam(функция не возвр.значение хэндла) .Какой параметр является WndParent?
     
  5. shoo

    shoo New Member

    Публикаций:
    0
    Регистрация:
    17 июл 2003
    Сообщения:
    1.537
    Адрес:
    Ukraine
    в оконной процедуре этого диалогового окна первый параметр - хэндл этого окна. дочернее окно можно создавать внутри этой процедуры (а то и нужно).

    DialogBoxParam возвращает параметр вызванной внутри оконной процедуры функции EndDialog. Когда функция отработала - окна уже нет.
     
  6. Zhelezovsky

    Zhelezovsky Member

    Публикаций:
    0
    Регистрация:
    24 окт 2006
    Сообщения:
    39
    INT_PTR CALLBACK DialogProc
    (
    HWND hwndDlg, // дескриптор диалогового окна
    UINT uMsg // идентификатор сообщения
    WPARAM wParam // первый параметр сообщения
    LPARAM lParam // второй параметр сообщения
    );

    Читай же MSDN!!!