Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to access Variables in different dialog box

Posted on 2013-06-14
3
Medium Priority
?
286 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 2000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

618 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