Link to home
Start Free TrialLog in
Avatar of edvinson
edvinsonFlag for United States of America

asked on

How to access Variables in different dialog box

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
Avatar of jkr
jkr
Flag of Germany image

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

Avatar of edvinson

ASKER

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!
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial