Solved

GetDlgItem() on a dialog in a formview?

Posted on 2001-06-06
9
590 Views
Last Modified: 2013-11-20
I have a CFormView object which contains some controls.  In the code for this class I add a dialog to this formview.  I have some 3rdparty library that uses the IDs of the items on my formview to move things around.  I want it to move the dialog around, but it uses GetDlgItem on the IDs to get ahold of the controls, and this doesn't work on the dialog.  

So the simple question, is it not possible to use GetDlgItem() on an actual dialog?  I'm guessing not but want to be sure.
0
Comment
Question by:appleby
  • 4
  • 4
9 Comments
 
LVL 4

Expert Comment

by:captainkirk
ID: 6160979
1) Is the diaog a child of the form view?
2) how are you creating the dialog?
0
 

Author Comment

by:appleby
ID: 6160996
The dialog is a child of the form view.  
I am creating the dialog thus:

        Dialog1* dlg;
     dlg = new Dialog1;
     ASSERT(dlg);
     VERIFY(dlg->Create(IDD_DIALOG1, this));

inside the formview class.

I know there is a GetDlgItem() version that takes a pointer to the window, as well as the ID.  Also there is the framework version that works on any two windows that are parent/child.  But the library I'm calling does not allow for use of either of these versions.
0
 

Author Comment

by:appleby
ID: 6161024
The dialog is a child of the form view.  
I am creating the dialog thus:

        Dialog1* dlg;
     dlg = new Dialog1;
     ASSERT(dlg);
     VERIFY(dlg->Create(IDD_DIALOG1, this));

inside the formview class.

I know there is a GetDlgItem() version that takes a pointer to the window, as well as the ID.  Also there is the framework version that works on any two windows that are parent/child.  But the library I'm calling does not allow for use of either of these versions.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 12

Expert Comment

by:migel
ID: 6161067
Hi!
you must handle child dialog instead view:
that is:
CWnd* pCtl = dlg->GetDlgItem(IDC_ITEM_YOU_WANT);
where dlg is a pointer to the created dialog
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 6161082
It should work with any parent-child relationship - I will build a test project and get back to you...
0
 

Author Comment

by:appleby
ID: 6161096
Migel - Let me clarify.  The 3rdparty library I'm calling is what is calling GetDlgItem(), not me.  I don't have control over that.  The call by me is like this:

third_party_function(IDD_DIALOG1);

I have to pass in the ID of a control within my formview, and the function does some stuff to it, including calling GetDlgItem(IDD_DIALOG).  I have no power over that.
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 6161099
It should work with any parent-child relationship - I will build a test project and get back to you...
0
 
LVL 4

Accepted Solution

by:
captainkirk earned 50 total points
ID: 6161246
Looks like the MSDN docs are incorrect - I can't yet seem to make the GetDlgItem() call work either...
0
 

Author Comment

by:appleby
ID: 6161304
Ok, thanks.

I didn't want to have to, but since I have access to the source for the 3rd party library I'm going to rewrite it to work the way I need to.

Thanks for the sanity check.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 423
viewing source code from eclipse 13 103
tripleUp challenge 7 78
fix34  challenge 9 115
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now