bod_1
asked on
retain values in structure between functions
I have a structure in my dialog's header file. One function creates an instance of the structure and stores info into its members. I need a second function (button press) to access that data. If i create a second instance of the structure with the same name as the instance in the first it will clear the data stored by the first?
How can i access the the data from the first instance of the structure in a seperate function?
Thanks in advance.
How can i access the the data from the first instance of the structure in a seperate function?
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Solved!
I was trying to store the info from PROCESSENTRY32 into my own structure. My GetProcessInfo() function I had to declare an instance of my structure.
My OnButton() was supposed to get the info from the first instance of the structure (from GetProcessInfo()) but the original instance is lost when the function ended.
A global instance of my structure will solve this problem.
Thank you nietod.
I was trying to store the info from PROCESSENTRY32 into my own structure. My GetProcessInfo() function I had to declare an instance of my structure.
My OnButton() was supposed to get the info from the first instance of the structure (from GetProcessInfo()) but the original instance is lost when the function ended.
A global instance of my structure will solve this problem.
Thank you nietod.
To do this You can use SetWindowLong() and GetWindowLong() with the GWL_USERDATA index to get and set the pointer associated with the dialog box. You will probably want to pass a pointer to the data when you create the dialog box using one of the dialog creation procedures that end in "param", like CreateDialogParam(). This way you can set the pointer in the dialog by intercepting the WM_CREATE message.
Hope this is what you were looking for.