Solved

How to access Variables in different dialog box

Posted on 2013-06-14
3
278 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
  • 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

707 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

11 Experts available now in Live!

Get 1:1 Help Now