Difference: GetDlgItem from CFormView vs. GetDlgItem from CDialog ???? 
Author Message
 Difference: GetDlgItem from CFormView vs. GetDlgItem from CDialog ????

In a CDialog class I've two similar functions.
One of them is called when I click on a Button and

void Cxxx::OnxxxButton() {
...
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT77);
...

Quote:
}

works fine.

The other is called from a CFormView and
void Cxxx::OnCallFromView() {
...
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT77);
...

Quote:
}

works not (Message box is popping up with assertion failed)

Why ?
Shouldn't refer GetDlgItem to the CDialog class (instance) to which it
belongs no matter from where the function is called ?
Are there other ways of getting a pointer to a certain control of the
dialog ?

Bye

Thomas

Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.



Wed, 21 Nov 2001 03:00:00 GMT  
 Difference: GetDlgItem from CFormView vs. GetDlgItem from CDialog ????
Thomas:

You must be doing something wrong, because this should work. Are you sure
there IS a IDC_EDIT77 control in the form view?

But anyway, when you get an ASSERTion error, you should ALWAYS hit "Retry"
and go into the de{*filter*}. The line of code where the ASSERT occurred will
tell you what is wrong.

HTH,

David Wilkinson

===============

Quote:

> In a CDialog class I've two similar functions.
> One of them is called when I click on a Button and

> void Cxxx::OnxxxButton() {
> ...
> CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT77);
> ...
> }
> works fine.

> The other is called from a CFormView and
> void Cxxx::OnCallFromView() {
> ...
> CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT77);
> ...
> }
> works not (Message box is popping up with assertion failed)

> Why ?
> Shouldn't refer GetDlgItem to the CDialog class (instance) to which it
> belongs no matter from where the function is called ?
> Are there other ways of getting a pointer to a certain control of the
> dialog ?

> Bye

> Thomas

> Sent via Deja.com http://www.*-*-*.com/
> Share what you know. Learn what you don't.



Wed, 21 Nov 2001 03:00:00 GMT  
 Difference: GetDlgItem from CFormView vs. GetDlgItem from CDialog ????
Hi,

from what you write I persume you are attempting to access IDC_EDIT77 *that
lives within the Dialog, not within the FormView*.

Note that GetDlgItem refers to the CWnd it is applied to. E.g. you can reuse
resource identifiers in different dialogs, they are not unique across the
whole app (note that otherwise multiple instances of the same
CDialog-derived class would not be able to separate their respective
controls)

HTH Andreas


Quote:
> In a CDialog class I've two similar functions.
> One of them is called when I click on a Button and

> void Cxxx::OnxxxButton() {
> ...
> CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT77);
> ...
> }
> works fine.

> The other is called from a CFormView and
> void Cxxx::OnCallFromView() {
> ...
> CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT77);
> ...
> }
> works not (Message box is popping up with assertion failed)

> Why ?
> Shouldn't refer GetDlgItem to the CDialog class (instance) to which it
> belongs no matter from where the function is called ?
> Are there other ways of getting a pointer to a certain control of the
> dialog ?

> Bye

> Thomas

> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.



Thu, 22 Nov 2001 03:00:00 GMT  
 Difference: GetDlgItem from CFormView vs. GetDlgItem from CDialog ????
Thomas:

I realize that I misinterpreted your question -- I thought the IDC_EDIT77
control which was giving you problems was in the form view.

If your Cxxx::OnCallFromView() function is a member of the dialog, then the
trouble is that you are trying to access the dialog when it is does not exist
as a Windows object. There is nothing wrong with accessing functions of the
C++ dialog object when the window does not exist, but you cannot perform
"Windows" operations on it.

It all has to do with the relationship between CWnd and HWND.

David Wilkinson

==============

Quote:

> Thomas:

> You must be doing something wrong, because this should work. Are you sure
> there IS a IDC_EDIT77 control in the form view?

> But anyway, when you get an ASSERTion error, you should ALWAYS hit "Retry"
> and go into the de{*filter*}. The line of code where the ASSERT occurred will
> tell you what is wrong.

> HTH,

> David Wilkinson

> ===============


> > In a CDialog class I've two similar functions.
> > One of them is called when I click on a Button and

> > void Cxxx::OnxxxButton() {
> > ...
> > CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT77);
> > ...
> > }
> > works fine.

> > The other is called from a CFormView and
> > void Cxxx::OnCallFromView() {
> > ...
> > CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT77);
> > ...
> > }
> > works not (Message box is popping up with assertion failed)

> > Why ?
> > Shouldn't refer GetDlgItem to the CDialog class (instance) to which it
> > belongs no matter from where the function is called ?
> > Are there other ways of getting a pointer to a certain control of the
> > dialog ?

> > Bye

> > Thomas

> > Sent via Deja.com http://www.*-*-*.com/
> > Share what you know. Learn what you don't.



Thu, 22 Nov 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Difference: GetDlgItem from CFormView vs. GetDlgItem from CDialog ????

2. dynamic_cast<> operator with CDialog::GetDlgItem()

3. GetDlgItem does not work on CFormView

4. Problems with GetDlgItem in Release of VS 6.0

5. GetDlgItem in composite control

6. How to get HWND in ::GetDlgItem(HWND hDlg,ID_SECTIONS) before dlg.DoModal()

7. GetDlgItem return NULL, help!

8. ATL Composite Control and GetDlgItem

9. GetDlgItem

10. GetDlgItem extension and pointer passing

11. Global Function problem with GetDlgItem

12. GetDlgItem

 

 
Powered by phpBB® Forum Software