PB à toute heure et à tout moment. (à parcourir avec modération)

Le forum (ô combien francophone) des utilisateurs de Powerbuilder.

Recherche rapide

Annonce

Certaines rubriques, dont des cours, sont uniquement visibles par les membres du forum ^^.
Dans la rubrique Liens & Références, vous avez accès à un sommaire de téléchargement, profitez-en !
Il existe maintenant un nouveau TOPIC "Votre CV en Ligne" accessible uniquement par demande.

#1 26-02-2007 15:13:32

wazou1812  
Modératrice
Award: bf
Date d'inscription: 24-05-2006
Messages: 610
Pépites: 2,097
Banque: 3,536,631,712,504

[RESOLU] Le control MonthCalendar en PB 10

Bonjour,

Quelqu'un a t-il déjà utilisé le nouveau control MonthCalendar de la version 10 de PB.

Pourriez vous me donner un exemple de code.

Hors ligne

 

#2 26-02-2007 15:43:15

thezerg  
Modérateur
Award: calimero
Lieu: Bordeaux
Date d'inscription: 12-09-2006
Messages: 966
Pépites: 22,449
Banque: 154,120,629,477,379,100

Re: [RESOLU] Le control MonthCalendar en PB 10

désole je bosse pas sous PB10

Personne ne peut l'aider?

Hors ligne

 

#3 26-02-2007 18:35:04

erasorz  
Admin
Lieu: Babylone
Date d'inscription: 23-11-2006
Messages: 5121
Pépites: 97,197
Banque: 2,147,483,647

Re: [RESOLU] Le control MonthCalendar en PB 10

wazou1812 a écrit:

Quelqu'un a t-il déjà utilisé le nouveau control MonthCalendar de la version 10 de PB.
Pourriez vous me donner un exemple de code.

Le MonthCalendar est utilisé pour sélectionner une plage de dates : (MonthCalendar)

http://infocenter.sybase.com/help/topic/com.sybase.help.pb_10.5.pbug/html/pbug/mcal01.gif

Le DatePicker est utilisé pour sélectionner une date unique : (DatePicker)

http://infocenter.sybase.com/help/topic/com.sybase.help.pb_10.5.pbug/html/pbug/dtpckr01.gif

Pour le code : rien de spécial, c'est un contrôle comme un autre que tu places dans une fenêtre ou une DW, regarde les propriétés et les méthodes pour y accèder dans la doc


N'envoyez jamais un humain faire le travail d'un programme.

Hors ligne

 

#4 27-02-2007 08:39:13

wazou1812  
Modératrice
Award: bf
Date d'inscription: 24-05-2006
Messages: 610
Pépites: 2,097
Banque: 3,536,631,712,504

Re: [RESOLU] Le control MonthCalendar en PB 10

Super et Merci , vous pouvez mettre Résolu......

Hors ligne

 

#5 30-05-2007 08:41:13

JCZ  
Builder Power
Award: bf
Lieu: 75019 paris
Date d'inscription: 21-05-2007
Messages: 1724
Pépites: 496,453,703,213
Banque: 9,223,372,036,854,776,000

Re: [RESOLU] Le control MonthCalendar en PB 10

tu peux utiliser ce bout de code c'est un userobject appeler u_hepek_calendar

Code: pb

forward
global type u_hepek_calendar from userobject
end type
type lb_months from u_months_list within u_hepek_calendar
end type
type st_aujour from statictext within u_hepek_calendar
end type
type cb_next_day from commandbutton within u_hepek_calendar
end type
type cb_prev_day from commandbutton within u_hepek_calendar
end type
type cb_next_month from commandbutton within u_hepek_calendar
end type
type cb_next_year from commandbutton within u_hepek_calendar
end type
type cb_prev_month from commandbutton within u_hepek_calendar
end type
type cb_prev_year from commandbutton within u_hepek_calendar
end type
type dw_calendar from datawindow within u_hepek_calendar
end type
end forward

global type u_hepek_calendar from userobject
integer width = 599
integer height = 640
long backcolor = 79741120
long tabtextcolor = 33554432
long tabbackcolor = 79741120
long picturemaskcolor = 553648127
event hpk_lose_focus ( )
lb_months lb_months
st_aujour st_aujour
cb_next_day cb_next_day
cb_prev_day cb_prev_day
cb_next_month cb_next_month
cb_next_year cb_next_year
cb_prev_month cb_prev_month
cb_prev_year cb_prev_year
dw_calendar dw_calendar
end type
global u_hepek_calendar u_hepek_calendar

type prototypes

end prototypes

type variables
Integer     ii_old_column, &
        ii_day, ii_month, ii_year
Date           id_date_selected, id_date_min, id_date_max
Time      it_time_selected
String     is_column
DataWindow   idw
Window    iw_parent
Boolean    ib_help_requested = FALSE
Integer     il_type_op 
  // barre si 
  //   1  --> id_date_min < ld_date
  //   2  --> id_date_min <= ld_date
  //   3  --> id_date_min = ld_date
  //   4  --> id_date_min >= ld_date
  //   5  --> id_date_min > ld_date

  //  11 --> id_date_min < ld_date and ld_date < id_date_max
  //  12 --> id_date_min <= ld_date and ld_date <= id_date_max
  //  13 --> id_date_min = ld_date and id_date_max = ld_date
  //  14 --> id_date_min >= ld_date or id_date_max <= ld_date
  //  15 --> id_date_min > ld_date or id_date_max < ld_date


Integer     ii_NOFH_visible = 0


Date          id_date
EditMask        iem_mask
SingleLineEdit    isle_edit
String        is_object_name

end variables
forward prototypes
public subroutine of_set_position ()
public function integer of_get_month_number (string as_month)
public function string of_date_string ()
public function integer of_days_in_month (integer ai_month, integer ai_year)
public function string of_get_month_string (integer as_month)
public subroutine of_init_calendar (date ad_start_date)
public subroutine of_set_date_min (date ad_date)
public subroutine of_set_date_interval (date ad_date_min,date ad_date_max)
public function integer of_barre_visible (integer ai_strikethrough, string as_column)
public subroutine of_draw_month (integer ai_year, integer ai_month)
public subroutine of_enter_day_numbers (integer ai_start_day_num, integer ai_days_in_month)
public subroutine of_set_nofh_visible (integer ai_nofh_visible)
public subroutine of_fermeture_visible ()
public subroutine of_set_type_op (integer ai_type_op)
public subroutine of_set_date (date adt_date)
public subroutine of_show_calendar (datawindow adw, string as_object_name)
public subroutine of_show_calendar (editmask aem_mask)
public subroutine of_show_calendar (singlelineedit asle_edit)
end prototypes

event hpk_lose_focus;PowerObject lpo_object

// If user asked for Help MessageBox, then do not hide calendar
IF ib_help_requested THEN Return
IF KeyDown(KeyTab!) THEN Return

lpo_object = GetFocus()

// If calendar loses focus then hide it
//this.cb_next_day,&
//this.cb_prev_day,&
//this.cb_aujour,&
//this.cb_next_month,&
//this.cb_next_year,&
//this.cb_prev_month,&
//this.cb_prev_year,&
//this.dw_calendar
IF  lpo_object <> control[1] &
AND lpo_object <> control[2] &
AND lpo_object <> control[3] &
AND lpo_object <> control[4] &
AND lpo_object <> control[5] &
AND lpo_object <> control[6] &
AND lpo_object <> control[7] &
AND lpo_object <> control[8] THEN Hide()

end event

public subroutine of_set_position ();Integer li_X, li_Y

li_X = iw_parent.PointerX() - Width + 5
li_Y = iw_parent.PointerY() + 10

// Check if calendar excides frame Width
IF li_X < 0 THEN li_X = li_X + Width
IF li_Y + Height > iw_parent.WorkSpaceHeight() THEN li_Y -= Height

// Move calendar to appropriate coordinates
Move(li_X, li_Y)

SetPosition(ToTop!)

BringToTop = TRUE

end subroutine

public function integer of_get_month_number (string as_month);Integer li_month_number

CHOOSE CASE as_month
  CASE 'Jan'
    li_month_number = 1
  CASE 'Feb'
    li_month_number = 2
  CASE 'Mar'
    li_month_number = 3
  CASE 'Apr'
    li_month_number = 4
  CASE 'May'
    li_month_number = 5
  CASE 'Jun'
    li_month_number = 6
  CASE 'Jul'
    li_month_number = 7
  CASE 'Aug'
    li_month_number = 8
  CASE 'Sep'
    li_month_number = 9
  CASE 'Oct'
    li_month_number = 10
  CASE 'Nov'
    li_month_number = 11
  CASE 'Dec'
    li_month_number = 12
END CHOOSE

Return li_month_number
end function

public function string of_date_string ();Return String(ii_year) + '/' + String(ii_month) + '/'+ String(ii_day)

end function

public function integer of_days_in_month (integer ai_month, integer ai_year);Integer  ln_days_in_month
Boolean  lb_leap_year

CHOOSE CASE ai_month
  CASE 1, 3, 5, 7, 8, 10, 12
    ln_days_in_month = 31
  CASE 4, 6, 9, 11
    ln_days_in_month = 30
  CASE 2
    // Check for leap year
    If IsDate(string(ai_year) + '/2/29') Then
      ln_days_in_month = 29
    Else
       ln_days_in_month = 28
    End If
END CHOOSE

Return ln_days_in_month
end function

public function string of_get_month_string (integer as_month);String ls_month

CHOOSE CASE as_month
  CASE 1
    ls_month = 'Janvier ' + string(ii_year,'0000')
  CASE 2
    ls_month = 'Février ' + string(ii_year,'0000')
  CASE 3
    ls_month = 'Mars ' + string(ii_year,'0000')
  CASE 4
    ls_month = 'Avril ' + string(ii_year,'0000')
  CASE 5
    ls_month = 'Mai ' + string(ii_year,'0000')
  CASE 6
    ls_month = 'Juin ' + string(ii_year,'0000')
  CASE 7
    ls_month = 'Juillet ' + string(ii_year,'0000')
  CASE 8
    ls_month = 'Août ' + string(ii_year,'0000')
  CASE 9
    ls_month = 'Sept. ' + string(ii_year,'0000')
  CASE 10
    ls_month = 'Octobre ' + string(ii_year,'0000')
  CASE 11
    ls_month = 'Nov. ' + string(ii_year,'0000')
  CASE 12
    ls_month = 'Déc. ' + string(ii_year,'0000')
END CHOOSE

Return ls_month
end function

public subroutine of_init_calendar (date ad_start_date);Integer  li_first_day_number, li_current_cell, li_days_in_month, li_i
String   ls_year, ls_modify, ls_return
Date     ld_first_day_in_month

// Set the variables for Day, Month and Year from the date passed to the function                                    */
ii_month = Month(ad_start_date)
ii_year  = Year(ad_start_date)
ii_day   = Day(ad_start_date)

// Find how many days in the relevant month
li_days_in_month = of_days_in_month(ii_month, ii_year)

// Find the date of the first day of this month
ld_first_day_in_month = Date(ii_year, ii_month, 1)

// What day of the week is the first day of the month
li_first_day_number = DayNumber(ld_first_day_in_month)

// Set the starting 'cell' in the datawindow. i.e the column in which
// the first day of the month will be displayed
li_current_cell = li_first_day_number + ii_day - 1

// Set the Title of the calendar with the Month and Year
//dw_calendar.Modify("st_year.text   = ~"" + String(ii_year) + "~"")
dw_calendar.Modify("st_month.text = ~""  + of_get_month_string(ii_month) + "~"")

// Enter the numbers of the days
of_enter_day_numbers(li_first_day_number, li_days_in_month)

dw_calendar.SetItem(1, li_current_cell, String(Day(ad_start_date)))

// Display the current day in bold and 3D
ls_modify = '#' + String(li_current_cell) + '.border=5'
ls_return = dw_calendar.Modify(ls_modify)
IF ls_return <> '' THEN MessageBox('Modify', ls_return)
ls_modify = '#' + String(li_current_cell) + '.Font.Weight=700'
ls_return = dw_calendar.Modify(ls_modify)
IF ls_return <> '' THEN MessageBox('Modify', ls_return)

// Affichage de la journée d'aujourd'hui en rouge
// On remet toutes les cellules en noir puis celle du jour en rouge
For li_i = 1 To 42
  ls_modify = '#' + String(li_i) + '.Color=0'
  ls_return = dw_calendar.Modify(ls_modify)
  IF ls_return <> '' THEN MessageBox('Modify', ls_return)
Next
If ii_month = Month(Today()) And ii_year = Year(Today()) Then
  ls_modify = '#' + String(li_first_day_number + Day(Today()) - 1) + '.Color=255'
  ls_return = dw_calendar.Modify(ls_modify)
  IF ls_return <> '' THEN MessageBox('Modify', ls_return)
Else
End if

// Set the instance variable i_old_column to hold the current cell,
// so when we change it, we know the old setting
ii_old_column = li_current_cell

end subroutine

public subroutine of_set_date_min (date ad_date);id_date_min = ad_date
end subroutine

public subroutine of_set_date_interval (date ad_date_min,date ad_date_max);id_date_max = ad_date_max
id_date_min = ad_date_min
end subroutine

public function integer of_barre_visible (integer ai_strikethrough, string as_column);string ls_return

If as_column <> '' then
  ls_return = dw_calendar.Modify(as_column + '.font.strikethrough="'+ string(ai_strikethrough)+'"')
  If ls_return <> "" then 
    MessageBox("Modify",ls_return)
    Return -1
  End if
End If

Return 1
end function

public subroutine of_draw_month (integer ai_year, integer ai_month);Integer  li_first_day_number, li_cell, li_days_in_month
Date     ld_first_day_in_month
String  ls_modify, ls_return

dw_calendar.SetRedraw(FALSE)

ii_month = ai_month
ii_year  = ai_year

