### Page Numbering Setup Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/ogugTOC/Pre-BuiltDialogsforAccessingObjectiveGridObjects Allows configuration of the starting page number for the document. Subsequent pages will be numbered sequentially from this initial value. ```c++ CGXProperties::GetFirstPage(); CGXProperties::SetFirstPage(); ``` -------------------------------- ### Page Setup, Edit, and Creation Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Charts/srgscrollview Handles graph page setup, graph editing commands, and initialization during creation. ```APIDOC ## void OnGraphPagesetup() ### Description Displays the print pagination setup dialog for the graph. ### Method `OnGraphPagesetup` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None ## void OnGraphEdit() ### Description Handles the GraphEdit command, likely to open an editing interface for the graph. ### Method `OnGraphEdit` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None ## int OnCreate(LPCREATESTRUCT lpCreateStruct) ### Description Performs initialization tasks when the chart object is created. Creates a color palette if required. ### Method `OnCreate` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **int** (integer) - Indicates success or failure of the creation process. #### Response Example ```json { "status": 0 } ``` ``` -------------------------------- ### Example: Creating and Configuring Docked Windows in CGXSplitterWnd Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Grid/CGXSplitterWnd_9279 Demonstrates how to create a CGXSplitterWnd and then dynamically add and configure docked windows using the CGXInsideWndState structure. This example showcases setting window properties like alignment, size, and resizability. ```cpp BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { // use the new record info wnd with support for dynamic splitter views m_pWndSplitter = new CGXRecordInfoSplitterWnd; if (!m_pWndSplitter->Create( this, 2, 2, // TODO: adjust the number of rows, columns CSize( 10, 10 ), // TODO: adjust the minimum pane size pContext )) return FALSE; m_pWndSplitter->m_nhSplitterBoxPos = gxLeft; m_pWndSplitter->m_nvSplitterBoxPos = gxBottom; // This is just some fancy sample to demonstrate that // you can embedd any CWnd into the scrollbar area // (e.g. like in MS Word a page up/page down button) { CButton* pButton = new CButton(); pButton->Create(_T("Resizable Button"), BS_PUSHBUTTON|WS_VISIBLE, CRect(0, 0, 1, 1), m_pWndSplitter, GX_IDW_INSIDE_FIRST+1); m_pWndSplitter->m_apInsideWndState[gxRight] = new CGXInsideWndState; CGXInsideWndState& state = *m_pWndSplitter->m_apInsideWndState[gxRight]; state.pWnd = pButton; state.size = CSize(100, 5); state.sizeMin = CSize(50, 0); state.sizeBox = CSize(6, 0); state.nAlign = gxRight; state.bResizable = TRUE; state.lRelSize = 500; } { CButton* pButton = new CButton(); pButton->Create(_T("X"), BS_PUSHBUTTON|WS_VISIBLE, CRect(0, 0, 1, 1), m_pWndSplitter, GX_IDW_INSIDE_FIRST+3); m_pWndSplitter->m_apInsideWndState[gxBottom] = new CGXInsideWndState; CGXInsideWndState& state = *m_pWndSplitter->m_apInsideWndState[gxBottom]; state.pWnd = pButton; state.size = CSize(0,100); state.sizeMin = CSize(0, 50); state.sizeBox = CSize(0, 6); state.nAlign = gxBottom; state.bResizable = FALSE; state.lRelSize = 500; } return TRUE; } ``` -------------------------------- ### Declare and Initialize MultiTrace Logger (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/otugTOC/Safe_Multi_Threaded_Trac Demonstrates how to declare an instance of the MultiTrace logger and initialize it with a log file path. This example shows the basic setup required to start logging from a C++ multithreaded application. ```cpp #include "MultiTrace.h" #include "MultiTraceException.h" // ... file scope declaration multithreadedlogger mt; // ... in initialization mt.fname=_T("c:\\logfile.txt"); mt.initialize(); ``` -------------------------------- ### Create and Configure Windowed Shortcut Bar (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/otugTOC/Using_the_Shortcut_Bar Demonstrates the creation and initial configuration of a windowed shortcut bar using the SECATLShortcutBarWnd class. It includes setting styles and adding window-based and visual clients. ```cpp // m_hWnd is the window handle of the parent. m_wndSCBar.Create(m_hWnd, rcBar); m_wndSCBar.SetBarStyle(m_wndSCBar.GetBarStyle() | SEC_TABBAR_CNTXTMENU); // m_pViewport is an instance of an MVC MvcViewport_T class m_wndSCBar.AddBarVisual(&m_pViewport, _T("Canvas Viewport")); // m_wndTree is a standard C++ wrapper(CWnd/CWindow) for // a HWND m_wndSCBar.AddBarWnd(m_wndTree.m_hWnd, _T("Tree")); m_wndSCBar.ActivateBar(0); ``` -------------------------------- ### Page Setup Dialog - Margins API Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/ogugTOC/Formula_Support APIs for getting and setting print margins in the Page Setup Dialog. ```APIDOC ## CGXProperties::GetMargins() ### Description Retrieves the current print margin settings. ### Method GET ### Endpoint `/websites/help_perforce_stingray_current_stingray_doc/api/CGXProperties/GetMargins` ### Parameters None ### Response #### Success Response (200) - **margins** (object) - An object containing the current margin settings. - **top** (number) - The top margin value. - **bottom** (number) - The bottom margin value. - **left** (number) - The left margin value. - **right** (number) - The right margin value. #### Response Example ```json { "margins": { "top": 1.0, "bottom": 1.0, "left": 1.0, "right": 1.0 } } ``` ## CGXProperties::SetMargins() ### Description Sets the print margin settings for the Page Setup Dialog. ### Method POST ### Endpoint `/websites/help_perforce_stingray_current_stingray_doc/api/CGXProperties/SetMargins` ### Parameters #### Request Body - **margins** (object) - Required - The new margin settings. - **top** (number) - Required - The desired top margin value. - **bottom** (number) - Required - The desired bottom margin value. - **left** (number) - Required - The desired left margin value. - **right** (number) - Required - The desired right margin value. ### Request Example ```json { "margins": { "top": 1.5, "bottom": 1.5, "left": 1.5, "right": 1.5 } } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Initialize Application with CApp::Init Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Foundation/capp__init Initializes the application, typically creating a main window. It accepts parameters for window display state, ATL object map, instance handle, and an optional type library ID. Returns S_OK on successful initialization. ```cpp HRESULT CApp::Init(int _nShowCmd_, _ATL_OBJMAP_ENTRY*_p_, HINSTANCE _h_, GUID*_plibid = NULL_) { // Initialize application logic here return S_OK; } ``` -------------------------------- ### Example: Reevaluate Specific Columns (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Grid/CGXGridCore_8v3n An example showing how to call DelayMergeCells to reevaluate only specific columns within the grid. The range is defined using SetCols, specifying the start and end columns to be reevaluated. ```c++ DelayMergeCells(CGXRange().SetCols(nFromCol, nToCol + 1)); ``` -------------------------------- ### Get Covered Cells Range Example (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Grid/CGXGridCore_7d0s This C++ example demonstrates how to use GetCoveredCellsRowCol after setting covered cells using SetCoveredCellsRowCol. It shows that GetCoveredCellsRowCol returns the previously set range for any cell within that range. ```cpp // When you specify a range of cells as covered with SetCoveredCellsRowCol(1,1,5,5); // GetCoveredCellsRowCol will return the range (1,1,5,5) for all cells in this range: CGXRange range; GetCoveredCellsRowCol(1,1,range); // returns (1,1,5,5); GetCoveredCellsRowCol(2,2,range); // returns (1,1,5,5); GetCoveredCellsRowCol(5,1,range); // returns (1,1,5,5); // ... ``` -------------------------------- ### Graph Pagination and Initialization Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Charts/srgraphview Manages graph pagination setup and performs initial creation tasks. This includes running a pagination dialog and handling the initial creation process. ```cpp afx_msg void OnGraphPagesetup() // Runs a simple pagination dialog afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct ) // Creation initialization ``` -------------------------------- ### Integrating Reference Counting into Classes (Example) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/sflug/Reference_Counting This example shows a concrete class _CCow_ that inherits from _CRefCountImpl_ and implements the _IFood_ interface. It utilizes the _BEGIN_GUID_MAP_ macro to define its GUID entries, including those for _IAnimal_, _IQueryGuid_, and _IRefCount_. ```cpp class CCow : public CRefCountImpl, public IFood { public: BEGIN_GUID_MAP(CCow) GUID_ENTRY(IAnimal) GUID_ENTRY2(IQueryGuid, IAnimal) GUID_ENTRY2(IRefCount, IAnimal) END_GUID_MAP // ... other methods for CCow ... }; ``` -------------------------------- ### Initialize Grid and Open Excel File Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/ogugTOC/sample_1 This snippet demonstrates initializing a grid window and opening an Excel file. It displays a file dialog to select an .xls file and then populates the grid with the first tab (index 0) of the selected Excel file. It uses CFileDialog for user interaction and m_gridWnd.ReadExcelFile for data loading. ```C++ m_gridWnd.SubclassDlgItem(IDC_GRID, this); m_gridWnd.Initialize(); CString strPath; CFileDialog dlgFile( TRUE, _T(".xls"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Excel 97 Files (*.xls)|*.xls|All Files (*.*)|*.*||") ); if (dlgFile.DoModal() == IDCANCEL) return FALSE; strPath = dlgFile.GetFileName(); m_gridWnd.ReadExcelFile(strPath); ``` -------------------------------- ### Initialize OLE Libraries for Clipboard Support (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/oeugTOC/Modify_CMy1stEditApp__In This code snippet shows how to initialize OLE libraries by calling AfxOleInit() at the beginning of the InitInstance() function. This is essential for enabling clipboard functionality and preventing errors like 'CoInitialize has not been called'. ```cpp AfxOleInit(); ``` -------------------------------- ### Get Selection Range (DWORD Return) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Edit/seceditcontroller__getsel Retrieves the selection range as a DWORD value. The low-order word contains the starting character position, and the high-order word contains the position of the first non-selected character after the selection. This is useful for quickly getting both values. ```cpp DWORD SECEditController::GetSel() const ``` -------------------------------- ### Open Document with Initially Docked View Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/otugTOC/Using_the_Docking_Views_Architecture This example shows how to call OpenDocumentFile() to create a document and its associated view in an initially docked state. By setting the third parameter `bInitiallyDocked` to TRUE, the view will be docked by default when opened. ```cpp // Doc the cloud view initially GetTemplate(CLOUD_DOCNAME) ->OpenDocumentFile(NULL, TRUE, TRUE); ``` -------------------------------- ### Get Starting Selection Position (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Edit/seceditselection__getselstart Retrieves the starting position of a text selection. This function compares the anchor and tail positions of the selection and returns the one that precedes the other. It can return the position as an SECEditLineCol object or via output parameters for line and column indices. ```cpp SECEditLineCol GetSelStart() const; void GetSelStart(int& nStartLine, int& nStartCol) const; ``` -------------------------------- ### Visual Basic: Initialize, Load, and Commit with XMLPropertyBag Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/sflug/Examples_2 Initializes an XMLPropertyBag, loads a 'BooksCollection' from 'books.xml' into a 'Books' object, and commits the changes. This demonstrates basic XML persistence in Visual Basic. ```vb Set bag = New XMLPropertyBag bag.Init "books.xml" bag.Load "BooksCollection", Books bag.Commit ``` -------------------------------- ### CGXGridCore::Rollback Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Grid/CGXGridCore_52qz Undoes all commands since the start of the transaction without generating redo information. Each command-object is popped off the undo-stack and its Execute method gets called with _ctCmd_ set to gxRollback. ```APIDOC ## CGXGridCore::Rollback ### Description Undoes all commands since the start of the transaction without generating redo information. ### Method virtual void ### Endpoint N/A (This is a class method, not an API endpoint) ### Parameters None ### Request Example N/A ### Response #### Success Response N/A (This is a void method) #### Response Example N/A ``` -------------------------------- ### Get Selection Range (Parameter Output) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Edit/seceditcontroller__getsel Retrieves the selection range by populating two integer reference parameters. This method is useful when you need to work with the start and end positions separately or prefer a more explicit parameter-based approach. The parameters receive the start character position and the position after the end of the selection, respectively. ```cpp void SECEditController::GetSel(int &nStartChar, int &nEndChar) const ``` -------------------------------- ### Create and Initialize Layout Listener in C++ Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/otugTOC/Using_the_Layout_Manager This example illustrates the creation of a SECLayoutWndListener using the layout factory and its subsequent initialization with a grid and the parent window to bridge event handling and layout recalculations. ```cpp // Use the factory to create the listener, this way we don’t // have to consider memory management SECLayoutWndListener* pListener=m_LayoutFactory.CreateLayoutWndListener(); // Use the AutoInit function to bridge the gap between window // and layout pListener->AutoInit(pGrid,this); ``` -------------------------------- ### SECAScriptHost Constructor Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Toolkit/secascripthost Initializes a new instance of the SECAScriptHost class. ```APIDOC ## SECAScriptHost constructor ### Description Constructs a new SECAScriptHost object. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` // No direct request example for a constructor ``` ### Response #### Success Response (N/A) N/A #### Response Example ``` // No direct response example for a constructor ``` ``` -------------------------------- ### SECEditController::GetSelection Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Edit/seceditcontroller__getselection_1 Retrieves the starting and ending positions of the current selection. The positions returned are those coordinates that would be needed to be passed to GetTextBlock to get the text that this selection represents. ```APIDOC ## SECEditController::GetSelection ### Description Retrieves the starting and ending positions of the current selection. The positions returned are those coordinates that would be needed to be passed to GetTextBlock to get the text that this selection represents. ### Method GET (conceptual, as this is a C++ method) ### Endpoint N/A (C++ method) ### Parameters #### Output Parameters - **amplcpSel** (SECEditLineColPair&) - Output - References the line column position. - **nStartLine** (int&) - Output - The starting line of the selection. - **nStartCol** (int&) - Output - The starting column of the selection. - **nEndLine** (int&) - Output - The ending line of the selection. - **nEndCol** (int&) - Output - The ending column of the selection. ### Request Example N/A (C++ method) ### Response #### Success Response - **Return Value** (BOOL) - Non-zero if there is text currently selected, zero otherwise. #### Response Example N/A (C++ method) ``` -------------------------------- ### Build DLL and Initialize Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Objective_Grid_KB/html/ogfaq398 This method involves building a language-specific DLL (e.g., `gx##deu.dll`) and then initializing it within your application using the `GXInit` function. This is only applicable when using OG as a shared DLL. ```APIDOC ## Build DLL and Initialize Language Resources ### Description Build the language-specific DLL (e.g., `gx##deu.dll`) and call `GXInit("Deu")` in your application's `InitInstance` method. This method requires using OG as a shared DLL and ensures that you do NOT include the base `gxres.rc` file in your application's resources, as it would take precedence. ### Method DLL Initialization ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```cpp // In your application's InitInstance method void CYourApp::InitInstance() { // ... other initialization code ... GXInit("Deu"); // Initialize German resources // ... } ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Overriding OnPreparePrinting with PreparePrinting (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/ovugTOC/The_CODViewport_Class Example demonstrating how to override the MFC `OnPreparePrinting` method to utilize the `PreparePrinting` function for custom print job setup. It includes setting print properties and calling the `PreparePrinting` overload. ```cpp BOOL CShowcaseView::OnPreparePrinting(CPrintInfo* pInfo) { ... // do things: see Showcase sample for details SetIsPrintMaintainAspect(TRUE); ... // do things: see Showcase sample for details if(!GetViewport()->PreparePrinting(pInfo, fZoom)) return FALSE; // Default Preparation return DoPreparePrinting(pInfo); } ``` -------------------------------- ### PreparePrinting Overload for Current View Print (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/ovugTOC/The_CODViewport_Class This overload prints only the portion of the canvas that is currently visible in the view. It respects the current zoom setting and page setup configurations, ensuring what the user sees is what gets printed. ```cpp virtual BOOL PreparePrinting(CPrintInfo* pInfo, long percentOfNorm, CRect rcCurView); ``` -------------------------------- ### Initialize Objective Grid in Application's InitInstance() Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/ogugTOC/DbQuery___Step_1 This code snippet shows how to initialize Objective Grid resources and variables by calling `GXInit()` and `GXInitODBC()` at the beginning of the `InitInstance()` function in the application's implementation file (`.cpp`). These calls ensure that the Objective Grid library and its ODBC support are properly initialized before any other Objective Grid functions are invoked. ```cpp // These calls will initialize the grid library GXInit(); GXInitODBC(); ``` -------------------------------- ### Example: Initializing with a Specific Language DLL Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Grid/MacrosAndGlobals_92yc Shows how to call GXInit to load a specific language DLL, such as Dutch ('Nld'). Ensure the corresponding language DLL is built and accessible. ```cpp GXInit(_T("Nld")); ``` -------------------------------- ### SECTabControl Operations Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Toolkit/sectabcontrol Provides C++ examples for key operations of the SECTabControl class, including scrolling to a tab, setting and getting fonts for different tab states (selected, unselected, active), and managing multi-selection. ```cpp // Scroll to a specific tab myTabControl.ScrollToTab(5); // Set font for selected tab CFont newFont; // ... initialize newFont ... myTabControl.SetFontSelectedTab(&newFont); // Get font for active tab CFont* activeFont = myTabControl.GetFontActiveTab(); // Enable multi-selection myTabControl.SetMultiSelect(TRUE); // Check if multi-selection is enabled BOOL multiSelectEnabled = myTabControl.GetMultiSelect(); ``` -------------------------------- ### Get Selection Line/Column Pair (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Edit/seceditcontroller__getselection_1 Retrieves the starting and ending line and column for the current selection as a SECEditLineColPair structure. This is useful for passing directly to other functions that require this format. It returns non-zero if text is selected. ```cpp BOOL GetSelection(SECEditLineColPair &lcpSel) const; ``` -------------------------------- ### SECImage Constructors and Initialization Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Foundation/secimage Details on how to create and initialize SECImage objects. ```APIDOC ## Constructors and Initialization ### SECImage() #### Description Constructs a SECImage object. ### virtual BOOL CreatePalette() #### Description Creates the image palette. #### Method `virtual BOOL` #### Parameters None ``` -------------------------------- ### Row Rearrangement Loop Example Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Grid/CGXData_96er This C++ code snippet demonstrates how to loop through the anRowIndex array to get the original row ID in the grid when rearranging rows. It adds sortRange.top to the index to obtain the correct source row. ```cpp for (int nDest = 0; nDest < anRowIndex.GetSize(); nDest++) { int nSrc = (int) (anRowIndex[nDest]+sortRange.top); // move data from nSrc to nDest // ... } ``` -------------------------------- ### Implement Scale Layout in Dialog - C++ Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/sflug/Examples This example demonstrates how to use the CScaleLayout algorithm to manage the scaling of dialog elements. It involves creating a ScaleLayout node, optionally setting size limits, and optimizing redraw for child nodes. This is suitable for simple dialog resizing. ```cpp virtual void InitLayout(foundation::ILayoutNode* pRootNode) { // Scale is perhaps the simplest and easiest layout algorithm to // merge into your code. This is all the code you need: pRootNode = CreateLayoutNode(__uuidof(foundation::CScaleLayout)); // optional: set dialog box size limits pRootNode->SetMinMaxSize(CSize(150, 255), CSize(900, 600), 0); // set all child nodes to use optimized redraw // (static controls require it) pRootNode->ModifyNodeStyleEx(0, foundation::OptimizeRedraw, true); // Delegate to base class to autopopulate the root node // and kick off the layout process _LayoutManager::InitLayout(pRootNode); } ``` -------------------------------- ### Get File Information with SECFileSystem Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/otugTOC/File_System_Access Shows how to retrieve various attributes and status information about a file using methods like GetFileAttribute, GetFileStatus, GetFileModifyTime, GetFileAccessTime, and GetFileSize. The example specifically calls GetFileAttribute. ```cpp SECFileSystem fs; BOOL bRetVal = fs.GetFileAttribute("c:\\\\test.txt", bAttr); ``` -------------------------------- ### Initialize Application with FoundationEx Defaults (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/gettingstartedugTOC/FeaturePackMigrationGuid This C++ code snippet demonstrates how to initialize the Stingray Studio FoundationEx application using the SFLWinAppEx class. The `Initialize()` function sets up common application defaults. It's recommended to set registry variables before calling `Initialize()`. This method is part of the FoundationEx library, built on MFC Feature Pack. ```cpp BOOL Initialize( BOOL bInitOleLibs = TRUE, BOOL bCtrlContainer = TRUE, BOOL bRegistryKey = TRUE, BOOL bInitKeyboardMgr= TRUE, BOOL bInitMouseMgr = TRUE, BOOL bInitContextMgr = TRUE, BOOL bInitTooltipMgr = TRUE, BOOL bInitShellMgr = TRUE BOOL bRestartMgr= TRUE); // In MyApp.cpp: BEGIN_MESSAGE_MAP(MyApp, SFLWinAppEx) //... END_MESSAGE_MAP() MyApp::InitInstance() { SFLWinAppEx::InitInstance(); // Set Registry variables, if needed, before Initialize(). SFLWinAppEx::Initialize(); // Using defaults //... } ``` -------------------------------- ### Create SECShortcutBar Instance Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/otugTOC/Using_SECShortcutBar Demonstrates how to instantiate an SECShortcutBar object and create its window within a parent class. This is the initial step to incorporate the shortcut bar into an application. It requires a parent window and specifies creation styles and an identifier. ```cpp SECShortcutBar m_scBar; m_scBar.Create(this, WS_CHILD | WS_VISIBLE | SEC_OBS_VERT | SEC_OBS_ANIMATESCROLL, IDC_SHORTCUTBAR); ``` -------------------------------- ### Get Selection Line/Column Integers (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Edit/seceditcontroller__getselection_1 Retrieves the starting and ending line and column for the current selection as individual integer parameters. This overload provides direct access to the coordinates, useful for custom processing. It returns non-zero if text is selected. ```cpp void GetSelection(int& nStartLine, int& nStartCol, int& nEndLine, int& nEndCol) const; ``` -------------------------------- ### Initialize Objective Grid Library in MFC Application Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/ogugTOC/1stGrid___Step_1_ This code demonstrates the essential step of initializing the Objective Grid library by calling 'GXInit()' within the `InitInstance()` function of your MFC application. This ensures that the grid library is properly set up before any other Objective Grid functions are called. ```cpp // This call will initialize the grid library GXInit(); ``` -------------------------------- ### Define _GXDLL for Objective Grid Extension DLL Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/ogugTOC/ogug-getstart This code defines the _GXDLL preprocessor macro, which is required when using the Objective Grid Extension DLLs. This can be done either in the project's C++ compiler settings or directly in the stdafx.h file. ```cpp #define _GXDLL ``` -------------------------------- ### Recalculate Specific Columns with DelayFloatCells Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Grid/CGXGridCore_1uyb This example shows how to use DelayFloatCells to reevaluate floating cells within a specific range of columns. It's used when only certain columns need to be reevaluated. The range is defined by a starting column (nFromCol) and an ending column (nToCol). ```cpp DelayFloatCells(CGXRange().SetCols(nFromCol, nToCol)); ``` -------------------------------- ### C++ CGXGridHint Constructor and Usage Example Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Grid/CGXGridHint_47w4 Demonstrates the construction and usage of CGXGridHint for updating column widths in a grid view. The example shows how to create a hint object, populate its members with relevant data, and pass it to UpdateAllViews. It also includes the OnUpdate method of CGXGridView to show how to process such hints. ```cpp void CGXGridCore::UpdateChangedColWidths(ROWCOL nFromCol, ROWCOL nToCol, GINT* anOldWidths, UINT flags, BOOL bCreateHint) { ... if (bCreateHint && m_bHintsEnabled) { CGXGridHint hint(gxHintUpdateChangedColWidths, m_nViewID); hint.nCol1 = nFromCol; hint.nCol2 = nToCol; hint.vptr = anOldWidths; hint.flags = flags; UpdateAllViews(this, 0, &hint); } } void CGXGridView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { if (pHint == NULL || !pHint->IsKindOf(RUNTIME_CLASS(CGXGridHint))) { Invalidate(); return; } CGXGridHint &info = *((CGXGridHint*) pHint); // check view-id if (info.nViewID != -1 && info.nViewID != m_nViewID) return; switch (info.m_id) { ... case gxHintUpdateChangedColWidths: UpdateChangedColWidths( info.nCol1, info.nCol2, (GINT*) info.vptr, info.flags, FALSE ); break; ... } ``` -------------------------------- ### Defining Custom Application Hints in C++ Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Grid/CGXGridHint_66n8 Example demonstrating how to define custom hint IDs in C++ that extend the default CGXGridHint IDs. This prevents conflicts by starting custom IDs after gxLastHint. It also shows how to filter these custom hints within an OnUpdate method. ```cpp enum AppHint { AppFirstHint = gxLastHint, Angelo, Leonardo... }; void CMyGridView::OnUpdate(CView* Sender, LPARAM Hint, CObject* Obj) { if( AppFirstHint <= Hint && Hint <= AppLastHint ) { // Handle custom application hints .... } else if( gxFirstHint <= Hint && Hint <= gxLastHint ) CGXGridView::OnUpdate(Sender, Hint, Obj); } ``` -------------------------------- ### SECMenuButton::Initialise Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Foundation/secmenubutton__initialise Initializes the SECMenuButton object with specified parameters. ```APIDOC ## SECMenuButton::Initialise ### Description Performs object initialisation for SECMenuButton. ### Method Not Applicable (This is a class method, not an HTTP endpoint) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Returns the alignment of the button (See SECBitmapButton::Alignment). #### Response Example None ### Parameters - **_lpszCaption_** (LPCTSTR) - Specifies the button control's caption. - **_hMenu_** (HMENU) - Handle to the popup menu. - **_direction_** (Direction) - Direction of the arrow on the popup menu. - **_nIDBmp_** (UINT &) - The arrow bitmap id that will be used. ### See Also SECMenuButton ``` -------------------------------- ### Example: Trace Tracking Start Message in C++ Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Grid/CGXGridCore_6n6v This C++ code snippet demonstrates how to override the OnStartTracking method to display a message when a user begins tracking row or column sizes. It uses MFC's TRACE for debugging output and updates the status bar. ```cpp BOOL CDerGridView::OnStartTracking(WORD nRow, WORD nCol, WORD nTrackingMode) { String2 sMessage; Message.LoadString(IDS_TRACKING_START); ((CMainFrame *) (AfxGetApp( )->m_pMainWnd)->SetStatusText(sMessage); TRACE("User starts Tracking"); return CGridView::OnStartTracking(nRow, nCol, nTrackingMode); } ``` -------------------------------- ### Setting Up Splitter Layout with C++ Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/sflug/Splitter_Layout Demonstrates how to initialize and configure a splitter layout in C++. It includes setting the drawing style, splitter flags for real-time dragging, and adding child nodes with specific pane arrangements. ```cpp pRootNode = CreateLayoutNode(__uuidof(CSplitterLayout)); ISplitter* pSplitter = guid_cast< ISplitter*>(pRootNode); // Use the Flat splitter style, and real time drag pSplitter->SetDrawingStyle(foundation::DrawFlat); pSplitter->SetSplitterFlags(SplitterRealtimeDrag); ILayoutNode* pNode; pNode = CreateLayoutNode(__uuidof(CWindowLayoutNode)); pNode->Init(m_hWnd, GetDlgItem(IDC_LABEL)); pSplitter->AddPane(pNode, 0, 0); // Span the list in one column, two rows pNode = CreateLayoutNode(__uuidof(CWindowLayoutNode)); pNode->Init(m_hWnd, GetDlgItem(IDC_LIST)); pSplitter->AddPane(pNode, 0, 1, 2, 1); pNode = CreateLayoutNode(__uuidof(CWindowLayoutNode)); pNode->Init(m_hWnd, GetDlgItem(IDC_NAME)); pSplitter->AddPane(pNode, 0, 2); pNode = CreateLayoutNode(__uuidof(CWindowLayoutNode)); pNode->Init(m_hWnd, GetDlgItem(IDOK)); pSplitter->AddPane(pNode, 1, 0); pNode = CreateLayoutNode(__uuidof(CWindowLayoutNode)); pNode->Init(m_hWnd, GetDlgItem(IDCANCEL)); pSplitter->AddPane(pNode, 1, 2); ``` -------------------------------- ### CGXFormula: Parse and Evaluate Expression (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Grid/CGXFormula_3d9d Demonstrates parsing a formula string into a CGXFormula object and then evaluating that object to get a result. This example requires including the 'gxall.h' header and utilizes CGXFormulaSheet::ParseExpression and CGXFormulaSheet::EvaluateExpression. It handles potential errors during parsing or evaluation. ```cpp CGXFormula fm; CString s; if (ParseExpression(_T("=sin(1)"), fm) && EvaluateExpression(s, fm)) { TRACE(_T("sin(1) = %s"), s); } else { GetError(s); TRACE(_T("sin(1): Error - %s"), s); } ``` -------------------------------- ### Initialize Grid with Data and Formulas (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_HTML_User_Guide/ogugTOC/Formula_Engine Demonstrates the initialization of a grid view in C++ using Objective Grid. It includes enabling the formula engine, setting grid dimensions, inserting numeric and string data, and defining various string manipulation formulas using SetExpressionRowCol. This snippet highlights the capabilities of the formula engine for handling data and formulas. ```cpp void CGridSampleView::OnInitialUpdate() { EnableFormulaEngine(); BOOL bNew = ConnectParam(); // Create all objects and link them to the grid CMyGridView::OnInitialUpdate(); // ... and now you can execute commands on the grid if (bNew) { EnableHints(FALSE); // Lock any drawing BOOL bOld = LockUpdate(); // initialize the grid data // disable Undo mechanism for the following commands GetParam()->EnableUndo(FALSE); // no iteration for circular references GetSheetContext()->SetIterationLimit(0); // automatic/manual recalculation GetSheetContext()->SetRecalcMode(GX_RECALC_AUTO); // reevaluate cells on demand GetSheetContext()->SetRecalcMethod(GX_RECALC_AS_NEEDED); // turn off constraint checks GetSheetContext()->SetConstraintCheck(FALSE); // Initialize grid with 1000 rows and 40 columns SetRowCount(1000); SetColCount(40); // Insert an array with numeric data ROWCOL nRow, nCol; double d = 0.0; for (nRow = 7; nRow <= 12; nRow++) { d *= 2.0; for (nCol = 1; nCol <= 4; nCol++) { d += 1.0; SetStyleRange(CGXRange(nRow, nCol), CGXStyle() .SetValue(d) .SetHorizontalAlignment(DT_RIGHT) ); } } // Some string data SetValueRange(CGXRange(7, 6), _T("Hello ")); SetValueRange(CGXRange(7, 7), _T("world ")); SetValueRange(CGXRange(8, 6), _T("Stingray ")); SetValueRange(CGXRange(8, 7), _T("Software ")); SetValueRange(CGXRange(9, 6), _T("Objective ")); SetValueRange(CGXRange(9, 7), _T("Grid ")); nRow++; nRow++; SetStyleRange(CGXRange(nRow, 1), CGXStyle() .SetValue(_T("String Functions")) .SetEnabled(FALSE) .SetFont(CGXFont().SetBold(TRUE)) ); nRow++; SetExpressionRowCol(nRow, 1, _T("STRCAT")); SetExpressionRowCol(nRow+1, 1, _T("=STRCAT(F7, G7)")); SetExpressionRowCol(nRow, 2, _T("LENGTH")); SetExpressionRowCol(nRow+1, 2, _T("=LENGTH(F7)")); SetExpressionRowCol(nRow, 3, _T("FIND")); SetExpressionRowCol(nRow+1, 3, _T("=FIND(\"l\", F7, 0)")); SetExpressionRowCol(nRow, 4, _T("MID")); SetExpressionRowCol(nRow+1, 4, _T("=MID(F9&G9, 3, 5)")); SetExpressionRowCol(nRow, 5, _T("LOWER")); SetExpressionRowCol(nRow+1, 5, _T("=LOWER(F9&G9)")); SetExpressionRowCol(nRow, 6, _T("REPEAT")); SetExpressionRowCol(nRow+1, 6, _T("=REPEAT(\"=\", 10)")); ... } ... } ``` -------------------------------- ### Get Selected Column Ranges into two arrays (C++) Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Grid/CGXGridCore_4i5v This C++ function retrieves selected columns by range, storing the starting column of each range in _awLeft_ and the ending column in _awRight_. It can optionally include columns with partially selected cells. The function returns TRUE if any columns were selected. ```cpp CRowColArray awLeft, awRight; if (GetSelectedCols(awLeft, awRight)) { for (ROWCOL n = 0; n < awLeft.GetCount( ); n++) { TRACE("Column %ld to %ld is selected\n", awLeft[n], awRight[n]); } } ``` -------------------------------- ### Initialize SECAFloatDocTemplate in CWinApp Source: https://help.perforce.com/stingray/current/stingray_doc/Content/Stingray_Studio_API_Documentation/Toolkit/secafloatdoctemplate_1 Demonstrates the typical initialization of SECAFloatDocTemplate within a CWinApp's InitInstance method. This involves creating a new instance of SECAFloatDocTemplate with specified resource IDs and runtime classes, and then adding it to the application's document templates. This setup enables support for scriptable frame creation. ```cpp SECAFloatDocTemplate* pFloatDocTempl = new SECAFloatDocTemplate(IDR_TOPLEVEL, RUNTIME_CLASS(SECScriptHostDoc), RUNTIME_CLASS(SECADlgFrame), RUNTIME_CLASS(SECScriptHostView)); AddDocTemplate(pFloatDocTempl); ```