Page 1 of 2

FW Preview user style

PostPosted: Sat May 07, 2022 10:18 am
by Detlef
Hi all,

again i have a problem with the FW Preview window.
I finally managed to get a nearly bare screen without any buttons except the one to close.
This button I want to put at the right end of the bar.
But I can't.
When I ask for the value oWnd:nWidht it gives me 545 which is completely wrong.
Here my code:
Code: Select all  Expand view
#include "FiveWin.ch"

REQUEST FWHARU

PROCEDURE Main()
//----------------
LOCAL oPrn

   TPreview():bSetUp := { |oPreview, oWnd| oWnd:oMenu:End(), oWnd:oMsgBar:End(),;
                                           oPreview:oBar:bPainted := {|| NIL } ,;
                                           oWnd:oBar:aControls[ 2 ]:End()      ,;
                                           msginfo( "width of window: " + trim( str( oWnd:nWidth ) ) ),;
                                           oWnd:oBar:aControls[ 1 ]:nLeft := oWnd:nWidth - 32,;
                                           oPreview:oFactor:End();
                        }
   RPrevUserBtns( { |oPrV, oBar| ReportExtend( oPrV, oBar ) }, 2007, { 48, 48 } )

   TPreview():lListViewHide := .t.
   TPrinter():lUseHaruPDF := .t.

   PRINT oPrn NAME "Druckvorschau" PREVIEW
      PAGE
         oPrn:Say( "Line one" )
      ENDPAGE
   ENDPRINT

RETURN

FUNCTION ReportExtend( oPreview, oBar )
//-------------------------------------
   do while len( oBar:aControls ) > 0
      oBar:Del( Len( oBar:aControls ) )
   enddo

RETURN .f.
 

I'll be glad for any helping idea.
Thanks,
Detlef

Re: FW Preview user style

PostPosted: Sat May 07, 2022 3:40 pm
by cnavarro
Look original code of RPREVIEW,PRG class
Code: Select all  Expand view

METHOD Activate() CLASS TPreview

   local hWndMain

   if ::oWnd == nil
      return nil
   endif

   if ::bSetUp != nil
      Eval( ::bSetUp, Self, ::oWnd )
   endif

   ACTIVATE WINDOW ::oWnd MAXIMIZED ;
 

Codeblock ::bSetup is evaluate before ACTIVATE WINDOW ::oWnd MAXIMIZED, then, ::oWnd does not yet have the dimensions of the window when it is maximized
Then, at moment, please, use this
Code: Select all  Expand view

   TPreview():bSetUp := { |oPreview, oWnd| oWnd:oMenu:End(), oWnd:oMsgBar:End(),;
                                           oPreview:oBar:bPainted := {|| NIL } ,;
                                           oWnd:oBar:aControls[ 2 ]:End()      ,;
                                           oWnd:Maximize(), ;
                                           MsgInfo( "width of window: " + trim( str( oWnd:nWidth ) ), oWnd:ClassName() ) }
 

Re: FW Preview user style

PostPosted: Sat May 07, 2022 4:23 pm
by Detlef
Many thanks for the clarification, Cristobal.
I overlooked that point in the rpreview.prg.

Re: FW Preview user style

PostPosted: Sat May 07, 2022 5:34 pm
by cnavarro
Dear Detlef, if you want to modify the method, try this way

Code: Select all  Expand view


METHOD Activate() CLASS TPreview

   local hWndMain
   local oThis    := Self

   if ::oWnd == nil
      return nil
   endif

   // Modified - CNL, look ON INIT clause
   // if ::bSetUp != nil
   //   Eval( ::bSetUp, Self, ::oWnd )
   // endif

   ACTIVATE WINDOW ::oWnd MAXIMIZED ;
      ON INIT      ( if( oThis:bSetUp != nil, Eval( oThis:bSetUp, Self, oThis:oWnd ), ) ) ;
      ON RESIZE    ( ::PaintMeta(), ::ResizeListView() ) ;
      ON UP        ::VScroll( GO_UP )             ;
      ON DOWN      ::VScroll( GO_DOWN )           ;
      ON PAGEUP    ::VScroll( GO_UP, GO_PAGE)     ;
      ON PAGEDOWN  ::VScroll( GO_DOWN, GO_PAGE)   ;
      ON LEFT      ::HScroll( GO_LEFT )           ;
      ON RIGHT     ::HScroll( GO_RIGHT )          ;
      ON PAGELEFT  ::HScroll( GO_LEFT, GO_PAGE )  ;
      ON PAGERIGHT ::HScroll( GO_RIGHT, GO_PAGE ) ;
      VALID        ( ::oWnd:oIcon := nil       ,;
                     ::oFont:End()             ,;
                     ::oCursor:End()           ,;
                     ::oMeta1:End()            ,;
                     ::oMeta2:End()            ,;
                     ::oDevice:End()           ,;
                     ::oHand:End()             ,;
                     If( Empty( ::oImageList ),, ( ::oImageList:End(), ::oImageList := nil ) ),;
                     If( ! Empty( ::oImageListPages ), ::oImageListPages:End(),),;
                     ::oWnd := nil             ,;
                     ::oDevice:oPreview := nil ,;
                     ::lExit := .T. )

     if ::oDevice:lPrvModal
         if ::oWndMain == nil
            StopUntil( { || ::lExit } )
         else
            hWndMain    := WndMain():hWnd
            StopUntil( { || ::lExit .or. !IsWindow( hWndMain ) } )
         endif
     endif

return nil
 

Re: FW Preview user style

PostPosted: Sat May 07, 2022 6:01 pm
by Otto
Hello friends,

