#include "fivewin.ch"
Static oInfo
function Main()
Local mPolje
local bSetup := { | oObj, cTitle, nAt, nID, cClsName, oSelf | SetupDlg( oObj, cTitle, nAt, nID, cClsName, oSelf ) }
DEFINE DIALOG oDlg RESOURCE "JedMere"
REDEFINE COMBOBOX oPolje VAR mPolje ITEMS {"Sifra","Naziv"} ID 1002 OF oDlg
oDlg:bStart := { | | oInfo := TDlgResize():New( oDlg, bSetup ) }
oDlg:bResized := { | nSizeType, nWidth, nHeight | oInfo:Resize( nWidth, nHeight ) }
ACTIVATE DIALOG oDlg CENTERED
return nil
//----------------------------------------------------------------------------// Report
FUNCTION SetupDlg( oObj, cTitle, nAt, nID, cClsName, oSelf )
LOCAL oFindObj
oObj:nTopStyle := 1 // 1.NONE 2.Upper relative position 3.Follow to Under Control OR Dialog Bottom
oObj:nLeftStyle := 1 // 1.NONE 2.Left relative position 3.Follow to Right Control OR Dialog Right
oObj:nRightStyle := 1 // 1.NONE 2.Dialog Width * Appointment Control
oObj:nBottomStyle := 1 // 1.NONE 2.Dialog Bottom * Appointment Control
DO CASE
CASE nId == 1001 // Get
oObj:nTopStyle := 1
oObj:nLeftStyle := 3
oObj:nRightStyle := 1
oObj:nBottomStyle := 1
ENDCASE
RETURN NIL
CLASS TDlgResize
DATA oDlg
DATA aChilds AS ARRAY INIT {}
DATA nTop
DATA nLeft
DATA nBottom
DATA nRight
DATA nHeight
DATA nWidth
DATA bSetup
METHOD New( oDlg ) CONSTRUCTOR
METHOD GetChilds()
METHOD AddChild( hWnd )
METHOD Resize( nWidth, nHeight )
METHOD FindByID( nID )
ENDCLASS
METHOD New( oDlg, bSetup ) CLASS TDlgResize
LOCAL aRect := {}
LOCAL oChild
LOCAL nI
::oDlg := oDlg
//aRect := GetCoors( oDlg:hWnd )
aRect := GetWndRect( oDlg:hWnd )
::nTop := aRect[ 1 ]
::nLeft := aRect[ 2 ]
::nBottom := aRect[ 3 ]
::nRight := aRect[ 4 ]
::nHeight := aRect[ 3 ] - aRect[ 1 ] + 1
::nWidth := aRect[ 4 ] - aRect[ 2 ] + 1
::bSetup := bSetup
::GetChilds()
IF ::bSetup <> NIL
FOR nI := 1 TO LEN( ::aChilds )
oChild := ::aChilds[ nI ]
EVAL ( ::bSetup, oChild, GetWindowText( oChild:hWnd ), nI, oChild:nID , oChild:cClsName, Self )
NEXT
ENDIF
RETURN Self
//
METHOD GetChilds() CLASS TDlgResize
::aChilds := {}
EnumChildWindows( ::oDlg:hWnd , { | hWnd | ::AddChild( hWnd ) } )
return NIL
//
METHOD AddChild( hWnd ) CLASS TDlgResize
LOCAL oChild
oChild := TDlgResizeItem():New( hWnd, Self )
AADD ( ::aChilds, oChild )
return nil
//
METHOD Resize( nWidth, nHeight ) CLASS TDlgResize
local ni
AEVAL ( ::aChilds, {|o|o:lResized := .f. } )
AEVAL ( ::aChilds, {|o|o:Resize( nWidth, nHeight ) } )
::oDlg:Refresh(.f.)
RETURN NIL
//
METHOD FindByID( nID ) CLASS TDlgResize
LOCAL nI
FOR nI := 1 TO LEN( ::aChilds )
IF ::aChilds[nI]:nID == nID
RETURN ::aChilds[nI]
ENDIF
NEXT
MsgInfo( "ID "+ALLTRIM(STR(nId))+" not found. So return 1")
RETURN 1
#pragma BEGINDUMP
#include <Windows.h>
#include <hbapi.h>
#include <hbapiitm.h>
static PHB_ITEM pCodeBlock = NULL, pParam = NULL;
static BOOL CALLBACK EnumChildProc( HWND hWnd, LPARAM lParam )
{
PHB_ITEM pNumber = hb_itemPutNL( NULL, ( LONG ) hWnd );
if( lParam )
hb_evalBlock( pCodeBlock, pNumber, lParam, NULL );
else
hb_evalBlock1( pCodeBlock, pNumber );
hb_itemRelease( pNumber );
return TRUE;
}
HB_FUNC( ENUMCHILDWINDOWS )
{
pCodeBlock = hb_param( 2, HB_IT_BLOCK );
pParam = hb_param( 3, HB_IT_NUMERIC );
hb_retl( EnumChildWindows( ( HWND ) hb_parnl( 1 ), EnumChildProc, hb_parnl( 2 ) ) );
pCodeBlock = NULL;
pParam = NULL;
}
HB_FUNC( GETDLGCTRLID )
{
hb_retni( GetDlgCtrlID( ( HWND ) hb_parnl( 1 ) ) );
}
#pragma ENDDUMP
//
CLASS TDlgResizeItem
DATA oParent
DATA oDlg
DATA hWnd
DATA nTop
DATA nLeft
DATA nBottom
DATA nRight
DATA nHeight
DATA nWidth
DATA nTopStyle
DATA nLeftStyle
DATA nRightStyle
DATA nBottomStyle
DATA aRect2
DATA lResized AS LOGICAL INIT .F.
DATA nID
DATA cClsName
METHOD New() CONSTRUCTOR
METHOD Resize ( nWidth, nHeight )
ENDCLASS
//
METHOD New( hWnd, oParent ) CLASS TDlgResizeItem
LOCAL aRect := {}
LOCAL aRect2 := {}
::oParent := oParent
::oDlg := oParent:oDlg
::hWnd := hWnd
aRect := GetCoors( ::hWnd ) // Absolute coordinate
::aRect2 := GetWndRect( ::hWnd )
::nId := GetDlgCtrlID( ::hWnd )
::cClsName := GetClassName( ::hWnd )
::nTop := aRect[ 1 ]
::nLeft := aRect[ 2 ]
::nBottom := aRect[ 3 ]
::nRight := aRect[ 4 ]
::nHeight := aRect[ 3 ] - aRect[ 1 ] + 1
::nWidth := aRect[ 4 ] - aRect[ 2 ] + 1
RETURN Self
//
METHOD Resize ( nWidth, nHeight ) CLASS TDlgResizeItem
LOCAL nTop
LOCAL nLeft
LOCAL nHeight2
LOCAL nWidth2
LOCAL oObj
LOCAL aRect
LOCAL lNoChangeHeight := .f.
LOCAL lNoChangeWidth := .f.
IF ::lResized
RETURN NIL
ENDIF
::lResized := .T.
IF nHeight >= ::oParent:nHeight
nTop := int ( ( nHeight * ::nTop / ::oParent:nHeight ) ) // top
nHeight2 := int ( ( nHeight * ::nHeight / ::oParent:nHeight ) ) // height
ELSE
nTop := ::nTop
nHeight2 := ::nHeight
lNoChangeHeight := .t.
ENDIF
IF nWidth >= ::oParent:nWidth
nLeft := int ( ( nWidth * ::nLeft / ::oParent:nWidth ) )
nWidth2 := int ( ( nWidth * ::nWidth / ::oParent:nWidth ) )
ELSE
nLeft := ::nLeft
nWidth2 := ::nWidth
lNoChangeWidth := .t.
ENDIF
/*
IF lNoChangeHeight .or. lNoChangeWidth
MoveWindow( ::hWnd, ::nTop, ::nLeft, ::nWidth, ::nHeight, .t. )
RETURN NIL
ENDIF
*/
DO CASE
CASE ::nTopStyle == 1
nTop := ::nTop
CASE ::nTopStyle == 3
nTop := nHeight - ::nHeight - ( ::oParent:nBottom - ::aRect2[3] ) + 1
ENDCASE
DO CASE
CASE ::nLeftStyle == 1
nLeft := ::nLeft
CASE ::nLeftStyle == 3
nLeft := nWidth - ::nWidth - ( ::oParent:nRight - ::aRect2[4] ) + 1
ENDCASE
IF VALTYPE ( ::nRightStyle ) == "N"
DO CASE
CASE ::nRightStyle == 1
nWidth2 := ::nWidth
ENDCASE
ELSE
oObj := ::nRightStyle
oObj:Resize( nWidth, nHeight )
aRect := GetCoors( oObj:hWnd )
nWidth2 := aRect[2] - nLeft - ( oObj:aRect2[2] - ::aRect2[4] )
ENDIF
IF VALTYPE( ::nBottomStyle ) == "N"
DO CASE
CASE ::nBottomStyle == 1
nHeight2 := ::nHeight
ENDCASE
ELSE
oObj := ::nBottomStyle
oObj:Resize( nWidth, nHeight )
aRect := GetCoors( oObj:hWnd )
nHeight2 := aRect[1] - nTop - ( oObj:aRect2[1] - ::aRect2[3] )
ENDIF
MoveWindow( ::hWnd, nTop, nLeft, nWidth2, nHeight2, .t. )
RETURN NIL
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 10.00".
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
JEDMERE DIALOG DISCARDABLE 26, -5, 199, 71
STYLE WS_POPUP|DS_MODALFRAME|WS_THICKFRAME|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_VISIBLE
CAPTION "Merne jedinice"
FONT 8, "MS Sans Serif"
{
CONTROL "", 1002, "ComboBox", WS_BORDER|CBS_DROPDOWNLIST|CBS_NOINTEGRALHEIGHT|WS_VSCROLL|WS_TABSTOP, 51, 21, 72, 182
}
#include "FiveWin.ch"
#include "constant.ch"
Function TestDlgResize()
local oDlg,oFont,oBold
local oBtn1
local oBtn2
local oBrowse
local aDatasample := { ;
{ '1', "61", "44", "50", "41", "39" }, ;
{ '2', "68", "4", "54", "22", "88" }, ;
{ '3', "Fi", "89", "9", "98", "56" },;
{ '4', "44", "Ve", "27", "12", "41" },;
{ '5', "19", "36", "Win", "89", "34" },;
{ '6', "2", "5", "30", "76", "33" }}
local nBottom := 20
local nRight := 55
Local nWd := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHt := nBottom * DLG_CHARPIX_H
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12 BOLD
DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL;
RESIZABLE FONT oFont TITLE "test resize" COLOR CLR_BLACK, CLR_HGRAY ;
STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
WS_MINIMIZEBOX, WS_THICKFRAME )
@ 18, 120 XBROWSE oBrowse OF oDlg SIZE 250,150 PIXEL;
AUTOCOLS ARRAY aDataSample NOBORDER;
CELL LINES FASTEDIT FONT oFont
SampleBrwRowConfig (oBrowse)
AEval( oBrowse:aCols, { |o| ; //o:nEditType := EDIT_GET,
o:nWidth := 40, ;
o:nDataStrAlign := AL_CENTER } )
oBrowse:CreateFromCode()
@ 10, 550 COMBOBOX oBrowse:oSortCbx VAR oBrowse:cSortOrder;
SIZE 300,400 PIXEL OF oDlg HEIGHTGET 20 STYLE CBS_DROPDOWN
@ 100,10 BUTTON oBtn1 PROMPT "Ok" of oDlg SIZE 80,22 DEFAULT ACTION ( oDlg:end( IDOK ) )
@ 100,10 BUTTON oBtn2 PROMPT "Close" of oDlg SIZE 80,22 CANCEL ACTION ( oDlg:end( IDCANCEL ) )
oDlg:bResized := <||
local oRect := oDlg:GetCliRect()
oBrowse:oSortCbx:nTop := oRect:nBottom - 75
oBrowse:oSortCbx:nLeft := oRect:nLeft +25
oBtn1:nLeft := oRect:nRight - 200
oBtn1:nTop := oRect:nBottom - 25
oBtn2:nLeft := oRect:nRight - 100
oBtn2:nTop := oRect:nBottom - 25
return nil
>
ACTIVATE DIALOG oDlg CENTER ;
ON INIT (oDlg:resize())
RETURN NIL
Function SampleBrwRowConfig (oBrw)
oBrw:RecSelShowKeyNo()
oBrw:lVScroll := .f.
oBrw:lHScroll := .f.
oBrw:lRecordSelector := .f.
oBrw:lAllowRowSizing := .t.
oBrw:lColDividerComplete := .t.
oBrw:lAllowColSwapping := .t.
oBrw:lAllowColHiding := .t.
oBrw:lFastEdit := .f.
oBrw:lfooter := .f.
oBrw:nRowSel := 1
oBrw:nColSel := 1
oBrw:nColOffset := 1
oBrw:nFreeze := 0
oBrw:nCaptured := 0
oBrw:nLastEditCol := 0
oBrw:l2007 := .f.
oBrw:l2015 := .t.
oBrw:nColDividerStyle := LINESTYLE_LIGHTGRAY
oBrw:nRowDividerStyle := LINESTYLE_LIGHTGRAY
oBrw:nHeaderHeight := 24
oBrw:nRowHeight := 22
oBrw:lExcelCellWise := .f.
oBrw:nClrBorder := CLR_GRAY
oBrw:lDrawBorder := .t.
oBrw:bRecSelHeader := { || " " }
RETURN nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 55 guests