IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Composants VCL Delphi Discussion :

Recherche Composant Planning Freeware pour D7PE


Sujet :

Composants VCL Delphi

  1. #1
    Membre actif Avatar de petitprince
    Homme Profil pro
    Développeur en systèmes embarqués
    Inscrit en
    Juillet 2006
    Messages
    322
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Développeur en systèmes embarqués

    Informations forums :
    Inscription : Juillet 2006
    Messages : 322
    Points : 267
    Points
    267
    Par défaut Recherche Composant Planning Freeware pour D7PE
    Salut !
    Comme le titre l'indique, je cherche un composant de gestion de planning GRATUIT et surtout sans avoir besoin des bases de donnée, car je développe avec Delphi 7 personnel...
    Merci d'avance...

  2. #2
    Membre chevronné
    Avatar de Droïde Système7
    Homme Profil pro
    Inscrit en
    Septembre 2003
    Messages
    2 262
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 2 262
    Points : 1 928
    Points
    1 928
    Par défaut
    Bonjour,

    J'ai trouvé peut-être quelque chose pour toi ici :
    http://www.bsdg.org/resources/Delphi...omponents.html

    Regarde à l'aide du mot clé de recherche : "Year"... (YearPlanner etc.)

  3. #3
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Citation Envoyé par petitprince
    Salut !
    Comme le titre l'indique, je cherche un composant de gestion de planning GRATUIT et surtout sans avoir besoin des bases de donnée, car je développe avec Delphi 7 personnel...
    Merci d'avance...
    Un stringgrid ne fait-il pas l'affaire ?
    Bidouilleuse Delphi

  4. #4
    Membre actif Avatar de petitprince
    Homme Profil pro
    Développeur en systèmes embarqués
    Inscrit en
    Juillet 2006
    Messages
    322
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Développeur en systèmes embarqués

    Informations forums :
    Inscription : Juillet 2006
    Messages : 322
    Points : 267
    Points
    267
    Par défaut
    ben oui... Mais je voudrai un truc tout fais, avec genre des panel qu'on place en DnD dans la StringGrid, et où l'on peu mettre du texte à foison dedans.
    Je sais je suis un peu faignant
    J-P, je vais aller jeter un coup d'oeil... Merci !
    T'aurais pas une chtite soluce sous la main waskol?

  5. #5
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Citation Envoyé par petitprince
    ben oui... Mais je voudrai un truc tout fais, avec genre des panel qu'on place en DnD dans la StringGrid, et où l'on peu mettre du texte à foison dedans.
    Je sais je suis un peu faignant
    J-P, je vais aller jeter un coup d'oeil... Merci !
    T'aurais pas une chtite soluce sous la main waskol?
    Ben... heuuuu....
    Là tout, de suite : non
    Bidouilleuse Delphi

  6. #6
    Membre actif Avatar de petitprince
    Homme Profil pro
    Développeur en systèmes embarqués
    Inscrit en
    Juillet 2006
    Messages
    322
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Développeur en systèmes embarqués

    Informations forums :
    Inscription : Juillet 2006
    Messages : 322
    Points : 267
    Points
    267
    Par défaut
    Bon j'ai regardé à l'adresse de J-P, et c'est un bon composant, mais ce n'est pas vraiment comme je recherche...
    Je cherche plutot un truc du style de TMS, mais surtout pas ceux de la JVCL, dont je ne comprend pas leur fonctionnement (ben oui j'ai pas les compo DB ).
    Voilà, a plus... et waskol, rassure-toi, c'est pas grave !!

  7. #7
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Citation Envoyé par petitprince
    Bon j'ai regardé à l'adresse de J-P, et c'est un bon composant, mais ce n'est pas vraiment comme je recherche...
    Je cherche plutot un truc du style de TMS, mais surtout pas ceux de la JVCL, dont je ne comprend pas leur fonctionnement (ben oui j'ai pas les compo DB ).
    Voilà, a plus... et waskol, rassure-toi, c'est pas grave !!
    Non mais je vois ce que tu veux, je vois comment faire en plus, mais
    le prob, c'est que je n'ai pas trop le temps.
    Pourtant il m'en faudrait un aussi pour le boulot, il faudra donc bien que je me penche sur la question un de ces jours....
    Bidouilleuse Delphi

  8. #8
    Membre actif Avatar de petitprince
    Homme Profil pro
    Développeur en systèmes embarqués
    Inscrit en
    Juillet 2006
    Messages
    322
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Développeur en systèmes embarqués

    Informations forums :
    Inscription : Juillet 2006
    Messages : 322
    Points : 267
    Points
    267
    Par défaut
    Ben je pense que je vais utiliser un canvas, et dessiner des rectangles, auquels j'affecterai une stringlist... Enfin, si quelqu'un connais un composant, ca m'aiderai grandement !!!!

  9. #9
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Citation Envoyé par petitprince
    Ben je pense que je vais utiliser un canvas, et dessiner des rectangles, auquels j'affecterai une stringlist... Enfin, si quelqu'un connais un composant, ca m'aiderai grandement !!!!
    Allez, je suis motivé, là, maintenant, de suite. Tu fait les specs, et j'adapte, Ok ?

    En gros, il nous faut d'abord définir un type enregistrement (pour le données).
    Quels seront les champs qui caractériseront une "boite" ? Heure du début, heure fin, texte (brut, formatté html ou rtf ?), etc...

    A partir de là, je peux mettre au point en moins de temps qu'il n'en faut pour le dir un descendant de TList, une sorte de TItemList capable de charger et sauver les données sur le disque dur.

    Ensuite, en prenant comme base un TWinControl pour la surface de dessin des boites, je peux lui adjoindre deux sous-composants que j'ai en réserve qui permettent de dessiner les plages horaires à gauche et les jours de la semaine en haut.

    L'affichage d'une semaine s'effectuera par la selection d'un numéro de semaine (j'ai ce qu'il faut aussi).

    Sinon, si tu n'est pas motivé, j'ai des composants dont l'affichage est généré par du html (tableaux compris), dérivés de composants gratuit (en fait j'ai corrigé les bugs avec l'accord de l'auteur) et que l'on aura bientot en ligne sur DVP.

    Quoi t'en penses-tu donc ?

    PS : j'ai Delphi 7
    Bidouilleuse Delphi

  10. #10
    Expert éminent sénior
    Avatar de Jipété
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    10 747
    Détails du profil
    Informations personnelles :
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations forums :
    Inscription : Juillet 2006
    Messages : 10 747
    Points : 15 168
    Points
    15 168
    Par défaut
    'Soir,

    J'ai développé pour mon usage perso et à ma manière perso (donc impubliable ici quand je vois le niveau de code parfois) un truc similaire.

    Ce qui me fait apporter mon grain de sel, c'est
    L'affichage d'une semaine s'effectuera par la selection d'un numéro de semaine
    À l'usage, il apparaît confortable d'avoir 2 semaines visibles (en cours et suivante), d'avoir le jour en cours d'une couleur, les jours non-travaillés d'une autre couleur, et comme les cells sont petites, "OnMouseOver" m'affiche dans un mémo sur le côté le contenu de la cell survolée, et au-dessus de ce mémo un calendrier pour vite changer de semaine/mois.
    HTH,
    --
    jp
    Il a à vivre sa vie comme ça et il est mûr sur ce mur se creusant la tête : peutêtre qu'il peut être sûr, etc.
    Oui, je milite pour l'orthographe et le respect du trait d'union à l'impératif.
    Après avoir posté, relisez-vous ! Et en cas d'erreur ou d'oubli, il existe un bouton « Modifier », à utiliser sans modération
    On a des lois pour protéger les remboursements aux faiseurs d’argent. On n’en a pas pour empêcher un être humain de mourir de misère.
    Mes 2 cts,
    --
    jp

  11. #11
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Citation Envoyé par Jipété
    'Soir,

    J'ai développé pour mon usage perso et à ma manière perso (donc impubliable ici quand je vois le niveau de code parfois) un truc similaire.

    Ce qui me fait apporter mon grain de sel, c'est
    À l'usage, il apparaît confortable d'avoir 2 semaines visibles (en cours et suivante), d'avoir le jour en cours d'une couleur, les jours non-travaillés d'une autre couleur, et comme les cells sont petites, "OnMouseOver" m'affiche dans un mémo sur le côté le contenu de la cell survolée, et au-dessus de ce mémo un calendrier pour vite changer de semaine/mois.
    HTH,
    --
    jp
    En fait, le composant qui affiche les jours TWADays) , que j'utilise déjà autour d'un DBCtrlGrid comme sous composant, permet
    - d'afficher le nombre de jour que l'on souhaite (1, 2, 7 , 14 ,365)
    - les jours fériés apparaissent grisé
    - et en fait on sélectionne le premier jour à afficher
    voici les propriétés publiées :
    Color : couleur du fond
    Font : couleur de la police (sauf les jours fériés qui sont en gras et rouge)
    Height : hauteur du bandeau
    Width : largeur
    NumberOfDays : nombre de jours à afficher

    Pour la sélection du premier jour, on a cette batterie de propriétés à dispo.
    Il suffit de sélectionner un jour de la semaine, et le contrôle affiche à partir du lundi correspondant
    ADate : Date du premier jour afficher
    ADayofWeek : 1=Lundi, 2=Mardi, etc...
    AWeek : numéro de la semaine dans l'année (en général de 1 à 52 ou 53)
    AYear_DowWY: Année dans le système "Jour de la semaine/Semaine/Année"
    ADay : numéro du jour dans le mois (système DMY)
    AMonth : numéro du mois
    AYear_DMY: Année dans le système "Jour/Mois/Année"

    exemple :
    dans le système DMY, on a Lundi 30/12/2002
    dans le système DowWY, on a 1/1/2003 (1er jour de la première semaine de 2003)

    AutomaticMonday : si mis à false, on peut très bien avoir comme premier jour affiché, un Mardi. Si mis à false et que vous entrez la date d'un Mardi, le composant recalcule le premier jour pour que ce soit le Lundi qui précède le jour de sélection.
    Pratique si on veut afficher la semaine du 18/5/2007 par exemple et si l'on ne sait pas quel jour tombe ce 18...

    voici le code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    unit TWAPanels;
     
    interface
     
    uses WinTypes, WinProcs, WIndows, Messages, SysUtils, Classes, Controls,
         Forms, Graphics,StdCtrls;
     
    type
      TWAHours = class(TGraphicControl)
      private
        FHoursPM: TStringList;
        FHoursAM: TStringList;
        procedure AutoInitialize;
        procedure AutoDestroy;
        procedure WMSize(var Message: TWMSize); message WM_SIZE;
        function CreateRotatedFont(Font: TFont; Angle: Integer): HFont;
        function IsTrueType( Font: TFont ): Boolean;
        procedure SetHoursAM(const Value: TStringList);
        procedure SetHoursPM(const Value: TStringList);
      protected
        procedure Loaded; override;
        procedure Paint; override;
        procedure DrawLabel(AString:string; ARect: TRect;Alignment:TAlignment;ALayout:TTextLayout;Angle:boolean);
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
      published
        property Color;
        property Font;
        property Height;
        property Width;
        property HoursAM:TStringList read FHoursAM write SetHoursAM;
        property HoursPM:TStringList read FHoursPM write SetHoursPM;
      end;
     
      TWADays = class(TGraphicControl)
      private
        FADate: TDate;
        FAMonth: Word;
        FAday: Word;
        FAYear_DMY: Word;
        FADayofWeek: Word;
        FAWeek: word;
        FAYear_DowWY: Word;
        FNumberOfDays: integer;
        FAutomaticMonday: boolean;
        procedure AutoInitialize;
        procedure AutoDestroy;
        procedure WMSize(var Message: TWMSize); message WM_SIZE;
        function GetDayofWeekDate(ADayOfWeek: word): TDate;
        procedure SetADate(const Value: TDate);
        procedure SetAday(const Value: Word);
        procedure SetADayofWeek(const Value: Word);
        procedure SetAMonth(const Value: Word);
        procedure SetAWeek(const Value: word);
        procedure SetAYear_DMY(const Value: Word);
        procedure SetAYear_DowWY(const Value: Word);
        procedure UpdateAll(cAday,cAMonth,cAYear_DMY,cADayofWeek,cAWeek,cAYear_DowWY:word);
        procedure SetNumberOfDays(const Value: integer);
        procedure SetAutomaticMonday(const Value: boolean);
        protected
        procedure Loaded; override;
        procedure Paint; override;
        procedure DrawLabel(AString:string; ARect: TRect;Ferie:boolean);
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
     
      published
        property Color;
        property Font;
        property Height;
        property Width;
        property NumberOfDays:integer read FNumberOfDays write SetNumberOfDays;
        property ADate : TDate read FADate write SetADate;
        property ADayofWeek :Word read FADayofWeek write SetADayofWeek;
        property AWeek : word read FAWeek write SetAWeek;
        property AYear_DowWY:Word read FAYear_DowWY write SetAYear_DowWY;
        property Aday:Word read FAday write SetAday;
        property AMonth : Word read FAMonth write SetAMonth;
        property AYear_DMY:Word read FAYear_DMY write SetAYear_DMY;
        property AutomaticMonday:boolean read FAutomaticMonday write SetAutomaticMonday;
      end;
     
    Function EstFerie(ADate:TDateTime;var Description:string):Boolean;
     
    implementation
     
    uses Types, Math, DateUtils,UnitDateSemaineUtils;
     
    function Paques(Annee : Integer) : TDateTime;
    var a, b, c, d, e, mois, jour: integer;
    begin
      a:=Annee mod 19;
      b:=Annee div 100;
      c:=(b-(b div 4)-((8*b+13) div 25)+(19*a)+15) mod 30;
      d:=c-(c div 28)*(1-(c div 28)*(29 div (c+1))*((21-a) div 11));
      e:=d-((Annee+(Annee div 4)+d+2-b+(b div 4)) mod 7);
      mois:=3+((e+40) div 44);
      jour:=e+28-(31*(mois div 4));
      Result:=EncodeDate(Annee, mois, jour );
    end;
     
    Function EstFerie(ADate:TDateTime;var Description:string):Boolean;
    var Annee:integer;
        JPaques,LPaques,Ascension,LPentecote:TDate;
        NouvelAn,FetTravail,Arm45,FetNat,Assomption,Toussaint,Arm18,Noel:TDate;
    begin
      Annee:=YearOf(ADate);
      JPaques:=Paques(Annee);
      LPaques:=IncDay(JPaques);
      Ascension:=IncDay(JPaques,39);
      LPentecote:=IncDay(JPaques,50);
     
      NouvelAn  :=EncodeDate(Annee,1,1);
      FetTravail:=EncodeDate(Annee,5,1);
      Arm45     :=EncodeDate(Annee,5,8);
      FetNat    :=EncodeDate(Annee,7,14);
      Assomption:=EncodeDate(Annee,8,15);
      Toussaint :=EncodeDate(Annee,11,1);
      Arm18     :=EncodeDate(Annee,11,11);
      Noel      :=EncodeDate(Annee,12,25);
     
      result:=true;
      if ADate=NouvelAn   Then begin
                                 Description:='Nouvel An';
                                 Exit;
                               end;
      if ADate=FetTravail Then begin
                                 Description:='Fête du Travail';
                                 Exit;
                               end;
      if ADate=Arm45      Then begin
                                 Description:='Armistice 1945';
                                 Exit;
                               end;
      if ADate=FetNat     Then begin
                                 Description:='Fête Nationale';
                                 Exit;
                               end;
      if ADate=Assomption Then begin
                                 Description:='Assomption';
                                 Exit;
                               end;
      if ADate=Toussaint  Then begin
                                 Description:='Toussaint';
                                 Exit;
                               end;
      if ADate=Arm18      Then begin
                                 Description:='Armistice 1918';
                                 Exit;
                               end;
      if ADate=Noel       Then begin
                                 Description:='Noël';
                                 Exit;
                               end;
      if ADate=LPaques    Then begin
                                 Description:='Lundi de Pâques';
                                 Exit;
                               end;
      if ADate=Ascension  Then begin
                                 Description:='Ascension';
                                 Exit;
                               end;
      if ADate=LPentecote Then begin
                                 Description:='Lundi de Pentecôte';
                                 Exit;
                               end;
      Description:='';
      result:=false;
    end;
     
     
    function TextSize(Phrase:string;police:TFont=nil):TPoint;
    var
      DC: HDC;
      Rect: TRect;
      C : TBitmap;
    begin
      C := TBitmap.create;
    try
      if police <> nil then  C.canvas.Font := police;
     
        Rect.Left := 0;
        Rect.Top:=0;
        Rect.Right:=0;
        Rect.Bottom:=0;
        DC := GetDC(0);
        C.Canvas.Handle := DC;
        DrawText(C.Canvas.Handle, PChar(Phrase), Length(Phrase), Rect, (DT_EXPANDTABS or DT_CALCRECT));
        C.Canvas.Handle := 0;
        ReleaseDC(0, DC);
        result.X:=Rect.Right;
        result.Y:=Rect.Bottom;
    finally
      C.Free;
    end;
    end;
     
    { Method to set variable and property values and create objects }
    procedure TWAHours.AutoInitialize;
    begin
      Font.Name:='Arial';
      ParentColor:=false;
      FHoursAM.Clear;
      FHoursPM.Clear;
      FHoursAM.Add('8h30/10h30');
      FHoursAM.Add('10h30/12h30');
      FHoursPM.Add('13h30/15h30');
      FHoursPM.Add('15h30/17h30');
    end;
     
    { Method to free any objects created by AutoInitialize }
    procedure TWAHours.AutoDestroy;
    begin
      FHoursAM.Free;
      FHoursPM.Free;
    end;
     
    constructor TWAHours.Create(AOwner: TComponent);
    begin
     inherited Create(AOwner);
     FHoursAM:=TStringList.Create;
     FHoursPM:=TStringList.Create;
     AutoInitialize;
    end;
     
    destructor TWAHours.Destroy;
    begin
      AutoDestroy;
      inherited Destroy;
    end;
     
    procedure TWAHours.Loaded;
    begin
      inherited Loaded;
    end;
     
    procedure TWAHours.Paint;
    var ZRect:TRect;
        i,j:Integer;
        NAM,NPM,NTOT:Integer;
        AMSectionHeight,PMSectionHeight:Integer;
        Hdeb,Hfin,s:string;
    begin
      NAM:=FHoursAM.Count;
      NPM:=FHoursPM.Count;
      NTOT:=NAM+NPM;
      if NTOT=0 then
      begin
        NAM:=1;
        NPM:=1;
        NTOT:=2;
      end;
     
      AMSectionHeight:=((NAM*Height) div NTOT);
      PMSectionHeight:=Height-AMSectionHeight;
      Canvas.Brush.Color := Color;
      Canvas.Brush.Style:=bsSolid;
      Canvas.Pen.Color :=Font.Color;
      Canvas.Rectangle(0, 0, Width, Height);
     
      //label matin
      ZRect:=Bounds(0,0,Width div 3,AMSectionHeight);
      DrawLabel('Matin',ZRect,taCenter,tlCenter,True);
     
      //label Après-Midi
      ZRect:=Bounds(0,0,Width div 3,PMSectionHeight);
      OffSetRect(ZRect,0,AMSectionHeight);
      DrawLabel('Après-Midi',ZRect,taCenter,tlCenter,True);
     
      ZRect:=Bounds(Width div 3,0,Width-(Width div 3),Height div NTOT);
      if FHoursAM.Count>0 then
      for i:=0 to NAM-1 do
      begin
        s:=FHoursAM.Strings[i];
        j:=pos('/',s);
        if j=-1 then begin
                       Hdeb:=s;
                       Hfin:='';
                     end
                else begin
                       Hdeb:=copy(s,1,j-1);
                       Hfin:=copy(s,j+1,length(s));
                     end;
        DrawLabel(Hdeb,ZRect,taRightJustify,tlTop,false);
        DrawLabel(Hfin,ZRect,taRightJustify,tlBottom,false);
        if (i<(NTOT-1)) then OffSetRect(ZRect,0,Height div NTOT);
      end;
     
      if FHoursPM.Count>0 then
      for i:=0 to NPM-1 do
      begin
        s:=FHoursPM.Strings[i];
        j:=pos('/',s);
        if j=-1 then begin
                       Hdeb:=s;
                       Hfin:='';
                     end
                else begin
                       Hdeb:=copy(s,1,j-1);
                       Hfin:=copy(s,j+1,length(s));
                     end;
        DrawLabel(Hdeb,ZRect,taRightJustify,tlTop,false);
        DrawLabel(Hfin,ZRect,taRightJustify,tlBottom,false);
        if (i<(NTOT-1)) then OffSetRect(ZRect,0,Height div NTOT);
      end;
    end;
     
    procedure TWAHours.WMSize(var Message: TWMSize);
    var
      W, H: Integer;
    begin
      inherited;
      W := Width;
      H := Height;
      if (W <> Width) or (H <> Height) then
        inherited SetBounds(Left, Top, W, H);
      Message.Result := 0;
    end;
     
     
    procedure TWAHours.DrawLabel(AString: string;ARect: TRect; Alignment:TAlignment;ALayout:TTextLayout;Angle:boolean);
    var
      AHeight,AWidth:integer;
      R:TRect;
      H,W,WW,ATop,ALeft:Integer;
      FontNewHeight:integer;
      AText:string;
    begin
      Canvas.Font:=Font;
      with Canvas do
      begin
        Brush.Color:=Font.Color;
        FrameRect(ARect);
        InflateRect(ARect,-1,-1);
        AHeight:=ARect.Bottom-ARect.Top;
        AWidth:=ARect.Right-ARect.Left;
        if AString[1]>='A'
        then AText:='WAprès-Midi'
        else AText:='W17h30';
        WW:=TextSize(AText,Font).X;
     
        if Angle then
        begin
          begin
            FontNewHeight:=Ceil(Font.Height*AHeight/WW);
            Font.Height:=FontNewHeight;
            W:=TextSize(AString,Font).X;
            H:=Round(TextSize(AString,Font).Y*1.5);
          end;
          if H>AWidth then
          begin
            FontNewHeight:=Ceil(Font.Height*AWidth/H);
            Font.Height:=FontNewHeight;
            W:=TextSize(AString,Font).X;
            H:=TextSize(AString,Font).Y;
          end;
        end
        else
        begin
          FontNewHeight:=Ceil(Font.Height*AWidth/WW);
          Font.Height:=FontNewHeight;
          W:=TextSize(AString,Font).X;
          H:=TextSize(AString,Font).Y;
        end;
        if Angle then Font.Handle:=CreateRotatedFont(Font, 90);
        ATop:=ARect.Top;
        ALeft:=ARect.Left;
        if Angle then
        begin
          case ALayout of
            tlBottom : ATop:=ARect.Bottom-W;
            tlCenter : ATop:=ARect.Top+((AHeight-W) div 2);
            tlTop    : ATop:=ARect.Top;
          end;
     
          case Alignment of
            taLeftJustify  : ALeft:=ARect.Left;
            taCenter       : ALeft:=ARect.Left+(AWidth-H) div 2;
            taRightJustify : ALeft:=ARect.Right-H;
          end;
          R := Bounds(ALeft,ATop,H,W);
        end
        else
        begin
          case ALayout of
            tlBottom : ATop:=ARect.Bottom-H;
            tlCenter : ATop:=ARect.Top+((AHeight-H) div 2);
            tlTop    : ATop:=ARect.Top;
          end;
     
          case Alignment of
            taLeftJustify  : ALeft:=ARect.Left;
            taCenter       : ALeft:=ARect.Left+(AWidth-W) div 2;
            taRightJustify : ALeft:=ARect.Right-W;
          end;
          R := Bounds(ALeft,ATop,H,W);
        end;
        Canvas.Brush.Color := Color;
        if Angle
        then TextOut(R.Left,R.Bottom,AString)
        else TextOut(R.Left,R.Top,AString);
      end;
    end;
     
    function TWAHours.CreateRotatedFont(Font: TFont; Angle: Integer): HFont;
    var
      LogFont: TLogFont;
    begin
      If not IsTrueType(Font) then Font.Name:='Arial';
      FillChar(LogFont, SizeOf(LogFont), 0);
      with LogFont do begin
        lfHeight := Font.Height;
        lfWidth := 0;
        lfEscapement := Angle * 10;
        lfOrientation := 0;
        if fsBold in Font.Style then lfWeight := FW_BOLD
        else lfWeight := FW_NORMAL;
        lfItalic := Ord(fsItalic in Font.Style);
        lfUnderline := Ord(fsUnderline in Font.Style);
        lfStrikeOut := Byte(fsStrikeOut in Font.Style);
        lfCharSet := Byte(Font.Charset);
        StrPCopy(lfFaceName, Font.Name);
        lfQuality := DEFAULT_QUALITY;
        lfOutPrecision := OUT_DEFAULT_PRECIS;
        lfClipPrecision := CLIP_DEFAULT_PRECIS;
        case Font.Pitch of
          fpVariable: lfPitchAndFamily := VARIABLE_PITCH;
          fpFixed: lfPitchAndFamily := FIXED_PITCH;
          else lfPitchAndFamily := DEFAULT_PITCH;
        end;
      end;
      Result := CreateFontIndirect(LogFont);
    end;
     
    function TWAHours.IsTrueType(Font: TFont): Boolean;
    var
      Metrics: TTextMetric;
    begin
      Canvas.Font := Font;
      GetTextMetrics( Canvas.Handle, Metrics );
      Result := ( Metrics.tmPitchAndFamily and tmpf_TrueType ) = tmpf_TrueType;
    end;
     
    { TWADays }
     
    procedure TWADays.AutoDestroy;
    begin
      //
    end;
     
    procedure TWADays.AutoInitialize;
    var TheDate:TDate;
    begin
      Font.Name:='Arial';
      FNumberOfDays:=5;
      ParentColor:=false;
      TheDate:=DateOf(Now);
      FAutomaticMonday:=true;
      SetADate(TheDate);
    end;
     
    constructor TWADays.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
     AutoInitialize;
    end;
     
    destructor TWADays.Destroy;
    begin
      AutoDestroy;
      inherited Destroy;
    end;
     
    procedure TWADays.DrawLabel(AString: string; ARect: TRect;Ferie:boolean);
    var
      AHeight,AWidth:integer;
      R:TRect;
      H,W,WW,ATop,ALeft:Integer;
      FontNewHeight:integer;
      AText:string;
    begin
      Canvas.Font:=Font;
      Canvas.Font.Style:=[fsBold];
      with Canvas do
      begin
        Pen.Color:=Font.Color;
        if Ferie then
        begin
          Brush.Color:=Color;
          Brush.Style:=bssolid;
          FillRect(ARect);
          Brush.Color:=Font.Color;
          Canvas.Font.Color:=clRed;
          Brush.Style:=bsBDiagonal;
        end
        else
        begin
          Brush.Color:=Color;
          Brush.Style:=bssolid;
        end;
        Rectangle(ARect);
        InflateRect(ARect,-1,-1);
        AHeight:=ARect.Bottom-ARect.Top;
        AWidth:=ARect.Right-ARect.Left;
        W:=TextSize(AString,Font).X;
        AText:='WWW. WW/WW';
        WW:=TextSize(AText,Font).X;
        WW:=Max(W,WW);
     
        FontNewHeight:=Ceil(Font.Height*AWidth/WW);
        Font.Height:=FontNewHeight;
        W:=TextSize(AString,Font).X;
        H:=TextSize(AString,Font).Y;
     
        while H>(AHeight * 0.9) do
        begin
          Inc(FontNewHeight);
          Font.Height:=FontNewHeight;
          W:=TextSize(AString,Font).X;
          H:=TextSize(AString,Font).Y;
        end;
     
        ATop:=ARect.Top+((AHeight-H) div 2);
        ALeft:=ARect.Left+(AWidth-W) div 2;
        R := Bounds(ALeft,ATop,H,W);
        DrawText(Canvas.Handle,PChar(AString),Length(AString),ARect,DT_CENTER or DT_VCENTER);
      end;
    end;
     
    function TWADays.GetDayofWeekDate(ADayOfWeek: word): TDate;
    begin
      Result:=DowWY_to_Date(ADayOfWeek,FAWeek,FAYear_DowWY);
    end;
     
    procedure TWADays.Loaded;
    begin
      inherited Loaded;
    end;
     
    procedure TWADays.Paint;
    var ZRect:TRect;
        th:integer;
        FirstDate,ADate:TDate;
        AText:string;
        JourFerie:Boolean;
        s:string;
    begin
      FirstDate:=FADate;
      Canvas.Brush.Color := Color;
      Canvas.Pen.Color :=Font.Color;
      Canvas.Rectangle(0, 0, Width, Height);
      for th:=0 to FNumberOfDays-1 do
      begin
         ZRect:=Rect(th*(Width div FNumberOfDays),0,(th+1)*(Width div FNumberOfDays),Height);
         ADAte:=IncDay(FirstDate,th);
         JourFerie:=EstFerie(ADAte,s);
         AText:=FormatDateTime('ddd d/m',ADAte);
         Atext[1]:=UpCase(AText[1]);
         if s<>'' then AText:=Atext+#13#10+s;
         DrawLabel(AText,ZRect,JourFerie);
      end;
    end;
     
    procedure TWADays.SetADate(const Value: TDate);
    var cAday,cAMonth,cAYear_DMY,
        cADayofWeek,cAWeek,cAYear_DowWY:word;
    begin
      if (FADate<>Value) then
      begin
        FADate := Value;
        Date_to_DMY(FADate,cAday,cAMonth,cAYear_DMY);
        Date_to_DowWY(FADate,cADayofWeek,cAWeek,cAYear_DowWY);
        UpdateAll(cAday,cAMonth,cAYear_DMY,cADayofWeek,cAWeek,cAYear_DowWY);
        if AutomaticMonday then ADate:=GetDayofWeekDate(1);
      end;
    end;
     
    procedure TWADays.SetAday(const Value: Word);
    begin
      if (FAday<>Value) then
      begin
        FAday := Value;
        ADate := DMY_to_Date(FAday,FAMonth,FAYear_DMY);
      end;
    end;
     
    procedure TWADays.SetADayofWeek(const Value: Word);
    begin
      if (FADayofWeek<>Value) then
      begin
        FADayofWeek := Value;
        ADate := DowWY_to_Date(FADayofWeek,FAWeek,FAYear_DowWY);
      end;
    end;
     
    procedure TWADays.SetAMonth(const Value: Word);
    begin
      if (FAMonth<>Value) then
      begin
        FAMonth := Value;
        ADate := DMY_to_Date(FAday,FAMonth,FAYear_DMY);
      end;
    end;
     
    procedure TWADays.SetAutomaticMonday(const Value: boolean);
    begin
     if (FAutomaticMonday<>Value) then
     begin
       FAutomaticMonday := Value;
       if AutomaticMonday then ADate:=GetDayofWeekDate(1);
       invalidate;
     end;
    end;
     
    procedure TWADays.SetAWeek(const Value: word);
    begin
      if (FAWeek<>Value) then
      begin
        FAWeek := Value;
     
        if (FAWeek=0) then
          if (FAYear_DowWY=2000)
          then FAWeek:=1
          else begin
                 dec(FAYear_DowWY);
                 AWeek:=WeeksInAYear(FAYear_DowWY);
               end;
     
        if (FAWeek>WeeksInAYear(FAYear_DowWY)) then
           if (FAYear_DowWY=2200)
           then FAWeek:=WeeksInAYear(FAYear_DowWY)
        else begin
               inc(FAYear_DowWY);
               FAWeek:=1;
             end;
     
        ADate := DowWY_to_Date(FADayofWeek,FAWeek,FAYear_DowWY);
      end;
    end;
     
    procedure TWADays.SetAYear_DMY(const Value: Word);
    begin
      if (FAYear_DMY<>Value) then
      begin
        FAYear_DMY := Value;
        ADate := DMY_to_Date(FAday,FAMonth,FAYear_DMY);
      end;
    end;
     
    procedure TWADays.SetAYear_DowWY(const Value: Word);
    begin
      if (FAYear_DowWY<>Value) then
      begin
        FAYear_DowWY := Value;
        while (FAWeek>WeeksInYear(FAYear_DowWY)) do dec(FAWeek);
        ADate := DowWY_to_Date(FADayofWeek,FAWeek,FAYear_DowWY);
      end;
    end;
     
    procedure TWADays.SetNumberOfDays(const Value: integer);
    begin
      if Value>=1 then
      if (FNumberOfDays<>Value) then
      begin
        FNumberOfDays := Value;
        Invalidate;
      end;
    end;
     
    procedure TWADays.UpdateAll(cAday, cAMonth, cAYear_DMY, cADayofWeek,
      cAWeek, cAYear_DowWY: word);
    begin
      fAday:=cAday;
      fAMonth:=cAMonth;
      fAYear_DMY:=cAYear_DMY;
      fADayofWeek:=cADayofWeek;
      fAWeek:=cAWeek;
      fAYear_DowWY:=cAYear_DowWY;
      invalidate;
    end;
     
    procedure TWADays.WMSize(var Message: TWMSize);
    var
      W, H: Integer;
    begin
      inherited;
      W := Width;
      H := Height;
      if (W <> Width) or (H <> Height) then
        inherited SetBounds(Left, Top, W, H);
      Message.Result := 0;
    end;
     
     
    procedure TWAHours.SetHoursAM(const Value: TStringList);
    begin
      FHoursAM := Value;
      Invalidate;
    end;
     
    procedure TWAHours.SetHoursPM(const Value: TStringList);
    begin
      FHoursPM := Value;
      Invalidate;
    end;
     
    end.
    et
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    unit UnitDateSemaineUtils;
    interface
    uses Controls,SysUtils,DateUtils;
     
    function DMY_to_Date(ADay,AMonth,AYear:Word):TDate;
    function DowWY_to_Date(ADayOfWeek,AWeek,AYear:Word):TDate;
    procedure Date_to_DMY(ADate:TDate;var ADay,AMonth,AYear:word);
    procedure Date_to_DowWY(ADate:TDate;var ADayOfWeek,AWeek,AYear:word);
    procedure DMY_to_DowWY(ADay,AMonth,AYear_DMY:Word;var ADayOfWeek,AWeek,AYear_DowWY:word);
    procedure DowWY_to_DMY(ADayOfWeek,AWeek,AYear_DowWY:Word;var ADay,AMonth,AYear_DMY:word);
    implementation
    function DMY_to_Date(ADay,AMonth,AYear:Word):TDate;
    begin
      result:=EncodeDate(AYear,AMonth,ADay);
    end;
     
    function DowWY_to_Date(ADayOfWeek,AWeek,AYear:Word):TDate;
    begin
      result:=EncodeDateWeek(AYear,AWeek,ADayOfWeek);
    end;
     
    procedure Date_to_DMY(ADate:TDate;var ADay,AMonth,AYear:word);
    begin
      DecodeDate(ADate,AYear,AMonth,ADay);
    end;
     
    procedure Date_to_DowWY(ADate:TDate;var ADayOfWeek,AWeek,AYear:word);
    begin
      DecodeDateWeek(ADate,AYear,AWeek,ADayOfWeek);
    end;
     
    procedure DMY_to_DowWY(ADay,AMonth,AYear_DMY:Word;var ADayOfWeek,AWeek,AYear_DowWY:word);
    var ADate:TDate;
    begin
      ADate:=DMY_to_Date(ADay,AMonth,AYear_DMY);
      Date_to_DowWY(ADate,ADayOfWeek,AWeek,AYear_DowWY);
    end;
     
    procedure DowWY_to_DMY(ADayOfWeek,AWeek,AYear_DowWY:Word;var ADay,AMonth,AYear_DMY:word);
    var ADate:TDate;
    begin
      ADate:=DowWY_to_Date(ADayOfWeek,AWeek,AYear_DowWY);
      Date_to_DMY(ADate,ADay,AMonth,AYear_DMY);
    end;
     
    end.
    Bidouilleuse Delphi

  12. #12
    Membre actif Avatar de petitprince
    Homme Profil pro
    Développeur en systèmes embarqués
    Inscrit en
    Juillet 2006
    Messages
    322
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Développeur en systèmes embarqués

    Informations forums :
    Inscription : Juillet 2006
    Messages : 322
    Points : 267
    Points
    267
    Par défaut
    Houlà !!!!! m'en veux pas trop, mais j'ai pas tout compris waskol...
    Mais ce que je recherche, c'est un peu comme tu dit, un decandant de TList pour la sauvegarde....
    Mais si t'as des compos, et qu'ils n'utilisent PAS de BASE DE DONNEE (D7 PE of course !!!), et qu'ils sont publiables, ça m'intéresse aussi !!!
    En tout cas merci de s'y intéresser...

  13. #13
    Membre actif Avatar de petitprince
    Homme Profil pro
    Développeur en systèmes embarqués
    Inscrit en
    Juillet 2006
    Messages
    322
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Développeur en systèmes embarqués

    Informations forums :
    Inscription : Juillet 2006
    Messages : 322
    Points : 267
    Points
    267
    Par défaut
    Waskol, j'ai regardé le code que tu as fournis, mais j'y comprend rien, peux-tu m'en dire 2-3 mots ?

  14. #14
    Rédacteur/Modérateur
    Avatar de ero-sennin
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2005
    Messages
    2 965
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2005
    Messages : 2 965
    Points : 4 935
    Points
    4 935
    Par défaut
    Salut PetitPrince,

    Je ne sais pas si c'est ce que tu souhaites, mais va voir ici

    Tu peux télécharger certains composants gratuitement via les petites disquettes tout en haut de l'écran.Tu choisis ta version, et tu cliques

    Bonne Soirée

  15. #15
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Salut petitprince

    En fait, ce sont deux composants, que j'utilise comme sous-composant d'un TDBCtrlGrid traficoté pour qu'il n'y ai plus les scrollbars et créer ainsi un nouveau composant composite (oui, je sais, je suis fou ) pour afficher un planning.

    J'ai mis un screenshot ici : http://www.developpez.net/forums/sho...light=planning

    La partie gauche que tu vois sur le screenshot, c'est le composant TWAHours, il permet d'afficher les heures de mes créneaux horarire, ainsi que l'indication Matin/Après-midi

    La partie du haut, avec les dates, c'est la partie affichée grace au composant TWADAys.

    En plus, comme je suis vraiment pas bon sur coup, si tu ne sais pas comment déclarer un composant de façon dynamique, je comprend pourquoi mon code t'est complètement imperméable

    Pour visualiser la chose en toute sérénité, ajoutes aux deux unités que je t'ai déjà jeté en pature de façon pas cool, une unité WAPlanning.pas dont voici le code pour Delphi 6 et plus (j'ai Delphi 7)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    unit WAPlanning;
    interface
    uses DesignIntf, DesignEditors;
     
    procedure Register;
     
    implementation
    uses TWapanels, stdctrls, classes;
     
    procedure Register;
    begin
      RegisterComponents('Waskol',[TWAHours,TWADays]);
    end;
     
    end.
    Donc tu te retrouves avec trois fichiers .pas dans un répertoire de ton choix

    Ensuite, depuis ton IDE (de ton Delphi donc), tu vas dans le menu "Composant-->Installer composant..."
    Puis tu choisis l'onglet "Dans un nouveau paquet" (pour ne pas pourrir les tiens )

    Nom d'unité : Cliques sur bouton parcourir, jusqu'a ton répertoire et tu choisis WAPlanning.pas
    Nom du paquet : Cliques sur bouton parcourir, jusqu'a ton répertoire et donne comme nom de paquet quelque chose comme Planning_Waskol.dpk
    Description du paquet lanning Waskol

    Vérifie que, dans les options d'environnement ("Outils-->Options d'environnement...", onglet Bibliothèque), tu as bien le chemin vers le répertoire dans "Chemin de bibliothèque".

    Normalement, si tu as tout bien fait comme il faut, tu auras deux composants dans ta palette de composants (onglet "Waskol"), que tu peux placer sur une fiche et tester.

    Si tu as des soucis, fait le moi savoir.
    Bidouilleuse Delphi

  16. #16
    Membre actif Avatar de petitprince
    Homme Profil pro
    Développeur en systèmes embarqués
    Inscrit en
    Juillet 2006
    Messages
    322
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Développeur en systèmes embarqués

    Informations forums :
    Inscription : Juillet 2006
    Messages : 322
    Points : 267
    Points
    267
    Par défaut
    Non, rassure toi, tu ne m'a pas lancer le code de facon pas cool. J'espère juste qu'il n'y a pas besoin des composants DB, mais il ne me semble pas les avoir vu...
    Merci, je teste ca au plus vite...

  17. #17
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Citation Envoyé par petitprince
    Non, rassure toi, tu ne m'a pas lancer le code de facon pas cool. J'espère juste qu'il n'y a pas besoin des composants DB, mais il ne me semble pas les avoir vu...
    Merci, je teste ca au plus vite...
    Non, il n'y a pas de composants DB là dedans, sinon, que penses tu qu'il faudrait pour décrire un créneau, rendez vous, etc ?

    Crois tu qu'une structure comme celle-là suffise ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    type TCreneau=record
                Debut,Fin:TDateTime; //Date et Heure de début et fin d'un évènement
                Commentaire : string;
           end;
    ou bien faudrait-il un peu plus de champs descriptifs, style "type de rendez vous" ?
    A moins que l'on crée un champ "fourre-tout" comme la propriété Tag des composants :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    type TCreneau=record
                Debut,Fin:TDateTime; //Date et Heure de début et fin d'un évènement
                Commentaire : string;
                Tag:integer;
           end;
    voir, deux ou trois, même...
    Bidouilleuse Delphi

  18. #18
    Membre actif Avatar de petitprince
    Homme Profil pro
    Développeur en systèmes embarqués
    Inscrit en
    Juillet 2006
    Messages
    322
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Développeur en systèmes embarqués

    Informations forums :
    Inscription : Juillet 2006
    Messages : 322
    Points : 267
    Points
    267
    Par défaut
    Bon je vien de tester, et j'ai une erreur " opération de pointeur incorecte", quand je rajoute une plage horaire, sur le composant jour....Enfin ce n'est pas gênant, je modifirai le compo...

    Pour ce que tu me demande: un record, bonne idée, mais il y a toujours le problème de la limite des string à 255 caractères... Mais si c'est juste un commentaire, pas de problème...
    Un champs fourre tout bonne idée.

    Mais pourquoi ne pas faire une classe, genre une List, comme cela on pourrai sauvegarder le planning semaine/semaine, avec par jour tout les TCréneaux...
    Je poursuis mes tests...

    Moi de mon coté, j'essai de dessiner sur un canvas des réctangle DnD pour les déplacer en fonction du jour....., et leur taille donne la durée du RDV... A suivre...

  19. #19
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Ha oui, ça craint pour la violation d'accès...

    Tiens, d'ailleurs je viens de le corriger (et j'en ai profité pour améliorer l'affichage :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    unit TWAPanels;
     
    interface
     
    uses WinTypes, WinProcs, WIndows, Messages, SysUtils, Classes, Controls,
         Forms, Graphics,StdCtrls;
     
    type
      TWAHours = class(TGraphicControl)
      private
        FHoursPM: TStringList;
        FHoursAM: TStringList;
        procedure AutoInitialize;
        procedure AutoDestroy;
        procedure WMSize(var Message: TWMSize); message WM_SIZE;
        function CreateRotatedFont(Font: TFont; Angle: Integer): HFont;
        function IsTrueType( Font: TFont ): Boolean;
        procedure SetHoursAM(const Value: TStringList);
        procedure SetHoursPM(const Value: TStringList);
      protected
        procedure Loaded; override;
        procedure Paint; override;
        procedure DrawLabel(AString:string; ARect: TRect;Alignment:TAlignment;ALayout:TTextLayout;Angle,Framed:boolean);
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
      published
        property Color;
        property Font;
        property Height;
        property Width;
        property HoursAM:TStringList read FHoursAM write SetHoursAM;
        property HoursPM:TStringList read FHoursPM write SetHoursPM;
      end;
     
      TWADays = class(TGraphicControl)
      private
        FADate: TDate;
        FAMonth: Word;
        FAday: Word;
        FAYear_DMY: Word;
        FADayofWeek: Word;
        FAWeek: word;
        FAYear_DowWY: Word;
        FNumberOfDays: integer;
        FAutomaticMonday: boolean;
        procedure AutoInitialize;
        procedure AutoDestroy;
        procedure WMSize(var Message: TWMSize); message WM_SIZE;
        function GetDayofWeekDate(ADayOfWeek: word): TDate;
        procedure SetADate(const Value: TDate);
        procedure SetAday(const Value: Word);
        procedure SetADayofWeek(const Value: Word);
        procedure SetAMonth(const Value: Word);
        procedure SetAWeek(const Value: word);
        procedure SetAYear_DMY(const Value: Word);
        procedure SetAYear_DowWY(const Value: Word);
        procedure UpdateAll(cAday,cAMonth,cAYear_DMY,cADayofWeek,cAWeek,cAYear_DowWY:word);
        procedure SetNumberOfDays(const Value: integer);
        procedure SetAutomaticMonday(const Value: boolean);
        protected
        procedure Loaded; override;
        procedure Paint; override;
        procedure DrawLabel(AString:string; ARect: TRect;Ferie:boolean);
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
     
      published
        property Color;
        property Font;
        property Height;
        property Width;
        property NumberOfDays:integer read FNumberOfDays write SetNumberOfDays;
        property ADate : TDate read FADate write SetADate;
        property ADayofWeek :Word read FADayofWeek write SetADayofWeek;
        property AWeek : word read FAWeek write SetAWeek;
        property AYear_DowWY:Word read FAYear_DowWY write SetAYear_DowWY;
        property Aday:Word read FAday write SetAday;
        property AMonth : Word read FAMonth write SetAMonth;
        property AYear_DMY:Word read FAYear_DMY write SetAYear_DMY;
        property AutomaticMonday:boolean read FAutomaticMonday write SetAutomaticMonday;
      end;
     
    Function EstFerie(ADate:TDateTime;var Description:string):Boolean;
     
    implementation
     
    uses Types, Math, DateUtils,UnitDateSemaineUtils;
     
    function Paques(Annee : Integer) : TDateTime;
    var a, b, c, d, e, mois, jour: integer;
    begin
      a:=Annee mod 19;
      b:=Annee div 100;
      c:=(b-(b div 4)-((8*b+13) div 25)+(19*a)+15) mod 30;
      d:=c-(c div 28)*(1-(c div 28)*(29 div (c+1))*((21-a) div 11));
      e:=d-((Annee+(Annee div 4)+d+2-b+(b div 4)) mod 7);
      mois:=3+((e+40) div 44);
      jour:=e+28-(31*(mois div 4));
      Result:=EncodeDate(Annee, mois, jour );
    end;
     
    Function EstFerie(ADate:TDateTime;var Description:string):Boolean;
    var Annee:integer;
        JPaques,LPaques,Ascension,LPentecote:TDate;
        NouvelAn,FetTravail,Arm45,FetNat,Assomption,Toussaint,Arm18,Noel:TDate;
    begin
      Annee:=YearOf(ADate);
      JPaques:=Paques(Annee);
      LPaques:=IncDay(JPaques);
      Ascension:=IncDay(JPaques,39);
      LPentecote:=IncDay(JPaques,50);
     
      NouvelAn  :=EncodeDate(Annee,1,1);
      FetTravail:=EncodeDate(Annee,5,1);
      Arm45     :=EncodeDate(Annee,5,8);
      FetNat    :=EncodeDate(Annee,7,14);
      Assomption:=EncodeDate(Annee,8,15);
      Toussaint :=EncodeDate(Annee,11,1);
      Arm18     :=EncodeDate(Annee,11,11);
      Noel      :=EncodeDate(Annee,12,25);
     
      result:=true;
      if ADate=NouvelAn   Then begin
                                 Description:='Nouvel An';
                                 Exit;
                               end;
      if ADate=FetTravail Then begin
                                 Description:='Fête du Travail';
                                 Exit;
                               end;
      if ADate=Arm45      Then begin
                                 Description:='Armistice 1945';
                                 Exit;
                               end;
      if ADate=FetNat     Then begin
                                 Description:='Fête Nationale';
                                 Exit;
                               end;
      if ADate=Assomption Then begin
                                 Description:='Assomption';
                                 Exit;
                               end;
      if ADate=Toussaint  Then begin
                                 Description:='Toussaint';
                                 Exit;
                               end;
      if ADate=Arm18      Then begin
                                 Description:='Armistice 1918';
                                 Exit;
                               end;
      if ADate=Noel       Then begin
                                 Description:='Noël';
                                 Exit;
                               end;
      if ADate=LPaques    Then begin
                                 Description:='Lundi de Pâques';
                                 Exit;
                               end;
      if ADate=Ascension  Then begin
                                 Description:='Ascension';
                                 Exit;
                               end;
      if ADate=LPentecote Then begin
                                 Description:='Lundi de Pentecôte';
                                 Exit;
                               end;
      Description:='';
      result:=false;
    end;
     
     
    function TextSize(Phrase:string;police:TFont=nil):TPoint;
    var
      DC: HDC;
      Rect: TRect;
      C : TBitmap;
    begin
      C := TBitmap.create;
    try
      if police <> nil then  C.canvas.Font := police;
     
        Rect.Left := 0;
        Rect.Top:=0;
        Rect.Right:=0;
        Rect.Bottom:=0;
        DC := GetDC(0);
        C.Canvas.Handle := DC;
        DrawText(C.Canvas.Handle, PChar(Phrase), Length(Phrase), Rect, (DT_EXPANDTABS or DT_CALCRECT));
        C.Canvas.Handle := 0;
        ReleaseDC(0, DC);
        result.X:=Rect.Right;
        result.Y:=Rect.Bottom;
    finally
      C.Free;
    end;
    end;
     
    { Method to set variable and property values and create objects }
    procedure TWAHours.AutoInitialize;
    begin
      Font.Name:='Arial';
      ParentColor:=false;
      FHoursAM.Clear;
      FHoursPM.Clear;
      FHoursAM.Add('8h30/10h30');
      FHoursAM.Add('10h30/12h30');
      FHoursPM.Add('13h30/15h30');
      FHoursPM.Add('15h30/17h30');
    end;
     
    { Method to free any objects created by AutoInitialize }
    procedure TWAHours.AutoDestroy;
    begin
      FHoursAM.Free;
      FHoursPM.Free;
    end;
     
    constructor TWAHours.Create(AOwner: TComponent);
    begin
     inherited Create(AOwner);
     FHoursAM:=TStringList.Create;
     FHoursPM:=TStringList.Create;
     AutoInitialize;
    end;
     
    destructor TWAHours.Destroy;
    begin
      AutoDestroy;
      inherited Destroy;
    end;
     
    procedure TWAHours.Loaded;
    begin
      inherited Loaded;
    end;
     
    procedure TWAHours.Paint;
    var ZRect,ZRectDeb,ZRectFin:TRect;
        i,j:Integer;
        NAM,NPM,NTOT:Integer;
        AMSectionHeight,PMSectionHeight:Integer;
        Hdeb,Hfin,s:string;
    begin
      NAM:=FHoursAM.Count;
      NPM:=FHoursPM.Count;
      NTOT:=NAM+NPM;
      if NTOT=0 then
      begin
        NAM:=1;
        NPM:=1;
        NTOT:=2;
      end;
     
      AMSectionHeight:=((NAM*Height) div NTOT);
      PMSectionHeight:=Height-AMSectionHeight;
      Canvas.Brush.Color := Color;
      Canvas.Brush.Style:=bsSolid;
      Canvas.Pen.Color :=Font.Color;
      Canvas.Rectangle(0, 0, Width, Height);
     
      //label matin
      ZRect:=Bounds(0,0,Width div 3,AMSectionHeight);
      DrawLabel('Matin',ZRect,taCenter,tlCenter,True,True);
     
      //label Après-Midi
      ZRect:=Bounds(0,0,Width div 3,PMSectionHeight);
      OffSetRect(ZRect,0,AMSectionHeight);
      DrawLabel('Après-Midi',ZRect,taCenter,tlCenter,True,True);
     
      ZRect:=Bounds(Width div 3,0,Width-(Width div 3),Height div NTOT);
      if FHoursAM.Count>0 then
      for i:=0 to NAM-1 do
      begin
        ZRectDeb:=ZRect;
        ZRectDeb.Bottom:=(zrect.Bottom+zrect.Top) div 2;
        ZRectFin:=ZRect;
        ZRectFin.top:=ZRectDeb.Bottom;
        s:=FHoursAM.Strings[i];
        j:=pos('/',s);
        if j=-1 then begin
                       Hdeb:=s;
                       Hfin:='';
                     end
                else begin
                       Hdeb:=copy(s,1,j-1);
                       Hfin:=copy(s,j+1,length(s));
                     end;
        DrawLabel('',ZRect,taRightJustify,tlTop,false,true);
        DrawLabel(Hdeb,ZRectDeb,taRightJustify,tlTop,false,false);
        DrawLabel(Hfin,ZRectFin,taRightJustify,tlBottom,false,false);
        if (i<(NTOT-1)) then OffSetRect(ZRect,0,Height div NTOT);
      end;
     
      if FHoursPM.Count>0 then
      for i:=0 to NPM-1 do
      begin
        ZRectDeb:=ZRect;
        ZRectDeb.Bottom:=(zrect.Bottom+zrect.Top) div 2;
        ZRectFin:=ZRect;
        ZRectFin.top:=ZRectDeb.Bottom;
        s:=FHoursPM.Strings[i];
        j:=pos('/',s);
        if j=-1 then begin
                       Hdeb:=s;
                       Hfin:='';
                     end
                else begin
                       Hdeb:=copy(s,1,j-1);
                       Hfin:=copy(s,j+1,length(s));
                     end;
        DrawLabel('',ZRect,taRightJustify,tlTop,false,true);
        DrawLabel(Hdeb,ZRectDeb,taRightJustify,tlTop,false,false);
        DrawLabel(Hfin,ZRectFin,taRightJustify,tlBottom,false,false);
        if (i<(NTOT-1)) then OffSetRect(ZRect,0,Height div NTOT);
      end;
    end;
     
    procedure TWAHours.WMSize(var Message: TWMSize);
    var
      W, H: Integer;
    begin
      inherited;
      W := Width;
      H := Height;
      if (W <> Width) or (H <> Height) then
        inherited SetBounds(Left, Top, W, H);
      Message.Result := 0;
    end;
     
     
    procedure TWAHours.DrawLabel(AString: string;ARect: TRect; Alignment:TAlignment;ALayout:TTextLayout;Angle,Framed:boolean);
    var
      AHeight,AWidth:integer;
      R:TRect;
      H,W,WW,HH,ATop,ALeft:Integer;
      FontNewHeight:integer;
      AText:string;
    begin
      Canvas.Font:=Font;
      with Canvas do
      begin
        Brush.Color:=Font.Color;
        if framed then
        FrameRect(ARect);
        if AString='' then exit;
        InflateRect(ARect,-1,-1);
        AHeight:=ARect.Bottom-ARect.Top;
        AWidth:=ARect.Right-ARect.Left;
        if AString[1]>='A'
        then AText:='WAprès-Midi'
        else AText:='W17h30';
        WW:=TextSize(AText,Font).X;
        HH:=TextSize(AText,Font).Y;
        if Angle then
        begin
          begin
            FontNewHeight:=Ceil(Font.Height*AHeight/WW);
            Font.Height:=FontNewHeight;
            W:=TextSize(AString,Font).X;
            H:=Round(TextSize(AString,Font).Y*1.5);
          end;
          if H>AWidth then
          begin
            FontNewHeight:=Ceil(Font.Height*AWidth/H);
            Font.Height:=FontNewHeight;
            W:=TextSize(AString,Font).X;
            H:=TextSize(AString,Font).Y;
          end;
        end
        else
        begin
          FontNewHeight:=Ceil(Font.Height*AWidth/WW);
          Font.Height:=FontNewHeight;
          W:=TextSize(AString,Font).X;
          H:=TextSize(AString,Font).Y;
          if H>AHeight then
          begin
            FontNewHeight:=Ceil(Font.Height*AHeight/H);
            Font.Height:=FontNewHeight;
            W:=TextSize(AString,Font).X;
            H:=TextSize(AString,Font).Y;
          end;
        end;
        if Angle then Font.Handle:=CreateRotatedFont(Font, 90);
        ATop:=ARect.Top;
        ALeft:=ARect.Left;
        if Angle then
        begin
          case ALayout of
            tlBottom : ATop:=ARect.Bottom-W;
            tlCenter : ATop:=ARect.Top+((AHeight-W) div 2);
            tlTop    : ATop:=ARect.Top;
          end;
     
          case Alignment of
            taLeftJustify  : ALeft:=ARect.Left;
            taCenter       : ALeft:=ARect.Left+(AWidth-H) div 2;
            taRightJustify : ALeft:=ARect.Right-H;
          end;
          R := Bounds(ALeft,ATop,H,W);
        end
        else
        begin
          case ALayout of
            tlBottom : ATop:=ARect.Bottom-H;
            tlCenter : ATop:=ARect.Top+((AHeight-H) div 2);
            tlTop    : ATop:=ARect.Top;
          end;
     
          case Alignment of
            taLeftJustify  : ALeft:=ARect.Left;
            taCenter       : ALeft:=ARect.Left+(AWidth-W) div 2;
            taRightJustify : ALeft:=ARect.Right-W;
          end;
          R := Bounds(ALeft,ATop,H,W);
        end;
        Canvas.Brush.Color := Color;
        if Angle
        then TextOut(R.Left,R.Bottom,AString)
        else TextOut(R.Left,R.Top,AString);
      end;
    end;
     
    function TWAHours.CreateRotatedFont(Font: TFont; Angle: Integer): HFont;
    var
      LogFont: TLogFont;
    begin
      If not IsTrueType(Font) then Font.Name:='Arial';
      FillChar(LogFont, SizeOf(LogFont), 0);
      with LogFont do begin
        lfHeight := Font.Height;
        lfWidth := 0;
        lfEscapement := Angle * 10;
        lfOrientation := 0;
        if fsBold in Font.Style then lfWeight := FW_BOLD
        else lfWeight := FW_NORMAL;
        lfItalic := Ord(fsItalic in Font.Style);
        lfUnderline := Ord(fsUnderline in Font.Style);
        lfStrikeOut := Byte(fsStrikeOut in Font.Style);
        lfCharSet := Byte(Font.Charset);
        StrPCopy(lfFaceName, Font.Name);
        lfQuality := DEFAULT_QUALITY;
        lfOutPrecision := OUT_DEFAULT_PRECIS;
        lfClipPrecision := CLIP_DEFAULT_PRECIS;
        case Font.Pitch of
          fpVariable: lfPitchAndFamily := VARIABLE_PITCH;
          fpFixed: lfPitchAndFamily := FIXED_PITCH;
          else lfPitchAndFamily := DEFAULT_PITCH;
        end;
      end;
      Result := CreateFontIndirect(LogFont);
    end;
     
    function TWAHours.IsTrueType(Font: TFont): Boolean;
    var
      Metrics: TTextMetric;
    begin
      Canvas.Font := Font;
      GetTextMetrics( Canvas.Handle, Metrics );
      Result := ( Metrics.tmPitchAndFamily and tmpf_TrueType ) = tmpf_TrueType;
    end;
     
    { TWADays }
     
    procedure TWADays.AutoDestroy;
    begin
      //
    end;
     
    procedure TWADays.AutoInitialize;
    var TheDate:TDate;
    begin
      Font.Name:='Arial';
      FNumberOfDays:=5;
      ParentColor:=false;
      TheDate:=DateOf(Now);
      FAutomaticMonday:=true;
      SetADate(TheDate);
    end;
     
    constructor TWADays.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
     AutoInitialize;
    end;
     
    destructor TWADays.Destroy;
    begin
      AutoDestroy;
      inherited Destroy;
    end;
     
    procedure TWADays.DrawLabel(AString: string; ARect: TRect;Ferie:boolean);
    var
      AHeight,AWidth:integer;
      R:TRect;
      H,W,WW,ATop,ALeft:Integer;
      FontNewHeight:integer;
      AText:string;
    begin
      Canvas.Font:=Font;
      Canvas.Font.Style:=[fsBold];
      with Canvas do
      begin
        Pen.Color:=Font.Color;
        if Ferie then
        begin
          Brush.Color:=Color;
          Brush.Style:=bssolid;
          FillRect(ARect);
          Brush.Color:=Font.Color;
          Canvas.Font.Color:=clRed;
          Brush.Style:=bsBDiagonal;
        end
        else
        begin
          Brush.Color:=Color;
          Brush.Style:=bssolid;
        end;
        Rectangle(ARect);
        InflateRect(ARect,-1,-1);
        AHeight:=ARect.Bottom-ARect.Top;
        AWidth:=ARect.Right-ARect.Left;
        W:=TextSize(AString,Font).X;
        AText:='WWW. WW/WW';
        WW:=TextSize(AText,Font).X;
        WW:=Max(W,WW);
     
        FontNewHeight:=Ceil(Font.Height*AWidth/WW);
        Font.Height:=FontNewHeight;
        W:=TextSize(AString,Font).X;
        H:=TextSize(AString,Font).Y;
     
        while H>(AHeight * 0.9) do
        begin
          Inc(FontNewHeight);
          Font.Height:=FontNewHeight;
          W:=TextSize(AString,Font).X;
          H:=TextSize(AString,Font).Y;
        end;
     
        ATop:=ARect.Top+((AHeight-H) div 2);
        ALeft:=ARect.Left+(AWidth-W) div 2;
        R := Bounds(ALeft,ATop,H,W);
        DrawText(Canvas.Handle,PChar(AString),Length(AString),ARect,DT_CENTER or DT_VCENTER);
      end;
    end;
     
    function TWADays.GetDayofWeekDate(ADayOfWeek: word): TDate;
    begin
      Result:=DowWY_to_Date(ADayOfWeek,FAWeek,FAYear_DowWY);
    end;
     
    procedure TWADays.Loaded;
    begin
      inherited Loaded;
    end;
     
    procedure TWADays.Paint;
    var ZRect:TRect;
        th:integer;
        FirstDate,ADate:TDate;
        AText:string;
        JourFerie:Boolean;
        s:string;
    begin
      FirstDate:=FADate;
      Canvas.Brush.Color := Color;
      Canvas.Pen.Color :=Font.Color;
      Canvas.Rectangle(0, 0, Width, Height);
      for th:=0 to FNumberOfDays-1 do
      begin
         ZRect:=Rect(th*(Width div FNumberOfDays),0,(th+1)*(Width div FNumberOfDays),Height);
         ADAte:=IncDay(FirstDate,th);
         JourFerie:=EstFerie(ADAte,s);
         AText:=FormatDateTime('ddd d/m',ADAte);
         Atext[1]:=UpCase(AText[1]);
         if s<>'' then AText:=Atext+#13#10+s;
         DrawLabel(AText,ZRect,JourFerie);
      end;
    end;
     
    procedure TWADays.SetADate(const Value: TDate);
    var cAday,cAMonth,cAYear_DMY,
        cADayofWeek,cAWeek,cAYear_DowWY:word;
    begin
      if (FADate<>Value) then
      begin
        FADate := Value;
        Date_to_DMY(FADate,cAday,cAMonth,cAYear_DMY);
        Date_to_DowWY(FADate,cADayofWeek,cAWeek,cAYear_DowWY);
        UpdateAll(cAday,cAMonth,cAYear_DMY,cADayofWeek,cAWeek,cAYear_DowWY);
        if AutomaticMonday then ADate:=GetDayofWeekDate(1);
      end;
    end;
     
    procedure TWADays.SetAday(const Value: Word);
    begin
      if (FAday<>Value) then
      begin
        FAday := Value;
        ADate := DMY_to_Date(FAday,FAMonth,FAYear_DMY);
      end;
    end;
     
    procedure TWADays.SetADayofWeek(const Value: Word);
    begin
      if (FADayofWeek<>Value) then
      begin
        FADayofWeek := Value;
        ADate := DowWY_to_Date(FADayofWeek,FAWeek,FAYear_DowWY);
      end;
    end;
     
    procedure TWADays.SetAMonth(const Value: Word);
    begin
      if (FAMonth<>Value) then
      begin
        FAMonth := Value;
        ADate := DMY_to_Date(FAday,FAMonth,FAYear_DMY);
      end;
    end;
     
    procedure TWADays.SetAutomaticMonday(const Value: boolean);
    begin
     if (FAutomaticMonday<>Value) then
     begin
       FAutomaticMonday := Value;
       if AutomaticMonday then ADate:=GetDayofWeekDate(1);
       invalidate;
     end;
    end;
     
    procedure TWADays.SetAWeek(const Value: word);
    begin
      if (FAWeek<>Value) then
      begin
        FAWeek := Value;
     
        if (FAWeek=0) then
          if (FAYear_DowWY=2000)
          then FAWeek:=1
          else begin
                 dec(FAYear_DowWY);
                 AWeek:=WeeksInAYear(FAYear_DowWY);
               end;
     
        if (FAWeek>WeeksInAYear(FAYear_DowWY)) then
           if (FAYear_DowWY=2200)
           then FAWeek:=WeeksInAYear(FAYear_DowWY)
        else begin
               inc(FAYear_DowWY);
               FAWeek:=1;
             end;
     
        ADate := DowWY_to_Date(FADayofWeek,FAWeek,FAYear_DowWY);
      end;
    end;
     
    procedure TWADays.SetAYear_DMY(const Value: Word);
    begin
      if (FAYear_DMY<>Value) then
      begin
        FAYear_DMY := Value;
        ADate := DMY_to_Date(FAday,FAMonth,FAYear_DMY);
      end;
    end;
     
    procedure TWADays.SetAYear_DowWY(const Value: Word);
    begin
      if (FAYear_DowWY<>Value) then
      begin
        FAYear_DowWY := Value;
        while (FAWeek>WeeksInYear(FAYear_DowWY)) do dec(FAWeek);
        ADate := DowWY_to_Date(FADayofWeek,FAWeek,FAYear_DowWY);
      end;
    end;
     
    procedure TWADays.SetNumberOfDays(const Value: integer);
    begin
      if Value>=1 then
      if (FNumberOfDays<>Value) then
      begin
        FNumberOfDays := Value;
        Invalidate;
      end;
    end;
     
    procedure TWADays.UpdateAll(cAday, cAMonth, cAYear_DMY, cADayofWeek,
      cAWeek, cAYear_DowWY: word);
    begin
      fAday:=cAday;
      fAMonth:=cAMonth;
      fAYear_DMY:=cAYear_DMY;
      fADayofWeek:=cADayofWeek;
      fAWeek:=cAWeek;
      fAYear_DowWY:=cAYear_DowWY;
      invalidate;
    end;
     
    procedure TWADays.WMSize(var Message: TWMSize);
    var
      W, H: Integer;
    begin
      inherited;
      W := Width;
      H := Height;
      if (W <> Width) or (H <> Height) then
        inherited SetBounds(Left, Top, W, H);
      Message.Result := 0;
    end;
     
     
    procedure TWAHours.SetHoursAM(const Value: TStringList);
    begin
      FHoursAM.Text:=value.Text;
      Invalidate;
    end;
     
    procedure TWAHours.SetHoursPM(const Value: TStringList);
    begin
      FHoursPM.Text:=value.Text;
      Invalidate;
    end;
     
    end.
    ça marche vachement mieux comme ça
    Bidouilleuse Delphi

  20. #20
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Citation Envoyé par petitprince
    Moi de mon coté, j'essai de dessiner sur un canvas des réctangle DnD pour les déplacer en fonction du jour....., et leur taille donne la durée du RDV... A suivre...
    Je vois TRES bien ce que tu veux faire, donc tu n'as pas besoin de TWAHours...
    Bidouilleuse Delphi

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 4 1234 DernièreDernière

Discussions similaires

  1. Recherche composant planning
    Par Sankasssss dans le forum VB.NET
    Réponses: 3
    Dernier message: 22/02/2011, 23h37
  2. Recherche composant ou méthode pour réaliser un plan dynamique
    Par kineton dans le forum Développement Windows
    Réponses: 0
    Dernier message: 14/10/2010, 10h14
  3. Recherche composant ou module pour newsletter+Joomla
    Par clem62173 dans le forum Autres
    Réponses: 1
    Dernier message: 11/01/2010, 17h00
  4. [Tests] Recherche Composant/outil/framework pour tester navigation web
    Par kaboume dans le forum Bibliothèques et frameworks
    Réponses: 2
    Dernier message: 25/11/2008, 11h34
  5. Recherche composant éditeur WYSIWYG pour Delphi (Win32)
    Par Nono40 dans le forum Composants VCL
    Réponses: 10
    Dernier message: 23/05/2008, 18h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo