Click to See Complete Forum and Search --> : Retrive the handle of Picture Control
Cooker
October 14th, 2005, 02:09 AM
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:
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!
humptydumpty
October 14th, 2005, 03:05 AM
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.
Cooker
October 14th, 2005, 03:12 AM
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));
humptydumpty
October 14th, 2005, 04:20 AM
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.
ovidiucucu
October 14th, 2005, 04:57 AM
GetDlgItem API function needs the handle of parent dialog of that control, as for example:
HWND hWnd = GetDlgItem(hWndDialog, IDC_STATIC_SCREEN);
BTW. Why do you not take a look in MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunctions/getdlgitem.asp)?
humptydumpty
October 14th, 2005, 05:18 AM
GetDlgItem API function needs the handle of parent dialog of that control, as for example:
HWND hWnd = GetDlgItem(hWndDialog, IDC_STATIC_SCREEN);
BTW. Why do you not take a look in MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunctions/getdlgitem.asp)?
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;
ovidiucucu
October 14th, 2005, 05:41 AM
Thank you for pointing us to CWindow::GetDlgItem, but:
CWindow is an ATL class.
I use Win32 API to write program
this is "C++ and WinAPI" forum.
Cooker
October 14th, 2005, 08:49 AM
GetDlgItem API function needs the handle of parent dialog of that control, as for example:
HWND hWnd = GetDlgItem(hWndDialog, IDC_STATIC_SCREEN);
BTW. Why do you not take a look in MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunctions/getdlgitem.asp)?
Thank you!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.