Resize a tpanel

Resize a tpanel

Postby Silvio.Falconi » Sat May 20, 2023 6:55 pm

if i have a tpanel in a window with controls is it possible to resize the tpanel
when i resize the window and still the same controls contained in the tpanel ?


I create the Panel with


Code: Select all  Expand view

 
#include "fivewin.ch"


function Main()
local oWnd,oPanel

DEFINE WINDOW oWnd
oPanel:= CreatePanel(oWnd,10,10,CLR_WHITE,CLR_HGRAY,200,200,.t.)
oPanel:bPainted := { || MyControls(oPanel) }


ACTIVATE WINDOW oWND
return nil
//-----------------------------------------------------------------------------//
Function CreatePanel(oWnd,nRow,nLeft,nColor1,nColor2,nBottom,nWidth,lBorder)
      local oPanel,oBrush
      local aGrad := { nColor1,nColor2}
      DEFAULT lBorder:=.f.
      DEFINE BRUSH oBrush GRADIENT aGrad

     oPanel:=Tpanel():New( nRow, nLeft, nBottom, nWidth, oWnd)
     oPanel:SetBrush( oBrush )
     IF lBorder
        oPanel:bPainted := { || oPanel:Box( 1,1,oPanel:nHeight-1,oPanel:nWidth-1 ) }
     Endif
     return oPanel
//-----------------------------------------------------------//
  Function MyControls(oPanel)
   local rc := GetClientRect(oPanel:hWnd)
   local hDc:=oPanel:getdc()
   local nTop     := rc[1]
   local nLeft    := rc[2]
   local nBottom  := rc[3]
   local nRight   := rc[4]
   LOCAL oFont := TFont():New("Tahoma" , 0, 40,, )
   Linea( hDc, nTop+48, nLeft+5, 0.5, nRight-11, CLR_HGRAY )
   PaintTEXT(nTop+60,nLeft,nBottom,nRight,hdc,"fivetech",CLR_RED,oFont)

   return nil
 //-----------------------------------------------------------//

static function Linea( hDC, nTop, nLeft, nBottom, nRight, nColor, nWidth )

   local hPen, hOldPen

   DEFAULT nColor := CLR_BLACK, nWidth := 1

   hPen = CreatePen( PS_SOLID, nWidth, nColor )
   hOldPen = SelectObject( hDC, hPen )

   MoveTo( hDC, nLeft, nTop )
   LineTo( hDC, nRight, nTop )

   SelectObject( hDC, hOldPen )
   DeleteObject( hPen )

return 0

Function PaintTEXT(nTop,nLeft,nBottom,nRight,hdc,ctext,ncolor1,oFont)
    local hFont, hOldFont
    local nOldMode,ncolor

    hFont    := oFont:hFont
    hOldFont := SelectObject( hDC, hFont )
    nOldMode := SetBkMode( hDC, 1 ) //transparent
    nColor   := SetTextColor( hDC, nColor1)

    nLeft +=  8

    DrawTextEx( hDC, cText , {nTop+2,nLeft,nBottom,nRight} )

    SetBkMode( hDC, nOldMode )
     SelectObject( hDC, hOldFont )
     SetTextColor( hDC, nColor   )
    DeleteObject( hFont )
    return nil

 


but on my application I use a tscrollpanel instead of the window
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: Resize a tpanel

Postby nageswaragunupudi » Sun May 21, 2023 3:07 am

For ScrollPanel, please set :oRightMargin and :oBottomMargin, to make it resizable when container window/dialog is resized.
Sample:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oWnd, oPanel, n

   DEFINE WINDOW oWnd

   oPanel := TScrollPanel():New( 20,20,100,100,oWnd )

   oPanel:nRightMargin  := 20
   oPanel:nBottomMargin := 20

   for n := 1 to 20
      @ n*20,20 SAY REPLICATE( Chr( n + 64 ), 20 ) SIZE 200,16 PIXEL OF oPanel
   next

   oPanel:SetRange()

   oWnd:nHeight   := 200
   oWnd:nWidth    := 200

   ACTIVATE WINDOW oWnd CENTERED

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Resize a tpanel

