2014-11-17 09:38 AM - last edited on 2024-09-24 09:52 AM by Doreena Deng
2014-11-17 10:27 PM
typedef struct { short dialId; bool isDocked; bool isDockedTitleHorizontal; } API_DockStateInfo; typedef void __ACENV_CALL APIDockStateChangedCallBackProc (short dialId, API_DockStateInfo dockStateInfo); void ACAPI_Notify_CatchDockStateChanged (short dialId, APIDockStateChangedCallBackProc *callBackProc);
void ACAPI_Notify_CatchDockStateChanged (short dialId, APIDockStateChangedCallBackProc *callBackProc) { if (DGGetDialogType (dialId) == DG_DT_PALETTE) { static GS::HashTable<short, API_DockStateInfo> dockStateInfos; API_DockStateInfo actDockStateInfo; actDockStateInfo.dialId = dialId; GS::Guid paletteGuid; DGGetPaletteGuid (dialId, &paletteGuid); actDockStateInfo.isDocked = DGIsPaletteDocked (paletteGuid); short hFrameSize; short vFrameSize; short hClientSize; short vClientSize; DGGetDialogSize (ACAPI_GetOwnResModule (), dialId, DG_ORIGFRAME, &hFrameSize, &vFrameSize); DGGetDialogSize (ACAPI_GetOwnResModule (), dialId, DG_ORIGCLIENT, &hClientSize, &vClientSize); actDockStateInfo.isDockedTitleHorizontal = (hFrameSize - hClientSize > vFrameSize - vClientSize); API_DockStateInfo prevDockStateInfo; if (!dockStateInfos.Get (dialId, &prevDockStateInfo) || prevDockStateInfo.isDocked != actDockStateInfo.isDocked || prevDockStateInfo.isDockedTitleHorizontal != actDockStateInfo.isDockedTitleHorizontal) { dockStateInfos.Put (dialId, actDockStateInfo); callBackProc (dialId, actDockStateInfo); } } }
void __ACENV_CALL DockStateChangedCallBack (short dialId, API_DockStateInfo dockStateInfo) { char buffer[512]; sprintf (buffer, "DockStateChanged: dialId=%d, isDocked=%d, isDockedTitleHorizontal=%d", dialId, dockStateInfo.isDocked, dockStateInfo.isDockedTitleHorizontal); ACAPI_WriteReport (buffer, true); // Handle dock state changed event as you want! } // -------------------------------------- With C++ style Palette: ----------------------------------------------------- // Define the following function in the dialog's observer class: virtual void PanelIdle (const DG::PanelIdleEvent&); // ------------------------------- void MyDialogObserver:PanelIdle (const DG::PanelIdleEvent& /*ev*/) { ACAPI_Notify_CatchDockStateChanged (myDialog->GetId (), DockStateChangedCallBack); // myDialog is a pointer to the dialog } // ---------------------------------------- With C style Palette: ----------------------------------------------------- // In the dialog's callback function: // at the end of DG_MSG_INIT message handling: DGEnableMessage (dialID, DG_ALL_ITEMS, DG_MSG_NULL); break; case DG_MSG_NULL: ACAPI_Notify_CatchDockStateChanged (dialID, DockStateChangedCallBack); break;