CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2003
    Posts
    280

    Retrive the handle of Picture Control

    Hi,
    I have a Picture control,and its ID is IDC_STATIC_SCREEN.
    I want to retrive the window Handle of the Picture control.
    Using MFC, I know how to do that:
    Code:
    void CLiveVideoDlg::DoDataExchange(CDataExchange* pDX)
    {
       CDialog::DoDataExchange(pDX);
       //{{AFX_DATA_MAP(CLiveVideoDlg)
       DDX_Control(pDX, IDC_STATIC_SCREEN, m_staticScreen);
       //}}AFX_DATA_MAP
    }
    ...
    CStatic	m_staticScreen;
    //Retrive the window Handle of the Video Screen
    HWND hWnd = m_staticScreen.GetSafeHwnd() ;
    ...
    But what shall do if I want to do the same thing by calling Win32 API ?
    HWND hWnd = ?????;
    Thank you!

  2. #2
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    Lightbulb Re: Retrive the handle of Picture Control

    just perform subclassing on this and use

    m_wndPicture.SubclassWindow(GetDlgItem(IDC_PIC));

    IDC_PIC is the id of your picture control.and m_WndPicture is the object of your Picture Class.

  3. #3
    Join Date
    Sep 2003
    Posts
    280

    Re: Retrive the handle of Picture Control

    Quote Originally Posted by humptydumpty
    just perform subclassing on this and use

    m_wndPicture.SubclassWindow(GetDlgItem(IDC_PIC));

    IDC_PIC is the id of your picture control.and m_WndPicture is the object of your Picture Class.
    I use Win32 API to write program, not MFC.
    What kind of type is m_wndPicture ?
    I can't do :
    HWND hScreen;
    hScreen.SubclassWindow(GetDlgItem(IDC_PIC));

  4. #4
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    Lightbulb Re: Retrive the handle of Picture Control

    Quote Originally Posted by Cooker
    I use Win32 API to write program, not MFC.
    What kind of type is m_wndPicture ?
    I can't do :
    HWND hScreen;
    hScreen.SubclassWindow(GetDlgItem(IDC_PIC));
    try this to get handle of your control
    HWND hWnd = GetDlgItem(IDC_MYPIC);//id of your picture control
    if you want to perform some operation extra let me your mail id.i will send you my Files to you.

  5. #5
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Retrive the handle of Picture Control

    GetDlgItem API function needs the handle of parent dialog of that control, as for example:
    Code:
    HWND hWnd = GetDlgItem(hWndDialog, IDC_STATIC_SCREEN);
    BTW. Why do you not take a look in MSDN?
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  6. #6
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    Lightbulb Re: Retrive the handle of Picture Control

    Quote Originally Posted by ovidiucucu
    GetDlgItem API function needs the handle of parent dialog of that control, as for example:
    Code:
    HWND hWnd = GetDlgItem(hWndDialog, IDC_STATIC_SCREEN);
    BTW. Why do you not take a look in MSDN?
    according to MSDN

    CWindow::GetDlgItem

    This method retrieves the specified child window.

    The GetDlgItem method only works for immediate child controls of a dialog box—it does not search through nested dialog boxes.

    HWND GetDlgItem(int nID )const;

  7. #7
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Retrive the handle of Picture Control

    Thank you for pointing us to CWindow::GetDlgItem, but:
    • CWindow is an ATL class.
    • Quote Originally Posted by Cooker
      I use Win32 API to write program
    • this is "C++ and WinAPI" forum.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  8. #8
    Join Date
    Sep 2003
    Posts
    280

    Re: Retrive the handle of Picture Control

    Quote Originally Posted by ovidiucucu
    GetDlgItem API function needs the handle of parent dialog of that control, as for example:
    Code:
    HWND hWnd = GetDlgItem(hWndDialog, IDC_STATIC_SCREEN);
    BTW. Why do you not take a look in MSDN?
    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured