These questions uses a reduced, self-contained example that'll appear way below as point of reference. Just copy it to \fwh\samples and compile and run it from there.
So here's the question:
1. When I click on File -> Edit, the dialogue box appear but the second RTF control (oEdit) doesn't appear. Why and how to solve this?
2. If user run this program and selects File -> Exit, the program terminates normally. However, if user runs File -> Edit prior to that, this error message appears:
Same question, why and how to solve it?
TIA
p.s. I think this post is basically asking the same issue.
- Code: Select all Expand view
#include "FiveWin.ch"
#include "richedit.ch"
static oWnd, oRtf, cRtf, oEdit, cVar
function main()
local o
local hDll := LoadLibrary( "Riched20.dll" )
define window oWnd menu oMenu() color "w/b"
cRtf := memoread("fiveodbc.rtf")
@ 10, 20 RICHEDIT oRtf VAR cRtf of oWnd
oRtf:setReadOnly(.t.)
activate window oWnd ;
on init adjustRtf() ;
maximized
freeLibrary(hDll)
return nil
//----------------------------------------------------------------------
function adjustRtf()
// position at lower-half and make full use of screen width
local nTop, nLeft, nHorRes, aRect, nHeight, nWidth
nTop := 600
nLeft := 10
nHorRes := GetSysMetrics( 0 )
aRect := GetClientRect(oWnd:hWnd)
nHeight := aRect[3] - nTop - 10
nWidth := aRect[4] - aRect[2] - 20
oRtf:move(nTop, nLeft, nWidth, nHeight , .t. )
return nil
//----------------------------------------------------------------------
function oMenu()
LOCAL oMenu
MENU oMenu 2007
MENUITEM "&File "
MENU
MENUITEM "Edit" ACTION edit()
MENUITEM "E&xit" ACTION oWnd:end()
ENDMENU
ENDMENU
RETURN oMenu
//----------------------------------------------------------------------
function edit()
local aRect := GetCoors(oRtf:hWnd)
local oDlg
DEFINE DIALOG oDlg of oWnd ;
FROM aRect[1]-33, aRect[2]-10 TO aRect[3]+33+10, aRect[4]+10 ;
STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_VISIBLE) ;
PIXEL
cVar := cRtf
@ aRect[1], aRect[2] RICHEDIT oEdit VAR cVar of oDlg ;
SIZE oRtf:nWidth, oRtf:nHeight ;
PIXEL
ACTIVATE DIALOG oDlg ;
on init ( ;
RtfBar(oDlg) ;
)
return nil
//----------------------------------------------------------------------
function rtfBar(oDlg)
local oBar, oBtns := array(10)
DEFINE BUTTONBAR oBar OF oDlg SIZE 30,33 3DLOOK 2007
DEFINE BUTTON oBtns[1] FILE "..\bitmaps\save.bmp" OF oBar ;
ACTION (oRtf:setText(cVar), oDlg:end() ) ;
TOOLTIP "Save"
return nil