Hi Christian,
> Dear Rooters
>
> To get the id of TGButtons, I have always used:
> if (id == -1) {
> TGButton *btn = (TGButton*)gTQSender;
> id = btn->WidgetId();
> }
>
TGButton is derived from TQObject and TGWidget,
so the cast is correct and calling btn->WidgetId() is correct.
> This has always worked, but I can only find TGButton Ids.
> Now I would like to find the Ids of either TGButton or
> TGListBox. Since both inherit from TGWidget I wanted to do:
> if (id == -1) {
> TGWidget *wdg = (TGWidget*)gTQSender;
> id = wdg->WidgetId();
> }
>
You can only do: TGListBox *wdg = (TGListBox*)gTQSender
gTQSender is inherited from TQObject, not from TGWidget.
So, casting TGWidget *wdg = (TGWidget*)gTQSender is not possible.
Even if you get non-zero wdg pointer, it can not be used and should
cause segementation violation when calling TGWidget methods.
> Sorrowly, this is not possible, since the return id is
> always zero.
>
> Do you know how I can get the WidgetId from different
> widgets such as TGButton, TGListBox, etc?
gTQSender is inherited from TQObject, not from TGWidget.
What is a purpose of getting WidgetId?
Regards. Valeriy
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:05 MET