2014-10-22 02:58 AM - last edited on 2023-07-12 08:50 PM by Doreena Deng
2014-11-13 10:59 PM
// Note that dialID could be different from dialog's resourceID static short myDialID = 0; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- static GSErrCode __ACENV_CALL PaletteAPIControlCallBack (Int32 referenceID, API_PaletteMessageID messageID, GS::IntPtr /*param*/) { if (referenceID == myDialID) { switch (messageID) { case APIPalMsg_ClosePalette: DGModelessClose (myDialID); break; case APIPalMsg_HidePalette_Begin: DGHideModelessDialog (myDialID); break; case APIPalMsg_HidePalette_End: DGShowModelessDialog (myDialID, DG_DF_FIRST); break; case APIPalMsg_DisableItems_Begin: case APIPalMsg_DisableItems_End: // actually do nothing, because the input finish functionality the buttons have to stay enabled case APIPalMsg_IsPaletteVisible: case APIPalMsg_OpenPalette: break; } } return NoError; } // ----------------------------------------------------------------------------- // 'GDLG' resource in (RINT) .grc file // ----------------------------------------------------------------------------- 'GDLG' 32400 Palette | leftCaption | grow | close 0 0 196 28 "Example Palette" { /* [ 1] */ Button 88 4 70 20 LargePlain "Close" /* [ 2] */ Button 8 4 70 20 LargePlain "Update" } const short CloseButtonID = 1; const short UpdateButtonID = 2; // ----------------------------------------------------------------------------- // Callback function for the palette // ----------------------------------------------------------------------------- static short DGCALLBACK CntlDlgCallBack (short message, short dialID, short item, DGUserData /*userData*/, DGMessageData msgData) { switch (message) { case DG_MSG_INIT: DGSetFocus (dialID, DG_NO_ITEM); if (ACAPI_RegisterModelessWindow (dialID, PaletteAPIControlCallBack, API_PalEnabled_FloorPlan + API_PalEnabled_Section + API_PalEnabled_Elevation + API_PalEnabled_InteriorElevation + API_PalEnabled_Detail + API_PalEnabled_Worksheet + API_PalEnabled_3D + API_PalEnabled_Layout) != NoError) DBPrintf ("ACAPI_RegisterModelessWindow failed\n"); break; case DG_MSG_ACTIVATE: break; case DG_MSG_UPDATE: break; case DG_MSG_CHANGE: break; case DG_MSG_DOUBLECLICK: break; case DG_MSG_CLICK: switch (item) { case UpdateButtonID: // handle update button click event! break; case CloseButtonID: case DG_CLOSEBOX: return item; // this will result in a DG_MSG_CLOSE message } break; case DG_MSG_GROW: { short vgrow = DGGetVGrow (msgData); short hgrow = DGGetHGrow (msgData); DGBeginMoveGrowItems (dialID); DGMoveItem (dialID, NavCloseButton, hgrow, vgrow); DGMoveItem (dialID, NavUpdateButton, hgrow, vgrow); DGEndMoveGrowItems (dialID); } break; case DG_MSG_CLOSE: ACAPI_UnregisterModelessWindow (myDialID); myDialID = 0; break; default: break; } return (0); } // CntlDlgCallBack // ----------------------------------------------------------------------------- // Initialize/open our palette // ----------------------------------------------------------------------------- static bool Do_PaletteInit (void) { if (myDialID == 0 || !DGIsDialogOpen (myDialID)) myDialID = DGModelessInit (ACAPI_GetOwnResModule (), 32400, ACAPI_GetOwnResModule (), CntlDlgCallBack, NULL, 1); return myDialID != 0; } // Do_PaletteInit