Page 1 of 1

Help for MDI Frame

Posted: Tue Sep 01, 2020 12:53 am
by Mulyadi
Please help checking my code.

in FWH version 17.09 after calling the print procedure, windows dialog1 is borderless.

in version 20.07 the return to windows dialog1 leaves a frame.

Code: Select all

#include "FiveWin.ch"

static oWnd
static lWnd1, oWnd1
// ... static lWnd2, oWnd2

Function Main()

    local oBar, oBar1, oBar2

    lWnd1 := .F.
    // lWnd2 := .F.
    
    DEFINE WINDOW oWnd TITLE "test MDI"  MDI
                 
        DEFINE BUTTONBAR oBar OF oWnd 3D SIZE 110, 30  2007

            oBar:bClrGrad := { |lMouseOver| If( lMouseOver, CLR_BROWN, nARGB( 64, 0, 192, 0 ) ) }
            oBar:SetColor( CLR_BLUE )

        DEFINE BUTTON oBar1 OF oBar ACTION test1() PROMPT " Dialog 1 " left 
      DEFINE BUTTON oBar2 OF oBar ACTION test2() PROMPT " Dialog 2 " left 
            
        DEFINE BUTTON OF oBar ACTION oWnd:end() PROMPT "Exit" left GROUP 

    ACTIVATE WINDOW oWnd maximized VALID MsgYesNo( "Exit ?" )
    
return nil

//--------------------------------------------------
Function ChangeParent( oDlg, oChild )
  local n

  for n = 1 to Len( oDlg:aControls )
      SetParent( oDlg:aControls[ n ]:hWnd, oChild:hWnd )
      AAdd( oChild:aControls, oDlg:aControls[ n ] )
      oDlg:aControls[ n ]:oWnd = oChild
  next
return nil


//---------------------------------------------------
static function test1()
    local oBrush

    if ! lWnd1
    
    DEFINE BRUSH oBrush GRADIENT { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } }

    DEFINE WINDOW oWnd1 from 0,0 to oWnd:nHeight, oWnd:nWidth pixel ;
      MDICHILD OF WndMain() BRUSH oBrush nosysmenu ;
      title "This frame exists after returning to the dialog1 test window"

    lWnd1 := .T.

        dialog1( oWnd1 )
             
    ACTIVATE WINDOW oWnd1 MAXIMIZED ON INIT oWnd1:paint()  ;
          VALID  ( oWnd1:Hide(), lWnd1 := .F., .t. )
          
    RELEASE BRUSH oBrush

  else

    oWnd1:Maximize()
    oWnd1:SetFocus()  

  endif
return nil

//------------------- Dialog1
// actual this function on other file
Function dialog1( oWnd )
  
  local oDlg, oBrush, oFld
  local btnprint  

  DEFINE BRUSH oBrush GRADIENT { { 1, 9815189, CLR_WHITE } }

  DEFINE DIALOG oDlg of oWnd size oWnd:nRight-20, oWnd:nBottom-80 TRUEPIXEL brush oBrush 

    @ 2, 1 FOLDEREX oFld OF oDlg PIXEL ;
         PROMPTS "Folder 11", "Folder 12", "Folder 13", "Folder 14", "Close" ;
         on change ( if( nOption == 5, oWnd:end(), ) ) ;
         TAB HEIGHT 24 ;
         SIZE oDlg:nWidth, oDlg:nHeight TRANSPARENT 

      @ 10, 5 say "This folder 11" of oFld:aDialogs[1] size 100,14 pixel transparent
      @ 10, 5 say "This folder 12" of oFld:aDialogs[2] size 100,14 pixel transparent
      @ 10, 5 say "This folder 13" of oFld:aDialogs[3] size 100,14 pixel transparent
      @ 10, 5 say "This folder 14" of oFld:aDialogs[4] size 100,14 pixel transparent

      @ 10,100 btnbmp btnprint prompt "test print" of oFld:aDialogs[1] size 100,14 pixel center adjust 2007 ;
        action test_print1()


  ACTIVATE DIALOG oDlg NOWAIT CENTERED ;
    ON INIT ( ChangeParent( oDlg, oWnd ) )

  oDlg:end()