// Check if the instance day is valid for month/year.
// Back the day down one if invalid for month ie 31 will become 30
DO WHILE Date(ii_year,ii_month,ii_day) = Date(00,1,1)
  ii_day --
LOOP

// Work out how many days in the month
li_days_in_month = of_days_in_month(ii_month, ii_year)

// Find the date of the first day in the month
ld_first_day_in_month = Date(ii_year, ii_month,1)

// Find what day of the week this is
li_first_day_number = DayNumber(ld_first_day_in_month)

// Set the first cell
li_cell = li_first_day_number + ii_day - 1

// If there was an old column turn off the highlight
IF ii_old_column <> 0 THEN
  ls_modify = '#' + string(ii_old_Column) + '.border=6'
  ls_return = dw_calendar.Modify(ls_modify)
  If ls_return <> '' THEN MessageBox('Modify', ls_return)
  ls_modify = '#' + string(ii_old_Column) + '.Font.Weight=400'
  ls_return = dw_calendar.Modify(ls_Modify)
  If ls_return <> '' THEN MessageBox('Modify', ls_return)
END IF

// Set the Title
//dw_calendar.Modify("st_year.text   = ~"" + String(ii_year) + "~"")
dw_calendar.Modify("st_month.text = ~""  + of_get_month_string(ii_month) + "~"")

of_enter_day_numbers(li_first_day_number,li_days_in_month)

dw_calendar.SetItem(1, li_cell, String(ii_day))

// Highlight the current date
ls_modify = '#' + string(li_cell) + '.border=5'
ls_return = dw_calendar.Modify(ls_modify)
IF ls_return <> '' THEN MessageBox('Modify',ls_return)
ls_modify = '#' + string(li_cell) + '.Font.Weight=700'
ls_return = dw_calendar.Modify(ls_Modify)
IF ls_return <> '' THEN MessageBox('Modify',ls_return)

// Set the old column for next time
ii_old_column = li_cell

// Reset the pointer and Redraw
SetPointer(Arrow!)
dw_calendar.SetRedraw(TRUE)

end subroutine

public subroutine of_enter_day_numbers (integer ai_start_day_num, integer ai_days_in_month);Integer  li_count, li_daycount
string  ls_modify, ls_return
Date     ld_date, ld_date_debut
Integer  li_barre

ld_date_debut = Date(ii_year, ii_month,1)
// Blank the columns before the first day of the month
FOR li_count = 1 TO ai_start_day_num
  dw_calendar.SetItem(1, li_count,'')
  of_barre_visible(0,'cell'+string(li_count))
NEXT

// Set the columns for the days to the String of their Day number
FOR li_count = 1 TO ai_days_in_month
  // Use li_daycount to find which column needs to be set
  li_daycount = ai_start_day_num + li_count - 1
  dw_calendar.SetItem(1, li_daycount, String(li_count))
  ld_date = RelativeDate(ld_date_debut,li_count - 1)
  IF Not Isnull(id_date_min) Then  
    li_barre = 0 
    choose case il_type_op
      case 1
        If id_date_min < ld_date Then
          li_barre = 1
        End if
      case 2
        If id_date_min <= ld_date Then
          li_barre = 1
        End if
      case 3
        If id_date_min = ld_date Then
          li_barre = 1
        End if
      case 4
        If id_date_min >= ld_date Then
          li_barre = 1
        End if
      case 5
        If id_date_min > ld_date Then
          li_barre = 1
        End if
      case 11
        If id_date_min < ld_date and ld_date < id_date_max Then
          li_barre = 1
        End if
      case 12
        If id_date_min <= ld_date and ld_date <= id_date_max Then
          li_barre = 1
        End if
      case 13
        If id_date_min = ld_date and id_date_max = ld_date  Then
          li_barre = 1
        End if
      case 14
        If id_date_min >= ld_date or id_date_max <= ld_date  Then
          li_barre = 1
        End if
      case 15
        If id_date_min > ld_date or id_date_max < ld_date  Then
          li_barre = 1
        End if
    end choose
    of_barre_visible(li_barre,'cell'+string(li_daycount))    
  End if
NEXT

// Move to next column
li_daycount = li_daycount + 1

// Blank remainder of columns
FOR li_count = li_daycount TO 42
  dw_calendar.SetItem(1, li_count,'')
  of_barre_visible(0,'cell'+string(li_count))  
NEXT

// If there was an old column turn off the highlight
IF ii_old_column <> 0 THEN
  ls_modify = '#' + string(ii_old_Column) + '.border=6'
  ls_return = dw_calendar.Modify(ls_modify)
  IF ls_return <> '' THEN MessageBox('Modify', ls_return)
  ls_modify = '#' + string(ii_old_Column) + '.Font.Weight=400'
  ls_return = dw_calendar.Modify(ls_Modify)
  IF ls_return <> '' THEN MessageBox('Modify', ls_return)
