Re: calling a parent window class method from a child window class
Stefano Mtangoo <[email protected]>
| Newsgroups | gmane.comp.lib.wxwindows.general |
|---|---|
| Message-ID | <[email protected]> |
Or even better
CMyParentClass* pParent = dynamic_cast<CMyParentClass*>(this->GetParent());
if(pParent){
pParent->MyMethod( ... );
}
On Wednesday, July 17, 2024 at 11:39:30 AM UTC+3 Gregory van der Heijden
wrote:
> Thanks!
> Your solution works perfectly. I'll have a look at generating a custom
> event and propagating it. It's bound to be handy one day or the other!
>
> On Wed, 17 Jul 2024 at 10:19, Rossano Paris <[email protected]> wrote:
>
>> Hello Gregory
>>
>> Based on my experience it is always better working with events ...
>> Anyway, in your child window .cpp file, you could try to use the code
>> below
>>
>> # include "MyParentClass.h"
>>
>> CMyParentClass* pParent = (CMyParentClass*)this->GetParent();
>> pParent->MyMethod( ... );
>>
>> On Wednesday 17 July 2024 at 10:07:41 UTC+2 Gregory van der Heijden wrote:
>>
>>> Hello,
>>>
>>> I am working on a plot/chart display wxWidgets application in which I
>>> have in my main frame a child wxWindow for drawing the chart and a panel in
>>> which I have four text controls.
>>> I can set the min and max range for the X and Y axes of my chart with
>>> the text controls but I have also implemented a mouse drag procedure to
>>> directly select an area on the chart to zoom into (this procedure uses
>>> mouse events in the chart window (child)).
>>>
>>> What I would like to do is update the values displayed in the text
>>> controls when the chart axis ranges are modified by the mouse drag
>>> procedure.
>>>
>>> *QUESTION: *Is there anyway for a child window (the class being nested
>>> within the parent class) to call a parent window method directly?
>>>
>>> it is my understanding that one solution would be to create a custom
>>> event in the child window that propagates to the parent which then handles
>>> it. But is there any other (simpler) way of doing this?
>>>
>>> Thanks in advance!
>>>
>> --
>> Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "wx-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/wx-users/0d5cdf29-f791-4d3a-a451-c1e1fef0070dn%40googlegroups.com
>> <https://groups.google.com/d/msgid/wx-users/0d5cdf29-f791-4d3a-a451-c1e1fef0070dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Gregory van der Heijden
>
--
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/e553edae-b32f-4d1e-b802-4d1fed0f11dcn%40googlegroups.com.