Page 1 of 1

Posición de Tcalendar en un Dialogo

Posted: Wed Apr 27, 2011 12:31 pm
by Marcelo Via Giglio
Hola,

saben como ubicar un tcalendar en un dialogo diseñado desde código?

El siguiente ejemplo no mustra el calendario al inicio (0,0) del dialogo, pero si en el lugar del
definimos un window la cosa cambia y si funciona

Code: Select all

#include "FiveWin.ch"
#include "calendar.ch"

FUNCTION Main()
   LOCAL oWnd, oCal
   LOCAL dHoy := Date()

   SET DATE TO BRITISH
   SET EPOCH TO 1980   
   
 
   DEFINE DIALOG oWnd FROM 0, 0 TO 170, 170 PIXEL 
  
   @ 0, 0 CALENDAR oCal VAR dHoy OF oWnd PIXEL DAYSTATE size 100,100
    
   ACTIVATE DIALOG oWnd ON INIT oCal:move(0,0)

 
RETURN NIL

Re: Posición de Tcalendar en un Dialogo

Posted: Wed Apr 27, 2011 2:25 pm
by Daniel Garcia-Gil
Marcelo

El problema (que no es problema) viene del api de window, el api usa unidades logicas para las coordenadas de los dialogos, luego son transformadas a pixels despues de su creacion, usando algoritmos de conversion dependiendo del "font", el tema no es tan simple, pero es loq ue nos ofrece el api

http://msdn.microsoft.com/en-us/library ... S.85).aspx

el tamaño del calendar es mas "grande", reducelo

tips: detalla la relacion del tamaño del dialogo con el tamaño del control

Code: Select all

#include "FiveWin.ch"
#include "calendar.ch"

FUNCTION Main()
   LOCAL oWnd, oCal
   LOCAL dHoy := Date()

   SET DATE TO BRITISH
   SET EPOCH TO 1980   
   
 
   DEFINE DIALOG oWnd FROM 0, 0 TO 150, 170 PIXEL 
  
   @ 0, 0 CALENDAR oCal VAR dHoy OF oWnd PIXEL DAYSTATE size 85,75
    
   ACTIVATE DIALOG oWnd ON INIT oCal:move(0,0)

 
RETURN NIL

Re: Posición de Tcalendar en un Dialogo

Posted: Wed Apr 27, 2011 2:31 pm
by Marcelo Via Giglio
Daniel,

gracias por responder

Marcelo

Re: Posición de Tcalendar en un Dialogo

Posted: Wed Apr 27, 2011 8:02 pm
by Silvio
Daniel,
I tried to inser your calendar on dialog but perhaps on windows seven there is an error

look the picture

I see a space , the control is at @0,0 but it show on down of the caption

any idea ?

Image

Re: Posición de Tcalendar en un Dialogo

Posted: Wed Apr 27, 2011 8:05 pm
by Daniel Garcia-Gil
Silvio

whats is the dialog and calendar size???

Re: Posición de Tcalendar en un Dialogo

Posted: Wed Apr 27, 2011 8:31 pm
by Silvio
I have windows seven 64 bit home premium


#include "FiveWin.ch"
#include "calendar.ch"
#include "constant.ch"

FUNCTION SHW_CAL()
LOCAL oWnd, oCal
LOCAL dHoy := Date()
Local nBottom := 13
Local nRight := 25.4
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
Local oFontCal :=TFont():New( GetDefaultFontName(), 0, GetDefaultFontHeight(),, )

SET DATE TO BRITISH
SET EPOCH TO 1980


DEFINE DIALOG oWnd SIZE nWidth, nHeight PIXEL ;
STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION, 4 );
TITLE "Seleziona una data" FONT oFontCal

@ 0, 0 CALENDAR oCal VAR dHoy OF oWnd PIXEL DAYSTATE size 100,100

ACTIVATE DIALOG oWnd ON INIT oCal:move(0,0)

RETURN dHoy


//-----------------------------------------------------------------//
#pragma BEGINDUMP
#include "Windows.h"
#include "hbapi.h"


HB_FUNC( GETDEFAULTFONTNAME )
{
LOGFONT lf;
GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT ) , sizeof( LOGFONT ), &lf );
hb_retc( lf.lfFaceName );
}

HB_FUNC( GETDEFAULTFONTHEIGHT )
{
LOGFONT lf;
GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT ) , sizeof( LOGFONT ), &lf );
hb_retni( lf.lfHeight );
}
#pragma ENDDUMP

Re: Posición de Tcalendar en un Dialogo

Posted: Wed Apr 27, 2011 8:47 pm
by Daniel Garcia-Gil
Silvio

you need more small calendar area... 85, 75

Re: Posición de Tcalendar en un Dialogo

Posted: Wed Apr 27, 2011 9:01 pm
by Silvio
for these measure I not see all the calendar on windows seven do you want see it ?

pls look it


Image

Re: Posición de Tcalendar en un Dialogo

Posted: Wed Apr 27, 2011 9:34 pm
by Daniel Garcia-Gil
Silvio

you should calculate the control size

Re: Posición de Tcalendar en un Dialogo

Posted: Thu Apr 28, 2011 7:10 am
by Silvio
ok, but I saw on Win xp it could be easy

then when I try it on Seven I have some problems.....

I saw for sample one dialog with says on xp run ok

the same dialog with the same says at same coordinates run bad

I think we must rewrite all dialog for windows seven and I have many problems because I must create two version for the same application