END IF

ii_old_column = 0

end subroutine

public subroutine of_set_nofh_visible (integer ai_nofh_visible);ii_NOFH_visible = ai_NOFH_visible
If ii_NOFH_visible > 0 Then 
  of_fermeture_visible()
End if
end subroutine

public subroutine of_fermeture_visible ();Integer  li_NOF1H, li_NOF2H , li_i, li_case
String   ls_modify, ls_return

select NOF1H,     NOF2H 
Into   :li_NOF1H, :li_NOF2H
from  r_agn;

If li_NOF1H > 0 and li_NOF1H < 8 Then 
  for li_i = 1 to 6
    li_case = li_NOF1H + 7 * (li_i - 1 )
    ls_modify = '#' + string(li_case) + '.background.color="12632256"'
    ls_return = dw_calendar.Modify(ls_modify)
    IF ls_return <> '' THEN 
      li_i = 8
      MessageBox('Modify', ls_return)
    End if        
  next
End if

If li_NOF2H > 0 and li_NOF2H < 8 Then 
  for li_i = 1 to 6
    li_case = li_NOF2H + 7 * (li_i - 1 )
    ls_modify = '#' + string(li_case) + '.background.color="12632256"'
    ls_return = dw_calendar.Modify(ls_modify)
    IF ls_return <> '' THEN 
      li_i = 8
      MessageBox('Modify', ls_return)
    End if        
  next
End if
end subroutine

public subroutine of_set_type_op (integer ai_type_op);il_type_op = ai_type_op
end subroutine

public subroutine of_set_date (date adt_date);
id_date = adt_date

end subroutine

public subroutine of_show_calendar (datawindow adw, string as_object_name);
String ls_current_data, ls_date, ls_col_type, ls_col_format
Date   ld_date
Integer li_pos

// Set the instance DW variable
idw = adw
is_object_name = as_object_name
SetNull(iem_mask)
SetNull(isle_edit)
lb_months.Visible = False

// Reset DataWindow and restore columns borders
dw_calendar.Event hpk_reset()

// Get current field value
If IsValid(idw) Then
  ls_current_data = idw.GetText() + ' '
End if

li_pos = Pos(ls_current_data, ' ', 1)
// Determine current column Date and Time if applicable
ls_date = Trim(Left(ls_current_data, li_pos))

// set date and time to null if no current value
IF ls_date = '' OR NOT IsDate(ls_date) THEN
  SetNull(ld_date)
ELSE
  ld_date = Date(ls_date)
END IF

// Set to today if no value in column
IF IsNull(ld_date) THEN ld_date = Today()

// initialize calendar
of_init_calendar(ld_date)

// position the calendar
of_set_position()

dw_calendar.SetFocus()
Show()

end subroutine

public subroutine of_show_calendar (editmask aem_mask);
String ls_current_data, ls_date, ls_col_type, ls_col_format
Date   ld_date
Integer li_pos

// Set the instance DW variable
iem_mask = aem_mask
SetNull(idw)
SetNull(isle_edit)
lb_months.Visible = False

// Reset DataWindow and restore columns borders
dw_calendar.Event hpk_reset()

// Get current field value
If IsValid(iem_mask) Then
  ls_current_data = iem_mask.Text + ' '
End if

li_pos = Pos(ls_current_data, ' ', 1)
// Determine current column Date and Time if applicable
ls_date = Trim(Left(ls_current_data, li_pos))

// set date and time to null if no current value
IF ls_date = '' OR NOT IsDate(ls_date) THEN
  SetNull(ld_date)
ELSE
  ld_date = Date(ls_date)
END IF

// Set to today if no value in column
IF IsNull(ld_date) THEN ld_date = Today()

// initialize calendar
of_init_calendar(ld_date)

// position the calendar
of_set_position()

dw_calendar.SetFocus()
Show()

end subroutine

public subroutine of_show_calendar (singlelineedit asle_edit);
String ls_current_data, ls_date, ls_col_type, ls_col_format
Date   ld_date
Integer li_pos

// Set the instance DW variable
isle_edit = asle_edit
SetNull(idw)
SetNull(iem_mask)
lb_months.Visible = False

// Reset DataWindow and restore columns borders
dw_calendar.Event hpk_reset()

// Get current field value
If IsValid(isle_edit) Then
  ls_current_data = isle_edit.Text + ' '
End if

li_pos = Pos(ls_current_data, ' ', 1)
// Determine current column Date and Time if applicable
ls_date = Trim(Left(ls_current_data, li_pos))

// set date and time to null if no current value
IF ls_date = '' OR NOT IsDate(ls_date) THEN
  SetNull(ld_date)
