Is there an easier way to do this?
Well I know I'm going to have to fill in the OPENFILENAME structure regardless, but is there an easier way to do this part?
Invoke GetOpenFileName, Addr ofn
Invoke DoEvents
.If Eax == TRUE
invoke CreateFile,ADDR buffer,\
GENERIC_READ or GENERIC_WRITE ,\
FILE_SHARE_READ or FILE_SHARE_WRITE,\
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,\
NULL
mov hFile,eax
invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT,MEMSIZE
mov hMemory,eax
invoke GlobalLock,hMemory
mov pMemory,eax
invoke ReadFile,hFile,pMemory,MEMSIZE-1,ADDR SizeReadWrite,NULL
invoke SendMessage,hwndEdit,WM_SETTEXT,NULL,pMemory
invoke CloseHandle,hFile
invoke GlobalUnlock,pMemory
invoke GlobalFree,hMemory
increase the size (to have a final zero, and to apply your string functions directly to the file in memory),
use HeapAlloc instead of GlobalAlloc (no need to lock/unlock),
keep the memory area, to make your modifications on it (just don't forget to free the memory area at the end of your program with HeapFree).
Invoke GetOpenFileName, Addr ofn
Invoke DoEvents
.If Eax == TRUE
invoke GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,MEMSIZE
mov pMemory,eax
invoke CreateFile,ADDR buffer,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL
mov hFile,eax
invoke ReadFile,hFile,pMemory,MEMSIZE-1,ADDR SizeReadWrite,NULL
invoke CloseHandle,hFile
invoke SendMessage,hwndEdit,WM_SETTEXT,NULL,pMemory
invoke GlobalFree,pMemory
.ENDIF
Icezlion has a nice tutortial, with beautifully written/easy to read code to make a editor.
http://win32assembly.online.fr/tutorials.html
tut 33-35
For your inspiration, here is a 6k rich text editor with essential features (F1 help, find & replace, bold, red, blue highlighting, one-key assembly etc). Source included.
EDIT: Tiny fix - name of current document now in window title
[attachment deleted by admin]
very cool Jochen :U
Quote from: dedndave on July 27, 2009, 03:42:58 PM
very cool Jochen :U
Thanks. I have been fighting for every single byte to get it down to 6,144 bytes :bg
Thanks a BUNCH you guys are awesome!
The reason I'm looking to do all this was so I can make video tutorials on how to do it. I've made three so far on msgbox, editable msgbox, and a calculator. The next step is a notepad, but I needed simpler code than what I had because otherwise it'd take like 5 videos to explain it. I knew there had to be an easier way so I asked here :).
Thanks again