I am trying to put the richedit control in an mdi window. But when i open a file only the fisrt few characters in the first line appear with no proper formatting and also the title of the window has the same words. How to get throught this? Here is my code -
;This is WndProc
.ELSEIF ax==CM_OPEN
invoke RtlZeroMemory ,addr ofn,sizeof ofn
mov ofn.lStructSize,sizeof ofn
push hWnd
pop ofn.hwndOwner
push hInstance
pop ofn.hInstance
mov ofn.lpstrFilter,offset OpenFilter
mov ofn.lpstrFile,offset FileNameBuffer
mov byte ptr ,0
mov ofn.nMaxFile ,sizeof FileNameBuffer
mov ofn.Flags, OFN_FILEMUSTEXIST or OFN_HIDEREADONLY or OFN_PATHMUSTEXIST
invoke GetOpenFileName,addr ofn
.if EAX!=0
invoke CreateFile,offset FileNameBuffer,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
.if eax!=INVALID_HANDLE_VALUE
mov hwndFile,eax
invoke CreateMDIWindow,addr RichEditClass,addr FileNameBuffer,WS_MAXIMIZE,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,\
hWndClient,hInstance,NULL
mov hRichEdit,eax
invoke SendMessage,hRichEdit,EM_LIMITTEXT,-1,0
push hwndFile
pop editstream.dwCookie
mov editstream.pfnCallback,offset StreamInProc
invoke SendMessage,hRichEdit,EM_STREAMIN,SF_TEXT,addr editstream
invoke CloseHandle,hwndFile
.else
invoke MessageBox,hWnd,addr OpenFileFail,addr AppName,MB_OK or MB_ICONERROR
.endif
.endif
;The child proc only has a handler to WM_CLOSE msg.
I have a MDI program that uses RichEdit controls on my Web Site at:
http://www20.brinkster.com/ewayne/AsmLoad.html
that you might want to look at, it would be a lot easier for you then digging through
your program .
Ewayne
Well here is my code for creating a new file but when i clik on the "new" menu item nothing happens.
.data
RichEditClass db "RichEdit20A",0
MDIChildClass db "MDIChildClass",0
MDIChildTitle db "MDI Child",0
.data?
hInstance dd ?
hWndClient dd ?
mdicreate MDICREATESTRUCT <>
.code
.ELSEIF ax==CM_NEW
; invoke CreateMDIWindow, addr MDIChildClass,addr MDIChildTitle,0,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,hWndClient,hInstance,NULL
;mov hWndChild,eax
INVOKE SendMessage, hWndClient, WM_MDICREATE, 0, addr mdicreate
mov hWndChild, eax
INVOKE CreateWindowEx, 0,addr RichEditClass,0,WS_CHILD or WS_VISIBLE or WS_BORDER or WS_HSCROLL or WS_VSCROLL or ES_MULTILINE or ES_NOHIDESEL, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,\
hWndChild,NULL,hInstance,NULL
.endif
Also cant CreateMDIWindow be used instead of MDICREATESTRUCT to make the application multithreaded?
Did you register your MDIChildClass?
Did you fill in your MDICREATESTRUCT structure?
Like I said it would be easer to look at my code, it should be easy to follow.
Ewayne
i have done all that.
why dont u take a look at the source from this link http://www.geocities.com/moving_fulcrum/mdi.zip
Its very small. Just the new file proc till now but the source is in several files cause i dont like cluttering up in one. Just open main.asm to get to the proc
Also in ur prog too when u clik on the new butt on the toolbar nothing happens. Though ur prog works fine from the menu.
When I get a minute I'll look at your program.
The New on the Toolbar only clears the active window, thats the way it was
meant to be.
Ewayne
You missed your Client window.
vars.asm
;--------------- ADDED -------------
MDIClientClass db 'MDICLIENT',0
create.asm
;--------------- ADDED -------------
INVOKE CreateWindowEx, NULL, addr MDIClientClass, NULL,\
WS_CHILD or WS_VISIBLE or WS_CLIPCHILDREN, CW_USEDEFAULT,\
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hWnd, NULL,\
hInst, addr ClientStruct
mov hWndClient, eax
;---------- ----------
.
.
size.asm
;--------------- ADDED -------------
INVOKE GetWindowRect, hWndStat, addr rect
mov eax, rect.bottom
sub eax, rect.top ; eax = height of statusbar
mov edx, lParam ; Width of new client area
and edx, 0ffffh ; ebx = width
mov ecx, lParam
shr ecx, 16 ; Height of new client area
sub ecx, eax ; Edit window - height of statusbar
add ecx, 2 ; For border
INVOKE MoveWindow, hWndClient, 0, 0, edx, ecx, TRUE
EwayneThankx a lot ewayne. That did work. I think that was a really silly mistake of mine. From the next time i would be careful about cheking my source code before i post my problems on this board :-)