return nil


//------------------------------------------------------
//------------------------------------------------------

static function test2()
  msginfo( "as of Dialog1")
return nil


//------------------------------------------- 
// 
static function test_print1
  local oPrn
  local oBrushRed, oBrushGrn
  local oFont

  DEFINE BRUSH oBrushRed COLOR CLR_RED
  DEFINE BRUSH oBrushGrn COLOR CLR_HGREEN

  PRINT oPrn PREVIEW

  DEFINE FONT oFont NAME "TAHOMA"  SIZE 0,-20 OF oPrn

    PAGE

      oPrn:SayText(  300, 400, "Yellow, RedBrush", 2000, 200, oFont, nil, CLR_YELLOW, oBrushRed, "PIXEL" )
      oPrn:SayText(  620, 400, "Default: nil,nil", 2000, 200, oFont, nil, nil,        nil,       "PIXEL" )
    
    ENDPAGE
  ENDPRINT

  RELEASE FONT oFont
  RELEASE BRUSH oBrushRed, oBrushGrn

  return nil
     
 
thank you

Mulyadi

Re: Help for MDI Frame

Posted: Tue Sep 01, 2020 1:51 am
by karinha

Code: Select all

#include "FiveWin.ch"

STATIC oWnd
STATIC lWnd1, oWnd1

FUNCTION Main()

   LOCAL oBar, oBar1, oBar2

   lWnd1 := .F.

   SetBalloon( .T. )
   SkinButtons()
   
   DEFINE WINDOW oWnd TITLE "test MDI"  MDI
                 
   DEFINE BUTTONBAR oBar OF oWnd 3D SIZE 110, 30  2007

   oBar:bClrGrad := { |lMouseOver| If( lMouseOver, CLR_BROWN, nARGB( 64, 0, 192, 0 ) ) }

   oBar:SetColor( CLR_BLUE )

   DEFINE BUTTON oBar1 OF oBar ACTION test1() PROMPT " Dialog 1 " left

   DEFINE BUTTON oBar2 OF oBar ACTION test2() PROMPT " Dialog 2 " left
           
   DEFINE BUTTON OF oBar ACTION oWnd:end() PROMPT "Exit" left GROUP

   ACTIVATE WINDOW oWnd maximized VALID MsgYesNo( "Exit ?" )
   
RETURN nil

FUNCTION ChangeParent( oDlg, oChild )

   LOCAL n

   FOR n = 1 TO Len( oDlg:aControls )

      SetParent( oDlg:aControls[ n ]:hWnd, oChild:hWnd )

      AAdd( oChild:aControls, oDlg:aControls[ n ] )

      oDlg:aControls[ n ]:oWnd = oChild

   NEXT

RETURN nil

STATIC FUNCTION test1()

   LOCAL oBrush

   IF .NOT. lWnd1
   
      DEFINE BRUSH oBrush GRADIENT { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } }

      DEFINE WINDOW oWnd1 FROM 0, 0 TO oWnd:nHeight, oWnd:nWidth pixel ;
         MDICHILD OF WndMain() BRUSH oBrush nosysmenu ;
         title "This frame exists after returning to the dialog1 test window"

      lWnd1 := .T.

      dialog1( oWnd1 )
             
      ACTIVATE WINDOW oWnd1 MAXIMIZED ON INIT oWnd1:paint()  ;
         VALID  ( oWnd1:Hide(), lWnd1 := .F. , .T. )
         
      RELEASE BRUSH oBrush

   ELSE

      oWnd1:Maximize()
      oWnd1:SetFocus()

   ENDIF

RETURN nil

