tags:

views:

9

answers:

0

Hi!

I am developing MDI application with help of wxErlang. I have a parent frame, implemented as wx_object:

-module(main_frame).
-export([new/0, init/1, handle_call/3, handle_event/2, terminate/2]).

-behaviour(wx_object).

....

And I have a child frame, implemented as wx_object too:

module(child_frame).
-export([new/2, init/1, handle_call/3, handle_event/2, terminate/2]).
-export([save/1]).

-behaviour(wx_object).

% some public API method
save(Frame) ->
    wx_object:call(Frame, save).

....

I want to call save/1 for an active child frame from the parent frame. There is my code:

 ActiveChild = wxMDIParentFrame:getActiveChild(Frame),
 case wx:is_null(ActiveChild) of
  false ->
   child_frame:save(ActiveChild);
  _ ->
   ignore
 end

This code fails because ActiveChild is #wx_ref{} with state=[], but wx_object:call/2 needs #wx_ref{} where state is set to the pid of the process which we call. What is the right method to do this? I thought only to store a list of all created child frames with its pids in the parent frame and search the pid in this list, but this is ugly.