Solved

How to access Variables in different dialog box

Posted on 2013-06-14
3
284 Views
Last Modified: 2013-06-16
My application is a Dialog box. Within my app, there is a button, which when pressed another dialog appears.

My questions is, am I able to access Global Variables from here, and can I access controls as I normally would?

For instance, from the second dialog, I want to check the contents of an edit field in the first one.

Thank you
0
Comment
Question by:edvinson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 39249102
If you have the window handle and the control IDs, you can just gather or set the data like in your own dialog. E.g.

#define ID_TEXTFIELD 1234 // finding that is the tricky part
HWND hwnd = FindWindow(NULL,_T("Dialog Title"));

TCHAR acText[256];

GetDlgItemText(hwnd,ID_TEXTFIELD,acText,256);

Open in new window

0
 
LVL 1

Author Comment

by:edvinson
ID: 39250888
Ok, let me elaborate a bit...

My main dialog is defined as IDD_DIALOG1

I have another dialog ( which is not shown until a button is pressed ) defined as IDD_DIALOG2

Inside of IDD_DIALOG2 is a textfield, defined as IDC_PRINT.

Question:

How do I retrieve IDC_PRINT from IDD_DIALOG1?

Could I copy the value of IDC_PRINT to a global variable, and simply access it that way from IDD_DIALOG1? If so, how?

Thanks!
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 39251347
Just like in the above - if you have the definitions ready (which I assume you have, since both are in your app) all you need is the 2nd dialog's windoe handle:

TCHAR acText[256];

GetDlgItemText(hwndDlg2,IDC_PRINT,acText,256);
                                            

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

717 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