hi again. Im having a few problems to do with a few of the components on my program. Firstly I have a button that once pressed allows the user to select a file and store its path in a variable. I would like to be able to access this variable whenever other buttons are used in my program but I cnt seem to find a way to pass the variable to each of my button components. Im not totally sure but I dont think its possible to make a variable global from within a button, and from looking around the only over thing i have come across is creating its own .h file which is something i have no clue about and would like to avoid if possible.
thanks any help will be appreciated
At this forum, we generally believe that one should walk before one runs. We also believe that you should write console programs to learn the basics of programming before you use an interface editor to create a GUI with buttons.
The button is the wrong place for this variable. In your program organization, the right place for the variable is probably the form containing the button. How you put the variable there and how to access it from the buttons, though, is for you to figure out.
I am starting to seriously wonder about your level of aptitude for doing whatever it is that you are doing. SetWindowLongPtr() is great for setting or retreiving some sort of data from a button control (assuming you are even using windows), but its not the best way of doing things unless you are actually wanting another process to have some sort of access to your button.
What are you doing? I mean that in the must blunt sense of the question. Can you explain why you are saving variables within a button, and how you are doing so. I somehow have a feeling you are not creatively using the GWLP_USERDATA or DWLP_USER flags with SetWindowLongPtr() to accomplish this task, so I can only assume you are setting the button text to a value and retreiving that value...
I may be wrong, so feel free to enlighten me.