PtDestroyWidget() does not work

Hi,
In Phab I have a window called “editWin”. It is meant to be a pop-up window that shows up on top of a window called “baseWin”.
I create an internal link for editWin, and launch it in my code by calling ApCreateModule(ABM_editWin, NULL, NULL ); It works fine.
Now there is an “Exit” button in baseWin. When that button is clicked, I want the pop up window to close as well. I think to close this window, I’m supposed to call PtDestroyWidget(ABW_editWin); . So I added this function to my “Exit” button’s callback. However, the popup window is not closed. PtDestroyWidget seems to do nothing, even though my printf statement tells me it’s able to find the popup window with no problem.

To get around this problem, I set baseWin to be the parent window, so when baseWin exits, editWin also seems to exit automatically. I have two questions:

  1. Is my observation correct? If a parent window exits, any child window also is closed automatically? I just want to make sure it’s actually lurking somewhere, just not displayed.
  2. Why does PtDestroywidget not work?

Thanks!

You have the right idea, but the wrong code.

ABM_editWin is a module pointer. You create a widget with APCreateModule as follows:

PtWidget_t *window;

window = ApCreateModule(…);

So to destroy the window you would call

PtDestroyWidget(window);