Page 1 of 1

Problem with Preview from trichedit RESOLVED

PostPosted: Tue Apr 26, 2016 11:37 am
by Silvio.Falconi
Dear Antonio, on my class mypad I use two methods to return me the active window child and the richedit control

Code: Select all  Expand view
METHOD WndActive() INLINE ( ::oWndMain:oWndActive != NIL )

and
Code: Select all  Expand view
METHOD WndChild() CLASS TMYPAD

   LOCAL oWnd

   #ifndef __XPP__
      oWnd := ::oWndMain:oWndActive:oControl
   #else
      oWnd := ::oWndMain:oWndActive:TMdiChild:oControl
   #endif

RETURN oWnd



when I show the preview of the window child ( ::WndChild():preview() )
I use this button from bar

DEFINE BUTTON RESOURCE "RTFPreview" OF ::oBar1 ;
MESSAGE "Displays full pages" ;
TOOLTIP "Print Preview" NOBORDER ;
WHEN ( ::WndActive() .and. ::WndChild():Len() > 0 ) ;
ACTION ::WndChild():Preview( ::oWndMain )

it make error

Application
===========
Path and name: F:\VERSIONI_RTFPAD\FivePad\FivePad.Exe (32 bits)
Size: 3,452,416 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603)
FiveWin Version: FWHX 16.03
Windows version: 6.1, Build 7600

Time from start: 0 hours 0 mins 8 secs
Error occurred at: 26/04/16, 13:20:36
Error description: Error BASE/1004 Class: 'NIL' has no exported method: LEN
Args:
[ 1] = U

Stack Calls
===========
Called from: => LEN( 0 )
Called from: Source\TFivePad.prg => (b)TFIVEPAD:SETBAR( 960 )


on cuurent trichedit I saw this method METHOD Len() INLINE RELen( ::hWnd )

I think make error because the function ::WndChild() return the ocontrol on tmdiclild and when I open the rpreview window it found many controls into
how I can resolve it ?

if I rename the command

DEFINE BUTTON RESOURCE "RTFPreview" OF ::oBar1 ;
MESSAGE "Displays full pages" ;
TOOLTIP "Print Preview" NOBORDER ;
WHEN ( ::WndActive() ) ; // .and. ::WndChild():Len() > 0 );
ACTION ::WndChild():Preview( ::oWndMain )


the rpreview is opened and then make another error

Error description: Error BASE/1004 Class: 'NIL' has no exported method: CANCUT

Code: Select all  Expand view
Application
===========
   Path and name: F:\VERSIONI_RTFPAD\FivePad\FivePad.Exe (32 bits)
   Size: 3,452,416 bytes
   Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603)
   FiveWin  Version: FWHX 16.03
   Windows version: 6.1, Build 7600

   Time from start: 0 hours 0 mins 3 secs
   Error occurred at: 26/04/16, 13:35:54
   Error description: Error BASE/1004  Class: 'NIL' has no exported method: CANCUT
   Args:
     [   1] = U  

Stack Calls
===========
   Called from:  => CANCUT( 0 )
   Called from: Source\TFivePad.prg => (b)TFIVEPAD:SETBAR( 975 )

 



on these lines of setbar method

METHOD SetBar() CLASS Tmypad
LOCAL oBar, oCursor, oClp

DEFINE CURSOR oCursor HAND

DEFINE CLIPBOARD oClp OF ::oWndMain FORMAT TEXT

DEFINE BUTTONBAR oBar OF ::oWndMain 3D SIZE 26, 84

oBar:bLClicked := { || NIL }
oBar:bRClicked := { || NIL }

@ -1, -1 BUTTONBAR ::oBar1 OF oBar 3D SIZE oBar:nWidth - 1, 29 ;
BUTTONSIZE 26, 27


DEFINE BUTTON RESOURCE "RTFCut" OF ::oBar1 GROUP ;
MESSAGE "Cuts the selection and puts it on the Clipboard" ;
TOOLTIP "Cut" NOBORDER ;
WHEN ( ::WndActive() .and. ::WndChild:CanCut() ) ; <------------------
ACTION ( ::WndChild():Cut(), ::WndChild():SetFocus() )

DEFINE BUTTON RESOURCE "RTFCopy" OF ::oBar1 ;
MESSAGE "Copies the selection and puts it on the Clipboard" ;
TOOLTIP "Copy" NOBORDER ;
WHEN ( ::WndActive() .and. ::WndChild():CanCopy() ) ;
ACTION ( ::WndChild():Copy(), ::WndChild():SetFocus() )

DEFINE BUTTON RESOURCE "RTFPaste" OF ::oBar1 ;
MESSAGE "Inserts Clipboard contents" ;
TOOLTIP "Paste" NOBORDER ;
WHEN ( ::WndActive() .and. ::WndChild:CanPaste() ) ;
ACTION ( ::WndChild():Paste(), ::WndChild():SetFocus() )

DEFINE BUTTON RESOURCE "RTFUndo" OF ::oBar1 GROUP ;
MESSAGE "Reverses the last action" ;
TOOLTIP "Undo" NOBORDER ;
WHEN ( ::WndActive() .and. ::WndChild():CanUndo() ) ;
ACTION ( ::WndChild:Undo(), ::WndChild():SetFocus() )

DEFINE BUTTON RESOURCE "RTFRedo" OF ::oBar1 ;
MESSAGE "Carries out the previously undone action" ;
TOOLTIP "Redo" NOBORDER ;
WHEN ( ::WndActive() .and. ::WndChild():CanRedo() ) ;
ACTION ( ::WndChild():Redo(), ::WndChild():SetFocus() )




why ?
I tried to modify it as

METHOD WndChild() CLASS TMypad

LOCAL oWnd

#ifndef __XPP__
oWnd := ::oWndMain:oWndActive:oControl
#else
oWnd := ::oWndMain:oWndActive:TMdiChild:oControl
#endif

if oWnd:ClassName() == "TRichEdit"
RETURN oWnd
endif

return nil

but not run ok
thanks

Re: Problem with Preview from trichedit

PostPosted: Tue Apr 26, 2016 6:23 pm
by Antonio Linares
Silvio,

Please provide a small and self contained example to reproduce here

Re: Problem with Preview from trichedit

PostPosted: Wed Apr 27, 2016 8:24 am
by Silvio.Falconi
..

Re: Problem with Preview from trichedit

PostPosted: Wed Apr 27, 2016 8:58 am
by Antonio Linares
DEFINE BUTTON RESOURCE "Cut" OF ::oBar1 ;
MESSAGE "Cuts the selection and puts it on the Clipboard" ;
TOOLTIP "Cut" NOBORDER ;
WHEN ( ::WndActive() .and. ::WndChild() != nil .and. ::WndChild:CanCut() ) ;
ACTION ( ::WndChild():Cut(), ::WndChild():SetFocus() )

Re: Problem with Preview from trichedit

PostPosted: Wed Apr 27, 2016 9:40 am
by Silvio.Falconi
GREAT

Image