ELSE
  ld_date = Date(ls_date)
END IF

// Set to today if no value in column
IF IsNull(ld_date) THEN ld_date = Today()

// initialize calendar
of_init_calendar(ld_date)

// position the calendar
of_set_position()

dw_calendar.SetFocus()
Show()

end subroutine

on u_hepek_calendar.create
this.lb_months=create lb_months
this.st_aujour=create st_aujour
this.cb_next_day=create cb_next_day
this.cb_prev_day=create cb_prev_day
this.cb_next_month=create cb_next_month
this.cb_next_year=create cb_next_year
this.cb_prev_month=create cb_prev_month
this.cb_prev_year=create cb_prev_year
this.dw_calendar=create dw_calendar
this.Control[]={this.lb_months,&
this.st_aujour,&
this.cb_next_day,&
this.cb_prev_day,&
this.cb_next_month,&
this.cb_next_year,&
this.cb_prev_month,&
this.cb_prev_year,&
this.dw_calendar}
end on

on u_hepek_calendar.destroy
destroy(this.lb_months)
destroy(this.st_aujour)
destroy(this.cb_next_day)
destroy(this.cb_prev_day)
destroy(this.cb_next_month)
destroy(this.cb_next_year)
destroy(this.cb_prev_month)
destroy(this.cb_prev_year)
destroy(this.dw_calendar)
end on

event constructor;Hide()
iw_parent = GetParent()

end event

type lb_months from u_months_list within u_hepek_calendar
boolean visible = false
integer height = 640
integer taborder = 30
boolean border = true
borderstyle borderstyle = styleraised!
end type

event doubleclicked;call super::doubleclicked;String    ls_date_old, ls_date_new

ls_date_old = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

ii_month = index

ls_date_new = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

Do While Not IsDate(ls_date_new)
  ii_day = ii_day - 1
  If ii_day < 1 Then ii_day = 1
  ls_date_new = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')
Loop

of_init_calendar(Date(ls_date_new))

This.Visible = False

dw_calendar.SetFocus()

end event

event losefocus;call super::losefocus;This.Visible = False

end event

type st_aujour from statictext within u_hepek_calendar
integer x = 114
integer y = 568
integer width = 366
integer height = 56
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 16711680
long backcolor = 15780518
string text = "Aujourd~'hui"
alignment alignment = center!
long bordercolor = 33554431
boolean focusrectangle = false
end type

event clicked;of_init_calendar(today())

end event

event losefocus;Parent.Event hpk_lose_focus()

end event

type cb_next_day from commandbutton within u_hepek_calendar
integer x = 489
integer y = 556
integer width = 101
integer height = 80
integer taborder = 40
integer textsize = -16
integer weight = 400
fontcharset fontcharset = symbol!
fontpitch fontpitch = variable!
string facename = "Wingdings"
string text = "ð"
end type

event clicked;
String    ls_date_old, ls_date_new

ls_date_old = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

ii_day = ii_day + 1

ls_date_new = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

Do While Not IsDate(ls_date_new)
  ii_day = 1
  ii_month = ii_month + 1
  If ii_month = 13 Then
    ii_month = 1
    ii_year = ii_year + 1
  End if
  If ii_day < 1 Then ii_day = 1
  ls_date_new = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')
Loop

id_date_selected = Date(ls_date_new)
of_init_calendar(id_date_selected)

end event

type cb_prev_day from commandbutton within u_hepek_calendar
integer x = 9
integer y = 556
integer width = 101
integer height = 80
integer taborder = 30
integer textsize = -16
integer weight = 400
fontcharset fontcharset = symbol!
fontpitch fontpitch = variable!
string facename = "Wingdings"
string text = "ï"
end type

event clicked;
String    ls_date_old, ls_date_new

ls_date_old = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

ii_day = ii_day - 1

If ii_day = 0 Then
  ii_day = 31
  ii_month = ii_month - 1
  If ii_month = 0 Then
    ii_month = 12
    ii_year = ii_year - 1
  End if
End if

ls_date_new = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

Do While Not IsDate(ls_date_new)
  ii_day = 1
  ii_month = ii_month + 1
  If ii_month = 13 Then
    ii_month = 1
    ii_year = ii_year + 1
  End if
  If ii_day < 1 Then ii_day = 1
  ls_date_new = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')
Loop

id_date_selected = Date(ls_date_new)
of_init_calendar(id_date_selected)

end event

type cb_next_month from commandbutton within u_hepek_calendar
integer x = 489
integer y = 8
integer width = 50
integer height = 76
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
string text = ">"
end type

event clicked;
String    ls_date_old, ls_date_new

ls_date_old = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

ii_month = ii_month + 1

