Examples |
[Top] [Chapter] [Previous] [Next] |
Here we show how to access the embedded editor. The variable edhwnd is the window handle of the editor. It is returned by the method fkt_wptextCreateDialog. Please see Initialization of the editor in C++
Load the file c:\test.rtf into the editor. We use the command WPDLL_COM_TEXT_LOADFILE (See c++ header)
SendMessage(edhwnd, 1042, WPDLL_COM_TEXT_LOADFILE,(int)((char *)"c:\\TEST.RTF"));
Select the language for the toolbar and dialogs:
SendMessage(edhwnd, 1042, WPSYS_SETLANGUAGE , (int)((char *)"DE")); // Select DE = German
Switch the tooltips on
SendMessage(edhwnd, WMP_EDCOMMAND, WPSYS_SETSHOWHINT, 1);
Set the initial text and image directory
SendMessage(edhwnd, 1042, WPDLL_COM_INITIALDIR, (int)((char *)"c:\\temp")); SendMessage(edhwnd, 1042, WPDLL_COM_INITIALGRAPHICDIR, (int)((char *)"c:\\temp"));
Retrieve and display the current directory
SendMessage(edhwnd, 1042, WPDLL_COM_INITIALDIR, 0); int len; char *p; len = SendMessage(edhwnd,1042,WPDLL_DATA_GETSTRING, 0); p = (char *)malloc(len); SendMessage(edhwnd,1042,WPDLL_DATA_GETSTRING, (int)p); MessageBoxA(0, p, "", 0); free(p, len);
Show the file open dialog and display the file name of the loaded file in the caption
// Load file SendMessage(edhwnd, 1051, (int)((char *)"diaOpen"), 0); // Display file name SendMessage(edhwnd, 1042, WPDLL_COM_LASTFILENAME, 0); int len; char buf[256]; len = SendMessage(edhwnd,1042,WPDLL_DATA_GETSTRINGW, 0); if(len<256) { SendMessage(edhwnd,1042,WPDLL_DATA_GETSTRINGW, (int)buf); SendMessage(hWnd, WM_SETTEXT, 0, (int)&buf[0] ); }
Initialize the editor to use a page size of DinA 4 with margins of 1.5 cm:
SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGE_WIDTH, (int)(21/2.54*1440)); // 21cm converted in twips SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGE_HEIGHT, (int)(29.7/2.54*1440)); // 29.7cm converted in twips int margin = (int)(1.5/2.54*1440); // 1.5cm converted in twips SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGE_LEFT_MARGIN, margin); SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGE_TOP_MARGIN, margin); SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGE_RIGHT_MARGIN, margin); SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGE_BOTTOM_MARGIN, margin);
Display the non-printable area (0.5 cm on all sides). Please see Memo.TextCommand(24) for other draw modes.
//Display frames to show not printable area SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGE_DRAW_MODE, 4); // Draw the frames SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGE_LINE_MODE, 2); // Draw lines int offset = (int)(0.5/2.54*1440); // 1.5cm converted in twips SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGE_LINEOFFSET_LEFT, offset); SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGE_LINEOFFSET_TOP, offset); SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGE_LINEOFFSET_RIGHT, offset); SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGE_LINEOFFSET_BOTTOM, offset);
Set a certain fixed page count. The editor should always display 8 pages. Please also see Memo.TextCommand(24).
// Fix the page count SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGES_MINCOUNT, 4); // minimum 4 pages SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGES_MAXCOUNT, 8); // maximum 8 pages
Please note, that a second editor can show the same text with a different count of pages. For example the thumbnail view will display less then 4 pages unless You use the code:
SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED2_PAGES_MINCOUNT, 4); // minimum 4 pages SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED2_PAGES_MAXCOUNT, 8); // maximum 8 pages
It is also possible to force the page count to be dividable by 4:
SendMessage(edhwnd, WMP_SETIPROP, WIPR_ED1_PAGES_MULTIPLICATOR, 4);
|