I try to implement new methods to the RichEdit Class by just me.
I've succeeded for some but don't succeed with EM_GETTABLEPARMS and EM_INSERTTABLE (used to get a table's parameters or Insert a new table)
Both messages returns -2147024809 which i believe is E_INVALIDARG.
If someone could try to explain why this returns an error that would be fantastic !
(I've asked just me but I guess this is quite a standard issue so anyone could help)
I've put every documentation in the code below.
I've tried to do everything according to documentation and even a post of a guy on MSDN said was working.
I've tried some variations but couldn't make it work, always the same ErrorLevel
You can try the following code with the sample contained in the Class from just me
https://github.com/AHK-just-me/Class_Ri ... master.zip
Code: Select all
RN_GetorSetTableParams:
EM_GETTABLEPARMS := 0x400 + 265
EM_INSERTTABLE := 0x400 + 232
; EM_SETTABLEPARMS := 0x400 + 307
;*****************************
; EM_GETTABLEPARMS := 0x509
; Returns S_OK if successful
; https://msdn.microsoft.com/en-us/library/windows/desktop/Hh768371(v=vs.85).aspx
; A pointer to a TABLEROWPARMS structure.
; A pointer to a TABLECELLPARMS structure.
; Retrieves the table parameters for a table row and the cell parameters for the specified number of cells.
;*****************************
; "E_INVALIDARG" SAYS:
; The wParam or lParam is NULL or points to an invalid structure. The cbRow member of the TABLEROWPARMS structure must equal sizeof(TABLEROWPARMS) or sizeof(TABLEROWPARMS) – 2*sizeof(long). The latter value is the size of the RichEdit 4.1 TABLEROWPARMS structure. The cbCell member of the TABLEROWPARMS structure must equal sizeof(TABLECELLPARMS).
;*****************************
;*****************************
;CONVERSION SCHEME USED
;MSDN=AHK=BYTES
;*****************************
; LONG=INT=4
; WORD=UShort=2
; DWORD=Uint=4
; SHORT=Short=2
; COLORREF=UInt=4
; BYTE=UChar=1
;*****************************
VarSetCapacity(TABLEROWPARMS,4+3*4+6*4+4+2,0)
;*****************************
; TABLEROWPARMS structure
; https://msdn.microsoft.com/en-us/library/windows/desktop/hh768761(v=vs.85).aspx
; typedef struct _tableRowParms {
; BYTE cbRow;
; BYTE cbCell;
; BYTE cCell;
; BYTE cRow;
; LONG dxCellMargin;
; LONG dxIndent;
; LONG dyHeight;
; DWORD nAlignment:3;
; DWORD fRTL:1;
; DWORD fKeep:1;
; DWORD fKeepFollow:1;
; DWORD fWrap:1;
; DWORD fIdentCells:1;
;ARE WE SUPPOSED TO INIT MEMBERS TO THE MENTIONED VALUE ?
; NumPut(3,TABLECELLPARMS,4+3*4,"Uint")
; NumPut(1,TABLECELLPARMS,4+3*4+4,"Uint")
; NumPut(1,TABLECELLPARMS,4+3*4+4*2,"Uint")
; NumPut(1,TABLECELLPARMS,4+3*4+4*3,"Uint")
; NumPut(1,TABLECELLPARMS,4+3*4+4*4,"Uint")
; NumPut(1,TABLECELLPARMS,4+3*4+4*5,"Uint")
; LONG cpStartRow;
; BYTE bTableLevel;
; BYTE iCell;
; } TABLEROWPARMS;
;NOTE:
; bTableLevel
; The table nesting level (EM_GETTABLEPARMS only).
; *****************************
VarSetCapacity(TABLECELLPARMS,4+7*2+4*2+6*4,0)
;*****************************
; TABLECELLPARMS structure
; https://msdn.microsoft.com/en-us/library/windows/desktop/hh768760(v=vs.85).aspx
; typedef struct _tableCellParms {
; LONG dxWidth;
; WORD nVertAlign:2;
; WORD fMergeTop:1;
; WORD fMergePrev:1;
; WORD fVertical:1;
; WORD fMergeStart:1;
; WORD fMergeCont:1;
;ARE WE SUPPOSED TO INIT MEMBERS TO THE MENTIONED VALUE ?
; NumPut(2,TABLECELLPARMS,4,"UShort")
; NumPut(1,TABLECELLPARMS,4+2,"UShort")
; NumPut(1,TABLECELLPARMS,4+2*2,"UShort")
; NumPut(1,TABLECELLPARMS,4+2*3,"UShort")
; NumPut(1,TABLECELLPARMS,4+2*4,"UShort")
; NumPut(1,TABLECELLPARMS,4+2*5,"UShort")
; WORD wShading;
; SHORT dxBrdrLeft;
; SHORT dyBrdrTop;
; SHORT dxBrdrRight;
; SHORT dyBrdrBottom;
; COLORREF crBrdrLeft;
; COLORREF crBrdrTop;
; COLORREF crBrdrRight;
; COLORREF crBrdrBottom;
; COLORREF crBackPat;
; COLORREF crForePat;
; } TABLECELLPARMS;
; }
;*****************************
; Try EM_INSERTTABLE based on "David Kinder" comment in MSDN
; https://blogs.msdn.microsoft.com/murrays/2008/09/15/richedits-nested-table-facility/
;*****************************
;put -1 in cpStartRow to start at selection (added by me)
NumPut(-1,TABLEROWPARMS,4+3*4+6*4,"INT")
;----
;cCell
NumPut(3,TABLEROWPARMS,2,"UChar")
;cRow
NumPut(2,TABLEROWPARMS,3,"UChar")
;dxCellMargin
NumPut(50,TABLEROWPARMS,4,"Int")
;dyHeight
NumPut(400,TABLEROWPARMS,4+4*2,"Int")
;nAlignment
NumPut(1,TABLEROWPARMS,4+4*3,"UInt")
;fIdentCells
NumPut(1,TABLEROWPARMS,4+4*3+4*5,"UInt")
;dxWidth
NumPut(1000,TABLECELLPARMS,0,"Int")
;dxBrdrLeft
NumPut(1,TABLECELLPARMS,4+2*7,"Short")
;dyBrdrTop
NumPut(1,TABLECELLPARMS,4+2*7+2*1,"Short")
;dxBrdrRight
NumPut(1,TABLECELLPARMS,4+2*7+2*2,"Short")
;dyBrdrBottom
NumPut(1,TABLECELLPARMS,4+2*7+2*3,"Short")
;crBackPat
NumPut(0xffffff,TABLECELLPARMS,4+2*7+2*4+4*4,"UInt")
;crForePat
NumPut(0x000000,TABLECELLPARMS,4+2*7+2*4+4*5,"UInt")
SendMessage, %EM_INSERTTABLE% , &TABLEROWPARMS, &TABLECELLPARMS,, % "ahk_id " RE2.HWND
msgbox % "ErrorLevel " ErrorLevel
;*****************************
; Try EM_GETTABLEPARMS based on standard docs
;*****************************
;put -1 in cpStartRow to start at selection
NumPut(-1,TABLEROWPARMS,4+3*4+6*4,"INT")
; set cbRow
;Should we check version of richedit (if 4.1), how?
NumPut((4+3*4+6*4+4+2)-2*4,TABLEROWPARMS,0,"UChar")
;Should we check version of richedit (if >4.1), how?
; NumPut((4+3*4+6*4+4+2),TABLEROWPARMS,0,"UChar")
; set cbCell
NumPut(4+7*2+4*2+6*4,TABLEROWPARMS,1,"UChar")
; set bTableLevel? (see NOTE above) tried it but no changes
; NumPut(1,TABLEROWPARMS,4+3*4+6*4+4+1,"UChar")
SendMessage, %EM_GETTABLEPARMS% , &TABLEROWPARMS, &TABLECELLPARMS,, % "ahk_id " RE2.HWND
msgbox % "ErrorLevel " ErrorLevel
; SHOWS 2147024809 WHICH I BELIEVE IS E_INVALIDARG
msgbox % "ccell " NumGet(TABLEROWPARMS,2,"UChar")
msgbox % "crow " NumGet(TABLEROWPARMS,3,"UChar")
return