FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Tables in RichEdit5
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Tables in RichEdit5
Posted: Sun Jul 16, 2023 02:51 PM

Hi,

In RichEdit5, open an RTF file. There are tables in this file. How can I access the cells of these tables ?

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Tables in RichEdit5
Posted: Mon Jul 17, 2023 05:43 AM
Dear Yuri,

Have a look at this code:
Code (fw): Select all Collapse
// Assuming you have a handle to the Rich Edit control
// in the variable `hRichEdit`.

// Get the number of tables in the document.
int tableCount = SendMessage(hRichEdit, EM_GETTABLECOUNT, 0, 0);

// Iterate through the tables.
for (int i = 0; i < tableCount; i++) {
    // Select the current table.
    SendMessage(hRichEdit, EM_SETSEL, 0, MAKELONG(i, i));

    // Get the table properties.
    TABLESELINFO tsi;
    SendMessage(hRichEdit, EM_GETTABLESEL, 0, (LPARAM)&tsi);

    // Extract the table structure information.
    int numRows = tsi.cRows;
    int numCols = tsi.cCols;

    // Iterate through the rows and columns of the table.
    for (int row = 0; row < numRows; row++) {
        for (int col = 0; col < numCols; col++) {
            // Access the cell at the current row and column.
            CELLINFO ci;
            ci.cbSize = sizeof(ci);
            ci.row = row;
            ci.col = col;
            SendMessage(hRichEdit, EM_GETCELLINFO, 0, (LPARAM)&ci);

            // Process the cell's information as needed.
            // The ci contains information such as cell's text, formatting, etc.
            // For example:
            wchar_t cellText[256];
            SendMessage(hRichEdit, EM_GETTEXTRANGE, ci.cpStart, ci.cpEnd, (LPARAM)cellText);
            // Process the cell text...

            // You can also modify the cell content if desired:
            // SendMessage(hRichEdit, EM_SETSEL, ci.cpStart, ci.cpEnd);
            // SendMessage(hRichEdit, EM_REPLACESEL, TRUE, (LPARAM)L"New Text");
        }
    }
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Tables in RichEdit5
Posted: Mon Jul 17, 2023 10:05 AM

Antonio, thanks for the example!

  1. What is a hRichedit handle, because we are working with a TRichEdit5 object ?

  2. Is there any guide for working with RichEdit5 ?

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Tables in RichEdit5
Posted: Mon Jul 17, 2023 11:46 AM
Dear Yuri,

oRichEdit:hWnd is hRichEdit

We need to adapt that code to FWH. We are going to try it... :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Tables in RichEdit5
Posted: Mon Jul 17, 2023 11:51 AM

I understood.

Continue the discussion