If ii_month = 13 Then
  ii_month = 1
  ii_year = ii_year + 1
End if

ls_date_new = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

Do While Not IsDate(ls_date_new)
  ii_day = ii_day - 1
  If ii_day < 1 Then ii_day = 1
  ls_date_new = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')
Loop

id_date_selected = Date(ls_date_new)
of_init_calendar(id_date_selected)

end event

type cb_next_year from commandbutton within u_hepek_calendar
integer x = 539
integer y = 8
integer width = 50
integer height = 76
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
string text = "+"
end type

event clicked;
String    ls_date_old, ls_date_new

ls_date_old = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

ii_year = ii_year + 1

ls_date_new = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

id_date_selected = Date(ls_date_new)
of_init_calendar(id_date_selected)

end event

type cb_prev_month from commandbutton within u_hepek_calendar
integer x = 59
integer y = 8
integer width = 50
integer height = 76
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
string text = "<"
end type

event clicked;
String    ls_date_old, ls_date_new

ls_date_old = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

ii_month = ii_month - 1

If ii_month = 0 Then
  ii_month = 12
  ii_year = ii_year - 1
End if

ls_date_new = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

Do While Not IsDate(ls_date_new)
  ii_day = ii_day - 1
  If ii_day < 1 Then ii_day = 1
  ls_date_new = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')
Loop

id_date_selected = Date(ls_date_new)
of_init_calendar(id_date_selected)

end event

type cb_prev_year from commandbutton within u_hepek_calendar
integer x = 9
integer y = 8
integer width = 50
integer height = 76
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
string text = "-"
end type

event clicked;
String    ls_date_old, ls_date_new

ls_date_old = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

ii_year = ii_year - 1

ls_date_new = String(ii_day, '##00') + '/' + String(ii_month, '##00') + '/'+ String(ii_year, '####0000')

id_date_selected = Date(ls_date_new)
of_init_calendar(id_date_selected)

end event

type dw_calendar from datawindow within u_hepek_calendar
event key pbm_dwnkey
event type boolean hpk_set_day ( integer ai_clicked_column )
event hpk_return_date_time ( )
event hpk_reset ( )
string tag = "TQBQW +12"
integer width = 599
integer height = 640
integer taborder = 20
string dataobject = "d_hepek_calendar"
boolean livescroll = true
borderstyle borderstyle = styleraised!
end type

event key;
IF key = KeyControl! THEN
  If IsValid(idw) Then
    idw.SetFocus()
  ElseIf IsValid(iem_mask) Then
    iem_mask.SetFocus()
  ElseIf IsValid(isle_edit) Then
    isle_edit.SetFocus()
  End if
  Return 1
END IF

IF key = KeyEscape! THEN 
  Parent.Hide()
  
  // Replace le focus
  If IsValid(idw) Then
    idw.SetFocus()
  ElseIf IsValid(iem_mask) Then
    iem_mask.SetFocus()
  ElseIf IsValid(isle_edit) Then
    isle_edit.SetFocus()
  End if
  SetNull(idw)
  SetNull(iem_mask)
  SetNull(isle_edit)
  lb_months.Visible = False
  
ELSEIF key = KeyEnter! THEN
  // Make shore that old column has some value
  IF Integer(GetItemString(1, ii_old_column)) > 0 THEN
    Event hpk_set_day(ii_old_column)
    Event hpk_return_date_time()
  END IF
ELSEIF key = KeyLeftArrow! THEN
  IF keyflags = 0 THEN  // Shift not pressed
    cb_prev_DAY.Event clicked()
  ELSEIF keyflags = 1 THEN
    // User Pressed Shift key - move to previous month
    cb_prev_month.Event clicked()
  END IF
ELSEIF key = KeyRightArrow! THEN 
  IF keyflags = 0 THEN  // Shift not pressed
    cb_next_DAY.Event clicked()
  ELSEIF keyflags = 1 THEN
    // User Pressed Shift key - move to next month
    cb_next_month.Event clicked()
  END IF
ELSEIF key = KeyUpArrow! THEN
  // move to next year
  cb_next_year.Event clicked()
ELSEIF key = KeyDownArrow! THEN
  // move to previous year
  cb_prev_year.Event clicked()
ELSEIF key = KeyTab! THEN
  SetRedraw(FALSE)

  POST SetFocus()

  POST SetRedraw(TRUE)

  Return 1
ELSE
  // IF Shift is pressed, do not display help
  IF keyflags <> 0 THEN Return
  // Help Keys, first set instance variable to prevent calendar from hiding
  ib_help_requested = TRUE
  Beep(1)
  Messagebox('Aide', 'Jour suivant           Right Arrow~r'       + &
               'Jour précédant         Left Arrow~r'       + &
               'Mois suivant           Shift + Right Arrow~r' + &
               'Mois précédant         Shift + Left Arrow~r'   + &
               'Valider                Entrée~r'           + &               
               'Annuler                Echap~r')
  ib_help_requested = FALSE
