How to get Dialog handle
-
Im using Setwindowpos of one dialog in another class. if i use Setwindowpos,it shows arror. I dont know how to get dialog handle. My dailog class is CToolTab and id is IDD_TOOLBAR I used
GetDlgItem(IDD_TOOLBAR)->SetWinowPos(.....
But fails. Pls help me.
Anu
-
Im using Setwindowpos of one dialog in another class. if i use Setwindowpos,it shows arror. I dont know how to get dialog handle. My dailog class is CToolTab and id is IDD_TOOLBAR I used
GetDlgItem(IDD_TOOLBAR)->SetWinowPos(.....
But fails. Pls help me.
Anu
One possibility could be (calling the function inside your dialog, maybe when showing up):
CSomeDialog::SomeMethod()
{
HANDLE p_Dlg = GetDlgItem((HANDLE)this, IDC_YOURDIALOG);
//...
}afterwards you can give the handle to be used in other place. Forget it. I choose false example from the net. Thanks for correction Stephen :)
Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpfull answers is nice, but saying thanks can be even nicer.
modified on Thursday, January 21, 2010 4:43 AM
-
Im using Setwindowpos of one dialog in another class. if i use Setwindowpos,it shows arror. I dont know how to get dialog handle. My dailog class is CToolTab and id is IDD_TOOLBAR I used
GetDlgItem(IDD_TOOLBAR)->SetWinowPos(.....
But fails. Pls help me.
Anu
-
Im using Setwindowpos of one dialog in another class. if i use Setwindowpos,it shows arror. I dont know how to get dialog handle. My dailog class is CToolTab and id is IDD_TOOLBAR I used
GetDlgItem(IDD_TOOLBAR)->SetWinowPos(.....
But fails. Pls help me.
Anu
Are you trying to add ToolBar to a CDialog? If yes Check following articles CToolbarDialog - dialog with floating toolbar[^] http://www.codeguru.com/cpp/w-d/dislog/toolbarsandstatusbars/article.php/c1949/[^] If that is not the case please ignore my message. I hope it helps.
Regards, Sandip.
-
if u have pointer of dialog, then CWnd *pWnd=NULL; HWND hWnd= m_pDlg->GetSafeHwnd(); pWnd=FromHandle(hWnd);
Regards, Srinivas
-
One possibility could be (calling the function inside your dialog, maybe when showing up):
CSomeDialog::SomeMethod()
{
HANDLE p_Dlg = GetDlgItem((HANDLE)this, IDC_YOURDIALOG);
//...
}afterwards you can give the handle to be used in other place. Forget it. I choose false example from the net. Thanks for correction Stephen :)
Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpfull answers is nice, but saying thanks can be even nicer.
modified on Thursday, January 21, 2010 4:43 AM
Nelek wrote:
CSomeDialog::SomeMethod() { HANDLE p_Dlg = GetDlgItem((HANDLE)this, IDC_YOURDIALOG); //... }
This code is flawed:
GetDlgItem
's first parameter is aHWND
, not aHANDLE
. Your code will give a compiler error.- Even is the code was modified to look like the following, it would still be wrong:
HWND p_Dlg = GetDlgItem((HWND)this, IDC_YOURDIALOG);
Using what in this case is essentially areinterpret_cast
doesn't make a pointer aHWND
. The cast just tells the compiler that although it knows a pointer isn't aHWND
and would normally not normally compile code that incorrectly assumes it is, that in this case it should just shut-up and plough on.
Steve
-
Nelek wrote:
CSomeDialog::SomeMethod() { HANDLE p_Dlg = GetDlgItem((HANDLE)this, IDC_YOURDIALOG); //... }
This code is flawed:
GetDlgItem
's first parameter is aHWND
, not aHANDLE
. Your code will give a compiler error.- Even is the code was modified to look like the following, it would still be wrong:
HWND p_Dlg = GetDlgItem((HWND)this, IDC_YOURDIALOG);
Using what in this case is essentially areinterpret_cast
doesn't make a pointer aHWND
. The cast just tells the compiler that although it knows a pointer isn't aHWND
and would normally not normally compile code that incorrectly assumes it is, that in this case it should just shut-up and plough on.
Steve
Hmmm, thanks for the info. I'll wrap the answer.
Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpfull answers is nice, but saying thanks can be even nicer.
-
Im using Setwindowpos of one dialog in another class. if i use Setwindowpos,it shows arror. I dont know how to get dialog handle. My dailog class is CToolTab and id is IDD_TOOLBAR I used
GetDlgItem(IDD_TOOLBAR)->SetWinowPos(.....
But fails. Pls help me.
Anu
Could you please post you code snippet?
-
Im using Setwindowpos of one dialog in another class. if i use Setwindowpos,it shows arror. I dont know how to get dialog handle. My dailog class is CToolTab and id is IDD_TOOLBAR I used
GetDlgItem(IDD_TOOLBAR)->SetWinowPos(.....
But fails. Pls help me.
Anu
Anu_Bala wrote:
Im using Setwindowpos of one dialog in another class.
GetDlgItem()
returns a handle to a sub item within a Dialog, not to a Dialog window. It is much better to do this in the Dialog itself, when you handle theWM_INITDIALOG
message.MVP 2010 - are they mad?
-
Im using Setwindowpos of one dialog in another class. if i use Setwindowpos,it shows arror. I dont know how to get dialog handle. My dailog class is CToolTab and id is IDD_TOOLBAR I used
GetDlgItem(IDD_TOOLBAR)->SetWinowPos(.....
But fails. Pls help me.
Anu
Anu_Bala wrote:
if i use Setwindowpos,it shows arror.
I'm having a hard time seeing the error from here. Could you please post it?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons