about RESIZE

about RESIZE

Postby Jimmy » Wed Jul 27, 2022 9:42 pm

hi,

i have some Control in WINDOW and want to "Resize" it
Code: Select all  Expand view  RUN
STATIC oWnd
   DEFINE WINDOW oWnd FROM 0, 0 TO 600, 800 + 16 PIXEL TITLE "TVIP" ICON  "A1MAIN" MENU BuildMenu()
   ...
   ACTIVATE WINDOW oWnd CENTERED ON RESIZE DoReSize( oWnd, oBrw )

Question : do i have to "arrange" each Child Control or is there a "LayoutManager" :?:

under Xbase++ i got
Code: Select all  Expand view  RUN
  :Childlist() -> Array of Child-Control of WINDOW

under HMG / Extended Version i have
Code: Select all  Expand view  RUN
PROCEDURE DoGetLayout(cForm)
LOCAL aControl := GetControls( cForm )
LOCAL i, iMax := LEN(aControl)

   FOR i := 1 TO iMax
      // {ControlType, ControlName}
      aItem := aControl[i]
      cType := aItem[1]
      cName := aItem[2]
      ...
      AADD(aLayOutE,{ cType, cName, nRow,nCol, nWidth, nHeight,cFont } )
   NEXT
RETURN

and use Array to Resize
Code: Select all  Expand view  RUN
PROCEDURE DoReSize(cForm)
LOCAL aOriginal := {800,600}
LOCAL nWidth  := GetProperty( cForm ,"WIDTH")
LOCAL nHeight := GetProperty( cForm ,"HEIGHT")
LOCAL i, iMax := LEN(aLayOutE)
LOCAL xFactor, yFactor
LOCAL cType, cName, nRow,nCol ,nWide, nHigh,cFont, nFont

   xFactor := nWidth  / aOriginal[1]
   yFactor := nHeight / aOriginal[2]

   FOR i := 1 TO iMax
      cType    := aLayOutE[i][1]
      cName    := aLayOutE[i][2]
      nRow     := aLayOutE[i][3]
      nCol     := aLayOutE[i][4]
      nWide    := aLayOutE[i][5]
      nHigh    := aLayOutE[i][6]
      cFont    := aLayOutE[i][7]
      nFont    := aLayOutE[i][8]

      SetProperty( cForm, cName ,"ROW",nRow*yFactor)
      SetProperty( cForm, cName ,"COL",nCol*xFactor)
      SetProperty( cForm, cName ,"WIDTH" ,nWide*xFactor )
      SetProperty( cForm, cName ,"HEIGHT",nHigh*yFactor)
      SetProperty( cForm, cName ,"FONTSIZE",nFont*yFactor)
   NEXT
RETURN



---

