Solved

GetDlgItem() on a dialog in a formview?

Posted on 2001-06-06
9
593 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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