FUNCTION dialog1( oWnd )
 
   LOCAL oDlg, oBrush, oFld
   LOCAL btnprint

   DEFINE BRUSH oBrush GRADIENT { { 1, 9815189, CLR_WHITE } }

   DEFINE DIALOG oDlg of oWnd size oWnd:nRight - 20, oWnd:nBottom - 80    ;
      TRUEPIXEL BRUSH oBrush

   oDlg:lHelpIcon := .F.

   @ 2, 1 FOLDEREX oFld OF oDlg PIXEL                                     ;
      PROMPTS "Folder 11", "Folder 12", "Folder 13", "Folder 14", "Close" ;
      ON change ( if( nOption == 5, oWnd:end(), ) )                       ;
      TAB HEIGHT 24 ;
      SIZE oDlg:nWidth, oDlg:nHeight // TRANSPARENT

   @ 10, 5 SAY "This folder 11" of oFld:aDialogs[1] size 100, 14 pixel    ;
      UPDATE TRANSPARENT

   @ 10, 5 SAY "This folder 12" of oFld:aDialogs[2] size 100, 14 pixel    ;
      UPDATE TRANSPARENT

   @ 10, 5 SAY "This folder 13" of oFld:aDialogs[3] size 100, 14 pixel    ;
      UPDATE TRANSPARENT

   @ 10, 5 SAY "This folder 14" of oFld:aDialogs[4] size 100, 14 pixel    ;
      UPDATE TRANSPARENT

   @ 10, 100 btnbmp btnprint PROMPT "test print" of oFld:aDialogs[1]      ;
      size 100, 14 pixel center adjust 2007                               ;
      action test_print1()

   ACTIVATE DIALOG oDlg NOWAIT CENTERED ;
      ON INIT ( ChangeParent( oDlg, oWnd ) )

   oDlg:End()

RETURN nil

STATIC FUNCTION test2()

   msginfo( "as of Dialog1" )

RETURN nil

STATIC FUNCTION test_print1

   LOCAL oPrn
   LOCAL oBrushRed, oBrushGrn
   LOCAL oFont

   DEFINE BRUSH oBrushRed COLOR CLR_RED
   DEFINE BRUSH oBrushGrn COLOR CLR_HGREEN

   PRINT oPrn PREVIEW // MODAL

      DEFINE FONT oFont NAME "TAHOMA"  SIZE 0, - 20 OF oPrn

      PAGE

         oPrn:SayText(  300, 400, "Yellow, RedBrush", 2000, 200, oFont, nil, CLR_YELLOW, oBrushRed, "PIXEL" )

         oPrn:SayText(  620, 400, "Default: nil,nil", 2000, 200, oFont, nil, nil,        nil,       "PIXEL" )
   
      ENDPAGE

   ENDPRINT

   RELEASE FONT oFont
   RELEASE BRUSH oBrushRed, oBrushGrn

RETURN nil
 

Re: Help for MDI Frame

Posted: Tue Sep 01, 2020 3:49 am
by Mulyadi
thanks for responding.

I mean how to get back to normal view after exiting the printer button.

normal view like this:
https://mega.nz/file/68pHQAgS#IM41IyGwv ... 3rOHFtfZxI

but with version 20.07 I got this:
https://mega.nz/file/r1gHVSYS#f5cqqfNK_ ... dEZ_QBgaTk

Thanks
Mulyadi

Re: Help for MDI Frame

Posted: Tue Sep 01, 2020 7:36 am
by mauri.menabue
Hi Mulyadi,

Try this :

Code: Select all


#include "FiveWin.ch"

static oWnd
static lWnd1, oWnd1
// ... static lWnd2, oWnd2

Function Main()

    local oBar, oBar1, oBar2

    lWnd1 := .F.
    // lWnd2 := .F.
   
    DEFINE WINDOW oWnd TITLE "test MDI"  MDI
                 
        DEFINE BUTTONBAR oBar OF oWnd 3D SIZE 110, 30  2007

            oBar:bClrGrad := { |lMouseOver| If( lMouseOver, CLR_BROWN, nARGB( 64, 0, 192, 0 ) ) }
            oBar:SetColor( CLR_BLUE )

        DEFINE BUTTON oBar1 OF oBar ACTION test1() PROMPT " Dialog 1 " left
      DEFINE BUTTON oBar2 OF oBar ACTION test2() PROMPT " Dialog 2 " left
           
        DEFINE BUTTON OF oBar ACTION oWnd:end() PROMPT "Exit" left GROUP

    ACTIVATE WINDOW oWnd maximized VALID MsgYesNo( "Exit ?" )
   
return nil