i found :SetSize() but no :SetPos() :(

what shell i use :?:
Code: Select all  Expand view  RUN
SetWindowPos( oObj:hWnd, HWND_TOP, X, Y, Width, Height )
or
Code: Select all  Expand view  RUN
SetBounds( X, Y, Width, Height )


---

Code: Select all  Expand view  RUN
PROCEDURE DoReSize()
   // "Original" Rect, need "Update"  
   ...
   nTop := oWnd:nTop
   nLeft := oWnd:nLeft
   nBottom := oWnd:nBottom
   nRight := oWnd:nRight

give me {0,0,600,800 } :shock:
but i have use CENTER

when using
Code: Select all  Expand view  RUN
  oWnd:CoorsUpdate()

before i got "real" Coordinate

Request : when MENU is "activate" is it possible to "include" :CoorsUpdate() :idea:

---

so i still search for a \SAMPLE which show how to "Resize" under FiveWin
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: about RESIZE

Postby cmsoft » Wed Jul 27, 2022 10:32 pm

Tal vez esto te pueda dar una pista
Code: Select all  Expand view  RUN

      for n := 1 to Len( oDlg:aControls )
              oControl    := oDlg:aControls[ n ]
              oControl:nWidth  := oControl:nWidth * xFactor
              oControl:nHeight := oControl:nHeight * yFactor
              oControl:nTop    := oControl:nTop * xFactor
              oControl:nLeft   := oControl:nLeft * yFactor
      next n
 

No lo he probado, pero te puede servir de base
User avatar
cmsoft
 
Posts: 1292
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: about RESIZE

Postby nageswaragunupudi » Thu Jul 28, 2022 7:05 pm

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

function Main()

   local oDlg, oFont
   local nVal := 123456

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12

   DEFINE DIALOG oDlg SIZE 400,250 PIXEL TRUEPIXEL RESIZABLE FONT oFont

   @ 50, 20 SAY "Value :" SIZE 80,24 PIXEL OF oDlg RIGHT VCENTER

   @ 50,140 GET nVal PICTURE "99,999,999.99" SIZE 100,24 PIXEL OF oDlg

   @ 150,280 BTNBMP PROMPT "Ok" SIZE 100,40 PIXEL FLAT

   //
   oDlg:Cargo  := { oDlg:nWidth, oDlg:nHeight, oDlg:oFont:nHeight }
   oDlg:OnResize   := { |o| DlgResize( o ) }
   //

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( AEval( oDlg:aControls, { |o| o:Cargo := { o:nTop, o:nLeft, o:nWidth, o:nHeight, o:oFont:nHeight } } ) )
   RELEASE FONT oFont


return nil

static function DlgResize( oDlg )

   local xFactor  := oDlg:nWidth  / oDlg:Cargo[ 1 ]
   local yFactor  := oDlg:nHeight / oDlg:Cargo[ 2 ]
   local oCtrl, h

   for each oCtrl in oDlg:aControls
      WITH OBJECT oCtrl
         :nTop    := :Cargo[ 1 ] * yFactor
         :nLeft   := :Cargo[ 2 ] * xFactor
         :nWidth  := :Cargo[ 3 ] * xFactor
         :nHeight := :Cargo[ 4 ] * yFactor

         h  := -:Cargo[ 5 ]
         h  := -ROUND( ( h * yFactor ), 0 )
         if h != :oFont:nInpHeight
            :SetFont( :oFont:Modify( h ) )
         endif

         :Refresh()
      END
   next

return nil


Image
Regards

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

Re: about RESIZE

Postby cmsoft » Thu Jul 28, 2022 7:50 pm

Excelente Mr. Rao!!!
Muchas gracias por compartirlo!
User avatar
cmsoft
 
Posts: 1292
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: about RESIZE

Postby Jimmy » Fri Jul 29, 2022 10:21 pm

hi

thx for Answer and Sample

i have try to use DIALOG for my Sample and got

Error description: Error BASE/1005 No exported variable: TOOLBAR
Args:
[ 1] = U
[ 2] = L .T.

Stack Calls
===========
Called from: => _TOOLBAR( 0 )
Called from: => __OBJSENDMSG( 0 )
Called from: .\source\classes\ACTIVEX.PRG => FWTVLC:_TOOLBAR( 169 )
Called from: FWIPTV.prg => FWTVLC:NEW( 785 )
Called from: FWIPTV.prg => MAIN( 122 )

"this" Toolbar is from VLC and does work when use WINDOW but not with DIALOG :shock:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: about RESIZE

Postby Jimmy » Fri Jul 29, 2022 10:28 pm

hi,

next is COMBOBOX which does not work as expect
Code: Select all  Expand view  RUN
#include "fivewin.ch"
#include "common.ch"

STATIC oDlg, oFont, oCombo
STATIC cCombo  := "all Record"
STATIC aItems    := { "Hello", "World" }

PROCEDURE Main( cDBF )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 12
   #IFDEF __HMG__
   END FONT
   #ENDIF

   DEFINE WINDOW oDlg FROM 0, 0 TO 600, 800 + 16 PIXEL TITLE "TVIP"

      @ 310, 010 COMBOBOX oCombo VAR cCombo ITEMS aItems SIZE 300, 300 PIXEL OF oDlg ON CHANGE DoChange()

   #IFDEF __HMG__
   END WINDOW
   #ENDIF

   oDlg:Cargo := { oDlg:nWidth, oDlg:nHeight, 16 }
   AEVAL( oDlg:aControls, { | o | o:Cargo := { o:nTop, o:nLeft, o:nWidth, o:nHeight, o:oFont:nHeight } } )

   ACTIVATE WINDOW oDlg CENTERED ;
           ON INIT DoInit() ;
           ON RESIZE DoReSize()

   RELEASE FONT oFont

RETURN

STATIC PROCEDURE DoInit()
   DoFillCombo()

   oCombo:SetItems( aItems )
   oCombo:Set( "all Record" )

   DoChange()

RETURN

STATIC PROCEDURE DoFillCombo()
LOCAL i
   aItems := {"all Record"}
   FOR i := 1 TO 100
      AADD( aItems,STRZERO(i,3) )
   NEXT
RETURN

STATIC PROCEDURE DoChange()
RETURN

STATIC PROCEDURE DoReSize()
LOCAL xFactor := oDlg:nWidth / oDlg:Cargo[ 1 ]
LOCAL yFactor := oDlg:nHeight / oDlg:Cargo[ 2 ]
LOCAL oCtrl, h

   FOR each oCtrl in oDlg:aControls
      WITH OBJECT oCtrl

         :nTop := :Cargo[ 1 ] * yFactor
         :nLeft := :Cargo[ 2 ] * xFactor
         :nWidth := :Cargo[ 3 ] * xFactor
         :nHeight := :Cargo[ 4 ] * yFactor

         h := - :Cargo[ 5 ]
         h := - ROUND( ( h * yFactor ), 0 )
         IF h != :oFont:nInpHeight
            :SetFont( :oFont:Modify( h ) )
         ENDIF

         :Refresh()
      END
   NEXT

RETURN

when "resize" it does use wrong Value for "Dropdown" Part of COMBOBOX

i try to use this as Workaround

Code: Select all  Expand view  RUN
  CASE :IsKindOf( "TCOMBOBOX" )
      :nHeight := :nWidth
      :nItemHeight( h * 2 )

but "2" is not the Solution (also yFactor does not work)

i saw "Ownerdraw" in Source c:\fwh\source\classes\combobox.prg
is there a \Sample for it :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: about RESIZE

Postby nageswaragunupudi » Sun Jul 31, 2022 4:08 am

Jimmy wrote:hi

thx for Answer and Sample

i have try to use DIALOG for my Sample and got

Error description: Error BASE/1005 No exported variable: TOOLBAR
Args:
[ 1] = U
[ 2] = L .T.

Stack Calls
===========
Called from: => _TOOLBAR( 0 )
Called from: => __OBJSENDMSG( 0 )
Called from: .\source\classes\ACTIVEX.PRG => FWTVLC:_TOOLBAR( 169 )
Called from: FWIPTV.prg => FWTVLC:NEW( 785 )
Called from: FWIPTV.prg => MAIN( 122 )

"this" Toolbar is from VLC and does work when use WINDOW but not with DIALOG :shock:


Can you please help me to find where is the program containing FWTVLC class in FWH sources?
Regards

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

Re: about RESIZE

Postby Jimmy » Sun Jul 31, 2022 4:30 am

hi,
nageswaragunupudi wrote:Can you please help me to find where is the program containing FWTVLC class in FWH sources?
this is a new CLASS which i just write for FiveWin :wink:

---

have found out that COMBOBOX under FiveWin does use "old" MeasureItem Value when resize
https://docs.microsoft.com/de-de/windows/win32/controls/combo-box-styles

CBS_OWNERDRAWFIXED does receive WM_MEASUREITEM once while
CBS_OWNERDRAWVARIABLE will receive WM_MEASUREITEM for each Item


now i have figure out how COMBOBOX Ownerdraw work under FiveWin
but i have a (small) "Problem" at Start : i need to resize (e.g maximize) to "see" COMBOBOX ...
Code: Select all  Expand view  RUN
*+--------------------------------------------------------------------
*+
*+ Source Module => c:\fwh\0\IPTV\RESIZE.PRG
*+
*+    Copyright(C) 1983-2022 by Auge & Ohr
*+
*+    Functions: Function Main()
*+               Static Function DlgResize()
*+
*+    Reformatted by Click! 2.05.40 on Jul-29-2022 at  5:26 am
*+
*+--------------------------------------------------------------------

#include "fivewin.ch"

#define COLOR_HIGHLIGHT      13
#define COLOR_HIGHLIGHTTEXT  14
#define COLOR_WINDOW          5
#define COLOR_WINDOWTEXT      6

*+--------------------------------------------------------------------
*+
*+    Function Main()
*+
*+--------------------------------------------------------------------
*+
FUNCTION Main()

LOCAL oDlg, oFont, oCombo
LOCAL nVal := 123456
LOCAL cCombo := "1"
LOCAL aItems := {"1","2","3","4","5","6","7","8","9","10"}

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 12

   DEFINE DIALOG oDlg SIZE 400, 250 PIXEL TRUEPIXEL RESIZABLE FONT oFont

      @ 50, 20 SAY "Value :" SIZE 80, 24 PIXEL OF oDlg RIGHT VCENTER
      @ 50, 140 GET nVal PICTURE "99,999,999.99" SIZE 100, 24 PIXEL OF oDlg

      @ 100, 20 COMBOBOX oCombo VAR cCombo ITEMS aItems SIZE 240, 300 PIXEL OF oDlg ;
           OWNERDRAW OwnerDrawItem( Self, nIdCtl, oItemStruct )

      @ 150, 280 BTNBMP PROMPT "Ok" SIZE 100, 40 PIXEL FLAT

      //
      oDlg:Cargo := { oDlg:nWidth, oDlg:nHeight, oDlg:oFont:nHeight }
      oDlg:OnResize := { | o | DlgResize( o ) }
      //

      ACTIVATE DIALOG oDlg CENTERED ;
        ON INIT( AEVAL( oDlg:aControls, { | o | o:Cargo := { o:nTop, o:nLeft, o:nWidth, o:nHeight, o:oFont:nHeight } } ) )

   RELEASE FONT oFont

RETURN nil

*+--------------------------------------------------------------------
*+
*+    Static Function DlgResize()
*+
*+    Called from ( resize.prg )   1 - function main()
*+
*+--------------------------------------------------------------------
*+
STATIC FUNCTION DlgResize( oDlg )
LOCAL xFactor := oDlg:nWidth / oDlg:Cargo[ 1 ]
LOCAL yFactor := oDlg:nHeight / oDlg:Cargo[ 2 ]
LOCAL oCtrl, h

   FOR each oCtrl in oDlg:aControls
      WITH OBJECT oCtrl
         :nTop := :Cargo[ 1 ] * yFactor
         :nLeft := :Cargo[ 2 ] * xFactor
         :nWidth := :Cargo[ 3 ] * xFactor
         :nHeight := :Cargo[ 4 ] * yFactor

         h := - :Cargo[ 5 ]
         h := - ROUND( ( h * yFactor ), 0 )

         IF h != :oFont:nInpHeight
            IF :IsKindOf( "TCOMBOBOX" )
               // Ownerdraw Combobox
               :nHeight += 300
               :HGet( h )
            ELSE
               :SetFont( :oFont:Modify( h ) )
               :Refresh()
            ENDIF
         ENDIF
      END
   NEXT

RETURN nil

FUNCTION OwnerDrawItem( Self, nIdCtl, oItem )
LOCAL oFont1, nClrText, nClrBack, cItem
LOCAL hDC    := oItem:hDC

   IF oItem:itemID >= 0
      cItem := oItem:itemData
      DEFINE Font oFont1 NAME oItem:itemData SIZE nil, oItem:nHeight
     #IFDEF __HMG__
      END FONT
     #ENDIF

      nClrText := IF( lAnd( oItem:itemState, 1 ), GetSysColor( COLOR_HIGHLIGHTTEXT ), GetSysColor( COLOR_WINDOWTEXT ) )
      nClrBack := IF( lAnd( oItem:itemState, 1 ), GetSysColor( COLOR_HIGHLIGHT ), GetSysColor( COLOR_WINDOW ) )

      FW_SayText( hDC, oItem:itemData, oItem:aRect, "L", oFont1, ;
                  nClrText, nARGB( 255, nClrBack ) )

      oFont1:End()
   ENDIF

RETURN 1

*+ EOF: RESIZE.PRG

what do i miss :?:
need some help please
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 48 guests