How to trigger redraw of a BOOPSI window (while an requester is open)

Online Status

In my app an ASL request is opened when the user selects the "Add files..." menu item. The parent window of the ASL request is a BOOPSI window that I create like this

  pWindowObject = NewObject(WINDOW_GetClass(), NULL,
    WINDOW_Position, WPOS_CENTERSCREEN,
    WA_Activate, TRUE,
    WA_Title, "MultiRename",
    WA_CloseGadget, TRUE,
    WA_DepthGadget, TRUE,
    WA_DragBar, TRUE,
    WA_SizeGadget, TRUE,
    WA_Width, 640,
    WA_Height, 480,
    WA_Zoom, (ULONG) zoomData,
    WA_PubScreen, pApp->pPubScreen,
    WA_AutoAdjust, TRUE,
    WA_NewLookMenus, TRUE,
    WA_IDCMP, IDCMP_CLOSEWINDOW|IDCMP_GADGETUP,
    WINDOW_Layout, pMainWindowLayout,
    WINDOW_NewMenu, mainWindowNewMenu,
    WINDOW_AppPort, pApp->pAppWindowPort,
    WINDOW_AppWindow, TRUE,
    WINDOW_AppMsgHook, &m_AppHook,
    TAG_DONE);

The problem is: when the user resizes this window with the size gadget while the ASL request is open, the window content disappears / is not redrawn.

Is see that I can give the ASL request a Intuition hook, ASLFR_IntuiMsgFunc:

AllocAslRequestTags(ASL_FileRequest,
                    ASLFR_TitleText, (ULONG) pHeaderText,
                    ASLFR_Window, (ULONG) pParentWindow,
                    ASLFR_RejectIcons, TRUE,
                    ASLFR_DoMultiSelect, TRUE,
                    ASLFR_IntuiMsgFunc, (ULONG)&aslHook,
                    TAG_DONE);

And the hook function itself would look like:

void __asm IntuiHook(register __a0 struct Hook *hook,
                     register __a2 struct FileRequester *fr,
                     register __a1 struct IntuiMessage *intuiMsg)
{
  putreg(REG_A4,(LONG)hook->h_Data);

  if (intuiMsg->Class == IDCMP_REFRESHWINDOW) {
    GT_BeginRefresh(intuiMsg->IDCMPWindow);

    // TODO: refresh the BOOPSI window

    GT_EndRefresh(intuiMsg->IDCMPWindow,TRUE);
  }
}

(I suppose GT_BeginRefresh and GT_EndRefresh might not be necessary at all as this is BOOPSI and not Gadtools..)

Is there a function I can call between the GT_BeginRefresh and GT_EndRefresh so that the BOOPSI window and its complex layout is redrawn?

Online Status

You definitely should not be using any GadTools functions in this case.

RefreshGadgets() or RefreshGList() will redraw the gadgets.

Online Status

Maybe give DoMethod(<your_window_object>, WM_RETHINK) a try?

Online Status

Many thanks for sharing your ideas! After some fiddling around I got it working and DoMethod(<your_window_object>, WM_RETHINK) did indeed help:-)

Here some (very incomplete) code of how it is done + working right now:

...
// For the compatiblity of thinks like __ASM__ and __REG between compilers
#include <clib/compiler-specific.h>

...

// Add the IDCMP_NEWSIZE in window oject creation
BOOL createWindow(...)
{
  pWindowObject = NewObject(WINDOW_GetClass(), NULL,
    WINDOW_Position, WPOS_CENTERSCREEN,
    WA_Activate, TRUE,
    WA_Title, "MultiRename",
    WA_CloseGadget, TRUE,
    WA_DepthGadget, TRUE,
    WA_DragBar, TRUE,
    WA_SizeGadget, TRUE,
    WA_Width, 640,
    WA_Height, 480,
    WA_Zoom, (ULONG) zoomData,
    WA_PubScreen, pApp->pPubScreen,
    WA_AutoAdjust, TRUE,
    WA_NewLookMenus, TRUE,
    WA_IDCMP, IDCMP_CLOSEWINDOW|IDCMP_GADGETUP|IDCMP_NEWSIZE,
    WINDOW_Layout, pMainWindowLayout,
    WINDOW_NewMenu, mainWindowNewMenu,
    WINDOW_AppPort, pApp->pAppWindowPort,
    WINDOW_AppWindow, TRUE,
    WINDOW_AppMsgHook, &m_AppHook,
    TAG_DONE);
    
    ...
}


// Define the hook function
void __ASM__ __SAVE_DS__ IntuiMsgFunc(__REG__(a0, struct Hook *pHook),
                                      __REG__(a2, struct FileRequester *pRequester),
                                      __REG__(a1, struct IntuiMessage *pMsg))
{
  Object* pWinObject = (Object*)pHook->h_Data;

  switch (pMsg->Class)
  {
    // Window has been resized
    case IDCMP_NEWSIZE:
    {
      DoMethod(pWinObject, WM_RETHINK);
      break;
    }
  }
}

// Create the hook variable
struct Hook m_IntuiMsgHook;


// Wire the hook and alloc the file requester
BOOL openFileRequester(...)
{
    m_IntuiMsgHook.h_Entry = (ULONG (* )())IntuiMsgFunc;
    m_IntuiMsgHook.h_SubEntry = NULL;
    m_IntuiMsgHook.h_Data = pWinObject;

    ...
    pFileRequest = (struct FileRequester*)
      AllocAslRequestTags(ASL_FileRequest,
                          ASLFR_TitleText, (ULONG) pHeaderText,
                          ASLFR_Window, (ULONG) pParentWindow,
                          ASLFR_RejectIcons, TRUE,
                          ASLFR_DoMultiSelect, TRUE,
                          ASLFR_IntuiMsgFunc, &m_IntuiMsgHook,
                          TAG_DONE);

    ...

  if(AslRequestTags(pFileRequest, TAG_DONE))
  {
    ...
  }

  ...
}