Hi All,
This is a general programming question but interested on any thoughts:
I try to use global variables (str, int, arrays) as much as possible and especially with COM objects to avoid the need for locking. So I try to pass things like child and window handles and arrays, etc in the function call and I construct the function to receive them as the defined parameters (top line).
However, when I use callbacks associated with a given COM object that I have used (e.g. MSFLEXGRID), I don't define the parameters of the available callback functions defined in the dll/ocx.
What is a good clean strategy for this. I have just been reluctantly globalizing more and more variables as needed. It worries me because I am also passing these variables in my custom functions (which I assume is the good behavior). But once I change this variable to global (and update all my declarations), then there is no point anymore in 'passing' the variable in my custom function definitions. But then this leads to sloppy dangerous code.
So any thoughts? I imagine this is a common problem.
Thanks,
Stuart
looking on StackOverflow and other forums, I am seeing some suggested solutions using set/get functions (which to me seem very similar to globals but just more inconvenient) and then stuff about wrapping/enclosing the callback in a more custom function that I can also pass my variables with. This sounds more promising. I just don't know how I would do this in QM.
Thanks for any advice.
S
I am sorry I didn't specify that these callback functions are Event handler callback functions eg. User clicked grid it selected row change.
S
This is a general programming question but interested on any thoughts:
I try to use global variables (str, int, arrays) as much as possible and especially with COM objects to avoid the need for locking. So I try to pass things like child and window handles and arrays, etc in the function call and I construct the function to receive them as the defined parameters (top line).
However, when I use callbacks associated with a given COM object that I have used (e.g. MSFLEXGRID), I don't define the parameters of the available callback functions defined in the dll/ocx.
What is a good clean strategy for this. I have just been reluctantly globalizing more and more variables as needed. It worries me because I am also passing these variables in my custom functions (which I assume is the good behavior). But once I change this variable to global (and update all my declarations), then there is no point anymore in 'passing' the variable in my custom function definitions. But then this leads to sloppy dangerous code.
So any thoughts? I imagine this is a common problem.
Thanks,
Stuart
looking on StackOverflow and other forums, I am seeing some suggested solutions using set/get functions (which to me seem very similar to globals but just more inconvenient) and then stuff about wrapping/enclosing the callback in a more custom function that I can also pass my variables with. This sounds more promising. I just don't know how I would do this in QM.
Thanks for any advice.
S
I am sorry I didn't specify that these callback functions are Event handler callback functions eg. User clicked grid it selected row change.
S