Auto-Ajuste de tela e componentes
Enviado: 24 Mar 2013 09:20
Justamente Jairo, é outra técnica mas era essa a intenção: ver resultado e comparar. Eu tinha pedido pro colega fazer uns testes baseado no código da primeira mensagem.Jairo Maia escreveu:não consigo ver diferença nenhuma em relação ao original. Tem que fazer algo para ver o que você diz?
Parabéns Luiz, gostei sim, você está conseguindo uma forma que parece ser mais prática e simples. Só que faltaram no seu exemplo postado os componentes: CHECKBOX, SPINNER, SLIDER e STATUSBAR. Deve ter sido porque você pegou o meu código antes da ultima atualização. Eu adicionei e funciona tudo bem menos com o STATUSBAR. Pois esse componente, ele se autoajusta e o acesso as propriedades são diferentes aos outros controles. Também observei que os tamanhos das fontes ficaram muito pequenas, mas acho que eu fiz algo errado:
Código: Selecionar todos
#include "hmg.ch"
Function Main()
Private cForm:='Principal'
DEFINE WINDOW Principal AT 126,66 WIDTH 648 HEIGHT 464 ;
TITLE 'AutoAdjust (c)2007-2010 MigSoft ' MAIN;
ON INIT dados_iniciais(cForm) ;
ON SIZE Auto_ajuste(cForm) ;
ON MAXIMIZE Auto_ajuste(cForm)
@ 18,31 FRAME frame_1 CAPTION "Datos Generales" ;
WIDTH 576 HEIGHT 321
principal.frame_1.fontcolor:={0,0,0}
principal.frame_1.fontname:='MS Sans Serif'
principal.frame_1.fontsize:= 10
@ 40,491 IMAGE image_1 PICTURE "HP_SAVE" ;
WIDTH 100 HEIGHT 100 STRETCH
@ 66,309 DATEPICKER datepicker_1 WIDTH 120 ;
FONT 'MS Sans Serif' SIZE 10
principal.datepicker_1.fontcolor:={0,0,0}
principal.datepicker_1.backcolor:={255,255,255}
DEFINE TAB tab_1 AT 40,40 WIDTH 250 HEIGHT 250 ;
FONT 'MS Sans Serif' SIZE 10
DEFINE PAGE " Page1 "
@ 48,24 GRID grid_1 WIDTH 200 HEIGHT 158 ;
HEADERS {'one','two'} WIDTHS {60,60} ;
FONT 'MS Sans Serif' SIZE 10
principal.grid_1.fontcolor:={0,0,0}
principal.grid_1.AddItem( {"Row1","Row1"} )
principal.grid_1.AddItem( {"Row2","Row2"} )
principal.grid_1.AddItem( {"Row3","Row3"} )
principal.grid_1.value:=1
END PAGE
DEFINE PAGE " Page2 "
@ 121,29 PROGRESSBAR progressbar_1 ;
WIDTH 191 HEIGHT 34 VALUE 25
principal.progressbar_1.fontcolor:={0,0,0}
END PAGE
END TAB
@ 108,308 LISTBOX list_1 WIDTH 158 HEIGHT 99 ;
FONT 'MS Sans Serif' SIZE 10
principal.list_1.fontcolor:={0,0,0}
principal.list_1.backcolor:={255,255,255}
principal.list_1.AddItem( "Item 1" )
principal.list_1.AddItem( "Item 2" )
principal.list_1.AddItem( "Item 3" )
principal.list_1.value:=1
@ 224,313 COMBOBOX combo_1 WIDTH 100 VALUE 2;
FONT 'MS Sans Serif' SIZE 10 ;
ITEMS {"MiniGUI","HMG","ooHG"}
principal.combo_1.fontcolor:={0,0,0}
principal.combo_1.backcolor:={255,255,255}
@ 243,488 BUTTON picbutt_3 PICTURE 'HMG_EDIT_CANCEL';
ACTION msginfo('Pic button pressed') WIDTH 100 HEIGHT 44
DEFINE RADIOGROUP RadioGroup_1
ROW 155
COL 490
WIDTH 100
HEIGHT 50
OPTIONS { 'Option 1','Option 2'}
VALUE 1
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
ONCHANGE Nil
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
TABSTOP .T.
VISIBLE .T.
TRANSPARENT .F.
SPACING 27
BACKCOLOR Nil
FONTCOLOR Nil
READONLY Nil
HORIZONTAL .F.
END RADIOGROUP
DEFINE RADIOGROUP RadioGroup_2
ROW 260
COL 310
WIDTH 160
HEIGHT 28
OPTIONS { 'Option 1','Option 2'}
VALUE 1
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
ONCHANGE Nil
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
TABSTOP .T.
VISIBLE .T.
TRANSPARENT .F.
SPACING 70
BACKCOLOR Nil
FONTCOLOR Nil
READONLY Nil
HORIZONTAL .T.
END RADIOGROUP
/*
DEFINE STATUSBAR FONT "Arial" SIZE 9
STATUSITEM "Test of StatusBar"
STATUSITEM "Test 2"
STATUSITEM "Test3"
END STATUSBAR
*/
DEFINE CHECKBOX Check_1
ROW 300
COL 40
WIDTH 100
HEIGHT 28
CAPTION "Check_1"
VALUE .F.
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
ONCHANGE Nil
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
BACKCOLOR NIL
FONTCOLOR NIL
HELPID Nil
TABSTOP .T.
VISIBLE .T.
TRANSPARENT .F.
END CHECKBOX
DEFINE SPINNER Spinner_1
ROW 300
COL 180
WIDTH 120
HEIGHT 24
RANGEMIN 1
RANGEMAX 10
VALUE 0
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
ONCHANGE Nil
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
TABSTOP .T.
VISIBLE .T.
WRAP .F.
READONLY .F.
INCREMENT 1
BACKCOLOR NIL
FONTCOLOR NIL
END SPINNER
DEFINE SLIDER Slider_1
ROW 300
COL 320
WIDTH 120
HEIGHT 35
RANGEMIN 1
RANGEMAX 10
VALUE 0
TOOLTIP ""
ONCHANGE Nil
HELPID Nil
TABSTOP .T.
VISIBLE .T.
BACKCOLOR NIL
END SLIDER
@ 362,35 LABEL label_1 WIDTH 95 HEIGHT 21 ;
VALUE 'Nombres' FONT 'MS Sans Serif' SIZE 10
principal.label_1.fontcolor:={0,0,0}
@ 361,150 TEXTBOX text_1 HEIGHT 24 WIDTH 219 ;
Font 'MS Sans Serif' size 10 MAXLENGTH 30
principal.text_1.fontcolor:={0,0,0}
principal.text_1.backcolor:={255,255,255}
@ 360,400 BUTTON button_1 CAPTION 'Aceptar' ;
ACTION msginfo('Button pressed') WIDTH 100 HEIGHT 28 ;
FONT 'MS Sans Serif' SIZE 10
principal.button_1.fontcolor:={0,0,0}
@ 360,507 BUTTON button_2 CAPTION 'Cancelar' ;
ACTION msginfo('Button pressed') WIDTH 100 HEIGHT 28 ;
FONT 'MS Sans Serif' SIZE 10
principal.button_2.fontcolor:={0,0,0}
END WINDOW
CENTER WINDOW principal
Activate Window principal
Return Nil
Function Dados_Iniciais(hwnd)
Local k, ControlName, ControlCount, ControlType
Local wd_ini:=GetProperty(hwnd,"Width"), hd_ini:=GetProperty(hwnd,"Height")
Public _rows,_cols,_wids,_heig,_font
ControlCount := Len ( _HMG_SYSDATA[3] )
_font:={}
_rows:={}
_cols:={}
_wids:={}
_heig:={}
For k := 1 To ControlCount
ControlName := _HMG_SYSDATA[2] [k]
// if _IsControlDefined ( ControlName, ParentForm )
ControlType := _HMG_SYSDATA[1] [k]
If ControlName<>"Message"
If ControlType <> "STATUSBAR"
_fnt:=(100/hd_ini)*getproperty(hwnd,ControlName,"fontsize")
_row:=(100/hd_ini)*getproperty(hwnd,ControlName,"row")
_col:=(100/wd_ini)*getproperty(hwnd,ControlName,"col")
_wid:=(100/wd_ini)*getproperty(hwnd,ControlName,"width")
_hei:=(100/hd_ini)*getproperty(hwnd,ControlName,"height")
aadd(_font,int(_fnt))
aadd(_rows,_row)
aadd(_cols,_col)
aadd(_wids,_wid)
aadd(_heig,_hei)
Endif
Endif
Next k
Return Nil
Function Auto_ajuste(hwnd)
Local k, ControlName, ControlCount, ControlType
Local wd, hd
wd:=GetProperty(hwnd,"width")
hd:=GetProperty(hwnd,"height")
ControlCount := Len ( _HMG_SYSDATA[3] )
For k := 1 To ControlCount
ControlName := _HMG_SYSDATA[2] [k]
ControlType := _HMG_SYSDATA[1] [k]
If ControlName<>"Message"
// If !Empty( ControlName ) .And. !( ControlType $ "MENU,HOTKEY,TOOLBAR,MESSAGEBAR,ITEMMESSAGE,TIMER" )
_fnt:=(hd*_font[k])/100
_row:=(hd*_rows[k])/100
_col:=(wd*_cols[k])/100
_wid:=(wd*_wids[k])/100
_hei:=(hd*_heig[k])/100
If _fnt<>0
SetProperty(hwnd,ControlName,"fontsize",_fnt)
Endif
SetProperty(hwnd,ControlName,"row",_row)
SetProperty(hwnd,ControlName,"col",_col)
SetProperty(hwnd,ControlName,"width",_wid)
SetProperty(hwnd,ControlName,"height",_hei)
Endif
Next k
Return NilAgradeço Luiz, Esgici e Jairo pelo interesse sobre o assunto. Tudo isto faz enriquecer a nossa ferramenta e consequentemente a nossa programação. :|<