//--------------------------------------------------
Function ChangeParent( oDlg, oChild )
  local n

  for n = 1 to Len( oDlg:aControls )
      SetParent( oDlg:aControls[ n ]:hWnd, oChild:hWnd )
      AAdd( oChild:aControls, oDlg:aControls[ n ] )
      oDlg:aControls[ n ]:oWnd = oChild
  next
return nil


//---------------------------------------------------
static function test1()
    local oBrush

    if ! lWnd1
   
    DEFINE BRUSH oBrush GRADIENT { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } }

    DEFINE WINDOW oWnd1 from 0,0 to oWnd:nHeight, oWnd:nWidth pixel ;
      MDICHILD OF WndMain() BRUSH oBrush nosysmenu ;
      title "This frame exists after returning to the dialog1 test window" ;
      STYLE nor(WS_THICKFRAME)  // <---------------------- NEW ADD BY MAURI !---------------------------------

    lWnd1 := .T.

        dialog1( oWnd1 )
             
    ACTIVATE WINDOW oWnd1 MAXIMIZED ON INIT oWnd1:paint()  ;
          VALID  ( oWnd1:Hide(), lWnd1 := .F., .t. )
         
    RELEASE BRUSH oBrush

  else

    oWnd1:Maximize()
    oWnd1:SetFocus()  

  endif
return nil

//------------------- Dialog1
// actual this function on other file
Function dialog1( oWnd )
 
  local oDlg, oBrush, oFld
  local btnprint  

  DEFINE BRUSH oBrush GRADIENT { { 1, 9815189, CLR_WHITE } }

  DEFINE DIALOG oDlg of oWnd size oWnd:nRight-20, oWnd:nBottom-80 TRUEPIXEL brush oBrush

    @ 2, 1 FOLDEREX oFld OF oDlg PIXEL ;
         PROMPTS "Folder 11", "Folder 12", "Folder 13", "Folder 14", "Close" ;
         on change ( if( nOption == 5, oWnd:end(), ) ) ;
         TAB HEIGHT 24 ;
         SIZE oDlg:nWidth, oDlg:nHeight TRANSPARENT

      @ 10, 5 say "This folder 11" of oFld:aDialogs[1] size 100,14 pixel transparent
      @ 10, 5 say "This folder 12" of oFld:aDialogs[2] size 100,14 pixel transparent
      @ 10, 5 say "This folder 13" of oFld:aDialogs[3] size 100,14 pixel transparent
      @ 10, 5 say "This folder 14" of oFld:aDialogs[4] size 100,14 pixel transparent

      @ 10,100 btnbmp btnprint prompt "test print" of oFld:aDialogs[1] size 100,14 pixel center adjust 2007 ;
        action test_print1()


  ACTIVATE DIALOG oDlg NOWAIT CENTERED ;
    ON INIT ( ChangeParent( oDlg, oWnd ) )

  oDlg:end()

return nil


//------------------------------------------------------
//------------------------------------------------------

static function test2()
  msginfo( "as of Dialog1")
return nil


//-------------------------------------------
//
static function test_print1
  local oPrn
  local oBrushRed, oBrushGrn
  local oFont

  DEFINE BRUSH oBrushRed COLOR CLR_RED
  DEFINE BRUSH oBrushGrn COLOR CLR_HGREEN

  PRINT oPrn PREVIEW

  DEFINE FONT oFont NAME "TAHOMA"  SIZE 0,-20 OF oPrn

    PAGE

      oPrn:SayText(  300, 400, "Yellow, RedBrush", 2000, 200, oFont, nil, CLR_YELLOW, oBrushRed, "PIXEL" )
      oPrn:SayText(  620, 400, "Default: nil,nil", 2000, 200, oFont, nil, nil,        nil,       "PIXEL" )
   
    ENDPAGE
  ENDPRINT

  RELEASE FONT oFont
  RELEASE BRUSH oBrushRed, oBrushGrn

  return nil
 
Bye

Re: Help for MDI Frame

Posted: Tue Sep 01, 2020 8:21 am
by Mulyadi
Hi Mauri,
thank you, and problem resolved.

:D

Regards

Mulyadi