Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
4/8/2010
To convert RichInk data into RTF
You can convert RichInk data that contains embedded drawings, bitmaps, or sound recordings, into Rich Text Format using a RichInk control.
-
Instantiate a RichInkwindow using the richink.dll library found in the your desktop computer's ActiveSync folder.
-
Instantiate a COOKIEstructure (e.g., named "Cookie"), and an EDITSTREAMstructure (e.g., named "es").
Copy Code // Create a handle to the.pwi file. Cookie.hFile = hSrc; es.dwCookie = (DWORD)&Cookie; es.dwError = 0; es.pfnCallback = ReadCallback;
-
Call EM_STREAMINon the ink window, with the read callback (see below) sourcing the data.
Copy Code // Load richink with the *.PWI file. SendMessage (hwndInk, EM_STREAMIN, SF_UNKNOWN, (LPARAM)&es);
-
Convert the data to RTF.
Copy Code // Create a handle to the output *.RTF file. Cookie.hFile = hDst; // Zero-out the cookie. es.dwCookie = (DWORD)&Cookie; es.dwError = 0; es.pfnCallback = WriteCallback; SendMessage (hwndInk, EM_STREAMOUT, SF_RTF, (LPARAM)&es);
Code Example
The following code example demonstrates the ReadCallback function.
Copy Code | |
---|---|
DWORD CALLBACK ReadCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { PCOOKIE pCookie = (PCOOKIE)dwCookie; *pcb = 0; if (ReadFile(pCookie->hFile, pbBuff, cb, pcb, 0) == 0) return (pCookie->dwError = GetLastError()); return 0; } |
Code Example
The following code example demonstrates the WriteCallback function.
Copy Code | |
---|---|
DWORD CALLBACK WriteCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { PCOOKIE pCookie = (PCOOKIE)dwCookie; if (WriteFile(pCookie->hFile, pbBuff, cb, pcb, 0) == 0) return (pCookie->dwError = GetLastError()); return 0; } |