I think there is a certain danger in our group.

I recently heard a lecture by a philosopher who said that it is dangerous to develop the technical language more and more.
This way you exclude people from active participation and eventually philosophy sinks into meaninglessness.

I notice a similar tendency here with us.

When I follow these ramifications, I ask myself, why don't we just make another class with these properties so that everyone understands how it works?

Best regards,
Otto


Image

Re: FW Preview user style

PostPosted: Sat May 07, 2022 8:23 pm
by cnavarro
Dear Otto
Sorry but I don't quite understand your proposal. Can he explain better what he means?

Re: FW Preview user style

PostPosted: Sat May 07, 2022 9:12 pm
by Detlef
cnavarro wrote:Dear Detlef, if you want to modify the method, try this way
Code: Select all  Expand view

METHOD Activate() CLASS TPreview ...
...
 


Thanks again, Cristobal, I will study this and modify rpreview.prg to my needs.

Re: FW Preview user style

PostPosted: Sun May 08, 2022 12:14 am
by Otto
Dear Cristobal,

For example, I only need preview and print button.

What I mean is, you should have - if we at FIVEWIN have the great advantage of having access to the source code courage and simply modify the classes.

But it's certainly easier with reduced, specific code to get what you want.

Best regards,
Otto


Image

Image

Re: FW Preview user style

PostPosted: Sun May 08, 2022 5:26 am
by nageswaragunupudi
Code: Select all  Expand view

TPreview():bButtonBar := { |oPrev, oWnd| CustomBar( oPrev, oWnd ) }
 


Code: Select all  Expand view

function CustomBar( oPrev, oWnd )

   local oBar, oBtn

   DEFINE BUTTONBAR oBar OF oWnd SIZE 48,48 2007

   DEFINE BUTTON oBtn OF oBar

   DEFINE BUTTON oBtn OF oBar RESOURCE FWBitmap( "Exit2" ) ;
   ACTION oWnd:End() BTNRIGHT TOOLTIP FWString( "Exit" )

   oPrev:oBar  := oBar

return oBar
 

Re: FW Preview user style

PostPosted: Sun May 08, 2022 8:01 am
by Otto
Dear Mr. Rao,

I know that.
But that's just a small example.
And if you want individual behaviour, you have to pass more code blocks. Not only the menu.

But tell me one reason why this is better.
I believe that few can understand or use these code blocks well.
It complicates programming.

I think it's easier for an application programmer to just build the menu and appearance.

We have to be careful not to lose touch with application programmers who just want to solve a problem quickly.

For us experienced programmers, it appears simply pass the object to a new function and continue working there.
But I have a young team of employees who always ask me the question, why can't we just change the method?

We can. But here in the forum, this is always dismissed as spaghetti code.
Maybe if some went along with the "Spaghetti Code" attempt, we'd have more help
from the "application developer segment" and visually, a preview that matches WINDOWS 11.

Best regards,
Otto

Re: FW Preview user style

PostPosted: Sun May 08, 2022 1:29 pm
by Antonio Linares
Dear Otto,

> a preview that matches WINDOWS 11

How would it look like ?

Re: FW Preview user style

PostPosted: Sun May 08, 2022 5:48 pm
by Otto
Dear Antonio,
I have not found anything yet.
But I think it will be similar to the browsers.

Best regards,
Otto
Image

Re: FW Preview user style

PostPosted: Sun May 08, 2022 6:54 pm
by Otto
Hello friends,
I think I found an easy way to modify class source and not loosing compatibility.

No matter how complex a class is, you can split the code into separate files
without paying attention to where the function/method starts or ends - just one block

Split the classes

copy the part you want to change into one file and save it 2 times, once as original and once for your modifications

// convention
for modification:
Class filename + _ + name for the block.
You can cut lines without paying attention to where the function starts or ends - simply a block
Original
class filename + _ STD_+ name for the block.

In the remaining class, you insert the file with #include

#include in the file where you saved the block


with this simple definition you can switch between the original CLASS and the modified CLASS


#define MODIFIED_CLASS MODIFIED_CLASS


#ifdef MODIFIED_CLASS
#include "C:\Entwicklung_2012\print\source\rpreview_BuildButtonBar.prg"
#else
#include "C:\Entwicklung_2012\print\source\rpreview_STD_BuildButtonBar.prg"
#endif

Best regards,
Otto

Re: FW Preview user style

PostPosted: Wed May 11, 2022 1:30 am
by James Bott
I highly recommend NOT modifying the FW source.

I recommend creating a new class that inherits from the FW class and create a method (with the same name) in that new class that contains the modification needed. This way when a new FW version comes out you won't have to keep modifying the source, you just inherit from the new source and override that one method.

Of course, if that method in the original source is modified in a new version of FW, then you will have to update your new class's method.

This is a standard OOP programming technique. It saves a lot of confusion and extra programming.

Re: FW Preview user style

PostPosted: Wed May 11, 2022 6:13 am
by Otto
Dear James,

You're right.
But remember when you taught me OOP, what problems I experienced first.

But the standardization and wrapping everything into FIVEWIN often inhibits the ideas of the application developers.

Even if we application-programmers try to create general solutions, it's an overload and then your own program suffers.

Also, regarding mod harbour I have so far the experience that the objects are to be seen somewhat with other eyes.
Here runs then the source code 1 time and then the program exits after it has created HTML/JS for the APACHE server.

I think here, to create an object that 5 lines later is already dead again brings nothing but that it becomes more complex.

I post a law here.
The more complex and sophisticated our source code becomes, the less contribution we get from the application programmers.

Best regards,
Otto