Jump to content

Recommended Posts


This can be done quite easy:

- make AutoIt main GUI

- programatically create RichEdit control (at start)

- load prepared RTF file into RichEdit with EM_STREAMIN API --> see callback UDF in examples

Note: prepared RTF text can be compiled into AutoIt's EXE by FileInstall or by #AutoIt3Wrapper_Res_File_Add

Link to post
Share on other sites


can you maybe help me more?

i can't find "#AutoIt3Wrapper_Res_File_Add" in the help file!

or can i download it?


- works only COMPILED (because RTF source is loaded from EXE resources)

- must be compiled with latest version of Scite4AutoIt3 and reshacker.exe in Auto3Wrapper directory

- at compile time must be test.rtf in script directory

- see my post with my resource UDF here

Note: This is modified Richedit.au3 example from piccaso's DllCallBack UDF


This script has RTF file defined at compile time.

If you wish to make some Load (RTF), Save (EXE) functionality like in Text2Exe then prepare compiled EXE from this script without first line containing #AutoIt3Wrapper_Res_File_Ad


Then Save (EXE) will do just adding RTF file to resources of that prepared EXE by reshacker.exe -add

#AutoIt3Wrapper_Res_File_Add=test.rtf, rcdata, TEST_RTF_1 
#include <GUIConstants.au3>
#include "DllCallBack.au3"
#include "resources.au3"

Global Const $EM_STREAMIN = 0x400+73
Global Const $EM_STREAMOUT = 0x400+74
Global Const $SF_RTF = 2

Global $EDITSTREAM = DllStructCreate("DWORD pdwCookie;DWORD dwError;PTR pfnCallback;")
Global $hWnd_Main = GUICreate("Text2Exe", 610, 410)
Global $RTFClassName

If @OSTYPE = "WIN32_WINDOWS" Then ; 95/98/Me
    $RTFClassName = "RichEdit20A"
Else ; NT/2000/XP/2003/Vista 
    $RTFClassName = "RichEdit50W"

$hInstance = DllCall("kernel32.dll","ptr","GetModuleHandle","ptr",0)
$hInstance = $hInstance[0]
$hRichedit = DllCall("user32.dll","hwnd","CreateWindowEx", _; HWND CreateWindowEx(
                     "dword",$WS_EX_CLIENTEDGE, _           ;   DWORD dwExStyle,    // extended window style
                     "str",$RTFClassName, _                 ;   LPCTSTR lpClassName,    // pointer to registered class name 
                     "str","", _                            ;   LPCTSTR lpWindowName,    // pointer to window name
                     "dword",$dwStyle, _                    ;   DWORD dwStyle,  // window style
                     "int", 5, _                            ;   int x,  // horizontal position of window
                     "int", 5, _                            ;   int y,  // vertical position of window
                     "int", 600, _                          ;   int nWidth, // window width
                     "int", 400, _                          ;   int nHeight,    // window height
                     "hwnd", $hWnd_Main, _                  ;   HWND hWndParent,    // handle to parent or owner window
                     "ptr", 0, _                            ;   HMENU hMenu,    // handle to menu or child-window identifier
                     "ptr", $hInstance, _                   ;   HANDLE hInstance,   // handle to application instance
                     "ptr",0 _                              ;   LPVOID lpParam  // pointer to window-creation data
                     )                                      ; );
$hRichedit = $hRichedit[0]
$pEditStreamCallback = _DllCallBack("_EditStreamCallback","ptr;ptr;long;ptr")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

Func _EditStreamCallback($pdwCookie,$pbBuff,$cb,$pcb)
   Local $szRTF = DllStructCreate("char[" & $cb & "]",$pbBuff)
      Local $sRTF = _ResourceGetAsString("TEST_RTF_1") ; get RTF text from resource
      Local $_pcb = DllStructCreate("long",$pcb)
   Return 0




Edited by Zedna
Link to post
Share on other sites

and thats why i dont use RTF, too much code... also i've never had a prgm that requires rtf over and edit control....

Nice work though!!!!

Unfortunately RichText control isn't natively supported by AutoIt.

Gary started RichEdit UDF and I want to help him with that but I haven't so much time.

With such RichEdit UDF it could be only a few lines of code.

Edited by Zedna
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...