03-29-2006 12:17 PM
03-29-2006 01:19 PM - edited 03-29-2006 01:19 PM
It depends on how you structure your application but if you have stored the panel handles in a central location you can compare the value for panel passed to the callback to the available list of panel handles.
Another method is calling GetPanelAttribute(panel, ATTR_CONSTANT_NAME, charBuffer); will return the constant name that was used when you called LoadPanel() you can use a switch statement (if the panels have a unique character) or some other comparison method to determine which panel was the caller.
Yet another is to call GetPanelAttribute(panel, ATTR_TITLE, charBuffer); This will get the panel title as a character string and again a switch statement or other comparison may be the way to go. This method is useful when you dynamically create panels.
Message Edited by mvr on 03-29-2006 01:20 PM
03-29-2006 01:52 PM
Well, in your particular application, the handle of the panel is the first parameter received from the callback! So you can simply pass "panel" variable to PrintPanel function to obtain an hard copy of your panel.
This supposing that the Print button is on the same panel that is to be printed as I seem to understand.
The solutions proposed from mvr are useful if you load only one instance of your panels: supposing you load two instances of one panel the constant name is the same for both of them, and the same will be the title provided that you don't personalize it after loading the panel. But if you are not in this situation you can indeed use those attributes.
03-29-2006 02:22 PM
Thanks mvr and Roberto,
Yeah i was able to solve my problem using roberto's method. i had a button on each panel that i wanted to print and thus passing panel worked for me....but what i dont understand is that hw come even though each panel hv its own unique name but by passing "panel" took the panelhandle of the panel from which i pressed the button and printed it.
Thanks once again
k1_ke
03-29-2006 02:41 PM
03-29-2006 04:02 PM - edited 03-29-2006 04:02 PM
K1_ke > When you load a panel, you obtain an handle to that panel, which is unique throughout the application. Supposing you load the same panel twice, you will get two different handles for them.
This handle is then automatically passed by the system to the callbacks for all objects on that panel: the panel itself, all controls and all menu items that are on it. This handle is passed in the first variable for panel and control collbacks, and in the last for menu callbacks. It's this handle that permits you to discriminate which panel and/or control has fired the callback, so that you can manpiulate this control and other controls on the same panel without need to retain global variables for all of them. This process is called "incapsulation": a function receives as its parameters all the variables that it needs to use. This permits to reduce the need for global variables, that in a multi-threaded executing environment are dangerous since another thread can modify their contents before the function has used them. If received in the function call, the parameters are unique to this function and nobody can alter them.
In control callback, "panel" identifies and defines and (integer) variable that holds the panel handle, the same as "control" is a variable that holds the control ID. This is the reason why you can use one callback for several controls on a panel and for controls on different panels: a simple switch () on the appropriate variable can be used to discriminate the control that has fired the callback:
Message Edited by Roberto Bozzolo on 03-29-2006 11:07 PM
03-30-2006 07:46 AM
Hi Roberto,
Thank you soo much for the clear explanation. Now everything makes sense.
really appreciated!
Thanks
k1_ke