Postby Otto » Sun May 21, 2023 6:52 am

Dear Mr. Rao,
Thank you for this example.
Could you also please show how to make it horizontally scrollable at the same time?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: Resize a tpanel

Postby nageswaragunupudi » Sun May 21, 2023 7:58 am

We did not provide horizontal scrolling as of now.
We will look in to this and get back to you.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Resize a tpanel

Postby Silvio.Falconi » Sun May 21, 2023 4:13 pm

nageswaragunupudi wrote:For ScrollPanel, please set :oRightMargin and :oBottomMargin, to make it resizable when container window/dialog is resized.
Sample:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oWnd, oPanel, n

   DEFINE WINDOW oWnd

   oPanel := TScrollPanel():New( 20,20,100,100,oWnd )

   oPanel:nRightMargin  := 20
   oPanel:nBottomMargin := 20

   for n := 1 to 20
      @ n*20,20 SAY REPLICATE( Chr( n + 64 ), 20 ) SIZE 200,16 PIXEL OF oPanel
   next

   oPanel:SetRange()

   oWnd:nHeight   := 200
   oWnd:nWidth    := 200

   ACTIVATE WINDOW oWnd CENTERED

return nil
 




Nages,
sorry i didn't mean that....

I have some panels inside a scrollpanel

the scrollpanel is inside a dialog which in turn is inside a window ( oWndMain)

when I resize the main window I perfectly resize the dialog and in turn also the scrollpanel it contains

the problem I have with the small panels that are inside the scrollpanel and the controls that are in each panel

Please see the video

Image



I make a small simulation

Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oWnd, oPanel, n

   local aPanel:=array(20)
   local nRow:= 1,nLeft:= 1
   local nColor1:= CLR_WHITE
   local nColor2:= rGb( 245,245,245)
   local nHeight := 20
   local nWidth
   DEFINE WINDOW oWnd

   oPanel := TScrollPanel():New( 20,20,100,100,oWnd )

   oPanel:nRightMargin  := 20
   oPanel:nBottomMargin := 20
   nWidth := oPanel:nWidth


    aPanel[1]:=CreatePanel(oPanel,nRow,nLeft,nColor1,nColor2,80,400,.t.)
    nRow+=80
    aPanel[2]:=CreatePanel(oPanel,nRow,nLeft,nColor1,nColor2,nRow+80,400,.t.)
     nRow+=80
    aPanel[3]:=CreatePanel(oPanel,nRow,nLeft,nColor1,nColor2,nRow+80,400,.t.)
    nRow+=80
    aPanel[4]:=CreatePanel(oPanel,nRow,nLeft,nColor1,nColor2,nRow+80,400,.t.)


    oPanel:SetRange()

   oWnd:nHeight   := 200
   oWnd:nWidth    := 200

   ACTIVATE WINDOW oWnd CENTERED

   return nil

 Function CreatePanel(oWnd,nRow,nLeft,nColor1,nColor2,nBottom,nWidth,lBorder)
      local oPanel,oBrush
      local aGrad := { nColor1,nColor2}
      DEFAULT lBorder:=.f.
      DEFINE BRUSH oBrush GRADIENT aGrad

     oPanel:=Tpanel():New( nRow, nLeft, nBottom, nWidth, oWnd)
     oPanel:SetBrush( oBrush )
     IF lBorder
     oPanel:bPainted := { || oPanel:Box( 1,1,oPanel:nHeight-1,oPanel:nWidth-1 ) }
     Endif
return oPanel



 


when i resize the scrollpanel i want the small panels to resize
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: Resize a tpanel

Postby Silvio.Falconi » Wed May 24, 2023 9:45 am

Nages any solution ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 82 guests