END IF
end event

event type boolean hpk_set_day(integer ai_clicked_column);String ls_day, ls_modify, ls_return

// Set Day to the text of the clicked column. 
ls_day = GetItemString(1, ai_clicked_column)
// Check If user clicked on an empty column
IF ls_day = '' OR IsNull(ls_day) THEN Return FALSE

// Convert to a number and place in Instance variable
ii_day = Integer(ls_day)

// Reset properties for old column back to normal
If ii_old_column <> 0 then
  ls_modify = '#' + String(ii_old_column) + '.border=6'
  ls_return = Modify(ls_modify)
  If ls_return <> '' then MessageBox('Modify',ls_return)
  ls_modify = '#' + string(ii_old_column) + '.Font.Weight=400'
  ls_return = dw_calendar.Modify(ls_Modify)
  If ls_return <> '' then MessageBox('Modify',ls_return)
End If

// Highlight chosen day
ls_modify = '#' + String(ai_clicked_column) + '.border=5'
ls_return = Modify(ls_modify)
If ls_return <> '' then MessageBox('Modify',ls_return)
ls_modify = '#' + string(ai_clicked_column) + '.Font.Weight=700'
ls_return = dw_calendar.Modify(ls_Modify)
If ls_return <> '' then MessageBox('Modify',ls_return)

// Set the chosen date
id_date_selected = Date(ii_year, ii_month, ii_day)

ii_old_column = ai_clicked_column

Return TRUE
end event

event hpk_return_date_time();String ls_return

ls_return = String(id_date_selected)

// Set the date value in current field and Accept Text
If IsValid(idw) Then
  idw.SetColumn(is_object_name)
  idw.SetText(ls_return)
  idw.AcceptText()
  idw.SetFocus()
ElseIf IsValid(iem_mask) Then
  iem_mask.Text = ls_return
  iem_mask.SetFocus()
ElseIf IsValid(isle_edit) Then
  isle_edit.Text = ls_return
  isle_edit.SetFocus()
End if

SetNull(idw)
SetNull(iem_mask)
SetNull(isle_edit)
lb_months.Visible = False

end event

event hpk_reset;Integer   li_cnt
String   ls_modify, ls_return

// Reset the instance variables
ii_day      = 0
ii_month      = 0
ii_year      = 0
ii_old_column  = 0

FOR li_cnt = 1 TO 42
  ls_modify = '#' + string(li_cnt) + '.border=6'
  ls_return = Modify(ls_modify)
  IF ls_return <> '' THEN MessageBox('Modify', ls_return)
  ls_modify = '#' + string(li_cnt) + '.Font.Weight=400'
  ls_return = Modify(ls_Modify)
  IF ls_return <> '' THEN MessageBox('Modify', ls_return)
NEXT
end event

event clicked;Integer  li_clicked_column

IF dwo.Name = "st_month" Then
  lb_months.Visible = True
ElseIF dwo.Type = 'column' THEN
  lb_months.Visible = False

  IF li_clicked_column < 0  THEN Return 1
  
  li_clicked_column = Integer(dwo.ID)
  
  // Set the chossen Date
  IF NOT Event hpk_set_day(li_clicked_column) THEN Return
  
  // Set the date value in current field and Accept Text
  Event hpk_return_date_time()
Else
  Return 1
End if

end event

event constructor;
InsertRow(1)

of_init_calendar(today())

end event

event losefocus;
Parent.TriggerEvent("hpk_lose_focus")

end event

Face à l'agression, la puissance de l'intelligence

Hors ligne

 

#6 30-05-2007 12:02:00

wazou1812  
Modératrice
Award: bf
Date d'inscription: 24-05-2006
Messages: 610
Pépites: 2,097
Banque: 3,536,631,712,504

Re: [RESOLU] Le control MonthCalendar en PB 10

Merci

Hors ligne

 

#7 30-05-2007 12:39:36

erasorz  
Admin
Lieu: Babylone
Date d'inscription: 23-11-2006
Messages: 5121
Pépites: 97,197
Banque: 2,147,483,647

Re: [RESOLU] Le control MonthCalendar en PB 10

JCZ a écrit:

tu peux utiliser ce bout de code c'est un userobject appeler u_hepek_calendar

JCZ.

Effectivement ce controle fonctionne bien : je l'ai utilisé jusqu'à ce que je passe de la v9 à la v10.5


N'envoyez jamais un humain faire le travail d'un programme.

Hors ligne

 

Pied de page des forums

Propulsé par FluxBB 1.2.22