XPost: alt.windows7.general
Newyana2,
| In my case I describe a dialog in a resource file, and than load
| that resource using "call DialogBoxParamA,0, IDC_DIALOG,0,offset
| DialogCB,0"
I've never used that. I use GetOpenFileName, to
give me a system file-open window with all the fixings.
Were talking about two very different things here : you're talking about the dialog which allows you to select a file to be opened, I on the other hand
was describing how I create a programs window with all the controls on it.
I could use that "GetOpenFileName" dialog to select the file to load into my programs RichEdit control, but I normally pass the filename as a commandline argument. Like when you click a datafile and the associated program gets executed, which than "automatically" opens the datafile.
That might be good. I'm having trouble following.
I thought you said the problem was with loading a file,
I can't remember I did. I did however mention that I loaded an RTF file
into a RichEdit control - as a base to test against.
My whole-and-only problem consists manipulating the position of the current "view", using those EM_GETSCROLLPOS and EM_SETSCROLLPOS messages. The rest
is just fluff to be able to see what happens.
Here are the two files (.RC and .ASM). I've removed any-and-everything not related to the problem.
Regards,
Rudy Wieser
.RC (resource) file :
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
#include "RichEd20.rci"
;================================================
#define IDD_BASEWIN 1000
#define IDC_EXECUTE 1002
#define IDC_RICHEDIT 1003
IDD_BASEWIN DIALOG DISCARDABLE 300, 0, 450, 200
;-- Create a sizable window
STYLE DS_3DLOOK | WS_THICKFRAME | WS_SYSMENU | WS_MAXIMIZEBOX |
WS_MINIMIZEBOX ;| DS_CENTER
CAPTION "RICHED20 20220411"
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "",IDC_RICHEDIT,"RichEdit20A"
,WS_TABSTOP | WS_BORDER ; | ES_SAVESEL | ES_NOHIDESEL
| ES_MULTILINE | WS_VSCROLL ; | ES_WANTRETURN
,5,5,445,175
PUSHBUTTON "&Execute",IDC_EXECUTE,5,185,50,11
END
;================================================
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
The .ASM (Assembly) file :
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
;=======================
.Target equ GUI
.486
.model flat,STDCALL
stackalign
locals
;-----------------------
.nolist
INCLUDELIB KERNEL32.LIB
INCLUDE KERNEL32.INC
INCLUDELIB USER32.LIB
INCLUDE USER32.INC
INCLUDELIB RichEd20.LIB
INCLUDE RichEd20.INC
.list
;-----------------------
;-- Load the control-ID constants (IDD_xxx and IDC_xxx, extracted from the resource file)
% include @FileName.rhi
;=======================
;=======================
.CODE
;-----------------------
Start proc
;-- Initialize RichEdit component
call LoadLibraryA,offset @@TXT_RichEdDLL
;-- Create the programs window
call DialogBoxParamA,0,IDD_BASEWIN,0,offset DialogCB,0
call ExitProcess,eax
;=======================
.DATA
;-----------------------
@@TXT_RichEdDLL db 'RichEd20.dll',0
;-----------------------
Start endp
;=======================
;=======================
.CODE
;-----------------------
DialogCB proc
arg @@hWnd:DWORD,@@wMsg:DWORD,@@wParam:DWORD,@@lParam:DWORD
uses ebx,ecx,edx,esi,edi
movzx eax,word ptr [@@wMsg]
cmp eax,WM_INITDIALOG
je @@Init
cmp eax,WM_CLOSE
je @@Close
cmp eax,WM_COMMAND
je @@Command
@@DialogCB_Cont:
xor eax,eax
@@DialogCB9:
ret
;-----------------------
@@Init:
call SendDlgItemMessageA,[@@hWnd],IDC_RICHEDIT,EM_EXLIMITTEXT,0,10000000
;10M chars
call LoadDocument,[@@hWnd],IDC_RICHEDIT,offset [@@TXT_File]
jmp @@DialogCB_Cont
;-----------------------
@@Close:
call EndDialog,[@@hWnd],0
jmp @@DialogCB_Cont
;-----------------------
@@Command:
movzx eax,word ptr [@@wParam]
cmp eax,IDC_EXECUTE
je @@Execute
jmp @@DialogCB_Cont
;---------------
@@Execute:
call GetDlgItem,[@@hWnd],IDC_RICHEDIT
call Fail1Test,eax
jmp @@DialogCB_Cont
;=======================
.DATA
;-----------------------
;-- Make sure the 'TestRTF.doc' file is large enough (over 250 KByte
; on my machine), otherwise the problem won't show
@@TXT_File label byte
db 'TestRTF.doc',0
;-----------------------
DialogCB endp
;=======================
;=======================
.CODE
;-----------------------
LoadDocument PROCDESC hWnd:DWORD,lCtlID:DWORD,sFile:DWORD
; Load either an RTF or plain text document
LoadDocument proc
arg @@hWnd:DWORD,@@lCtlID:DWORD,@@sFile:DWORD
uses ebx
local @@rES:EDITSTREAM
cmp [@@lCtlID],0
je @@LoadDocument1
call GetDlgItem,[@@hWnd],[@@lCtlID]
mov [@@hWnd],eax
@@LoadDocument1:
lea ebx,[@@rES]
call RtlZeroMemory,ebx,size EDITSTREAM
mov [ebx].ES_pCallBack,offset @@LoadFileCB
;-- Needs to be set, as EM_SETTEXTMODE can cause an RTF file to
; be rejected, but EM_STREAMIN than *doesn't* set an error ..
mov [ebx].ES_lError,0FFFFFFF0h ;Needs to be given a real error code
call CreateFileA,[@@sFile],GENERIC_READ, FILE_SHARE_READ, 0 \
,OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0
mov [ebx].ES_lCookie,eax
cmp eax,INVALID_HANDLE_VALUE
je @@LoadDocument_E
;-- Try to load the file as RTF. Might fail.
call SendMessageA,[@@hWnd],EM_STREAMIN,SF_RTF,ebx
; and eax,eax ;# of chars read. Zero doesn't need to be an error ...
; jz @@LoadDocument_E1
cmp [ebx].ES_lError,0FFFFFFF0h ; -16 (no idea what this error means...)
jne @@LoadDocument2
;-- Try to load the file as plain text
call SetFilePointer,[ebx].ES_lCookie,0,0,FILE_BEGIN
call SendMessageA,[@@hWnd],EM_STREAMIN,SF_TEXT,ebx
@@LoadDocument2:
cmp [ebx].ES_lError,0 ;Any error?
jne @@LoadDocument_E1 ;Yep
call CloseHandle,[ebx].ES_lCookie
;-- OK --
clc
@@LoadDocument9:
ret
;---------------
@@LoadDocument_E1:
call CloseHandle,[ebx].ES_lCookie
@@LoadDocument_E:
;-- Error --
stc
jmp @@LoadDocument9
;-----------------------
@@LoadFileCB proc
arg @@lCookie:DWORD,@@pBufDat:DWORD,@@lBufSiz:DWORD,@@plReadCnt:DWORD
call ReadFile,[@@lCookie],[@@pBufDat],[@@lBufSiz],[@@plReadCnt],0
cmp eax,1
sbb eax,eax
ret
endp
;-----------------------
LoadDocument endp
;=======================
;=======================
.CODE
;-----------------------
Fail1Test PROCDESC hWnd:DWORD
Fail1Test proc
arg @@hWnd:DWORD
uses ebx
local @@rPnt:POINT
lea ebx,[@@rPnt]
;-- Get the current scrollpos location
call SendMessageA,[@@hWnd],EM_GETSCROLLPOS, 0, ebx
;-- go to that same location
call SendMessageA,[@@hWnd],EM_SETSCROLLPOS, 0, ebx
ret
;-----------------------
Fail1Test endp
;=======================
;=======================
end Start
ends
;-----------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)