// UTS 2000 - Fichier ' aff_bloc.cpp' Affiche un bloc graphique dans un TCO - 
// V3.7c - Le 22/09/2016
#include <windows.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "canton.h"
#include "balauto.h"
#include "Train_UTS.h"
#include "Train.h"

#define _CRT_SECURE_NO_WARNINGS  // Limite les messages de warning dans Visual C++

// Déclaration de diverses fonctions générales
extern void draw_fleche(char* sz, int x, int y);
extern int rendu_need_grostrait(int c);
extern int rendu_need_fleche(int c);
extern int pio_get_val(int);
extern void bmp_SetTextColor(int no_color);
extern int rendu_select_brush_for_canton(int c);
extern void rendu_select_pen_for_canton(int c);
extern void bmp_select_pen(int no_color);
extern void bmp_select_pen(HDC h_dc_, int no_color);
extern void bmp_select_brush(int no_color);
extern void bmp_select_brush(HDC h_dc_, int no_color);
extern int pio_set_val(int, int);
extern void cadre_relief(int, int, int, int, int, int);
extern void cadre_cercle_relief(int, int, int, int, int, int);
extern void cadenas_relief(int, int);

// Déclaration des classes externes
extern cBalauto     balauto;
extern cTrain train;

// Déclaration des variables externes
extern int moins_char_normal;   // 1: - est un caractère normal (comme 0)  0: - est un séparateur (comme +)
extern cCanton   canton;
extern HDC       hMemDC;
extern HFONT     la_fonte;
extern HFONT     cells_font;
extern HDC       h_dc_mem_cells;
extern HPEN      bmp_stylo_noir, bmp_stylo_bleu, bmp_stylo_vert, bmp_stylo_cyan, bmp_stylo_rouge, bmp_stylo_violet, bmp_stylo_jaune, bmp_stylo_blanc;
extern HPEN      bmp_stylo_gris128, bmp_stylo_gris192, bmp_stylo_orange, bmp_stylo_marron, bmp_stylo_kaki, bmp_stylo_bleuf, bmp_stylo_grisvert, bmp_stylo_vertfonce;
extern HPEN      bmp_stylo_bleuf2;
extern HPEN      bmp_stylo_griswin, bmp_stylo_gris32, bmp_stylo_gris64, bmp_stylo_gris128, bmp_stylo_gris192, bmp_stylo_gris220, bmp_stylo_gris230, bmp_stylo_gris240;
extern HBRUSH    bmp_pinceau_noir, bmp_pinceau_bleu, bmp_pinceau_vert, bmp_pinceau_cyan, bmp_pinceau_rouge, bmp_pinceau_orange;
extern HBRUSH    bmp_pinceau_violet, bmp_pinceau_jaune, bmp_pinceau_blanc, bmp_pinceau_gris192, bmp_pinceau_grisf;
extern HBRUSH    bmp_pinceau_bleuf2;
extern HBRUSH    bmp_pinceau_griswin, bmp_pinceau_gris32, bmp_pinceau_gris64, bmp_pinceau_gris128, bmp_pinceau_gris192, bmp_pinceau_gris220, bmp_pinceau_gris230, bmp_pinceau_gris240;
extern int balauto_halt_tab[BALAUTO_HALT_NB][BALAUTO_HALT_TAB_IND_TAILLE];

extern int rendu[RENDU_TAILLE];
extern int cells_tick;
extern int horo_tic_on;
extern int horo_blocked;
extern int horo_j;
extern int horo_h;
extern int horo_m;
extern int color_train[NB_TRAIN];
extern int train_pb_capt[NB_TRAIN]; // 0 ou 1, 1 => Le train n'est pas détecté sur les cantons.
extern char copy_train_name[NB_TRAIN][10], c_conf_wnd;

extern int vio_garage_lock_status[NB_GARAGE]; // 0 ou 1, 1 => Le garage est isolé du canton (état réel).

extern int color_canton[NB_CARTE][NB_CANTON];

extern int vio_det[NB_CARTE][NB_CANTON];
extern int copy_res_auto[NB_CARTE][NB_CANTON];
extern int copy_num_train[NB_CARTE][NB_CANTON];
extern int vio_canton_vit[NB_CARTE][NB_CANTON];
extern int canton_pb_capt[NB_CARTE][NB_CANTON];
extern int copy_allowed_sens[NB_CARTE][NB_CANTON];
extern int copy_master_selectif[NB_CARTE][NB_CANTON];
extern int copy_update_selectif[NB_CARTE][NB_CANTON];

extern int vio_aig_res[NB_AIG];
extern int vio_aig_pos0[NB_AIG];
extern int vio_aig_pos1[NB_AIG];

extern int copy_garage_num_train[NB_GARAGE];
extern int copy_garage_ass_canton[NB_GARAGE];
extern int cfg_relief, horo_nettoyage;
//extern int cells_rendu_general_couleur_fond;
//extern int cells_rendu_general_couleur_grille;
extern int cmd_divers[CMD_DIVERS_TAILLE];   // Tableau pour commander directement les déplacements par clic sur les cases du TCO
extern int depl_tab[DEPL_TAB_NB][DEPL_TAB_IND_TAILLE];
extern int iti_tab[ITI_TAB_NB][ITI_TAB_IND_TAILLE];

extern int balauto_vitmax_train[NB_TRAIN]; // Vitesse en cas de limitation de vitesse d'un train '#balauto' + 'vitmax:' != 0 => 'vitmax:'.
extern int balauto_halt_train[NB_TRAIN];   // =1 => En cas de halte d'un train sur un canton '#balauto' + 'halt:' = 1 => Train en 'halt:'.
extern int balauto_cant_train[NB_TRAIN];   // =2 => En cas de blocage d'un train sur un canton '#balauto' +'cant:' = 1 => Consigne vitesse du train = 0. =1 => Ralentissement.

void dessine_picto(int, int, int, int, int, int, int); // Fonction interne.


// Affiche le contenu animé d'une case de TCO à l'écran en fonction du contenu.
//
//                              Type/Sous type de bloc           Texte à afficher        Option n° et n°2                                                                Option
//                                                 Coordonnées xy du bloc à l'écran                      Variables V1,V2,v3 et V4                                                 Sens	
//                                                                             n° du canton                                              Couleur C1,C2,C3 et C4
void private_cells_draw_one(int type, int subtype, int x, int y, char szTxt[], int cant, int n1, int n2, int v1, int v2, int v3, int v4, int c1, int c2, int c3, int c4, int opt, int sens)
{
	int i, j, k, l, v, t, g, color, numpasse, color_fond, color2;
	char szTemp[100];
	int use_gros_trait = 0;
	g = -1;
	if (cant >= 1000)		// Si le numéro de canton est celui d'un garage, alors g=numéro de garage de 0 à 15.
	{					// Si le numéro de canton est celui d'un canton, alors g=-1; (ce n'est pas un garage)
		g = cant - 1000;
		if (g >= 0 && g < NB_GARAGE_REEL) cant = copy_garage_ass_canton[g]; else { g = 0; cant = -1; }
	}

	color = -1;
	color2 = -1;
	if (cfg_relief == 0) {
		bmp_select_pen(rendu[RENDU_COLOR_GRILLE]);	// Sélection de couleur pour la grille du TCO
		bmp_select_brush(rendu[RENDU_COLOR_FOND]);	// Sélection de couleur pour le fond du TCO
		color_fond = RENDU_COLOR_FOND;
	}
	else {
		bmp_select_pen(BMP_CST_COLOR_GRIS220);
		bmp_select_brush(BMP_CST_COLOR_GRISWIN);	// Sélection de couleur pour le fond du TCO
		color_fond = BMP_CST_COLOR_GRISWIN;
	}
	if (cfg_relief == 0) bmp_select_pen(rendu[RENDU_COLOR_GRILLE]);	// Sélection de couleur pour la grille du TCO
	else           bmp_select_pen(BMP_CST_COLOR_GRIS220);

	// V3.6a On optimise l'affichage en traçant un seul rectangle plutôt que : x*y Rectangle(h_dc_mem_cells,x,y,x+41,y+41);
	if (c_conf_wnd != ' ') Rectangle(h_dc_mem_cells, x, y, x + CELLS_SIZE + 1, y + CELLS_SIZE + 1); // Si une fenêtre est superposée, pas d'optimisation, on affiche tous les rectangles.
	else if (x == 0 && y == 0) {  // x = 0, 40, 80, 120,... 
		Rectangle(h_dc_mem_cells, 0, 0, CELLS_SIZE * (CELLS_X_NB), CELLS_SIZE * (CELLS_Y_NB)); // A l'affichage du premier bloc, on efface toute la fenêtre => Gain cpu.
		for (i = 0; i <= CELLS_X_NB; i++) { // Trace les lignes verticales
			MoveToEx(h_dc_mem_cells, i*CELLS_SIZE, 0, NULL); LineTo(h_dc_mem_cells, i*CELLS_SIZE, CELLS_Y_NB*CELLS_SIZE);
		}
		for (i = 0; i <= CELLS_Y_NB; i++) { // Trace les lignes verticales
			MoveToEx(h_dc_mem_cells, 0, i*CELLS_SIZE, NULL); LineTo(h_dc_mem_cells, CELLS_X_NB*CELLS_SIZE, i*CELLS_SIZE);
		}
	}

	// Sélectionne la couleur de fond d'un objet en fonction de son numéro de canton (occupation ou état).
	if (type == CELLS_TYPE_LINK || type == CELLS_TYPE_AIG || type == CELLS_TYPE_SPE) color2 = rendu_select_brush_for_canton(cant);
	if (g != -1) if (vio_garage_lock_status[g]) if (cant != -1)	// Si le garage est isolé, il n'est pas utilisé // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
	{
		if (cfg_relief == 0) bmp_select_pen(rendu[RENDU_COLOR_GRILLE]);	// Sélection de couleur pour la grille du TCO
		else                 bmp_select_pen(BMP_CST_COLOR_GRIS220);
		if (cfg_relief > 0) color = BMP_CST_COLOR_GRISWIN; else color = rendu[RENDU_COLOR_FOND_GARALOCK];
		if (color == BMP_CST_COLOR_TRAIN)  if (copy_num_train[cant / 100][cant % 100] != -1) color = color_train[copy_num_train[cant / 100][cant % 100]];
		if (color == BMP_CST_COLOR_CANTON) if (cant != -1) color = color_canton[cant / 100][cant % 100]; // 1 en -1
		bmp_select_brush(color);
	}

	if (sens == -10 ) { // Bloc symbol de démonstration pour la configuration du TCO.
		sens = -1;
		color = BMP_CST_COLOR_BLANC;
		bmp_select_brush(color);
	}

	if ((color_fond != color && color != -1) || (color_fond != color2 && color2 != -1)) { // Pour redessiner le fond uniquement les blocs qui ont une autre couleur de fond.
		Rectangle(h_dc_mem_cells, x , y , x + CELLS_SIZE+1, y + CELLS_SIZE+1);
	}

	if (type == CELLS_TYPE_SPE && ((subtype == CELLS_SUBTYPE_SPE_CANT) || (subtype == CELLS_SUBTYPE_SPE_CANTV))) {
		if (cfg_relief == 0) bmp_select_pen(rendu[RENDU_COLOR_GRILLE]);	// Sélection de couleur pour la grille du TCO
		else           bmp_select_pen(BMP_CST_COLOR_GRIS220);
		if (cant != -1) if (g == -1 || (g != -1 && vio_garage_lock_status[g] == 0)) {  // Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
			if (CLIGNOTE_LENT) if (canton_pb_capt[cant / 100][cant % 100]) {
				SelectObject(h_dc_mem_cells, bmp_pinceau_rouge); color = BMP_CST_COLOR_ROUGE;
			}
		}
		Rectangle(h_dc_mem_cells, x + 2, y + 2, x + CELLS_SIZE - 1, y + CELLS_SIZE - 1);
	}
	
	// Selection de la couleur des traits pour les voies
	rendu_select_pen_for_canton(cant);
	use_gros_trait = rendu_need_grostrait(cant);
	if (g != -1) if (vio_garage_lock_status[g]) if (cant != -1) { // Garage isolé. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
		color = rendu[RENDU_COLOR_RAIL_GARALOCK];
		if (color == BMP_CST_COLOR_TRAIN)  if (copy_garage_num_train[g] != -1) color = color_train[copy_garage_num_train[g]];
		if (color == BMP_CST_COLOR_CANTON) if (cant != 1) color = color_canton[cant / 100][cant % 100];
		bmp_select_pen(color);
		if (rendu[RENDU_USE_GROS_GARALOCK]) use_gros_trait = 1; else use_gros_trait = 0;
	}


	// Dessine le contenu d'un bloc du TCO
	if (type == CELLS_TYPE_LINK) { // Dessine une portion de voie simple dans le TCO
		for (numpasse = 0; numpasse<2; numpasse++) { // Deuxième passe pour tracer la deuxième voie sur le même bloc.
			switch (subtype) {
			case CELLS_SUBTYPE_LINK_H:  // Voie horizontale = '-'
				if (g == -1 && rendu_need_fleche(cant)) { // On va afficher l'état d'un canton.
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
				}
				if (g != -1) { // On va afficher l'état d'un garage
					if (vio_garage_lock_status[g] == 0 && cant != -1 && rendu_need_fleche(cant)) { //  Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
						if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
						if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
					}
				}
				if ((opt & 1) == 0 || opt == -1 || opt > 3) { // Voie principale horizontale en trait plein = '-'. NE PAS SUPPRIMER les parenthéses autour de (opt&1).
					MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E); // Dessine le trait simple
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19); // Dessine le trait gras
						MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
					}
				}
				else { // Voie principale horizontale en pointillé = '-'
					MoveToEx(h_dc_mem_cells, x + 03, y + 20, NULL); LineTo(h_dc_mem_cells, x + 07, y + 20);
					MoveToEx(h_dc_mem_cells, x + 13, y + 20, NULL); LineTo(h_dc_mem_cells, x + 17, y + 20);
					MoveToEx(h_dc_mem_cells, x + 23, y + 20, NULL); LineTo(h_dc_mem_cells, x + 27, y + 20);
					MoveToEx(h_dc_mem_cells, x + 33, y + 20, NULL); LineTo(h_dc_mem_cells, x + 37, y + 20);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 03, y + 19, NULL); LineTo(h_dc_mem_cells, x + 07, y + 19); // Dessine le trait gras
						MoveToEx(h_dc_mem_cells, x + 13, y + 19, NULL); LineTo(h_dc_mem_cells, x + 17, y + 19);
						MoveToEx(h_dc_mem_cells, x + 23, y + 19, NULL); LineTo(h_dc_mem_cells, x + 27, y + 19);
						MoveToEx(h_dc_mem_cells, x + 33, y + 19, NULL); LineTo(h_dc_mem_cells, x + 37, y + 19);
						MoveToEx(h_dc_mem_cells, x + 03, y + 21, NULL); LineTo(h_dc_mem_cells, x + 07, y + 21);
						MoveToEx(h_dc_mem_cells, x + 13, y + 21, NULL); LineTo(h_dc_mem_cells, x + 17, y + 21);
						MoveToEx(h_dc_mem_cells, x + 23, y + 21, NULL); LineTo(h_dc_mem_cells, x + 27, y + 21);
						MoveToEx(h_dc_mem_cells, x + 33, y + 21, NULL); LineTo(h_dc_mem_cells, x + 37, y + 21);
					}
				}
				break;

			case CELLS_SUBTYPE_LINK_V:  // Voie verticale = '|'
				if (g == -1 && rendu_need_fleche(cant)) { // On va afficher l'état d'un canton.
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
				}
				if (g != -1) { // On va afficher l'état d'un garage
					if (vio_garage_lock_status[g] == 0 && cant != -1 && rendu_need_fleche(cant)) { //  Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
						if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
						if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
					}
				}
				if ((opt & 1) == 0 || opt == -1 || opt > 3) { // Voie principale horizontale en trait plein = '|'
					MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_S);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
						MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
					}
				}
				else { // Voie principale horizontale en pointillé = '|'
					MoveToEx(h_dc_mem_cells, x + 20, y + 03, NULL); LineTo(h_dc_mem_cells, x + 20, y + 07);
					MoveToEx(h_dc_mem_cells, x + 20, y + 13, NULL); LineTo(h_dc_mem_cells, x + 20, y + 17);
					MoveToEx(h_dc_mem_cells, x + 20, y + 23, NULL); LineTo(h_dc_mem_cells, x + 20, y + 27);
					MoveToEx(h_dc_mem_cells, x + 20, y + 33, NULL); LineTo(h_dc_mem_cells, x + 20, y + 37);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 19, y + 03, NULL); LineTo(h_dc_mem_cells, x + 19, y + 07); // Dessine le trait gras
						MoveToEx(h_dc_mem_cells, x + 19, y + 13, NULL); LineTo(h_dc_mem_cells, x + 19, y + 17);
						MoveToEx(h_dc_mem_cells, x + 19, y + 23, NULL); LineTo(h_dc_mem_cells, x + 19, y + 27);
						MoveToEx(h_dc_mem_cells, x + 19, y + 33, NULL); LineTo(h_dc_mem_cells, x + 19, y + 37);
						MoveToEx(h_dc_mem_cells, x + 21, y + 03, NULL); LineTo(h_dc_mem_cells, x + 21, y + 07);
						MoveToEx(h_dc_mem_cells, x + 21, y + 13, NULL); LineTo(h_dc_mem_cells, x + 21, y + 17);
						MoveToEx(h_dc_mem_cells, x + 21, y + 23, NULL); LineTo(h_dc_mem_cells, x + 21, y + 27);
						MoveToEx(h_dc_mem_cells, x + 21, y + 33, NULL); LineTo(h_dc_mem_cells, x + 21, y + 37);
					}
				}
				break;

			case CELLS_SUBTYPE_LINK_PH:  // Voie horizontale = '-' en pointillée
				MoveToEx(h_dc_mem_cells, x + 03, y + 20, NULL); LineTo(h_dc_mem_cells, x + 07, y + 20);
				MoveToEx(h_dc_mem_cells, x + 13, y + 20, NULL); LineTo(h_dc_mem_cells, x + 17, y + 20);
				MoveToEx(h_dc_mem_cells, x + 23, y + 20, NULL); LineTo(h_dc_mem_cells, x + 27, y + 20);
				MoveToEx(h_dc_mem_cells, x + 33, y + 20, NULL); LineTo(h_dc_mem_cells, x + 37, y + 20);
				if (use_gros_trait) {
					MoveToEx(h_dc_mem_cells, x + 03, y + 19, NULL); LineTo(h_dc_mem_cells, x + 07, y + 19);	// Dessine le trait gras
					MoveToEx(h_dc_mem_cells, x + 13, y + 19, NULL); LineTo(h_dc_mem_cells, x + 17, y + 19);
					MoveToEx(h_dc_mem_cells, x + 23, y + 19, NULL); LineTo(h_dc_mem_cells, x + 27, y + 19);
					MoveToEx(h_dc_mem_cells, x + 33, y + 19, NULL); LineTo(h_dc_mem_cells, x + 37, y + 19);
					MoveToEx(h_dc_mem_cells, x + 03, y + 21, NULL); LineTo(h_dc_mem_cells, x + 07, y + 21);
					MoveToEx(h_dc_mem_cells, x + 13, y + 21, NULL); LineTo(h_dc_mem_cells, x + 17, y + 21);
					MoveToEx(h_dc_mem_cells, x + 23, y + 21, NULL); LineTo(h_dc_mem_cells, x + 27, y + 21);
					MoveToEx(h_dc_mem_cells, x + 33, y + 21, NULL); LineTo(h_dc_mem_cells, x + 37, y + 21);
				}
				if (rendu_need_fleche(cant)) {	// Dessine une fléche droite au gauche sur la voie
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
				}
				break;


			case CELLS_SUBTYPE_LINK_PV:  // Voie verticale = '|' en pointillée
				MoveToEx(h_dc_mem_cells, x + 20, y + 03, NULL); LineTo(h_dc_mem_cells, x + 20, y + 07);
				MoveToEx(h_dc_mem_cells, x + 20, y + 13, NULL); LineTo(h_dc_mem_cells, x + 20, y + 17);
				MoveToEx(h_dc_mem_cells, x + 20, y + 23, NULL); LineTo(h_dc_mem_cells, x + 20, y + 27);
				MoveToEx(h_dc_mem_cells, x + 20, y + 33, NULL); LineTo(h_dc_mem_cells, x + 20, y + 37);
				if (use_gros_trait) {
					MoveToEx(h_dc_mem_cells, x + 19, y + 03, NULL); LineTo(h_dc_mem_cells, x + 19, y + 07);
					MoveToEx(h_dc_mem_cells, x + 19, y + 13, NULL); LineTo(h_dc_mem_cells, x + 19, y + 17);
					MoveToEx(h_dc_mem_cells, x + 19, y + 23, NULL); LineTo(h_dc_mem_cells, x + 19, y + 27);
					MoveToEx(h_dc_mem_cells, x + 19, y + 33, NULL); LineTo(h_dc_mem_cells, x + 19, y + 37);
					MoveToEx(h_dc_mem_cells, x + 21, y + 03, NULL); LineTo(h_dc_mem_cells, x + 21, y + 07);
					MoveToEx(h_dc_mem_cells, x + 21, y + 13, NULL); LineTo(h_dc_mem_cells, x + 21, y + 17);
					MoveToEx(h_dc_mem_cells, x + 21, y + 23, NULL); LineTo(h_dc_mem_cells, x + 21, y + 27);
					MoveToEx(h_dc_mem_cells, x + 21, y + 33, NULL); LineTo(h_dc_mem_cells, x + 21, y + 37);
				}
				if (rendu_need_fleche(cant)) {
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
				}
				break;

			case CELLS_SUBTYPE_LINK_SONE: // Voie grande diagonale = '/'
				if (g == -1 && rendu_need_fleche(cant)) { // On va afficher l'état d'un canton.
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("NE", x, y); if (sens == 1) draw_fleche("SO", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("SO", x, y); if (sens == 1) draw_fleche("NE", x, y); }
				}
				if (g != -1) { // On va afficher l'état d'un garage
					if (vio_garage_lock_status[g] == 0 && cant != -1 && rendu_need_fleche(cant)) { //  Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
						if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("NE", x, y); if (sens == 1) draw_fleche("SO", x, y); }
						if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("SO", x, y); if (sens == 1) draw_fleche("NE", x, y); }
					}
				}
				if ((opt & 1) == 0 || opt == -1 || opt > 3) { // Voie principale grande diagonale en trait plein = '/'
					MoveToEx(h_dc_mem_cells, CELLS_SO, NULL); LineTo(h_dc_mem_cells, CELLS_NE);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 0, y + 39, NULL); LineTo(h_dc_mem_cells, x + 39, y + 0);
						MoveToEx(h_dc_mem_cells, x + 1, y + 40, NULL); LineTo(h_dc_mem_cells, x + 40, y + 1);
					}
				}
				else { // Voie principale grande diagonale en pointillé = '/'
					MoveToEx(h_dc_mem_cells, x + 03, y + 37, NULL); LineTo(h_dc_mem_cells, x + 07, y + 33);
					MoveToEx(h_dc_mem_cells, x + 13, y + 27, NULL); LineTo(h_dc_mem_cells, x + 17, y + 23);
					MoveToEx(h_dc_mem_cells, x + 23, y + 17, NULL); LineTo(h_dc_mem_cells, x + 27, y + 13);
					MoveToEx(h_dc_mem_cells, x + 33, y + 07, NULL); LineTo(h_dc_mem_cells, x + 37, y + 03);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 03, y + 36, NULL); LineTo(h_dc_mem_cells, x + 06, y + 33); // Dessine le trait gras
						MoveToEx(h_dc_mem_cells, x + 04, y + 37, NULL); LineTo(h_dc_mem_cells, x + 07, y + 34);
						MoveToEx(h_dc_mem_cells, x + 13, y + 26, NULL); LineTo(h_dc_mem_cells, x + 16, y + 23);
						MoveToEx(h_dc_mem_cells, x + 14, y + 27, NULL); LineTo(h_dc_mem_cells, x + 17, y + 24);
						MoveToEx(h_dc_mem_cells, x + 23, y + 16, NULL); LineTo(h_dc_mem_cells, x + 26, y + 13);
						MoveToEx(h_dc_mem_cells, x + 24, y + 17, NULL); LineTo(h_dc_mem_cells, x + 27, y + 14);
						MoveToEx(h_dc_mem_cells, x + 33, y + 06, NULL); LineTo(h_dc_mem_cells, x + 36, y + 03);
						MoveToEx(h_dc_mem_cells, x + 34, y + 07, NULL); LineTo(h_dc_mem_cells, x + 37, y + 04);
					}
				}
				break;

			case CELLS_SUBTYPE_LINK_NOSE: // Voie grande diagonale = '\'
				if (g == -1 && rendu_need_fleche(cant)) { // On va afficher l'état d'un canton.
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("SE", x, y); if (sens == 1) draw_fleche("NO", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("NO", x, y); if (sens == 1) draw_fleche("SE", x, y); }
				}
				if (g != -1) { // On va afficher l'état d'un garage
					if (vio_garage_lock_status[g] == 0 && cant != -1 && rendu_need_fleche(cant)) { //  Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
						if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("SE", x, y); if (sens == 1) draw_fleche("NO", x, y); }
						if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("NO", x, y); if (sens == 1) draw_fleche("SE", x, y); }
					}
				}
				if ((opt & 1) == 0 || opt == -1 || opt > 3) { // Voie principale grande diagonale en trait plein = '\'
					MoveToEx(h_dc_mem_cells, CELLS_NO, NULL); LineTo(h_dc_mem_cells, CELLS_SE);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 1, y + 0, NULL); LineTo(h_dc_mem_cells, x + 40, y + 39);
						MoveToEx(h_dc_mem_cells, x + 0, y + 1, NULL); LineTo(h_dc_mem_cells, x + 39, y + 40);
					}
				}
				else { // Voie principale grande diagonale en pointillé = '\'
					MoveToEx(h_dc_mem_cells, x + 03, y + 03, NULL); LineTo(h_dc_mem_cells, x + 07, y + 07);
					MoveToEx(h_dc_mem_cells, x + 13, y + 13, NULL); LineTo(h_dc_mem_cells, x + 17, y + 17);
					MoveToEx(h_dc_mem_cells, x + 23, y + 23, NULL); LineTo(h_dc_mem_cells, x + 27, y + 27);
					MoveToEx(h_dc_mem_cells, x + 33, y + 33, NULL); LineTo(h_dc_mem_cells, x + 37, y + 37);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 04, y + 03, NULL); LineTo(h_dc_mem_cells, x + 07, y + 06); // Dessine le trait gras
						MoveToEx(h_dc_mem_cells, x + 03, y + 04, NULL); LineTo(h_dc_mem_cells, x + 06, y + 07);
						MoveToEx(h_dc_mem_cells, x + 14, y + 13, NULL); LineTo(h_dc_mem_cells, x + 17, y + 16);
						MoveToEx(h_dc_mem_cells, x + 13, y + 14, NULL); LineTo(h_dc_mem_cells, x + 16, y + 17);
						MoveToEx(h_dc_mem_cells, x + 24, y + 23, NULL); LineTo(h_dc_mem_cells, x + 27, y + 26);
						MoveToEx(h_dc_mem_cells, x + 23, y + 24, NULL); LineTo(h_dc_mem_cells, x + 26, y + 27);
						MoveToEx(h_dc_mem_cells, x + 34, y + 33, NULL); LineTo(h_dc_mem_cells, x + 37, y + 36);
						MoveToEx(h_dc_mem_cells, x + 33, y + 34, NULL); LineTo(h_dc_mem_cells, x + 36, y + 37);
					}
				}
				break;

			case CELLS_SUBTYPE_LINK_SE: // Voie petite diagonale bas-droit = '/'
				if ((opt & 1) == 0 || opt == -1 || opt > 3) {
					MoveToEx(h_dc_mem_cells, CELLS_S, NULL); LineTo(h_dc_mem_cells, CELLS_E);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 19, y + 40, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
						MoveToEx(h_dc_mem_cells, x + 21, y + 40, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
					}
				}
				else {
					MoveToEx(h_dc_mem_cells, x + 23, y + 37, NULL); LineTo(h_dc_mem_cells, x + 27, y + 33);
					MoveToEx(h_dc_mem_cells, x + 33, y + 27, NULL); LineTo(h_dc_mem_cells, x + 37, y + 23);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 22, y + 37, NULL); LineTo(h_dc_mem_cells, x + 26, y + 33);
						MoveToEx(h_dc_mem_cells, x + 23, y + 38, NULL); LineTo(h_dc_mem_cells, x + 27, y + 34);
						MoveToEx(h_dc_mem_cells, x + 32, y + 27, NULL); LineTo(h_dc_mem_cells, x + 36, y + 23);
						MoveToEx(h_dc_mem_cells, x + 33, y + 28, NULL); LineTo(h_dc_mem_cells, x + 37, y + 24);
					}
				}
				if (rendu_need_fleche(cant)) {
					if ((vio_canton_vit[cant / 100][cant % 100]>0 && sens == 0) || (vio_canton_vit[cant / 100][cant % 100]<0 && sens == 1)) {
						MoveToEx(h_dc_mem_cells, x + 33, y + 23, NULL); LineTo(h_dc_mem_cells, x + 37, y + 23); // draw_fleche("E",x,y) 
						LineTo(h_dc_mem_cells, x + 37, y + 27);        LineTo(h_dc_mem_cells, x + 33, y + 23);
					}
					if ((vio_canton_vit[cant / 100][cant % 100]>0 && sens == 1) || (vio_canton_vit[cant / 100][cant % 100]<0 && sens == 0)) {
						MoveToEx(h_dc_mem_cells, x + 23, y + 33, NULL); LineTo(h_dc_mem_cells, x + 23, y + 37); // draw_fleche("S",x,y)
						LineTo(h_dc_mem_cells, x + 27, y + 37);        LineTo(h_dc_mem_cells, x + 23, y + 33);
					}
				}
				break;


			case CELLS_SUBTYPE_LINK_OS: // Voie petite diagonale gauche-bas = '\'
				if ((opt & 1) == 0 || opt == -1 || opt > 3) {
					MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_S);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 19, y + 40, NULL); LineTo(h_dc_mem_cells, x + 0, y + 21);
						MoveToEx(h_dc_mem_cells, x + 21, y + 40, NULL); LineTo(h_dc_mem_cells, x + 0, y + 19);
					}
				}
				else {
					MoveToEx(h_dc_mem_cells, x + 03, y + 23, NULL); LineTo(h_dc_mem_cells, x + 07, y + 27);
					MoveToEx(h_dc_mem_cells, x + 13, y + 33, NULL); LineTo(h_dc_mem_cells, x + 17, y + 37);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 4, y + 23, NULL); LineTo(h_dc_mem_cells, x + 8, y + 27);
						MoveToEx(h_dc_mem_cells, x + 03, y + 24, NULL); LineTo(h_dc_mem_cells, x + 07, y + 28);
						MoveToEx(h_dc_mem_cells, x + 14, y + 33, NULL); LineTo(h_dc_mem_cells, x + 18, y + 37);
						MoveToEx(h_dc_mem_cells, x + 13, y + 34, NULL); LineTo(h_dc_mem_cells, x + 17, y + 38);
					}
				}
				if (rendu_need_fleche(cant)) {
					if ((vio_canton_vit[cant / 100][cant % 100]>0 && sens == 0) || (vio_canton_vit[cant / 100][cant % 100]<0 && sens == 1)) {
						MoveToEx(h_dc_mem_cells, x + 13, y + 37, NULL); LineTo(h_dc_mem_cells, x + 17, y + 37); // draw_fleche("S",x,y)
						LineTo(h_dc_mem_cells, x + 17, y + 33);        LineTo(h_dc_mem_cells, x + 13, y + 37);
					}
					if ((vio_canton_vit[cant / 100][cant % 100]>0 && sens == 1) || (vio_canton_vit[cant / 100][cant % 100]<0 && sens == 0)) {
						MoveToEx(h_dc_mem_cells, x + 07, y + 23, NULL); LineTo(h_dc_mem_cells, x + 03, y + 23); // draw_fleche("O",x,y)
						LineTo(h_dc_mem_cells, x + 03, y + 27);      LineTo(h_dc_mem_cells, x + 07, y + 23);
					}
				}
				break;


			case CELLS_SUBTYPE_LINK_NE: // Voie petite diagonale haut-droit = '\'
				if ((opt & 1) == 0 || opt == -1 || opt > 3) {
					MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_E);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
						MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
					}
				}
				else {
					MoveToEx(h_dc_mem_cells, x + 23, y + 3, NULL); LineTo(h_dc_mem_cells, x + 27, y + 7);
					MoveToEx(h_dc_mem_cells, x + 33, y + 13, NULL); LineTo(h_dc_mem_cells, x + 37, y + 17);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 23, y + 4, NULL); LineTo(h_dc_mem_cells, x + 27, y + 8);
						MoveToEx(h_dc_mem_cells, x + 24, y + 3, NULL); LineTo(h_dc_mem_cells, x + 28, y + 7);
						MoveToEx(h_dc_mem_cells, x + 33, y + 14, NULL); LineTo(h_dc_mem_cells, x + 37, y + 18);
						MoveToEx(h_dc_mem_cells, x + 34, y + 13, NULL); LineTo(h_dc_mem_cells, x + 38, y + 17);
					}
				}
				if (rendu_need_fleche(cant)) {
					if ((vio_canton_vit[cant / 100][cant % 100]>0 && sens == 0) || (vio_canton_vit[cant / 100][cant % 100]<0 && sens == 1)) {
						MoveToEx(h_dc_mem_cells, x + 37, y + 13, NULL); LineTo(h_dc_mem_cells, x + 37, y + 17); // draw_fleche("E",x,y)
						LineTo(h_dc_mem_cells, x + 33, y + 17);        LineTo(h_dc_mem_cells, x + 37, y + 13);
					}
					if ((vio_canton_vit[cant / 100][cant % 100]>0 && sens == 1) || (vio_canton_vit[cant / 100][cant % 100]<0 && sens == 0)) {
						MoveToEx(h_dc_mem_cells, x + 27, y + 03, NULL); LineTo(h_dc_mem_cells, x + 23, y + 03); // draw_fleche("N",x,y)
						LineTo(h_dc_mem_cells, x + 23, y + 07);      LineTo(h_dc_mem_cells, x + 27, y + 03);
					}
				}
				break;

			case CELLS_SUBTYPE_LINK_ON: // Voie petite diagonale gauche-haut = '/'
				if ((opt & 1) == 0 || opt == -1 || opt > 3) {
					MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_N);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 19, y + 0);
						MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 21, y + 0);
					}
				}
				else {
					MoveToEx(h_dc_mem_cells, x + 3, y + 17, NULL); LineTo(h_dc_mem_cells, x + 7, y + 13);
					MoveToEx(h_dc_mem_cells, x + 13, y + 7, NULL); LineTo(h_dc_mem_cells, x + 17, y + 3);
					if (use_gros_trait) {
						MoveToEx(h_dc_mem_cells, x + 2, y + 17, NULL); LineTo(h_dc_mem_cells, x + 6, y + 13);
						MoveToEx(h_dc_mem_cells, x + 3, y + 18, NULL); LineTo(h_dc_mem_cells, x + 7, y + 14);
						MoveToEx(h_dc_mem_cells, x + 12, y + 7, NULL); LineTo(h_dc_mem_cells, x + 16, y + 3);
						MoveToEx(h_dc_mem_cells, x + 13, y + 8, NULL); LineTo(h_dc_mem_cells, x + 17, y + 4);
					}
				}
				if (rendu_need_fleche(cant)) {
					if ((vio_canton_vit[cant / 100][cant % 100]>0 && sens == 0) || (vio_canton_vit[cant / 100][cant % 100]<0 && sens == 1)) {
						MoveToEx(h_dc_mem_cells, x + 13, y + 03, NULL); LineTo(h_dc_mem_cells, x + 17, y + 03); // draw_fleche("N",x,y)
						LineTo(h_dc_mem_cells, x + 17, y + 07);        LineTo(h_dc_mem_cells, x + 13, y + 03);
					}
					if ((vio_canton_vit[cant / 100][cant % 100]>0 && sens == 1) || (vio_canton_vit[cant / 100][cant % 100]<0 && sens == 0)) {
						MoveToEx(h_dc_mem_cells, x + 07, y + 17, NULL); LineTo(h_dc_mem_cells, x + 03, y + 17); // draw_fleche("O",x,y)
						LineTo(h_dc_mem_cells, x + 03, y + 13);      LineTo(h_dc_mem_cells, x + 07, y + 17);
					}
				}
				break;

			case CELLS_SUBTYPE_LINK_SOE:// Voie diagonale par le centre bas-droit = '/-'
				MoveToEx(h_dc_mem_cells, CELLS_SO, NULL); LineTo(h_dc_mem_cells, CELLS_C);
				MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_E);
				if (use_gros_trait) {
					MoveToEx(h_dc_mem_cells, x + 0, y + 39, NULL); LineTo(h_dc_mem_cells, x + 20, y + 19); LineTo(h_dc_mem_cells, x + 40, y + 19);
					MoveToEx(h_dc_mem_cells, x + 1, y + 40, NULL); LineTo(h_dc_mem_cells, x + 20, y + 21); LineTo(h_dc_mem_cells, x + 40, y + 21);
				}
				if (rendu_need_fleche(cant)) {
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("SO", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("SO", x, y); if (sens == 1) draw_fleche("E", x, y); }
				}
				break;

			case CELLS_SUBTYPE_LINK_OSE: // Voie diagonale par le centre gauche-bas = '-\'
				MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_C);
				MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_SE);
				if (use_gros_trait) {
					MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 20, y + 19); LineTo(h_dc_mem_cells, x + 40, y + 39);
					MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 20, y + 21); LineTo(h_dc_mem_cells, x + 39, y + 40);
				}
				if (rendu_need_fleche(cant)) {
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("SE", x, y); if (sens == 1) draw_fleche("O", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("SE", x, y); }
				}
				break;

			case CELLS_SUBTYPE_LINK_NOE: // Voie diagonale par le centre haut-gauche= '\-'
				MoveToEx(h_dc_mem_cells, CELLS_NO, NULL); LineTo(h_dc_mem_cells, CELLS_C);
				MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_E);
				if (use_gros_trait) {
					MoveToEx(h_dc_mem_cells, x + 1, y + 0, NULL); LineTo(h_dc_mem_cells, x + 20, y + 19); LineTo(h_dc_mem_cells, x + 40, y + 19);
					MoveToEx(h_dc_mem_cells, x + 0, y + 1, NULL); LineTo(h_dc_mem_cells, x + 20, y + 21); LineTo(h_dc_mem_cells, x + 40, y + 21);
				}
				if (rendu_need_fleche(cant)) {
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("NO", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("NO", x, y); if (sens == 1) draw_fleche("E", x, y); }
				}
				break;

			case CELLS_SUBTYPE_LINK_ONE: // Voie diagonale par le centre gauche-haut= '-/'
				MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_C);
				MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_NE);
				if (use_gros_trait) {
					MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 20, y + 19); LineTo(h_dc_mem_cells, x + 39, y + 0);
					MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 20, y + 21); LineTo(h_dc_mem_cells, x + 40, y + 1);
				}
				if (rendu_need_fleche(cant)) {
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("NE", x, y); if (sens == 1) draw_fleche("O", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("NE", x, y); }
				}
				break;


				//                                                                               '|'
			case CELLS_SUBTYPE_LINK_SON: // Voie diagonale par le centre V3.3 = '/'
				MoveToEx(h_dc_mem_cells, CELLS_SO, NULL); LineTo(h_dc_mem_cells, CELLS_C);
				MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_N);
				if (use_gros_trait) {
					MoveToEx(h_dc_mem_cells, x + 0, y + 39, NULL); LineTo(h_dc_mem_cells, x + 19, y + 20); LineTo(h_dc_mem_cells, x + 19, y);
					MoveToEx(h_dc_mem_cells, x + 1, y + 40, NULL); LineTo(h_dc_mem_cells, x + 21, y + 20); LineTo(h_dc_mem_cells, x + 21, y);
				}
				if (rendu_need_fleche(cant)){
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("SO", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("SO", x, y); if (sens == 1) draw_fleche("N", x, y); }
				}
				break;

				//                                                                               '|'
			case CELLS_SUBTYPE_LINK_NSE: // Voie diagonale par le centre V3.3 = '\'
				MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_C);
				MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_SE);
				if (use_gros_trait) {
					MoveToEx(h_dc_mem_cells, x + 39, y + 40, NULL); LineTo(h_dc_mem_cells, x + 19, y + 20); LineTo(h_dc_mem_cells, x + 19, y);
					MoveToEx(h_dc_mem_cells, x + 40, y + 39, NULL); LineTo(h_dc_mem_cells, x + 21, y + 20); LineTo(h_dc_mem_cells, x + 21, y);
				}
				if (rendu_need_fleche(cant)) {
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("SE", x, y); if (sens == 1) draw_fleche("N", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("SE", x, y); }
				}
				break;

				//                                                                               '\'
			case CELLS_SUBTYPE_LINK_NOS: // Voie diagonale par le centre V3.3 = '|'
				MoveToEx(h_dc_mem_cells, CELLS_NO, NULL); LineTo(h_dc_mem_cells, CELLS_C);
				MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_S);
				if (use_gros_trait) {
					MoveToEx(h_dc_mem_cells, x, y + 1, NULL); LineTo(h_dc_mem_cells, x + 19, y + 20); LineTo(h_dc_mem_cells, x + 19, y + 40);
					MoveToEx(h_dc_mem_cells, x + 1, y, NULL); LineTo(h_dc_mem_cells, x + 21, y + 20); LineTo(h_dc_mem_cells, x + 21, y + 40);
				}
				if (rendu_need_fleche(cant)) {
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("NO", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("NO", x, y); if (sens == 1) draw_fleche("S", x, y); }
				}
				break;
				//                                                                               '/'
			case CELLS_SUBTYPE_LINK_SNE: // Voie diagonale par le centre V3.3 = '|'
				MoveToEx(h_dc_mem_cells, CELLS_S, NULL); LineTo(h_dc_mem_cells, CELLS_C);
				MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_NE);
				if (use_gros_trait) {
					MoveToEx(h_dc_mem_cells, x + 39, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 20); LineTo(h_dc_mem_cells, x + 19, y + 40);
					MoveToEx(h_dc_mem_cells, x + 40, y + 1, NULL); LineTo(h_dc_mem_cells, x + 21, y + 20); LineTo(h_dc_mem_cells, x + 21, y + 40);
				}
				if (rendu_need_fleche(cant)) {
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("NE", x, y); if (sens == 1) draw_fleche("S", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("NE", x, y); }
				}
				break;

			case CELLS_SUBTYPE_LINK_BALA:	// Case vide, mais sa couleur de fond est la même que pour les bloc de voie (avec ou sans n°de canton).
				break;

			default: break;
			}


			// Fin boucle switch. On va dessiné le pictogramme sans risque de modifier la couleur du pinceau. Uniquement sur les rails verticaux ou horizontaux.
			if ((opt > 3 && numpasse == 0) && (subtype == CELLS_SUBTYPE_LINK_PV || subtype == CELLS_SUBTYPE_LINK_PH || subtype == CELLS_SUBTYPE_LINK_V || subtype == CELLS_SUBTYPE_LINK_H )) {
				dessine_picto(x, y, c1, c2, c3, c4, opt);  // Dessine un pictogramme suivant opt.
				opt = -1; // Pour ne pas aller dans le traitement des voies superposées.
			}

			// Fin boucle switch. On va recalculer les nouveaux paramètres pour un second tour si nécessaire.
			//
			// Pour tous les éléments de voies, on ajoute au bloc un second dessin si opt > xx10.
			if (n1 == -1) break; // Pas de deuxième bloc. On sort de la boucle :  for(numpasse=0;...) {

			subtype = n1 % 100;         // n1  = XXYY => N° de pont = XX, forme du fond == YY.
			if (n2 >= 0 && n2<(300 + NB_CANTON) && (n2 % 100)<NB_CANTON) cant = n2;  // n2  = Pour le 2eme bloc le n° de canton = 'n2'.
			else cant = -1;
			if (opt != -1) opt = opt>1; // opt = Décalage d'un bit vers la droite pour savoir si le deuxième trait est en pointillé.
			sens = -1; // Pas de flèche de sens de parcours sur le deuxième trait.

			use_gros_trait = 0;
			g = -1;
			if (cant >= 1000)		// Si le numéro de canton est celui d'un garage, alors g=numéro de garage de 0 à 15.
			{					// Si le numéro de canton est celui d'un canton, alors g=-1; (ce n'est pas un garage)
				g = cant - 1000;
				if (g >= 0 && g<NB_GARAGE_REEL) cant = copy_garage_ass_canton[g]; else { g = 0; cant = -1; }
			}
			/*			if (cfg_relief==0) {
			bmp_select_pen(rendu[RENDU_COLOR_GRILLE]);	// Sélection de couleur pour la grille du TCO
			bmp_select_brush(rendu[RENDU_COLOR_FOND]);	// Sélection de couleur pour le fond du TCO
			}
			else {
			bmp_select_pen(BMP_CST_COLOR_GRIS220);
			bmp_select_brush(BMP_CST_COLOR_GRISWIN);	// Sélection de couleur pour le fond du TCO
			}
			if (cfg_relief==0) bmp_select_pen(rendu[RENDU_COLOR_GRILLE]);	// Sélection de couleur pour la grille du TCO
			else           bmp_select_pen(BMP_CST_COLOR_GRIS220);*/
			// Sélectionne la couleur de fond d'un objet en fonction de son numéro de canton (occupation ou état).
			if (type == CELLS_TYPE_LINK || type == CELLS_TYPE_AIG || type == CELLS_TYPE_SPE) rendu_select_brush_for_canton(cant);
			if (g != -1) if (vio_garage_lock_status[g]) if (cant != -1)	// Si le garage est isolé, il n'est pas utilisé // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
			{
				if (cfg_relief == 0) bmp_select_pen(rendu[RENDU_COLOR_GRILLE]);	// Sélection de couleur pour la grille du TCO
				else           bmp_select_pen(BMP_CST_COLOR_GRIS220);
				if (cfg_relief>0) color = BMP_CST_COLOR_GRISWIN; else color = rendu[RENDU_COLOR_FOND_GARALOCK];
				if (color == BMP_CST_COLOR_TRAIN)  if (copy_num_train[cant / 100][cant % 100] != -1) color = color_train[copy_num_train[cant / 100][cant % 100]];
				if (color == BMP_CST_COLOR_CANTON) if (cant != -1) color = color_canton[cant / 100][cant % 100]; // 1 en -1
				bmp_select_brush(color);
			}
			//Rectangle(h_dc_mem_cells,x,y,x+41,y+41);
			if (type == CELLS_TYPE_SPE && ((subtype == CELLS_SUBTYPE_SPE_CANT) || (subtype == CELLS_SUBTYPE_SPE_CANTV))) {
				if (cfg_relief == 0) bmp_select_pen(rendu[RENDU_COLOR_GRILLE]);	// Sélection de couleur pour la grille du TCO
				else           bmp_select_pen(BMP_CST_COLOR_GRIS220);
				if (cant != -1) if (g == -1 /**/ || (g != -1 && vio_garage_lock_status[g] == 0)/**/) {  // Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					if (CLIGNOTE_LENT) if (canton_pb_capt[cant / 100][cant % 100]) SelectObject(h_dc_mem_cells, bmp_pinceau_rouge);
				}
				//  Rectangle(h_dc_mem_cells,x+2,y+2,x+41-2,y+41-2);
			}
			rendu_select_pen_for_canton(cant);
			use_gros_trait = rendu_need_grostrait(cant);
			if (g != -1) if (vio_garage_lock_status[g]) if (cant != -1) { // Garage isolé. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
				color = rendu[RENDU_COLOR_RAIL_GARALOCK];
				if (color == BMP_CST_COLOR_TRAIN)  if (copy_garage_num_train[g] != -1) color = color_train[copy_garage_num_train[g]];
				if (color == BMP_CST_COLOR_CANTON) if (cant != 1) color = color_canton[cant / 100][cant % 100];
				bmp_select_pen(color);
				if (rendu[RENDU_USE_GROS_GARALOCK]) use_gros_trait = 1; else use_gros_trait = 0;
			}
		} // Fin boucle For(numpasse=0;...)

		// - - - - - - -
		// Après avoir dessiné une ou deux voies, on dessine en dernier les ponts. Option = 1000, 2000, 3000...
		i = n1 / 100;
		if (i != 0) {
			bmp_select_pen(rendu[RENDU_COLOR_RAIL_LIBRE]);
			if (i == 1) { // + PONT '||'
				MoveToEx(h_dc_mem_cells, x + 16, y + 6, NULL); LineTo(h_dc_mem_cells, x + 16, y + 35);
				MoveToEx(h_dc_mem_cells, x + 24, y + 6, NULL); LineTo(h_dc_mem_cells, x + 24, y + 35);
			}
			else if (i == 2) { // + PONT '//'
				MoveToEx(h_dc_mem_cells, x + 10 - 2, y + 30 - 2, NULL); LineTo(h_dc_mem_cells, x + 30 - 2 + 1, y + 10 - 2 - 1);
				MoveToEx(h_dc_mem_cells, x + 10 + 2, y + 30 + 2, NULL); LineTo(h_dc_mem_cells, x + 30 + 2 + 1, y + 10 + 2 - 1);
			}
			else if (i == 3) { // + PONT '=='
				MoveToEx(h_dc_mem_cells, x + 6, y + 16, NULL); LineTo(h_dc_mem_cells, x + 35, y + 16);
				MoveToEx(h_dc_mem_cells, x + 6, y + 24, NULL); LineTo(h_dc_mem_cells, x + 35, y + 24);
			}
			else if (i == 4) { // + PONT '\\'
				MoveToEx(h_dc_mem_cells, x + 10 + 2, y + 10 - 2, NULL); LineTo(h_dc_mem_cells, x + 31 + 2, y + 31 - 2);
				MoveToEx(h_dc_mem_cells, x + 10 - 2, y + 10 + 2, NULL); LineTo(h_dc_mem_cells, x + 31 - 2, y + 31 + 2);
			}
			else if (i == 5) { // + PONT petite diagonale haut-droit = '\\'
				MoveToEx(h_dc_mem_cells, x + 24, y + 0, NULL); LineTo(h_dc_mem_cells, x + 40, y + 16);
				MoveToEx(h_dc_mem_cells, x + 16, y + 0, NULL); LineTo(h_dc_mem_cells, x + 40, y + 24);
			}
			else if (i == 6) { // + PONT petite diagonale bas-droit = '//'
				MoveToEx(h_dc_mem_cells, x + 16, y + 40, NULL); LineTo(h_dc_mem_cells, x + 40, y + 16);
				MoveToEx(h_dc_mem_cells, x + 24, y + 40, NULL); LineTo(h_dc_mem_cells, x + 40, y + 24);
			}
			else if (i == 7) { // + PONT petite diagonale gauche-bas = '\\'
				MoveToEx(h_dc_mem_cells, x, y + 16, NULL); LineTo(h_dc_mem_cells, x + 24, y + 40);
				MoveToEx(h_dc_mem_cells, x, y + 24, NULL); LineTo(h_dc_mem_cells, x + 16, y + 40);
			}
			else if (i == 8) { // + PONT petite diagonale gauche-haut = '//'
				MoveToEx(h_dc_mem_cells, x, y + 16, NULL); LineTo(h_dc_mem_cells, x + 16, y);
				MoveToEx(h_dc_mem_cells, x, y + 24, NULL); LineTo(h_dc_mem_cells, x + 24, y);
			}
		}
	}

	// -----------------------------------------------------------------------------------------------

	if (type == CELLS_TYPE_AIG) {				// Dessine les aiguillages dans le TCO
		switch (subtype) {
		case CELLS_SUBTYPE_AIG_CH:
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);	// Dessine les traits simples
			MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_NE);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);	// Dessine les traits gras
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
				MoveToEx(h_dc_mem_cells, x + 20, y + 19, NULL); LineTo(h_dc_mem_cells, x + 39, y + 0);
				MoveToEx(h_dc_mem_cells, x + 20, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 1);
			}
			if (rendu_need_fleche(cant))	{		// Dessine une flèche droite ou gauche
				if (vio_canton_vit[cant / 100][cant % 100]>0) { /*if(sens==0) draw_fleche("E",x,y);*/ if (sens == 1) draw_fleche("O", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); /*if(sens==1) draw_fleche("E",x,y);*/ }
			}
			if (n1 != -1)                {
				v = vio_aig_pos0[n1];
				// Dessine un rectangle jaune pour la position de l'aiguille et noire pour l'autre.
				// Dessine un rectangle jaune pour la position de l'aiguille et noire pour l'autre. La taille est plus grande en cfg_relief.
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 29, y + 20 - 4, x + 29 + 8, y + 20 + 4, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 29, y + 20 - 4, x + 29 + 8, y + 20 + 4, -1, rendu[RENDU_COLOR_AIG_OFF]);
				// Dessine un rectangle jaune pour la position de l'aiguille et noire pour l'autre.
				v = vio_aig_pos1[n1];
				rendu_select_pen_for_canton(cant);
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 29, y + 3, x + 29 + 8, y + 3 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 29, y + 3, x + 29 + 8, y + 3 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				if (vio_aig_res[n1]) cadenas_relief(x + 7, y + 10); // Dessine un cadenas rouge si l'aiguillage est verrouillé.
				// Affiche le n° de l'aiguillage = 'axx'.
				SelectObject(h_dc_mem_cells, cells_font);		// V3.3
				SetBkMode(h_dc_mem_cells, TRANSPARENT);		// V3.3
				SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// V3.3
				if (n1 == -1) sprintf_s(szTemp, "aXX "); else sprintf_s(szTemp, "a%-2d ", n1);
				TextOut(h_dc_mem_cells, x + 2, y + 3, szTemp, 4); // else: +3
			}
			break;


		case CELLS_SUBTYPE_AIG_CB:
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_SE);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
				MoveToEx(h_dc_mem_cells, x + 20, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 39);
				MoveToEx(h_dc_mem_cells, x + 20, y + 21, NULL); LineTo(h_dc_mem_cells, x + 39, y + 40);
			}
			if (rendu_need_fleche(cant)) {
				if (vio_canton_vit[cant / 100][cant % 100]>0) { /*if(sens==0) draw_fleche("E",x,y);*/ if (sens == 1) draw_fleche("O", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); /*if(sens==1) draw_fleche("E",x,y);*/ }
			}
			if (n1 != -1) {
				v = vio_aig_pos0[n1];
				// Dessine un rectangle jaune pour la position de l'aiguille et noire pour l'autre.
				// Dessine un rectangle jaune pour la position de l'aiguille et noire pour l'autre. La taille est plus grande en relief.
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 29, y + 20 - 4, x + 29 + 8, y + 20 + 4, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 29, y + 20 - 4, x + 29 + 8, y + 20 + 4, -1, rendu[RENDU_COLOR_AIG_OFF]);
				// Dessine un rectangle jaune pour la position de l'aiguille et noire pour l'autre.
				v = vio_aig_pos1[n1];
				rendu_select_pen_for_canton(cant);
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 29, y + 29, x + 29 + 8, y + 29 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 29, y + 29, x + 29 + 8, y + 29 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				if (vio_aig_res[n1]) cadenas_relief(x + 7, y + 23); // Dessine un cadenas rouge si l'aiguillage est verrouillé.
				SelectObject(h_dc_mem_cells, cells_font);		// V3.3
				SetBkMode(h_dc_mem_cells, TRANSPARENT);		// V3.3
				SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// V3.3
				if (n1 == -1) sprintf_s(szTemp, "aXX "); else sprintf_s(szTemp, "a%-2d ", n1);
				TextOut(h_dc_mem_cells, x + 2, y + 31, szTemp, 4); // else: +3
			}
			break;


		case CELLS_SUBTYPE_AIG_CHB:
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_NE);
			MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_SE);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
				MoveToEx(h_dc_mem_cells, x + 20, y + 19, NULL); LineTo(h_dc_mem_cells, x + 39, y + 0);
				MoveToEx(h_dc_mem_cells, x + 20, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 1);
				MoveToEx(h_dc_mem_cells, x + 20, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 39);
				MoveToEx(h_dc_mem_cells, x + 20, y + 21, NULL); LineTo(h_dc_mem_cells, x + 39, y + 40);
			}
			if (rendu_need_fleche(cant)) {
				if (vio_canton_vit[cant / 100][cant % 100]>0) { /*if(sens==0) draw_fleche("E",x,y);*/ if (sens == 1) draw_fleche("O", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); /*if(sens==1) draw_fleche("E",x,y);*/ }
			}
			if (n1 != -1 && n2 != -1){
				if (vio_aig_pos0[n1] && vio_aig_pos0[n2]) v = 1; else v = 0;
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 29, y + 20 - 4, x + 29 + 8, y + 20 + 4, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 29, y + 20 - 4, x + 29 + 8, y + 20 + 4, -1, rendu[RENDU_COLOR_AIG_OFF]);
				rendu_select_pen_for_canton(cant);
				if (vio_aig_pos1[n1] && vio_aig_pos0[n2]) v = 1; else v = 0;
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 29, y + 3, x + 29 + 8, y + 3 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 29, y + 3, x + 29 + 8, y + 3 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				rendu_select_pen_for_canton(cant);
				if (vio_aig_pos0[n1] && vio_aig_pos1[n2]) v = 1; else v = 0;
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 29, y + 29, x + 29 + 8, y + 29 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 29, y + 29, x + 29 + 8, y + 29 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				if (vio_aig_res[n1]) cadenas_relief(x + 7, y + 10); // Dessine un cadenas rouge si l'aiguillage est verrouillé.
				if (vio_aig_res[n2]) cadenas_relief(x + 7, y + 23); // Dessine un cadenas rouge si l'aiguillage est verrouillé.
				SelectObject(h_dc_mem_cells, cells_font);		// V3.3
				SetBkMode(h_dc_mem_cells, TRANSPARENT);		// V3.3
				SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// V3.3
				if (n1 == -1) sprintf_s(szTemp, "aXX "); else sprintf_s(szTemp, "a%-2d ", n1);
				TextOut(h_dc_mem_cells, x + 2, y + 3, szTemp, 4); // else: +3
				if (n2 == -1) sprintf_s(szTemp, "aXX "); else sprintf_s(szTemp, "a%-2d ", n2);
				TextOut(h_dc_mem_cells, x + 2, y + 31, szTemp, 4); // else: +3
			}
			break;


		case CELLS_SUBTYPE_AIG_HC:
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_NO);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
				MoveToEx(h_dc_mem_cells, x + 1, y + 0, NULL); LineTo(h_dc_mem_cells, x + 20, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 1, NULL); LineTo(h_dc_mem_cells, x + 20, y + 21);
			}
			if (rendu_need_fleche(cant)) {
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); /*if(sens==1) draw_fleche("O",x,y);*/ }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { /*if(sens==0) draw_fleche("O",x,y);*/ if (sens == 1) draw_fleche("E", x, y); }
			}
			if (n1 != -1) {
				v = vio_aig_pos0[n1];
				if (v) bmp_select_brush(rendu[RENDU_COLOR_AIG_ON]); else  bmp_select_brush(rendu[RENDU_COLOR_AIG_OFF]);
				// Dessine un rectangle jaune pour la position de l'aiguille et noire pour l'autre.
				// Dessine un rectangle jaune pour la position de l'aiguille et noire pour l'autre. La taille est plus grande en relief.
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 3, y + 20 - 4, x + 3 + 8, y + 20 + 4, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 3, y + 20 - 4, x + 3 + 8, y + 20 + 4, -1, rendu[RENDU_COLOR_AIG_OFF]);
				v = vio_aig_pos1[n1];
				rendu_select_pen_for_canton(cant);
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 3, y + 3, x + 3 + 8, y + 3 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 3, y + 3, x + 3 + 8, y + 3 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				if (vio_aig_res[n1]) cadenas_relief(x + 27, y + 10); // Dessine un cadenas rouge si l'aiguillage est verrouillé.
				SelectObject(h_dc_mem_cells, cells_font);
				SetBkMode(h_dc_mem_cells, TRANSPARENT);
				SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));
				if (n1 == -1) sprintf_s(szTemp, " aXX"); else sprintf_s(szTemp, " a%-2d", n1);
				TextOut(h_dc_mem_cells, x + 3, y + 3, szTemp, 4); // else: +3
			}
			break;


		case CELLS_SUBTYPE_AIG_BC:
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_SO);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
				MoveToEx(h_dc_mem_cells, x + 0, y + 39, NULL); LineTo(h_dc_mem_cells, x + 20, y + 19);
				MoveToEx(h_dc_mem_cells, x + 1, y + 40, NULL); LineTo(h_dc_mem_cells, x + 20, y + 21);
			}
			if (rendu_need_fleche(cant)) {
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); /*if(sens==1) draw_fleche("O",x,y);*/ }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { /*if(sens==0) draw_fleche("O",x,y);*/ if (sens == 1) draw_fleche("E", x, y); }
			}
			if (n1 != -1) {
				v = vio_aig_pos0[n1];
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 3, y + 20 - 4, x + 3 + 8, y + 20 + 4, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 3, y + 20 - 4, x + 3 + 8, y + 20 + 4, -1, rendu[RENDU_COLOR_AIG_OFF]);
				v = vio_aig_pos1[n1];
				rendu_select_pen_for_canton(cant);
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 3, y + 29, x + 3 + 8, y + 29 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 3, y + 29, x + 3 + 8, y + 29 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				if (vio_aig_res[n1]) cadenas_relief(x + 27, y + 23); // Dessine un cadenas rouge si l'aiguillage est verrouillé.
				SelectObject(h_dc_mem_cells, cells_font);
				SetBkMode(h_dc_mem_cells, TRANSPARENT);
				SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));
				if (n1 == -1) sprintf_s(szTemp, " aXX"); else sprintf_s(szTemp, " a%-2d", n1);
				TextOut(h_dc_mem_cells, x + 3, y + 31, szTemp, 4); // else: +3
			}
			break;


		case CELLS_SUBTYPE_AIG_HBC:
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_NO);
			MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_SO);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
				MoveToEx(h_dc_mem_cells, x + 1, y + 0, NULL); LineTo(h_dc_mem_cells, x + 20, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 1, NULL); LineTo(h_dc_mem_cells, x + 20, y + 21);
				MoveToEx(h_dc_mem_cells, x + 0, y + 39, NULL); LineTo(h_dc_mem_cells, x + 20, y + 19);
				MoveToEx(h_dc_mem_cells, x + 1, y + 40, NULL); LineTo(h_dc_mem_cells, x + 20, y + 21);
			}
			if (rendu_need_fleche(cant)){
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); /*if(sens==1) draw_fleche("O",x,y);*/ }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { /*if(sens==0) draw_fleche("O",x,y);*/ if (sens == 1) draw_fleche("E", x, y); }
			}
			if (n1 != -1 && n2 != -1) {
				if (vio_aig_pos0[n1] && vio_aig_pos0[n2]) v = 1; else v = 0;
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 3, y + 20 - 4, x + 3 + 8, y + 20 + 4, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 3, y + 20 - 4, x + 3 + 8, y + 20 + 4, -1, rendu[RENDU_COLOR_AIG_OFF]);
				if (vio_aig_pos1[n1] && vio_aig_pos0[n2]) v = 1; else v = 0;
				rendu_select_pen_for_canton(cant);
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 3, y + 3, x + 3 + 8, y + 3 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 3, y + 3, x + 3 + 8, y + 3 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				if (vio_aig_pos0[n1] && vio_aig_pos1[n2]) v = 1; else v = 0;
				if (v) bmp_select_brush(rendu[RENDU_COLOR_AIG_ON]); else bmp_select_brush(rendu[RENDU_COLOR_AIG_OFF]);
				rendu_select_pen_for_canton(cant);
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 3, y + 29, x + 3 + 8, y + 29 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 3, y + 29, x + 3 + 8, y + 29 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				if (vio_aig_res[n1]) cadenas_relief(x + 27, y + 10); // Dessine un cadenas rouge si l'aiguillage est verrouillé.
				if (vio_aig_res[n2]) cadenas_relief(x + 27, y + 23); // Dessine un cadenas rouge si l'aiguillage est verrouillé.
				SelectObject(h_dc_mem_cells, cells_font);		// V3.3
				SetBkMode(h_dc_mem_cells, TRANSPARENT);		// V3.3
				SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// V3.3
				if (n1 == -1) sprintf_s(szTemp, " aXX"); else sprintf_s(szTemp, " a%-2d", n1);
				TextOut(h_dc_mem_cells, x + 3, y + 3, szTemp, 4); // else: +3
				if (n2 == -1) sprintf_s(szTemp, " aXX"); else sprintf_s(szTemp, " a%-2d", n2);
				TextOut(h_dc_mem_cells, x + 3, y + 31, szTemp, 4); // else: +3
			}
			break;


		case CELLS_SUBTYPE_AIG_HCV: // = '\|' V3.3
			MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_S);
			MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_NO);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
				MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
				MoveToEx(h_dc_mem_cells, x + 1, y + 0, NULL); LineTo(h_dc_mem_cells, x + 20, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 1, NULL); LineTo(h_dc_mem_cells, x + 20, y + 21);
			}
			if (rendu_need_fleche(cant)){
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 1) draw_fleche("S", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); }
			}
			if (n1 != -1) {
				v = vio_aig_pos0[n1];
				if (v) bmp_select_brush(rendu[RENDU_COLOR_AIG_ON]); else  bmp_select_brush(rendu[RENDU_COLOR_AIG_OFF]);
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 20 - 4, y + 3, x + 20 + 4, y + 3 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 20 - 4, y + 3, x + 20 + 4, y + 3 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				v = vio_aig_pos1[n1];
				if (v) bmp_select_brush(rendu[RENDU_COLOR_AIG_ON]); else  bmp_select_brush(rendu[RENDU_COLOR_AIG_OFF]);
				rendu_select_pen_for_canton(cant);
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 3, y + 3, x + 3 + 8, y + 3 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 3, y + 3, x + 3 + 8, y + 3 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				if (vio_aig_res[n1]) cadenas_relief(x + 12, y + 20); // Dessine un cadenas rouge si l'aiguillage est verrouillé.
				SelectObject(h_dc_mem_cells, cells_font);		// V3.3
				SetBkMode(h_dc_mem_cells, TRANSPARENT);		// V3.3
				SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// V3.3
				if (n1 == -1) sprintf_s(szTemp, "a XX "); else sprintf_s(szTemp, "a% -2d ", n1);
				TextOut(h_dc_mem_cells, x + 3 + 1, y + 30, szTemp, 4); // else: +3
			}
			break;


		case CELLS_SUBTYPE_AIG_CHV: // = '|/' V3.3
			MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_S);
			MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_NE);
			if (use_gros_trait)
			{
				MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
				MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
				MoveToEx(h_dc_mem_cells, x + 20, y + 19, NULL); LineTo(h_dc_mem_cells, x + 39, y + 0);
				MoveToEx(h_dc_mem_cells, x + 20, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 1);
			}
			if (rendu_need_fleche(cant))  {
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 1) draw_fleche("S", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); }
			}
			if (n1 != -1) {
				v = vio_aig_pos0[n1];
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 20 - 4, y + 3, x + 20 + 4, y + 3 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 20 - 4, y + 3, x + 20 + 4, y + 3 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				rendu_select_pen_for_canton(cant);
				v = vio_aig_pos1[n1];
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 29, y + 3, x + 29 + 8, y + 3 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 29, y + 3, x + 29 + 8, y + 3 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				if (vio_aig_res[n1]) cadenas_relief(x + 23, y + 20); // Dessine un cadenas rouge si l'aiguillage est verrouillé.
				SelectObject(h_dc_mem_cells, cells_font);		// V3.3
				SetBkMode(h_dc_mem_cells, TRANSPARENT);		// V3.3
				SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// V3.3
				if (n1 == -1) sprintf_s(szTemp, "a XX "); else sprintf_s(szTemp, "a% -2d ", n1);
				TextOut(h_dc_mem_cells, x + 3 + 1, y + 30, szTemp, 4); // else: +3
			}
			break;

		case CELLS_SUBTYPE_AIG_CBV: // = '|\' V3.3
			MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_S);
			MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_SE);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
				MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
				MoveToEx(h_dc_mem_cells, x + 20, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 39);
				MoveToEx(h_dc_mem_cells, x + 20, y + 21, NULL); LineTo(h_dc_mem_cells, x + 39, y + 40);
			}
			if (rendu_need_fleche(cant)) {
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 1) draw_fleche("N", x, y); }
			}
			if (n1 != -1) {
				v = vio_aig_pos0[n1];
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 20 - 4, y + 29, x + 20 + 4, y + 29 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 20 - 4, y + 29, x + 20 + 4, y + 29 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				v = vio_aig_pos1[n1];
				rendu_select_pen_for_canton(cant);
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 29, y + 29, x + 29 + 8, y + 29 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 29, y + 29, x + 29 + 8, y + 29 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				if (vio_aig_res[n1]) cadenas_relief(x + 23, y + 13); // Dessine un cadenas rouge si l'aiguillage est verrouillé.
				SelectObject(h_dc_mem_cells, cells_font);		// V3.3
				SetBkMode(h_dc_mem_cells, TRANSPARENT);		// V3.3
				SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// V3.3
				if (n1 == -1) sprintf_s(szTemp, "a XX "); else sprintf_s(szTemp, "a% -2d ", n1);
				TextOut(h_dc_mem_cells, x + 3 + 1, y + 3, szTemp, 4); // else: +3
			}
			break;

		case CELLS_SUBTYPE_AIG_BCV: // = '/|' V3.3
			MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_S);
			MoveToEx(h_dc_mem_cells, CELLS_C, NULL); LineTo(h_dc_mem_cells, CELLS_SO);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
				MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
				MoveToEx(h_dc_mem_cells, x + 0, y + 39, NULL); LineTo(h_dc_mem_cells, x + 20, y + 19);
				MoveToEx(h_dc_mem_cells, x + 1, y + 40, NULL); LineTo(h_dc_mem_cells, x + 20, y + 21);
			}
			if (rendu_need_fleche(cant)) {
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 1) draw_fleche("N", x, y); }
			}
			if (n1 != -1) {
				v = vio_aig_pos0[n1];
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 20 - 4, y + 29, x + 20 + 4, y + 29 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 20 - 4, y + 29, x + 20 + 4, y + 29 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				v = vio_aig_pos1[n1];
				rendu_select_pen_for_canton(cant);
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				if (v == 1) cadre_relief(x + 3, y + 29, x + 3 + 8, y + 29 + 8, 0, rendu[RENDU_COLOR_AIG_ON]);
				else       cadre_relief(x + 3, y + 29, x + 3 + 8, y + 29 + 8, -1, rendu[RENDU_COLOR_AIG_OFF]);
				if (vio_aig_res[n1]) cadenas_relief(x + 12, y + 13); // Dessine un cadenas rouge si l'aiguillage est verrouillé.
				SelectObject(h_dc_mem_cells, cells_font);		// V3.3
				SetBkMode(h_dc_mem_cells, TRANSPARENT);		// V3.3
				SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// V3.3
				if (n1 == -1) sprintf_s(szTemp, "a XX "); else sprintf_s(szTemp, "a% -2d ", n1);
				TextOut(h_dc_mem_cells, x + 3 + 1, y + 3, szTemp, 4); // else: +3
			}
			break;
		default: break;
		}
	}

	// Dessine les autres types de blocs du TCO. 
	if (type == CELLS_TYPE_SPE)
	{
		switch (subtype)
		{
		case CELLS_SUBTYPE_SPE_VOY: // Rail horizontal avec voyant rectangulaire = '-[]-' d'indication de présence de trains.
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
			}

			if (rendu_need_fleche(cant) && (g == -1 || (g != -1 && vio_garage_lock_status[g] == 0 && cant != -1))) { // Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
			}
			v = 1;
			SelectObject(h_dc_mem_cells, bmp_stylo_noir); bmp_select_brush(rendu[RENDU_COLOR_DET_ON]); // Voyant allumé par défaut.
			if (g == -1 && cant != -1) {		// On va afficher l'état d'un canton.
				v = vio_det[cant / 100][cant % 100];
				if (v == 0) bmp_select_brush(rendu[RENDU_COLOR_DET_OFF]); // Canton inocupé.
			}

			if (g != -1 && cant != -1) {		// On va afficher l'état d'un garage.
				if (vio_garage_lock_status[g] == 1) {} // Garage isolé. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
				if (vio_garage_lock_status[g] == 0) {  // Garage connecté // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					v = vio_det[cant / 100][cant % 100];
					if (v == 0) bmp_select_brush(rendu[RENDU_COLOR_DET_OFF]);
				}
			}
			if (v == 0) {
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				cadre_relief(x + 10, y + 15, x + 30, y + 25, -1, rendu[RENDU_COLOR_DET_OFF]);
			}
			else {
				cadre_relief(x + 10, y + 15, x + 30, y + 25, 0, rendu[RENDU_COLOR_DET_ON]);
				if ((g == -1 && cant != -1) || (g != -1 && cant != -1 && vio_garage_lock_status[g] == 0)) { // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					// Si le canton est occupé, ajoute les lettres 'VM' ou 'HA' ou 'BL' sur le rectangle rouge d'occupation de canton..
					// On ne le fait que sur un canton occupé, ou sur un garage connecté au canton.
					t = copy_num_train[cant / 100][cant % 100];
					if (t != -1) {
						if (balauto_halt_train[t] == 1) {
							SelectObject(h_dc_mem_cells, cells_font);
							SetBkMode(h_dc_mem_cells, TRANSPARENT);
							bmp_SetTextColor(BMP_CST_COLOR_BLANC);
							TextOut(h_dc_mem_cells, x + 11, y + 17, "HT", 2);	// Canton en 'halt:' car train en fin de voie '#BALAUTO'+'halt:'.
						}
						else if (balauto_cant_train[t] == 1) {  // =1 ? => Train ralenti ?
							SelectObject(h_dc_mem_cells, cells_font);
							SetBkMode(h_dc_mem_cells, TRANSPARENT);
							bmp_SetTextColor(BMP_CST_COLOR_BLANC);
							TextOut(h_dc_mem_cells, x + 11, y + 17, "RA", 2);	// Canton bloqué car le canton suivant n'est pas libre '#BALAUTO'+'cant:'.
						}
						else if (balauto_cant_train[t] == 2) {  // =2 ? => Train bloqué ?
							SelectObject(h_dc_mem_cells, cells_font);
							SetBkMode(h_dc_mem_cells, TRANSPARENT);
							bmp_SetTextColor(BMP_CST_COLOR_BLANC);
							TextOut(h_dc_mem_cells, x + 11, y + 17, "BL", 2);	// Canton bloqué car le canton suivant n'est pas libre '#BALAUTO'+'cant:'.
						}
						else if (balauto_vitmax_train[t] != 0) {
							SelectObject(h_dc_mem_cells, cells_font);
							SetBkMode(h_dc_mem_cells, TRANSPARENT);
							bmp_SetTextColor(BMP_CST_COLOR_BLANC);
							TextOut(h_dc_mem_cells, x + 11, y + 17, "VM", 2);	// Canton limité en vitesse '#BALAUTO'+'Vitmax:'.
						}
					}
				}
			}
			// Si on a cliqué sur ce canton, c'est pour donner le canton de départ d'un déplacement.
			if (cmd_divers[CMD_DIVERS_TEMPO]>0) {
				if (CLIGNOTE_RAPIDE && (cmd_divers[CMD_DIVERS_C_DEPART] == cant || cmd_divers[CMD_DIVERS_C_DEPART] == g + 1000))
				if (cmd_divers[CMD_DIVERS_RELACHE] == 0) cadre_relief(x + 10, y + 15, x + 30, y + 25, 0, rendu[RENDU_COLOR_FOND_AUTOPREV]); // Le canton d'origine = jaune/rouge clignotant
				else cadre_relief(x + 10, y + 15, x + 30, y + 25, 0, BMP_CST_COLOR_MAGENTA); // En vue de séparation ou regroupement Locomotive<->Wagons.
				else if (CLIGNOTE_RAPIDE && v == 0 && cmd_divers[CMD_DIVERS_RELACHE] == 0) {
					j = 0;
					for (i = 0; i<DEPL_TAB_NB; i++) {  // Pour ne faire clignoter que les cantons ou garages pouvant être l'arrivée du déplacement par le 2éme clic de souris.
						if (depl_tab[i][DEPL_TAB_IND_CANT_START] == cmd_divers[CMD_DIVERS_C_DEPART]) {
							if ((depl_tab[i][DEPL_TAB_IND_CANT_STOP] == 1000 + g && g != -1) || (depl_tab[i][DEPL_TAB_IND_CANT_STOP] == cant && cant != -1 && g == -1)) {
								j++;	// Test avec le canton de 'stop:cxx'.
								break;
							}
							if (depl_tab[i][DEPL_TAB_IND_FIN_F_VAR] == cant && g == -1 && cant != -1) {
								j++;// Test avec le canton de fin 'fin:det_xx'.
								break;
							}
						}
					}
					if (j>0) cadre_relief(x + 10, y + 15, x + 30, y + 25, 0, rendu[RENDU_COLOR_FOND_AUTOPREV]);// Les cantons cibles inoccupés= jaune/gris clignotant.
				}
			}
			// On affiche un cadre de couleur en périphérie du bloc suivant que la commande de déplacement est valide ou non.
			if (cmd_divers[CMD_DIVERS_TEMPO_RESULT]>0) {
				if ((g == -1 && cmd_divers[CMD_DIVERS_C_DEPART] == cant) || (g != -1 && cmd_divers[CMD_DIVERS_C_DEPART] == g + 1000) ||
					(g == -1 && cmd_divers[CMD_DIVERS_C_ARRIVEE] == cant) || (g != -1 && cmd_divers[CMD_DIVERS_C_ARRIVEE] == g + 1000)) {
					if (cmd_divers[CMD_DIVERS_RESULT] == 2) {
						bmp_select_pen(BMP_CST_COLOR_MAGENTA); // Jonction ou séparation Locomotive + Wagons = OK => Cadre du bloc fixe magenta.
						cadre_relief(x + 1, y + 1, x + 39, y + 39, -1, -1);
					}
					else if (cmd_divers[CMD_DIVERS_RESULT] == 1) {
						bmp_select_pen(BMP_CST_COLOR_VERT); // ==1 => Déplacement automatique valide => Cadre du bloc fixe vert. 
						cadre_relief(x + 1, y + 1, x + 39, y + 39, -1, -1);
					}
					else if (cmd_divers[CMD_DIVERS_RESULT] == 0 && CLIGNOTE_TRAPIDE) {
						bmp_select_pen(BMP_CST_COLOR_ROUGE); // ==0 => Déplacement automatique inexistant => Cadre clignotant rouge.
						cadre_relief(x + 1, y + 1, x + 39, y + 39, -1, -1);
					}
				}
			}
			break;


		case CELLS_SUBTYPE_SPE_VOYV: // Rail vertical avec voyant rectangulaire = '-[]-' d'indication de présence de trains.
			MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_S);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
				MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
			}
			if (rendu_need_fleche(cant) && (g == -1 || (g != -1 && vio_garage_lock_status[g] == 0 && cant != -1))) { // Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
			}
			v = 1;
			SelectObject(h_dc_mem_cells, bmp_stylo_noir); bmp_select_brush(rendu[RENDU_COLOR_DET_ON]); // Voyant allumé par défaut.
			if (g == -1 && cant != -1) {		// On va afficher l'état d'un canton.
				v = vio_det[cant / 100][cant % 100];
				if (v == 0) bmp_select_brush(rendu[RENDU_COLOR_DET_OFF]); // Canton inocupé.
			}
			if (g != -1 && cant != -1) {		// On va afficher l'état d'un garage.
				if (vio_garage_lock_status[g] == 1) { // Garage isolé. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
				}
				if (vio_garage_lock_status[g] == 0) { // Garage connécté // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					v = vio_det[cant / 100][cant % 100];
					if (v == 0) bmp_select_brush(rendu[RENDU_COLOR_DET_OFF]);
				}
			}
			if (v == 0) {
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				cadre_relief(x + 15, y + 10, x + 25, y + 30, -1, rendu[RENDU_COLOR_DET_OFF]);
			}
			else {
				cadre_relief(x + 15, y + 10, x + 25, y + 30, 0, rendu[RENDU_COLOR_DET_ON]);
				if ((g == -1 && cant != -1) || (g != -1 && cant != -1 && vio_garage_lock_status[g] == 0)) { // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					// Si le canton est occupé, ajoute les lettres 'VM' ou 'HA' ou 'BL' sur le rectangle rouge d'occupation de canton..
					// On ne le fait que sur un canton occupé, ou sur un garage connecté au canton.
					t = copy_num_train[cant / 100][cant % 100];
					if (t != -1) {
						if (balauto_halt_train[t] == 1) {
							SelectObject(h_dc_mem_cells, cells_font);
							SetBkMode(h_dc_mem_cells, TRANSPARENT);
							bmp_SetTextColor(BMP_CST_COLOR_BLANC);
							TextOut(h_dc_mem_cells, x + 16, y + 13, "H", 1);	// Canton en 'halt:' car train en fin de voie '#BALAUTO'+'halt:'.
							TextOut(h_dc_mem_cells, x + 16, y + 21, "T", 1);
						}
						else if (balauto_cant_train[t] == 1) { // =1 ? => Train ralenti ?
							SelectObject(h_dc_mem_cells, cells_font);
							SetBkMode(h_dc_mem_cells, TRANSPARENT);
							bmp_SetTextColor(BMP_CST_COLOR_BLANC);
							TextOut(h_dc_mem_cells, x + 16, y + 13, "R", 1);	// Canton bloqué car le canton suivant n'est pas libre '#BALAUTO'+'cant:'.
							TextOut(h_dc_mem_cells, x + 16, y + 21, "A", 1);
						}
						else if (balauto_cant_train[t] == 2) { // =2 ? => Train bloqué ?
							SelectObject(h_dc_mem_cells, cells_font);
							SetBkMode(h_dc_mem_cells, TRANSPARENT);
							bmp_SetTextColor(BMP_CST_COLOR_BLANC);
							TextOut(h_dc_mem_cells, x + 16, y + 13, "B", 1);	// Canton bloqué car le canton suivant n'est pas libre '#BALAUTO'+'cant:'.
							TextOut(h_dc_mem_cells, x + 16, y + 21, "L", 1);
						}
						else if (balauto_vitmax_train[t] != 0) {
							SelectObject(h_dc_mem_cells, cells_font);
							SetBkMode(h_dc_mem_cells, TRANSPARENT);
							bmp_SetTextColor(BMP_CST_COLOR_BLANC);
							TextOut(h_dc_mem_cells, x + 16, y + 13, "V", 1);	// Canton limité en vitesse '#BALAUTO'+'Vitmax:'.
							TextOut(h_dc_mem_cells, x + 16, y + 21, "M", 1);
						}
					}
				}
			}
			// Si on a cliquer sur ce canton, c'est pour donner le canton de départ d'un déplacement.
			if (cmd_divers[CMD_DIVERS_TEMPO]>0) {
				if (CLIGNOTE_RAPIDE && (cmd_divers[CMD_DIVERS_C_DEPART] == cant || cmd_divers[CMD_DIVERS_C_DEPART] == g + 1000))
				if (cmd_divers[CMD_DIVERS_RELACHE] == 0) cadre_relief(x + 15, y + 10, x + 25, y + 30, 0, rendu[RENDU_COLOR_FOND_AUTOPREV]); // Le canton d'origine = jaune/rouge clignotant
				else cadre_relief(x + 15, y + 10, x + 25, y + 30, 0, BMP_CST_COLOR_MAGENTA); // En vue de séparation ou regroupement Locomotive<->Wagons.
				else if (CLIGNOTE_RAPIDE && v == 0 && cmd_divers[CMD_DIVERS_RELACHE] == 0) {
					j = 0;
					for (i = 0; i<DEPL_TAB_NB; i++) {  // Pour ne faire clignoter que les cantons ou garages pouvant être l'arrivée du déplacement par le 2éme clic de souris.
						if (depl_tab[i][DEPL_TAB_IND_CANT_START] == cmd_divers[CMD_DIVERS_C_DEPART]) {
							if ((depl_tab[i][DEPL_TAB_IND_CANT_STOP] == 1000 + g && g != -1) || (depl_tab[i][DEPL_TAB_IND_CANT_STOP] == cant && cant != -1 && g == -1)) {
								j++;	// Test avec le canton de 'stop:cxx'.
								break;
							}
							if (depl_tab[i][DEPL_TAB_IND_FIN_F_VAR] == cant && g == -1 && cant != -1) {
								j++;  // Test avec le canton de fin 'fin:det_xx'.
								break;
							}
						}
					}
					if (j>0) cadre_relief(x + 15, y + 10, x + 25, y + 30, 0, rendu[RENDU_COLOR_FOND_AUTOPREV]);// Les cantons cibles inoccupés= jaune/gris clignotant.
				}
			}
			// On affiche un cadre de couleur en périphérie du bloc suivant que la commande de déplacement est valide ou non.
			if (cmd_divers[CMD_DIVERS_TEMPO_RESULT]>0) {
				if ((g == -1 && cmd_divers[CMD_DIVERS_C_DEPART] == cant) || (g != -1 && cmd_divers[CMD_DIVERS_C_DEPART] == g + 1000) ||
					(g == -1 && cmd_divers[CMD_DIVERS_C_ARRIVEE] == cant) || (g != -1 && cmd_divers[CMD_DIVERS_C_ARRIVEE] == g + 1000)) {
					if (cmd_divers[CMD_DIVERS_RESULT] == 2) {
						bmp_select_pen(BMP_CST_COLOR_MAGENTA); // Jonction ou séparation Locomotive + Wagons = OK => Cadre du bloc fixe magenta.
						cadre_relief(x + 1, y + 1, x + 39, y + 39, -1, -1);
					}
					else if (cmd_divers[CMD_DIVERS_RESULT] == 1) {
						bmp_select_pen(BMP_CST_COLOR_VERT); // ==1 => Déplacement automatique valide => Cadre du bloc fixe vert. 
						cadre_relief(x + 1, y + 1, x + 39, y + 39, -1, -1);
					}
					else if (cmd_divers[CMD_DIVERS_RESULT] == 0 && CLIGNOTE_TRAPIDE) {
						bmp_select_pen(BMP_CST_COLOR_ROUGE); // ==0 => Déplacement automatique inexistant => Cadre clignotant rouge.
						cadre_relief(x + 1, y + 1, x + 39, y + 39, -1, -1);
					}
				}
			}
			break;


		case CELLS_SUBTYPE_SPE_DETEL: // Rail horizontal avec dételeur  '-)(-'
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
			}
			if (g == -1 && rendu_need_fleche(cant)) {		// On va afficher l'état d'un canton.
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
			}
			if (g != -1) {		// On va afficher l'état d'un garage
				if (vio_garage_lock_status[g] == 0 && cant != -1 && rendu_need_fleche(cant)) { // Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
				}
			}
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			if (v1 != -1) v = pio_get_val(v1); else v = 0; // Si la variable 'V1' est définie, v = état de la variable = 0 ou 1.
			if (v == 0) {
				MoveToEx(h_dc_mem_cells, x + 19, y + 30, NULL); LineTo(h_dc_mem_cells, x + 10, y + 30); // '-'
				MoveToEx(h_dc_mem_cells, x + 17, y + 25, NULL); LineTo(h_dc_mem_cells, x + 19, y + 27); LineTo(h_dc_mem_cells, x + 19, y + 30);// ')'
				MoveToEx(h_dc_mem_cells, x + 17, y + 35, NULL); LineTo(h_dc_mem_cells, x + 19, y + 33); LineTo(h_dc_mem_cells, x + 19, y + 30);

				MoveToEx(h_dc_mem_cells, x + 21, y + 30, NULL); LineTo(h_dc_mem_cells, x + 30, y + 30); // '-'
				MoveToEx(h_dc_mem_cells, x + 23, y + 25, NULL); LineTo(h_dc_mem_cells, x + 21, y + 27); LineTo(h_dc_mem_cells, x + 21, y + 30);// '('
				MoveToEx(h_dc_mem_cells, x + 23, y + 35, NULL); LineTo(h_dc_mem_cells, x + 21, y + 33); LineTo(h_dc_mem_cells, x + 21, y + 30);
			}
			else {
				v = 4;
				MoveToEx(h_dc_mem_cells, x + 19 - v, y + 30, NULL); LineTo(h_dc_mem_cells, x + 10 - v, y + 30); // '-'
				MoveToEx(h_dc_mem_cells, x + 17 - v, y + 25, NULL); LineTo(h_dc_mem_cells, x + 19 - v, y + 27); LineTo(h_dc_mem_cells, x + 19 - v, y + 30);// ')'
				MoveToEx(h_dc_mem_cells, x + 17 - v, y + 35, NULL); LineTo(h_dc_mem_cells, x + 19 - v, y + 33); LineTo(h_dc_mem_cells, x + 19 - v, y + 30);

				MoveToEx(h_dc_mem_cells, x + 21 + v, y + 30, NULL); LineTo(h_dc_mem_cells, x + 30 + v, y + 30); // '-'
				MoveToEx(h_dc_mem_cells, x + 23 + v, y + 25, NULL); LineTo(h_dc_mem_cells, x + 21 + v, y + 27); LineTo(h_dc_mem_cells, x + 21 + v, y + 30);// '('
				MoveToEx(h_dc_mem_cells, x + 23 + v, y + 35, NULL); LineTo(h_dc_mem_cells, x + 21 + v, y + 33); LineTo(h_dc_mem_cells, x + 21 + v, y + 30);
				MoveToEx(h_dc_mem_cells, x + 20, y + 34, NULL); LineTo(h_dc_mem_cells, x + 23, y + 37); LineTo(h_dc_mem_cells, x + 17, y + 37); LineTo(h_dc_mem_cells, x + 20, y + 34); // '^'
			}
			break;


		case CELLS_SUBTYPE_SPE_DETELV: // Rail vertical avec dételeur  '-)(-'
			MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_S);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
				MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
			}

			if (g == -1 && rendu_need_fleche(cant)) {		// On va afficher l'état d'un canton.
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
			}

			if (g != -1) {		// On va afficher l'état d'un garage
				if (vio_garage_lock_status[g] == 0 && cant != -1 && rendu_need_fleche(cant)) { // garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
				}
			}

			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			if (v1 != -1) v = pio_get_val(v1); else v = 0; // Si la variable 'V1' est définie, v = état de la variable = 0 ou 1.
			if (v == 0) {
				MoveToEx(h_dc_mem_cells, x + 30, y + 19, NULL); LineTo(h_dc_mem_cells, x + 30, y + 10); // '-'
				MoveToEx(h_dc_mem_cells, x + 25, y + 17, NULL); LineTo(h_dc_mem_cells, x + 27, y + 19); LineTo(h_dc_mem_cells, x + 30, y + 19);// ')'
				MoveToEx(h_dc_mem_cells, x + 35, y + 17, NULL); LineTo(h_dc_mem_cells, x + 33, y + 19); LineTo(h_dc_mem_cells, x + 30, y + 19);

				MoveToEx(h_dc_mem_cells, x + 30, y + 21, NULL); LineTo(h_dc_mem_cells, x + 30, y + 30); // '-'
				MoveToEx(h_dc_mem_cells, x + 25, y + 23, NULL); LineTo(h_dc_mem_cells, x + 27, y + 21); LineTo(h_dc_mem_cells, x + 30, y + 21);// '('
				MoveToEx(h_dc_mem_cells, x + 35, y + 23, NULL); LineTo(h_dc_mem_cells, x + 33, y + 21); LineTo(h_dc_mem_cells, x + 30, y + 21);
			}
			else {
				v = 4;
				MoveToEx(h_dc_mem_cells, x + 30, y + 19 - v, NULL); LineTo(h_dc_mem_cells, x + 30, y + 10 - v); // '-'
				MoveToEx(h_dc_mem_cells, x + 25, y + 17 - v, NULL); LineTo(h_dc_mem_cells, x + 27, y + 19 - v); LineTo(h_dc_mem_cells, x + 30, y + 19 - v);// ')'
				MoveToEx(h_dc_mem_cells, x + 35, y + 17 - v, NULL); LineTo(h_dc_mem_cells, x + 33, y + 19 - v); LineTo(h_dc_mem_cells, x + 30, y + 19 - v);

				MoveToEx(h_dc_mem_cells, x + 30, y + 21 + v, NULL); LineTo(h_dc_mem_cells, x + 30, y + 30 + v); // '-'
				MoveToEx(h_dc_mem_cells, x + 25, y + 23 + v, NULL); LineTo(h_dc_mem_cells, x + 27, y + 21 + v); LineTo(h_dc_mem_cells, x + 30, y + 21 + v);// '('
				MoveToEx(h_dc_mem_cells, x + 35, y + 23 + v, NULL); LineTo(h_dc_mem_cells, x + 33, y + 21 + v); LineTo(h_dc_mem_cells, x + 30, y + 21 + v);
				MoveToEx(h_dc_mem_cells, x + 34, y + 20, NULL); LineTo(h_dc_mem_cells, x + 37, y + 23); LineTo(h_dc_mem_cells, x + 37, y + 17); LineTo(h_dc_mem_cells, x + 34, y + 20); // '^'
			}
			break;


		case CELLS_SUBTYPE_SPE_CANT: // Ligne horizontale + passe au rouge en cas de perte de détection + affiche des informations du canton
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
			}
			if (g == -1) {
				if (rendu_need_fleche(cant)) {
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
				}
				SelectObject(h_dc_mem_cells, cells_font);
				SetBkMode(h_dc_mem_cells, TRANSPARENT);
				SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));
				if (cant == -1) sprintf_s(szTemp, "CXXX");
				else {
					sprintf_s(szTemp, "C%3d", cant);
					TextOut(h_dc_mem_cells, x + 2, y + 3, szTemp, 4);
					strcpy(szTemp, "    ");
					if (copy_res_auto[cant / 100][cant % 100] && vio_det[cant / 100][cant % 100]) szTemp[0] = 'A';
					if (copy_res_auto[cant / 100][cant % 100] && vio_det[cant / 100][cant % 100] == 0) szTemp[0] = 'a';
					if (copy_master_selectif[cant / 100][cant % 100]) szTemp[0] = 'S';
					if (copy_update_selectif[cant / 100][cant % 100]) szTemp[0] = 's';
					if (vio_canton_vit[cant / 100][cant % 100]>0) sprintf(&szTemp[1], "+%2d", vio_canton_vit[cant / 100][cant % 100]);
					else if (vio_canton_vit[cant / 100][cant % 100]<0) sprintf(&szTemp[1], "%3d", vio_canton_vit[cant / 100][cant % 100]);
					else sprintf(&szTemp[1], "  0");
					TextOut(h_dc_mem_cells, x + 2, y + 11, szTemp, 4);
					t = copy_num_train[cant / 100][cant % 100];
					if (t != -1) {
						if (CLIGNOTE_LENT && train_pb_capt[t]) {  // 0 ou 1, 1 => Le train n'est pas détecté sur les cantons.
							TextOut(h_dc_mem_cells, x + 2, y + 23, " PB ", 4);
							TextOut(h_dc_mem_cells, x + 2, y + 31, "CAPT", 4);
						}
						else if (strlen(copy_train_name[t]) == 8) {
							sprintf_s(szTemp, "%s", copy_train_name[t]);     szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 23, szTemp, 4);
							sprintf_s(szTemp, "%s", &copy_train_name[t][4]); szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 31, szTemp, 4);
						}
						else {
							sprintf_s(szTemp, " t%-2d", t); TextOut(h_dc_mem_cells, x + 2, y + 23, szTemp, 4);
							TextOut(h_dc_mem_cells, x + 2, y + 31, "    ", 4);
						}
					}
				}
			}
			if (g != -1) {
				if (vio_garage_lock_status[g] && cant != -1) { // Garage isolé  // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					SelectObject(h_dc_mem_cells, cells_font);
					SetBkMode(h_dc_mem_cells, TRANSPARENT);
					SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));
					if (g == -1) sprintf_s(szTemp, "gXX");
					if (g != -1 && cant != -1) {
						sprintf_s(szTemp, "g%2d", g);
						TextOut(h_dc_mem_cells, x + 2, y + 2, szTemp, 3);
						t = copy_garage_num_train[g];
						if (t != -1) {
							if (strlen(copy_train_name[t]) == 8) {
								sprintf_s(szTemp, "%s", copy_train_name[t]);     szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 23, szTemp, 4);
								sprintf_s(szTemp, "%s", &copy_train_name[t][4]); szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 31, szTemp, 4);
							}
							else {
								sprintf_s(szTemp, " t%-2d", t); TextOut(h_dc_mem_cells, x + 2, y + 23, szTemp, 4);
								TextOut(h_dc_mem_cells, x + 2, y + 31, "    ", 4);
							}
							// V3.4 on affiche un trait rouge cligotant si la vitesse !0, car si l'on remet le garage sous tension le train risque de partir tout seul.
							if (train.cons[t] != 0) {
								SelectObject(h_dc_mem_cells, bmp_stylo_vert);
								MoveToEx(h_dc_mem_cells, x + 2, y + 30, NULL); LineTo(h_dc_mem_cells, x + 38, y + 30); // Dessine un trait
							}
						}
						// On affiche un rectangle indiquant un garage isolé avec un train parqué = rectangle de couleur du train.
						SelectObject(h_dc_mem_cells, bmp_stylo_noir);
						if (cfg_relief > 0) cadre_relief(x + 3, y + 10, x + 37, y + 18, 0, color_train[t]);
						else            cadre_relief(x + 2, y + 10, x + 38, y + 18, 1, color_train[t]); //rendu[RENDU_COLOR_VOY_OFF]
					}
				}
				if (vio_garage_lock_status[g] == 0 && cant != -1) { //  Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					if (rendu_need_fleche(cant)) {
						if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
						if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
					}
					SelectObject(h_dc_mem_cells, cells_font);
					SetBkMode(h_dc_mem_cells, TRANSPARENT);
					SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));
					if (g == -1) sprintf_s(szTemp, "gXX");
					if (g != -1 && cant != -1) {
						sprintf_s(szTemp, "g%2d", g);
						TextOut(h_dc_mem_cells, x + 2, y + 2, szTemp, 3);
						t = copy_num_train[cant / 100][cant % 100];
						if (t != -1) {
							if (CLIGNOTE_LENT && train_pb_capt[t]) {  // 0 ou 1, 1 => Le train n'est pas détecté sur les cantons.
								TextOut(h_dc_mem_cells, x + 2, y + 23, " PB ", 4);
								TextOut(h_dc_mem_cells, x + 2, y + 31, "CAPT", 4);
							}
							else if (strlen(copy_train_name[t]) == 8) {
								sprintf_s(szTemp, "%s", copy_train_name[t]);     szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 23, szTemp, 4);
								sprintf_s(szTemp, "%s", &copy_train_name[t][4]); szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 31, szTemp, 4);
							}
							else {
								sprintf_s(szTemp, " t%-2d", t); TextOut(h_dc_mem_cells, x + 2, y + 23, szTemp, 4);
								TextOut(h_dc_mem_cells, x + 2, y + 31, "    ", 4);
							}
						}
						// On affiche un rectangle indiquant un garage connecté = rectangle vert(RENDU_COLOR_VOY_ON) ou gris en relief
						if (cfg_relief > 0) {
							bmp_select_pen(BMP_CST_COLOR_GRIS128);
							cadre_relief(x + 3, y + 10, x + 37, y + 18, -1, BMP_CST_COLOR_GRIS192);
						}
						else {
							SelectObject(h_dc_mem_cells, bmp_stylo_noir);
							cadre_relief(x + 2, y + 10, x + 38, y + 18, -1, BMP_CST_COLOR_GRIS192);//rendu[RENDU_COLOR_VOY_ON]
						}
					}
				}
				// Si ce bloc concerne un garage, on peut cliquer dessus. Alors il est en relief toujours haut.
				if (cfg_relief > 0) cadre_relief(x + 1, y + 1, x + 39, y + 39, 20, -1);
			}
			break;


		case CELLS_SUBTYPE_SPE_CANTV: // Ligne verticale + passe au rouge en cas de perte de détection + affiche des info du canton
			MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_S);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
				MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
			}
			if (g == -1) {
				if (rendu_need_fleche(cant)) {
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
				}
				SelectObject(h_dc_mem_cells, cells_font);
				SetBkMode(h_dc_mem_cells, TRANSPARENT);
				SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));
				if (cant == -1) sprintf_s(szTemp, "CXXX");
				else {
					sprintf_s(szTemp, "C%3d", cant);
					TextOut(h_dc_mem_cells, x + 2, y + 3, szTemp, 4);
					strcpy(szTemp, "    ");
					if (copy_res_auto[cant / 100][cant % 100] && vio_det[cant / 100][cant % 100]) szTemp[0] = 'A';
					if (copy_res_auto[cant / 100][cant % 100] && vio_det[cant / 100][cant % 100] == 0) szTemp[0] = 'a';
					if (copy_master_selectif[cant / 100][cant % 100]) szTemp[0] = 'S';
					if (copy_update_selectif[cant / 100][cant % 100]) szTemp[0] = 's';
					if (vio_canton_vit[cant / 100][cant % 100]>0) sprintf(&szTemp[1], "+%2d", vio_canton_vit[cant / 100][cant % 100]);
					else if (vio_canton_vit[cant / 100][cant % 100]<0) sprintf(&szTemp[1], "%3d", vio_canton_vit[cant / 100][cant % 100]);
					else sprintf(&szTemp[1], "  0");
					TextOut(h_dc_mem_cells, x + 2, y + 11, szTemp, 4);
					t = copy_num_train[cant / 100][cant % 100];
					if (t != -1) {
						if (CLIGNOTE_LENT && train_pb_capt[t]) {  // 0 ou 1, 1 => Le train n'est pas détecté sur les cantons.
							TextOut(h_dc_mem_cells, x + 2, y + 23, " PB ", 4);
							TextOut(h_dc_mem_cells, x + 2, y + 31, "CAPT", 4);
						}
						else if (strlen(copy_train_name[t]) == 8) {
							sprintf_s(szTemp, "%s", copy_train_name[t]);     szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 23, szTemp, 4);
							sprintf_s(szTemp, "%s", &copy_train_name[t][4]); szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 31, szTemp, 4);
						}
						else {
							sprintf_s(szTemp, " t%-2d", t); TextOut(h_dc_mem_cells, x + 2, y + 23, szTemp, 4);
							TextOut(h_dc_mem_cells, x + 2, y + 31, "    ", 4);
						}
					}
				}
			}
			if (g != -1) {
				if (vio_garage_lock_status[g]) if (cant != -1) { // Garage isolé. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					SelectObject(h_dc_mem_cells, cells_font);
					SetBkMode(h_dc_mem_cells, TRANSPARENT);
					SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));
					if (g == -1) sprintf_s(szTemp, "gXX");
					if (g != -1 && cant != -1) {
						sprintf_s(szTemp, "g%2d", g);
						TextOut(h_dc_mem_cells, x + 2, y + 2, szTemp, 3);
						t = copy_garage_num_train[g];
						if (t != -1) {
							if (strlen(copy_train_name[t]) == 8) {
								sprintf_s(szTemp, "%s", copy_train_name[t]);     szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 23, szTemp, 4);
								sprintf_s(szTemp, "%s", &copy_train_name[t][4]); szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 31, szTemp, 4);
							}
							else {
								sprintf_s(szTemp, " t%-2d", t); TextOut(h_dc_mem_cells, x + 2, y + 23, szTemp, 4);
								TextOut(h_dc_mem_cells, x + 2, y + 31, "    ", 4);
							}
						}
						// On affiche un rectangle indiquant un garage isolé avec un train parqué = rectangle de couleur du train.
						SelectObject(h_dc_mem_cells, bmp_stylo_noir);
						if (cfg_relief > 0) cadre_relief(x + 3, y + 10, x + 37, y + 18, 0, color_train[t]);
						else            cadre_relief(x + 2, y + 10, x + 38, y + 18, 1, color_train[t]); //rendu[RENDU_COLOR_VOY_OFF]
					}
				}
				if (vio_garage_lock_status[g] == 0) if (cant != -1) //  Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
				{
					if (rendu_need_fleche(cant)) {
						if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
						if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
					}
					SelectObject(h_dc_mem_cells, cells_font);
					SetBkMode(h_dc_mem_cells, TRANSPARENT);
					SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));
					if (g == -1) sprintf_s(szTemp, "gXX");
					if (g != -1 && cant != -1) {
						sprintf_s(szTemp, "g%2d", g);
						TextOut(h_dc_mem_cells, x + 2, y + 2, szTemp, 3);
						t = copy_num_train[cant / 100][cant % 100];
						if (t != -1) {
							if (CLIGNOTE_LENT && train_pb_capt[t]) {  // 0 ou 1, 1 => Le train n'est pas détecté sur les cantons.
								TextOut(h_dc_mem_cells, x + 2, y + 23, " PB ", 4);
								TextOut(h_dc_mem_cells, x + 2, y + 31, "CAPT", 4);
							}
							else if (strlen(copy_train_name[t]) == 8) {
								sprintf_s(szTemp, "%s", copy_train_name[t]);     szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 23, szTemp, 4);
								sprintf_s(szTemp, "%s", &copy_train_name[t][4]); szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 31, szTemp, 4);
							}
							else {
								sprintf_s(szTemp, " t%-2d", t); TextOut(h_dc_mem_cells, x, y + 23, szTemp, 4);
								TextOut(h_dc_mem_cells, x + 2, y + 31, "    ", 4);
							}
						}
						// On affiche un rectangle indiquant un garage connecté = rectangle vert(RENDU_COLOR_VOY_ON) ou gris en relief
						if (cfg_relief > 0) {
							bmp_select_pen(BMP_CST_COLOR_GRIS128);
							cadre_relief(x + 3, y + 10, x + 37, y + 18, -1, BMP_CST_COLOR_GRIS192);
						}
						else {
							SelectObject(h_dc_mem_cells, bmp_stylo_noir);
							cadre_relief(x + 2, y + 10, x + 38, y + 18, -1, BMP_CST_COLOR_GRIS192); //rendu[RENDU_COLOR_VOY_ON]
						}
					}
				}
				// Si ce bloc concerne un garage, on peut cliquer dessus. Alors il est en relief toujours haut.
				if (cfg_relief > 0) cadre_relief(x + 1, y + 1, x + 39, y + 39, 20, -1);
			}
			break;


		case CELLS_SUBTYPE_SPE_IN: // Voie horizontale avec pédale de détection de passage de train = petit rectangle
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
			}
			if (g == -1 && rendu_need_fleche(cant)) {		// On va afficher le sens du canton.
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
			}
			if (g != -1) {		// On va afficher le sens du garage
				if (vio_garage_lock_status[g] == 0 && cant != -1 && rendu_need_fleche(cant)) { //  Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
				}
			}
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			v = 0;
			if (v1 != -1) v = pio_get_val(v1);		// Si la variable 'V1' est définie, v = état de la variable = 0 ou 1.
			if (v == 0) {
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				cadre_relief(x + 12, y + 17 - 6, x + 28, y + 23 - 6, -1, rendu[RENDU_COLOR_DET_OFF]);
			}
			else cadre_relief(x + 12, y + 17 - 6, x + 28, y + 23 - 6, 0, rendu[RENDU_COLOR_DET_ON]);
			break;


		case CELLS_SUBTYPE_SPE_INV: // Voie verticale avec pédale de détection de passage de train = petit rectangle
			MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_S);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
				MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
			}
			if (g == -1 && rendu_need_fleche(cant)) {		// On va afficher le sens du canton.
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
			}
			if (g != -1) {		// On va afficher le sens du garage
				if (vio_garage_lock_status[g] == 0 && cant != -1 && rendu_need_fleche(cant)) { //  Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
				}
			}
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			v = 0;
			if (v1 != -1) v = pio_get_val(v1);		// Si la variable 'V1' est définie, v = état de la variable = 0 ou 1.
			if (v == 0) {
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				cadre_relief(x + 17 - 6, y + 12, x + 23 - 6, y + 28, -1, rendu[RENDU_COLOR_DET_OFF]);
			}
			else cadre_relief(x + 17 - 6, y + 12, x + 23 - 6, y + 28, 0, rendu[RENDU_COLOR_DET_ON]);
			break;


		case CELLS_SUBTYPE_SPE_OUT: // Voie horizontale avec pédale de détection de passage de train par programme = '-\/-' (pas codé).
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			if (use_gros_trait)
			{
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
			}
			if (rendu_need_fleche(cant))
			{
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
			}
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			if (cant != -1)
			{
				v = vio_det[cant / 100][cant % 100];
				if (v) bmp_select_pen(rendu[RENDU_COLOR_DET_ON]); else bmp_select_pen(rendu[RENDU_COLOR_DET_OFF]);
			}
			for (i = 0; i<10; i++) { MoveToEx(h_dc_mem_cells, x + 20 - i, y + 34 - i, NULL); LineTo(h_dc_mem_cells, x + 20 + i, y + 34 - i); }
			if (v1 != -1) pio_set_val(v1, v);
			break;


		case CELLS_SUBTYPE_SPE_OUTV: // Voie verticale avec pédale de détection de passage de train par programme = '-\/-' (pas codé).
			MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_S);
			if (use_gros_trait){
				MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
				MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
			}
			if (rendu_need_fleche(cant)){
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
			}
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			if (cant != -1){
				v = vio_det[cant / 100][cant % 100];
				if (v) bmp_select_brush(rendu[RENDU_COLOR_DET_ON]); else bmp_select_brush(rendu[RENDU_COLOR_DET_OFF]);
			}
			for (i = 0; i<10; i++) { MoveToEx(h_dc_mem_cells, x + 34 - i, y + 20 - i, NULL); LineTo(h_dc_mem_cells, x + 34 - i, y + 20 + i); }
			if (v1 != -1) pio_set_val(v1, v);
			break;


		case CELLS_SUBTYPE_SPE_SENS: // Bloc de TCO pour voie horizontale avec flèches d'imposition de sens de circulation = '-<->-' (impose un sens de parcours).
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
			}
			if (rendu_need_fleche(cant)) {
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
			}
			j = 0;
			if (cfg_relief > 0) SelectObject(h_dc_mem_cells, bmp_stylo_gris192); else SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			if (sens == 0 && (copy_allowed_sens[cant / 100][cant % 100] & 2)) { SelectObject(h_dc_mem_cells, bmp_stylo_vert); j++; }
			if (sens == 1 && (copy_allowed_sens[cant / 100][cant % 100] & 1)) { SelectObject(h_dc_mem_cells, bmp_stylo_vert); j++; }
			for (i = 0; i<10; i++) { MoveToEx(h_dc_mem_cells, x + 7 + i, y + 20 - i, NULL); LineTo(h_dc_mem_cells, x + 7 + i, y + 21 + i); }

			if (cfg_relief > 0) SelectObject(h_dc_mem_cells, bmp_stylo_gris192); else SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			if (sens == 0 && (copy_allowed_sens[cant / 100][cant % 100] & 1)) { SelectObject(h_dc_mem_cells, bmp_stylo_vert); j++; }
			if (sens == 1 && (copy_allowed_sens[cant / 100][cant % 100] & 2)) { SelectObject(h_dc_mem_cells, bmp_stylo_vert); j++; }
			for (i = 0; i<10; i++) { MoveToEx(h_dc_mem_cells, x + 33 - i, y + 20 - i, NULL); LineTo(h_dc_mem_cells, x + 33 - i, y + 21 + i); }

			if (j > 0) { // Dessine un trait vers entre les deux fléches, si au moins une fléche de dessinée.
				SelectObject(h_dc_mem_cells, bmp_stylo_vert);
				for (i = 0; i<5; i++) { MoveToEx(h_dc_mem_cells, x + 17, y + 18 + i, NULL); LineTo(h_dc_mem_cells, x + 24, y + 18 + i); }
			}
			if (cfg_relief >0 && j == 0) { // Dessine un trait vers entre les deux fléches, si au moins une fléche de dessinée.
				SelectObject(h_dc_mem_cells, bmp_stylo_gris128);
				MoveToEx(h_dc_mem_cells, x + 17, y + 11, NULL); LineTo(h_dc_mem_cells, x + 17, y + 30);
				MoveToEx(h_dc_mem_cells, x + 23, y + 11, NULL); LineTo(h_dc_mem_cells, x + 23, y + 30);
			}
			break;


		case CELLS_SUBTYPE_SPE_SENSV: // Voie verticale avec flèches d'imposition de sens de circulation = '-<>-'.
			MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_S);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
				MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
			}
			if (rendu_need_fleche(cant)) {
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
			}
			j = 0;
			if (cfg_relief > 0) SelectObject(h_dc_mem_cells, bmp_stylo_gris192); else SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			if (sens == 0 && (copy_allowed_sens[cant / 100][cant % 100] & 2)) { SelectObject(h_dc_mem_cells, bmp_stylo_vert); j++; }
			if (sens == 1 && (copy_allowed_sens[cant / 100][cant % 100] & 1)) { SelectObject(h_dc_mem_cells, bmp_stylo_vert); j++; }
			for (i = 0; i<10; i++) { MoveToEx(h_dc_mem_cells, x + 20 - i, y + 33 - i, NULL); LineTo(h_dc_mem_cells, x + 21 + i, y + 33 - i); } // Bas
			if (cfg_relief > 0) SelectObject(h_dc_mem_cells, bmp_stylo_gris192); else SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			if (sens == 0 && (copy_allowed_sens[cant / 100][cant % 100] & 1)) { SelectObject(h_dc_mem_cells, bmp_stylo_vert); j++; }
			if (sens == 1 && (copy_allowed_sens[cant / 100][cant % 100] & 2)) { SelectObject(h_dc_mem_cells, bmp_stylo_vert); j++; }
			for (i = 0; i<10; i++) { MoveToEx(h_dc_mem_cells, x + 20 - i, y + 7 + i, NULL); LineTo(h_dc_mem_cells, x + 21 + i, y + 7 + i); } // haut
			if (j > 0) { // Dessine un trait vers entre les deux fléches, si au moins une fléche de dessinée.
				SelectObject(h_dc_mem_cells, bmp_stylo_vert);
				for (i = 0; i<5; i++) { MoveToEx(h_dc_mem_cells, x + 18 + i, y + 17, NULL); LineTo(h_dc_mem_cells, x + 18 + i, y + 24); }
			}
			if (cfg_relief >0 && j == 0) { // Dessine un trait vers entre les deux fléches, si au moins une fléche de dessinée.
				SelectObject(h_dc_mem_cells, bmp_stylo_gris128);
				MoveToEx(h_dc_mem_cells, x + 11, y + 17, NULL); LineTo(h_dc_mem_cells, x + 30, y + 17);
				MoveToEx(h_dc_mem_cells, x + 11, y + 23, NULL); LineTo(h_dc_mem_cells, x + 30, y + 23);
			}
			break;


		case CELLS_SUBTYPE_SPE_CH: // Butoir à droite = '--|' avec indicateur de passage facultatif
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, x + 26, y + 20);	// Dessine les traits simples
			MoveToEx(h_dc_mem_cells, x + 26, y + 12, NULL); LineTo(h_dc_mem_cells, x + 26, y + 29);

			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 26, y + 19);	// Dessine des traits gras
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 26, y + 21);
			}

			if (g == -1 && rendu_need_fleche(cant)) {		// On va afficher l'état d'un canton.
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 1) draw_fleche("O", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); }
			}

			if (g != -1) {		// On va afficher l'état d'un garage
				if (vio_garage_lock_status[g] == 0 && cant != -1 && rendu_need_fleche(cant)) { //  Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 1) draw_fleche("O", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); }
				}
			}
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			v = -1;
			if (v1 != -1) v = pio_get_val(v1);		// Si la variable 'V1' est définie, v = état de la variable = 0 ou 1.
			if (v == 0) {
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				cadre_relief(x + 17, y + 12, x + 23, y + 28, -1, rendu[RENDU_COLOR_DET_OFF]);
			}
			if (v == 1) cadre_relief(x + 17, y + 12, x + 23, y + 28, 0, rendu[RENDU_COLOR_DET_ON]);
			break;


		case CELLS_SUBTYPE_SPE_HC: // Butoir à gauche = '|--' avec indicateur de passage facultatif
			MoveToEx(h_dc_mem_cells, x + 14, y + 20, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			MoveToEx(h_dc_mem_cells, x + 14, y + 12, NULL); LineTo(h_dc_mem_cells, x + 14, y + 29);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 14, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 14, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
			}

			if (g == -1 && rendu_need_fleche(cant)) {		// On va afficher l'état d'un canton.
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 1) draw_fleche("E", x, y); }
			}

			if (g != -1) {		// On va afficher l'état d'un garage
				if (vio_garage_lock_status[g] == 0 && cant != -1 && rendu_need_fleche(cant)) { //  Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 1) draw_fleche("E", x, y); }
				}
			}
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			v = -1;
			if (v1 != -1) v = pio_get_val(v1);		// Si la variable 'V1' est définie, v = état de la variable = 0 ou 1.
			if (v == 0) {
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				cadre_relief(x + 17, y + 12, x + 23, y + 28, -1, rendu[RENDU_COLOR_DET_OFF]);
			}
			if (v == 1) cadre_relief(x + 17, y + 12, x + 23, y + 28, 0, rendu[RENDU_COLOR_DET_ON]);
			break;



		case CELLS_SUBTYPE_SPE_CV: // Butoir en haut = 'T' avec indicateur de passage facultatif
			MoveToEx(h_dc_mem_cells, x + 20, y + 14, NULL); LineTo(h_dc_mem_cells, CELLS_S);
			MoveToEx(h_dc_mem_cells, x + 12, y + 14, NULL); LineTo(h_dc_mem_cells, x + 29, y + 14);
			if (use_gros_trait)
			{
				MoveToEx(h_dc_mem_cells, x + 19, y + 14, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
				MoveToEx(h_dc_mem_cells, x + 21, y + 14, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
			}

			if (g == -1 && rendu_need_fleche(cant)) {		// On va afficher l'état d'un canton.
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 1) draw_fleche("S", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); }
			}

			if (g != -1) {		// On va afficher l'état d'un garage
				if (vio_garage_lock_status[g] == 0 && cant != -1 && rendu_need_fleche(cant)) { //  Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 1) draw_fleche("S", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); }
				}
			}
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			v = -1;
			if (v1 != -1) v = pio_get_val(v1);		// Si la variable 'V1' est définie, v = état de la variable = 0 ou 1.
			if (v == 0) {
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				cadre_relief(x + 12, y + 17, x + 28, y + 23, -1, rendu[RENDU_COLOR_DET_OFF]);
			}
			if (v == 1) cadre_relief(x + 12, y + 17, x + 28, y + 23, 0, rendu[RENDU_COLOR_DET_ON]);
			break;


		case CELLS_SUBTYPE_SPE_VC: // Butoir en bas = '_|_'  avec indicateur de passage facultatif.
			MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, x + 20, y + 26);
			MoveToEx(h_dc_mem_cells, x + 12, y + 26, NULL); LineTo(h_dc_mem_cells, x + 29, y + 26);
			if (use_gros_trait)
			{
				MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 26);
				MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 26);
			}

			if (g == -1 && rendu_need_fleche(cant)) {		// On va afficher l'état d'un canton.
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 1) draw_fleche("N", x, y); }
			}

			if (g != -1) {		// On va afficher l'état d'un garage
				if (vio_garage_lock_status[g] == 0 && cant != -1 && rendu_need_fleche(cant)) { //  Garage connecté. // 0 ou 1, 1 => Le garage est isolé du canton (état réel).
					if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); }
					if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 1) draw_fleche("N", x, y); }
				}
			}
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			v = -1;
			if (v1 != -1) v = pio_get_val(v1);		// Si la variable 'V1' est définie, v = état de la variable = 0 ou 1.
			if (v == 0) {
				if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS128);
				cadre_relief(x + 12, y + 17, x + 28, y + 23, -1, rendu[RENDU_COLOR_DET_OFF]);
			}
			if (v == 1) cadre_relief(x + 12, y + 17, x + 28, y + 23, 0, rendu[RENDU_COLOR_DET_ON]);
			break;


		case CELLS_SUBTYPE_SPE_HOR: // Bloc de TCO avec l'horloge "heure-horo".
			if (c1 != -1)  bmp_select_brush(h_dc_mem_cells, c1);				// Couleur horloge à 'ON' = c1,
			else           bmp_select_brush(rendu[RENDU_COLOR_FOND]);		// ou la couleur du fond du TCO par défaut.
			if (cfg_relief > 0) bmp_select_brush(BMP_CST_COLOR_GRISWIN);
			if (horo_blocked && (CLIGNOTE_LENT) && cfg_relief == 0) {		    	// Si l'horloge est 'BLOQUéE', fait clignoter la couleur de fond,
				if (c3 != -1) bmp_select_brush(h_dc_mem_cells, c3);				// = c3 par alternance,
				else       SelectObject(h_dc_mem_cells, bmp_pinceau_rouge);	// ou la couleur rouge par défaut par alternance.
				if (cfg_relief > 0) bmp_select_brush(BMP_CST_COLOR_BLANC);
			}
			if (horo_tic_on == 0) {											// Si l'horloge est à l'arrêt.
				if (c2 != -1) bmp_select_brush(h_dc_mem_cells, c2);				// Couleur horloge à 'OFF' = c2,
				else	   SelectObject(h_dc_mem_cells, bmp_pinceau_rouge);	// ou la couleur rouge par défaut.
				if (cfg_relief > 0) bmp_select_brush(BMP_CST_COLOR_GRISWIN);
			}
			if (cfg_relief == 0) bmp_select_pen(rendu[RENDU_COLOR_GRILLE]);	// Sélection de couleur pour la grille du TCO
			else                bmp_select_pen(BMP_CST_COLOR_GRIS220);

			SelectObject(h_dc_mem_cells, cells_font); SetBkMode(h_dc_mem_cells, TRANSPARENT);
			SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));		// Texte en bleu
			sprintf_s(szTemp, " J%d %02d%02d", horo_j, horo_h, horo_m);

			TextOut(h_dc_mem_cells, x + 2, y + 3, szTemp, 4);  //   J0    Affiche le jour de la semaine.
			TextOut(h_dc_mem_cells, x + 2, y + 11, &szTemp[4], 4);  //  0830   Affiche l'heure et les minutes.
			SetTextColor(h_dc_mem_cells, RGB(255, 0, 0));		// Texte en rouge
			if (horo_blocked && CLIGNOTE_LENT)   TextOut(h_dc_mem_cells, x + 2, y + 21, "bloc", 4);  // Si l'horloge est bloquée.
			SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));		// Texte en bleu
			if (horo_tic_on == 0) TextOut(h_dc_mem_cells, x + 7, y + 29, "off", 3);  // Si l'horloge est arrêtée.

			if (cfg_relief > 0) {
				SelectObject(h_dc_mem_cells, bmp_stylo_gris192);		// Couleur des traits	
				MoveToEx(h_dc_mem_cells, x + 5, y + 2, NULL);       LineTo(h_dc_mem_cells, x + 35, y + 2);  /* - */ // Dessine le cadre en relief autour de l'horloge.
				SelectObject(h_dc_mem_cells, bmp_stylo_gris128);		// Couleur des traits	
				LineTo(h_dc_mem_cells, x + 38, y + 5);  /* \ */
				LineTo(h_dc_mem_cells, x + 38, y + 16);  /* | */
				LineTo(h_dc_mem_cells, x + 35, y + 19);  /* / */   LineTo(h_dc_mem_cells, x + 5, y + 19);  /* - */
				SelectObject(h_dc_mem_cells, bmp_stylo_gris192);		// Couleur des traits	
				LineTo(h_dc_mem_cells, x + 2, y + 16);  /* \ */   LineTo(h_dc_mem_cells, x + 2, y + 5);  /* | */
				LineTo(h_dc_mem_cells, x + 5, y + 2);  /* / */

				SelectObject(h_dc_mem_cells, bmp_stylo_blanc);		// Couleur des traits	
				MoveToEx(h_dc_mem_cells, x + 5, y + 1, NULL);       LineTo(h_dc_mem_cells, x + 35, y + 1);  /* - */ // Dessine le cadre en relief autour de l'horloge.
				SelectObject(h_dc_mem_cells, bmp_stylo_gris64);		// Couleur des traits	
				LineTo(h_dc_mem_cells, x + 39, y + 5);  /* \ */
				LineTo(h_dc_mem_cells, x + 39, y + 16);  /* | */
				LineTo(h_dc_mem_cells, x + 35, y + 20);  /* / */   LineTo(h_dc_mem_cells, x + 5, y + 20);  /* - */
				SelectObject(h_dc_mem_cells, bmp_stylo_blanc);		// Couleur des traits	
				LineTo(h_dc_mem_cells, x + 1, y + 16);  /* \ */   LineTo(h_dc_mem_cells, x + 1, y + 5);  /* | */
				LineTo(h_dc_mem_cells, x + 5, y + 1);  /* / */
			}
			else {
				SelectObject(h_dc_mem_cells, bmp_stylo_noir);		// Couleur des traits	
				MoveToEx(h_dc_mem_cells, x + 5, y + 2, NULL);       LineTo(h_dc_mem_cells, x + 35, y + 2);  /* - */ // Dessine le cadre autour de l'horloge.
				LineTo(h_dc_mem_cells, x + 38, y + 5);  /* \ */   LineTo(h_dc_mem_cells, x + 38, y + 16);  /* | */
				LineTo(h_dc_mem_cells, x + 35, y + 19);  /* / */   LineTo(h_dc_mem_cells, x + 5, y + 19);  /* - */
				LineTo(h_dc_mem_cells, x + 2, y + 16);  /* \ */   LineTo(h_dc_mem_cells, x + 2, y + 5);  /* | */
				LineTo(h_dc_mem_cells, x + 5, y + 2);  /* / */
			}

			if (horo_tic_on == 1 && !horo_blocked && CLIGNOTE_LENT) {
				SetPixel(h_dc_mem_cells, x + 19, y + 13, NULL); SetPixel(h_dc_mem_cells, x + 19, y + 15, NULL);		// Si l'horloge tourne, affiche un ':' clignotant.
			}

			if (horo_tic_on && !horo_blocked)  {														// Dessine le pied de l'horloge en marche et non bloquée,
				if (cfg_relief > 0) {
					SelectObject(h_dc_mem_cells, bmp_stylo_blanc);		// Couleur des traits	
					MoveToEx(h_dc_mem_cells, x + 17, y + 21, NULL);     LineTo(h_dc_mem_cells, x + 17, y + 38);		// (pleine hauteur).
					SelectObject(h_dc_mem_cells, bmp_stylo_gris128);		// Couleur des traits	
					MoveToEx(h_dc_mem_cells, x + 21, y + 21, NULL);     LineTo(h_dc_mem_cells, x + 21, y + 37);    LineTo(h_dc_mem_cells, x + 17, y + 37);
					SelectObject(h_dc_mem_cells, bmp_stylo_gris64);		// Couleur des traits	
					MoveToEx(h_dc_mem_cells, x + 22, y + 21, NULL);     LineTo(h_dc_mem_cells, x + 22, y + 38);    LineTo(h_dc_mem_cells, x + 16, y + 38);
					if (horo_nettoyage == 1) {
						SelectObject(h_dc_mem_cells, bmp_stylo_jaune);		// Couleur des traits jaune = train nettoyage.
						MoveToEx(h_dc_mem_cells, x + 18, y + 21, NULL);     LineTo(h_dc_mem_cells, x + 18, y + 37);		// (pleine hauteur).
						MoveToEx(h_dc_mem_cells, x + 19, y + 21, NULL);     LineTo(h_dc_mem_cells, x + 19, y + 37);
						MoveToEx(h_dc_mem_cells, x + 20, y + 21, NULL);     LineTo(h_dc_mem_cells, x + 20, y + 37);
					}
				}
				else {
					SelectObject(h_dc_mem_cells, bmp_stylo_noir);		// Couleur des traits	
					MoveToEx(h_dc_mem_cells, x + 17, y + 20, NULL);     LineTo(h_dc_mem_cells, x + 17, y + 39);		// (pleine hauteur).
					MoveToEx(h_dc_mem_cells, x + 22, y + 20, NULL);     LineTo(h_dc_mem_cells, x + 22, y + 39);
				}
				SelectObject(h_dc_mem_cells, bmp_stylo_vert); // Voyant vert de témoin de marche
				bmp_select_brush(BMP_CST_COLOR_VERT);
				Rectangle(h_dc_mem_cells, x + 5, y + 5, x + 8, y + 8);

			}
			if (horo_tic_on && horo_blocked)  {														// Dessine le pied de l'horloge en marche et bloquée,
				if (cfg_relief > 0) {
					SelectObject(h_dc_mem_cells, bmp_stylo_blanc);		// Couleur des traits	
					MoveToEx(h_dc_mem_cells, x + 17, y + 29, NULL);     LineTo(h_dc_mem_cells, x + 17, y + 38);		// (demi hauteur).
					SelectObject(h_dc_mem_cells, bmp_stylo_gris128);		// Couleur des traits	
					MoveToEx(h_dc_mem_cells, x + 21, y + 29, NULL);     LineTo(h_dc_mem_cells, x + 21, y + 37);    LineTo(h_dc_mem_cells, x + 17, y + 37);
					SelectObject(h_dc_mem_cells, bmp_stylo_gris64);		// Couleur des traits	
					MoveToEx(h_dc_mem_cells, x + 22, y + 29, NULL);     LineTo(h_dc_mem_cells, x + 22, y + 38);    LineTo(h_dc_mem_cells, x + 16, y + 38);
					if (horo_nettoyage == 1) {
						SelectObject(h_dc_mem_cells, bmp_stylo_jaune);		// Couleur des traits jaune = train nettoyage.
						MoveToEx(h_dc_mem_cells, x + 18, y + 29, NULL);     LineTo(h_dc_mem_cells, x + 18, y + 37);		// (demi hauteur).
						MoveToEx(h_dc_mem_cells, x + 19, y + 29, NULL);     LineTo(h_dc_mem_cells, x + 19, y + 37);
						MoveToEx(h_dc_mem_cells, x + 20, y + 29, NULL);     LineTo(h_dc_mem_cells, x + 20, y + 37);
					}
				}
				else {
					SelectObject(h_dc_mem_cells, bmp_stylo_noir);		// Couleur des traits	
					MoveToEx(h_dc_mem_cells, x + 17, y + 29, NULL);     LineTo(h_dc_mem_cells, x + 17, y + 39);		// (demi hauteur).
					MoveToEx(h_dc_mem_cells, x + 22, y + 29, NULL);     LineTo(h_dc_mem_cells, x + 22, y + 39);
				}
				if (CLIGNOTE_LENT) {
					SelectObject(h_dc_mem_cells, bmp_stylo_rouge); // Voyant rouge clignotant de témoin de blocage.
					bmp_select_brush(BMP_CST_COLOR_ROUGE);
					Rectangle(h_dc_mem_cells, x + 5, y + 5, x + 8, y + 8);
				}
			}
			break;


		case CELLS_SUBTYPE_SPE_FEU:		// Bloc de TCO avec voie horizontale avec feu tricolore 
			MoveToEx(h_dc_mem_cells, CELLS_O, NULL); LineTo(h_dc_mem_cells, CELLS_E);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 0, y + 19, NULL); LineTo(h_dc_mem_cells, x + 40, y + 19);
				MoveToEx(h_dc_mem_cells, x + 0, y + 21, NULL); LineTo(h_dc_mem_cells, x + 40, y + 21);
			}

			if (rendu_need_fleche(cant)) {
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("E", x, y); if (sens == 1) draw_fleche("O", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("O", x, y); if (sens == 1) draw_fleche("E", x, y); }
			}

			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS64);
			if (opt == 1) { MoveToEx(h_dc_mem_cells, x + 6, y + 19, NULL);  LineTo(h_dc_mem_cells, x + 6, y + 9 + 3);   LineTo(h_dc_mem_cells, x + 14 - 4, y + 9 + 3); }
			if (opt == 2) { MoveToEx(h_dc_mem_cells, x + 6, y + 21, NULL);  LineTo(h_dc_mem_cells, x + 6, y + 31 - 3);  LineTo(h_dc_mem_cells, x + 14 - 4, y + 31 - 3); }
			if (opt == 3) { MoveToEx(h_dc_mem_cells, x + 34, y + 19, NULL); LineTo(h_dc_mem_cells, x + 34, y + 9 + 3);  LineTo(h_dc_mem_cells, x + 26 + 4, y + 9 + 3); }
			if (opt == 4) { MoveToEx(h_dc_mem_cells, x + 34, y + 21, NULL); LineTo(h_dc_mem_cells, x + 34, y + 31 - 3); LineTo(h_dc_mem_cells, x + 26 + 4, y + 31 - 3); }
			if (opt == 5) {
				// Cas spécial pour les feux routiers configurés en clignotant rouge automatiquement pour un passage à niveau.
				// Il suffit de mettre '5' dans la case option => feux ronds rouges pour voitures.
				// Une seule variable utilisée = V1.
				if (v1 != -1) { v = 0; if (pio_get_val(v1)) v = (cells_tick >> 1) & 1; }		// si la variable v1 est définie...

				if (v>0) bmp_select_brush(h_dc_mem_cells, BMP_CST_COLOR_ROUGE);	// Si v1 = 1, alors les feux clignotent.
				else SelectObject(h_dc_mem_cells, bmp_pinceau_gris192);
				j = 1; i = 0;
				Ellipse(h_dc_mem_cells, x + 3 + 7 * i, y + 4 + 6 * j, x + 10 + 7 * i, y + 11 + 6 * j);
				MoveToEx(h_dc_mem_cells, x + 6 + 7 * i, y + 3 + 6 * j, NULL); LineTo(h_dc_mem_cells, x + 6 + 7 * i, y - 6 + 6 * j); // Dessine les croix de Saint-André.
				MoveToEx(h_dc_mem_cells, x + 3 + 7 * i, y + 2 + 6 * j, NULL); LineTo(h_dc_mem_cells, x + 10 + 7 * i, y - 5 + 6 * j);
				MoveToEx(h_dc_mem_cells, x + 3 + 7 * i, y - 4 + 6 * j, NULL); LineTo(h_dc_mem_cells, x + 10 + 7 * i, y + 3 + 6 * j);
				j = 2; i = 4;
				Ellipse(h_dc_mem_cells, x + 3 + 7 * i, y + 12 + 6 * j, x + 10 + 7 * i, y + 19 + 6 * j);
				MoveToEx(h_dc_mem_cells, x + 6 + 7 * i, y + 19 + 6 * j, NULL); LineTo(h_dc_mem_cells, x + 6 + 7 * i, y + 28 + 6 * j);
				MoveToEx(h_dc_mem_cells, x + 3 + 7 * i, y + 20 + 6 * j, NULL); LineTo(h_dc_mem_cells, x + 10 + 7 * i, y + 27 + 6 * j);
				MoveToEx(h_dc_mem_cells, x + 3 + 7 * i, y + 26 + 6 * j, NULL); LineTo(h_dc_mem_cells, x + 10 + 7 * i, y + 19 + 6 * j);

				SelectObject(h_dc_mem_cells, bmp_stylo_gris192);												// Dessine la route.
				MoveToEx(h_dc_mem_cells, x + 14, y + 4, NULL); LineTo(h_dc_mem_cells, x + 14, y + 36);
				MoveToEx(h_dc_mem_cells, x + 26, y + 4, NULL); LineTo(h_dc_mem_cells, x + 26, y + 36);

			}
			else {
				SelectObject(h_dc_mem_cells, bmp_stylo_noir);
				for (j = 0; j<4; j++) for (i = 0; i<5; i++) {
					v = 1;
					if (szTxt[5 * j + i] == '0') SelectObject(h_dc_mem_cells, bmp_pinceau_gris192);
					if (szTxt[5 * j + i] == '1') {
						v = 0; if (v1 != -1) v = pio_get_val(v1);
						if (v>0) {
							if (c1 == -1) bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]);
							else bmp_select_brush(h_dc_mem_cells, c1);
						}
						else SelectObject(h_dc_mem_cells, bmp_pinceau_gris192);
					}
					if (szTxt[5 * j + i] == '2') {
						v = 0; if (v2 != -1) v = pio_get_val(v2);
						if (v>0) {
							if (c2 == -1) bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]);
							else bmp_select_brush(h_dc_mem_cells, c2);
						}
						else SelectObject(h_dc_mem_cells, bmp_pinceau_gris192);
					}
					if (szTxt[5 * j + i] == '3') {
						v = 0; if (v3 != -1) v = pio_get_val(v3);
						if (v>0) {
							if (c3 == -1) bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]);
							else bmp_select_brush(h_dc_mem_cells, c3);
						}
						else SelectObject(h_dc_mem_cells, bmp_pinceau_gris192);
					}
					if (szTxt[5 * j + i] == '4') {
						v = 0; if (v4 != -1) v = pio_get_val(v4);
						if (v>0) {
							if (c4 == -1) bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]);
							else bmp_select_brush(h_dc_mem_cells, c4);
						}
						else SelectObject(h_dc_mem_cells, bmp_pinceau_gris192);
					}
					if (szTxt[5 * j + i] >= '1' && szTxt[5 * j + i] <= '4') {
						if (j <= 1) {
							Rectangle(h_dc_mem_cells, x + 3 + 7 * i, y + 3 + 6 * j, x + 3 + 7 * i + 7, y + 3 + 6 * j + 7);
							if (cfg_relief > 0) cadre_relief(x + 3 + 7 * i - 1, y + 3 + 6 * j - 1, x + 3 + 7 * i + 7, y + 3 + 6 * j + 7, 20 + !v, -1);
						}
						if (j >= 2) {
							Rectangle(h_dc_mem_cells, x + 3 + 7 * i, y + 3 + 6 * j + 10, x + 3 + 7 * i + 7, y + 3 + 6 * j + 7 + 10);
							if (cfg_relief > 0)  cadre_relief(x + 3 + 7 * i - 1, y + 3 + 6 * j + 10 - 1, x + 3 + 7 * i + 7, y + 3 + 6 * j + 7 + 10, 20 + !v, -1);
						}
					}
				}
			}
			break;


		case CELLS_SUBTYPE_SPE_FEUV:		// Voie verticale avec feu tricolore.
			MoveToEx(h_dc_mem_cells, CELLS_N, NULL); LineTo(h_dc_mem_cells, CELLS_S);
			if (use_gros_trait) {
				MoveToEx(h_dc_mem_cells, x + 19, y + 0, NULL); LineTo(h_dc_mem_cells, x + 19, y + 40);
				MoveToEx(h_dc_mem_cells, x + 21, y + 0, NULL); LineTo(h_dc_mem_cells, x + 21, y + 40);
			}

			if (rendu_need_fleche(cant)) {
				if (vio_canton_vit[cant / 100][cant % 100]>0) { if (sens == 0) draw_fleche("N", x, y); if (sens == 1) draw_fleche("S", x, y); }
				if (vio_canton_vit[cant / 100][cant % 100]<0) { if (sens == 0) draw_fleche("S", x, y); if (sens == 1) draw_fleche("N", x, y); }
			}
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			if (cfg_relief > 0) bmp_select_pen(BMP_CST_COLOR_GRIS64);
			if (opt == 1) { MoveToEx(h_dc_mem_cells, x + 19, y + 6, NULL);  LineTo(h_dc_mem_cells, x + 9 + 3, y + 6);   LineTo(h_dc_mem_cells, x + 9 + 3, y + 14 - 4); }
			if (opt == 2) { MoveToEx(h_dc_mem_cells, x + 21, y + 6, NULL);  LineTo(h_dc_mem_cells, x + 31 - 3, y + 6);  LineTo(h_dc_mem_cells, x + 31 - 3, y + 14 - 4); }
			if (opt == 3) { MoveToEx(h_dc_mem_cells, x + 19, y + 34, NULL); LineTo(h_dc_mem_cells, x + 9 + 3, y + 34);  LineTo(h_dc_mem_cells, x + 9 + 3, y + 26 + 4); }
			if (opt == 4) { MoveToEx(h_dc_mem_cells, x + 21, y + 34, NULL); LineTo(h_dc_mem_cells, x + 31 - 3, y + 34); LineTo(h_dc_mem_cells, x + 31 - 3, y + 26 + 4); }
			if (opt == 5) {
				// Cas spécial pour les feux routiers configurés en clignotant rouge automatiquement pour un passage à niveau.
				// Il suffit de mettre '5' dans la case option => feux ronds rouges pour voitures.
				// Une seule variable utilisée = V1.
				if (v1 != -1) { v = 0; if (pio_get_val(v1)) v = (cells_tick >> 1) & 1; }	// si la variable v1 est définie...

				if (v>0) bmp_select_brush(h_dc_mem_cells, BMP_CST_COLOR_ROUGE);	// Si v1 = 1, alors les feux clignotent.
				else        SelectObject(h_dc_mem_cells, bmp_pinceau_gris192);
				j = 1; i = 0;
				Ellipse(h_dc_mem_cells, x + 4 + 6 * j, y + 3 + 7 * i, x + 11 + 6 * j, y + 10 + 7 * i);
				MoveToEx(h_dc_mem_cells, x + 3 + 6 * j, y + 6 + 7 * i, NULL); LineTo(h_dc_mem_cells, x - 6 + 6 * j, y + 6 + 7 * i); // Dessine les croix de Saint-André
				MoveToEx(h_dc_mem_cells, x + 2 + 6 * j, y + 3 + 7 * i, NULL); LineTo(h_dc_mem_cells, x - 5 + 6 * j, y + 10 + 7 * i);	//OK
				MoveToEx(h_dc_mem_cells, x + 2 + 6 * j, y + 9 + 7 * i, NULL); LineTo(h_dc_mem_cells, x - 5 + 6 * j, y + 2 + 7 * i);

				j = 2; i = 4;
				Ellipse(h_dc_mem_cells, x + 12 + 6 * j, y + 3 + 7 * i, x + 19 + 6 * j, y + 10 + 7 * i);
				MoveToEx(h_dc_mem_cells, x + 19 + 6 * j, y + 6 + 7 * i, NULL); LineTo(h_dc_mem_cells, x + 28 + 6 * j, y + 6 + 7 * i);
				MoveToEx(h_dc_mem_cells, x + 20 + 6 * j, y + 9 + 7 * i, NULL); LineTo(h_dc_mem_cells, x + 27 + 6 * j, y + 2 + 7 * i);
				MoveToEx(h_dc_mem_cells, x + 20 + 6 * j, y + 2 + 7 * i + 1, NULL); LineTo(h_dc_mem_cells, x + 27 + 6 * j, y + 9 + 7 * i + 1);

				SelectObject(h_dc_mem_cells, bmp_stylo_gris192);												// Dessine la route en gris.
				MoveToEx(h_dc_mem_cells, x + 4, y + 14, NULL); LineTo(h_dc_mem_cells, x + 36, y + 14);
				MoveToEx(h_dc_mem_cells, x + 4, y + 26, NULL); LineTo(h_dc_mem_cells, x + 36, y + 26);
			}
			else {
				SelectObject(h_dc_mem_cells, bmp_stylo_noir);
				for (j = 0; j<4; j++) for (i = 0; i<5; i++) {
					v = 1;
					if (szTxt[5 * j + i] == '0') SelectObject(h_dc_mem_cells, bmp_pinceau_gris192);
					if (szTxt[5 * j + i] == '1') {
						v = 0; if (v1 != -1) v = pio_get_val(v1);
						if (v>0) {
							if (c1 == -1) bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]);
							else bmp_select_brush(h_dc_mem_cells, c1);
						}
						else SelectObject(h_dc_mem_cells, bmp_pinceau_gris192);
					}
					if (szTxt[5 * j + i] == '2') {
						v = 0; if (v2 != -1) v = pio_get_val(v2);
						if (v>0) {
							if (c2 == -1) bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]);
							else bmp_select_brush(h_dc_mem_cells, c2);
						}
						else SelectObject(h_dc_mem_cells, bmp_pinceau_gris192);
					}
					if (szTxt[5 * j + i] == '3') {
						v = 0; if (v3 != -1) v = pio_get_val(v3);
						if (v>0) {
							if (c3 == -1) bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]);
							else bmp_select_brush(h_dc_mem_cells, c3);
						}
						else SelectObject(h_dc_mem_cells, bmp_pinceau_gris192);
					}
					if (szTxt[5 * j + i] == '4') {
						v = 0; if (v4 != -1) v = pio_get_val(v4);
						if (v>0) {
							if (c4 == -1) bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]);
							else bmp_select_brush(h_dc_mem_cells, c4);
						}
						else SelectObject(h_dc_mem_cells, bmp_pinceau_gris192);
					}
					if (szTxt[5 * j + i] >= '1' && szTxt[5 * j + i] <= '4') {
						if (j <= 1) {
							Rectangle(h_dc_mem_cells, x + 3 + 6 * j, y + 3 + 7 * i, x + 3 + 6 * j + 7, y + 3 + 7 * i + 7);
							if (cfg_relief > 0)  cadre_relief(x + 3 + 6 * j - 1, y + 3 + 7 * i - 1, x + 3 + 6 * j + 7, y + 3 + 7 * i + 7, 20 + !v, -1);
						}
						if (j >= 2) {
							Rectangle(h_dc_mem_cells, x + 3 + 6 * j + 10, y + 3 + 7 * i, x + 3 + 6 * j + 7 + 10, y + 3 + 7 * i + 7);
							if (cfg_relief > 0)  cadre_relief(x + 3 + 6 * j + 10 - 1, y + 3 + 7 * i - 1, x + 3 + 6 * j + 7 + 10, y + 3 + 7 * i + 7, 20 + !v, -1);
						}
					}
				}
			}
			break;
		default: break;
		}
	}

	if (type == CELLS_TYPE_CMDVOY) {
		SelectObject(h_dc_mem_cells, bmp_stylo_noir);
		switch (subtype) {

		case CELLS_SUBTYPE_CMDVOY_DIVERS: // Une case de TCO aux fonctions diverses (Affichage et action) suivant la valeur de 'OPT'.
			SelectObject(h_dc_mem_cells, cells_font);
			SetBkMode(h_dc_mem_cells, TRANSPARENT);
			SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// Texte en bleu

			if (opt == 1) {	// Une case de TCO pour afficher les déplacements (et raz des déplacements si l'on clic dessus).
				TextOut(h_dc_mem_cells, x + 11, y + 3, "DPL", 3);
				MoveToEx(h_dc_mem_cells, x + 11, y + 10, NULL); LineTo(h_dc_mem_cells, x + 38, y + 10); // Dessine un trait
				v = 0; j = 0;
				cmd_divers[CMD_DIVERS_VAR_DEPL1] = -1;
				cmd_divers[CMD_DIVERS_VAR_DEPL2] = -1;
				cmd_divers[CMD_DIVERS_VAR_DEPL3] = -1;
				for (i = 0; i < DEPL_TAB_NB; i++) { // Pour tous les déplacements.
					if (depl_tab[i][DEPL_TAB_IND_STEP] != DEPL_CST_STATE_IDLE) {
						v = 1;
						if (j<3) cmd_divers[CMD_DIVERS_VAR_DEPL1 + j] = i;	// On stocke les 3 premiers déplacements
						j++;
					}
				}
				if (cmd_divers[CMD_DIVERS_VAR_DEPL1] != -1) { sprintf_s(szTemp, "D%3d", cmd_divers[CMD_DIVERS_VAR_DEPL1]); TextOut(h_dc_mem_cells, x + 2, y + 11, szTemp, 4); }
				if (cmd_divers[CMD_DIVERS_VAR_DEPL2] != -1) { sprintf_s(szTemp, "D%3d", cmd_divers[CMD_DIVERS_VAR_DEPL2]); TextOut(h_dc_mem_cells, x + 2, y + 19, szTemp, 4); }
				if (cmd_divers[CMD_DIVERS_VAR_DEPL3] != -1) { sprintf_s(szTemp, "D%3d", cmd_divers[CMD_DIVERS_VAR_DEPL3]); TextOut(h_dc_mem_cells, x + 2, y + 27, szTemp, 4); }
				cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON1], -1);  // valeur du bouton poussoir DEPL = cmd_divers[CMD_DIVERS_VAR_BOUTON]
				// Allume le voyant en haut à gauche. La taille est plus grande en relief.si un déplacement est reservé ou en cours
				v = v&CLIGNOTE_RAPIDE_1;
				if (cfg_relief > 0) {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 10, y + 10, 0, rendu[RENDU_COLOR_INT_ON]);
					else       cadre_relief(x + 3, y + 3, x + 10, y + 10, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				else {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 8, y + 8, 0, rendu[RENDU_COLOR_INT_ON]);
					else       cadre_relief(x + 3, y + 3, x + 8, y + 8, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
			}
			else if (opt == 2) {	// Une case de TCO pour afficher les itinéraires (et raz des itinéraires si l'on clic dessus).
				TextOut(h_dc_mem_cells, x + 11, y + 3, "ITI", 3);
				MoveToEx(h_dc_mem_cells, x + 11, y + 10, NULL); LineTo(h_dc_mem_cells, x + 38, y + 10); // Dessine un trait
				v = 0; j = 0;
				cmd_divers[CMD_DIVERS_VAR_ITI1] = -1;
				cmd_divers[CMD_DIVERS_VAR_ITI2] = -1;
				cmd_divers[CMD_DIVERS_VAR_ITI3] = -1;
				for (i = 0; i < ITI_TAB_NB; i++) { // Pour tous les itinéraires.
					if (iti_tab[i][ITI_TAB_IND_STEP] != ITI_CST_STATE_IDLE) {
						v = 1;
						if (j<3) cmd_divers[CMD_DIVERS_VAR_ITI1 + j] = i;	// On stocke les 3 premiers itinéraires
						j++;
					}
				}
				if (cmd_divers[CMD_DIVERS_VAR_ITI1] != -1) { sprintf_s(szTemp, "I%3d", cmd_divers[CMD_DIVERS_VAR_ITI1]); TextOut(h_dc_mem_cells, x + 2, y + 11, szTemp, 4); }
				if (cmd_divers[CMD_DIVERS_VAR_ITI2] != -1) { sprintf_s(szTemp, "I%3d", cmd_divers[CMD_DIVERS_VAR_ITI2]); TextOut(h_dc_mem_cells, x + 2, y + 19, szTemp, 4); }
				if (cmd_divers[CMD_DIVERS_VAR_ITI3] != -1) { sprintf_s(szTemp, "I%3d", cmd_divers[CMD_DIVERS_VAR_ITI3]); TextOut(h_dc_mem_cells, x + 2, y + 27, szTemp, 4); }
				cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON2], -1);  // valeur du bouton poussoir DEPL = cmd_divers[CMD_DIVERS_VAR_BOUTON]
				// Allume le voyant en haut à gauche. La taille est plus grande en relief.si un déplacement est reservé ou en cours
				v = v&CLIGNOTE_RAPIDE_1;
				if (cfg_relief > 0) {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 10, y + 10, 0, rendu[RENDU_COLOR_INT_ON]);
					else       cadre_relief(x + 3, y + 3, x + 10, y + 10, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				else {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 8, y + 8, 0, rendu[RENDU_COLOR_INT_ON]);
					else       cadre_relief(x + 3, y + 3, x + 8, y + 8, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
			}
			else if (opt == 3) { // Une case de TCO pour afficher le train en défaut et le canton en défaut. Si l'on clic dessus, place ce train sur ce canton.
				TextOut(h_dc_mem_cells, x + 11, y + 3, "AFF", 3);
				j = 0; t = 0; v = 0;
				for (i = 0; i < NB_TRAIN; i++) {
					if (train_pb_capt[i] == 1) { j++; t = i; }  // j = nombre de train en panne, t = n° du train en panne.
				}
				if (j == 1) {
					//sprintf_s(szTemp,"T %2d",t);TextOut(h_dc_mem_cells, x+2, y+19, szTemp,4); // N'affiche le train que si il y en a qu'un en défaut!
					g = 0;
					for (j = 0; j < NB_CARTE; j++) for (i = 0; i<NB_CANTON; i++){
						if (canton.num_train[j][i] == -1 && vio_det[j][i] == 1) { k = j, l = i; g++; } // Jaune = Canton inoccupé et detecté ='Manque un train ici'.
					}
					if (g == 1) {
						if (strlen(copy_train_name[t]) == 8) {
							sprintf_s(szTemp, "%s", copy_train_name[t]);     szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 11, szTemp, 4);
							sprintf_s(szTemp, "%s", &copy_train_name[t][4]); szTemp[4] = '\0'; TextOut(h_dc_mem_cells, x + 2, y + 19, szTemp, 4);
						}
						if (k>0) sprintf_s(szTemp, "C%1d%2d", k, l);
						else     sprintf_s(szTemp, "C %2d", l);
						TextOut(h_dc_mem_cells, x + 2, y + 27, szTemp, 4); // N'affiche le train que si il y en a qu'un en défaut!
						v = 1;
						cmd_divers[CMD_DIVERS_OPT3_OK] = 1;
						cmd_divers[CMD_DIVERS_OPT3_TRAIN] = t;
						cmd_divers[CMD_DIVERS_OPT3_CARTE] = k;
						cmd_divers[CMD_DIVERS_OPT3_CANTON] = l;
					}
				}
				cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON3], -1);  // valeur du bouton poussoir DEPL = cmd_divers[CMD_DIVERS_VAR_BOUTON]
				v = v&CLIGNOTE_RAPIDE_1;
				if (cfg_relief > 0) {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 10, y + 10, 0, BMP_CST_COLOR_ROUGE);
					else      cadre_relief(x + 3, y + 3, x + 10, y + 10, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				else {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 8, y + 8, 0, BMP_CST_COLOR_ROUGE);
					else      cadre_relief(x + 3, y + 3, x + 8, y + 8, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				SelectObject(h_dc_mem_cells, bmp_stylo_vert);
				MoveToEx(h_dc_mem_cells, x + 11, y + 10, NULL); LineTo(h_dc_mem_cells, x + 38, y + 10); // Dessine un trait
			}

			else if (opt == 4) {	// Une case de TCO, "STOP" interrupteur pour arrêter les locomotives.
				v = cmd_divers[CMD_DIVERS_OPT4_ARRET];	 // 1 = STOP.
				// Allume le voyant en haut à gauche. La taille est plus grande en relief.si un déplacement est reservé ou en cours
				v = v&CLIGNOTE_RAPIDE_1;
				if (v == 1) cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON4], BMP_CST_COLOR_ROUGE);  // valeur du bouton poussoir DEPL = cmd_divers[CMD_DIVERS_VAR_BOUTON]
				else       cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON4], -1);  // valeur du bouton poussoir DEPL = cmd_divers[CMD_DIVERS_VAR_BOUTON]
				TextOut(h_dc_mem_cells, x + 11, y + 3, "STP", 3);
				v = cmd_divers[CMD_DIVERS_OPT4_ARRET];	 // 1 = STOP.
				if (v == 1) TextOut(h_dc_mem_cells, x + 2, y + 19, "STOP", 4);
				if (cfg_relief > 0) {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 10, y + 10, 0, BMP_CST_COLOR_ROUGE);
					else      cadre_relief(x + 3, y + 3, x + 10, y + 10, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				else {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 8, y + 8, 0, BMP_CST_COLOR_ROUGE);
					else      cadre_relief(x + 3, y + 3, x + 8, y + 8, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				SelectObject(h_dc_mem_cells, bmp_stylo_rouge);
				MoveToEx(h_dc_mem_cells, x + 11, y + 10, NULL); LineTo(h_dc_mem_cells, x + 38, y + 10); // Dessine un trait
			}

			else if (opt == 5) {	// Une case de TCO pour afficher les cantons en 'halte:' de '#balauto' (et inhibition des 'haltes:'si l'on clic dessus).
				// Allume le voyant en haut à gauche.
				v = 0; j = 0;
				cmd_divers[CMD_DIVERS_VAR_HALT1] = -1;
				cmd_divers[CMD_DIVERS_VAR_HALT2] = -1;
				cmd_divers[CMD_DIVERS_VAR_HALT3] = -1;
				for (i = 0; i < BALAUTO_HALT_NB; i++) { // Pour tous les éléments du tableau.
					if (balauto.balauto_halt_tab[i][BALAUTO_HALT_TAB_IND_CANT_NO] == -1) break; // Dernier élément du tableau.
					if (balauto.balauto_halt_tab[i][BALAUTO_HALT_TAB_IND_ACTION_OK] == 1) {
						v = 1;
						if (j < 3) cmd_divers[CMD_DIVERS_VAR_HALT1 + j] = balauto.balauto_halt_tab[i][BALAUTO_HALT_TAB_IND_CANT_NO];	// On stocke les 3 premiers 'halt:'
						j++;
					}
				}
				if (cmd_divers[CMD_DIVERS_VAR_HALT1] != -1) { sprintf_s(szTemp, "C%3d", cmd_divers[CMD_DIVERS_VAR_HALT1]); TextOut(h_dc_mem_cells, x + 2, y + 11, szTemp, 4); }
				if (cmd_divers[CMD_DIVERS_VAR_HALT2] != -1) { sprintf_s(szTemp, "C%3d", cmd_divers[CMD_DIVERS_VAR_HALT2]); TextOut(h_dc_mem_cells, x + 2, y + 19, szTemp, 4); }
				if (cmd_divers[CMD_DIVERS_VAR_HALT3] != -1) { sprintf_s(szTemp, "C%3d", cmd_divers[CMD_DIVERS_VAR_HALT3]); TextOut(h_dc_mem_cells, x + 2, y + 27, szTemp, 4); }
				cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON5], -1);  // valeur du bouton poussoir DEPL = cmd_divers[CMD_DIVERS_VAR_BOUTON]
				// Allume le voyant en haut à gauche. La taille est plus grande en relief.si un 'halte:' est  en cours
				if (cmd_divers[CMD_DIVERS_OPT5_HALTE] == 1) { // valeur du bouton poussoir HLT
					cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON5], BMP_CST_COLOR_ORANGE);
					if (v == 1) TextOut(h_dc_mem_cells, x + 2, y + 19, "INHB", 4);
				}
				TextOut(h_dc_mem_cells, x + 11, y + 3, "HLT", 3);
				SelectObject(h_dc_mem_cells, bmp_stylo_bleuf);
				MoveToEx(h_dc_mem_cells, x + 11, y + 10, NULL); LineTo(h_dc_mem_cells, x + 38, y + 10); // Dessine un trait
				if (cfg_relief > 0) {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 10, y + 10, 0, rendu[RENDU_COLOR_INT_ON]);
					else      cadre_relief(x + 3, y + 3, x + 10, y + 10, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				else {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 8, y + 8, 0, rendu[RENDU_COLOR_INT_ON]);
					else      cadre_relief(x + 3, y + 3, x + 8, y + 8, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
			}
			else if (opt == 6) { // Une case de TCO pour afficher les cantons en 'blocage:' de '#balauto' (et inhibition des 'blocages:'si l'on clic dessus).
				// Allume le voyant en haut à gauche. 
				v = 0; j = 0;
				cmd_divers[CMD_DIVERS_VAR_BLOCAG1] = -1;
				cmd_divers[CMD_DIVERS_VAR_BLOCAG2] = -1;
				cmd_divers[CMD_DIVERS_VAR_BLOCAG3] = -1;
				for (i = 0; i < BALAUTO_CANT_NB; i++) { // Pour tous les éléments du tableau.
					if (balauto.balauto_cant_tab[i][BALAUTO_CANT_TAB_IND_CANT_NO] == -1) break; // Dernier élément du tableau.
					if (balauto.balauto_cant_tab[i][BALAUTO_CANT_TAB_IND_ACTION_OK] == 2) { // =2 => canton bloqué (=1 => canton ralenti)
						v = 1;
						if (j < 3) cmd_divers[CMD_DIVERS_VAR_BLOCAG1 + j] = balauto.balauto_cant_tab[i][BALAUTO_CANT_TAB_IND_CANT_NO];	// On stocke les 3 premiers 'cant:'
						j++;
					}
				}
				if (cmd_divers[CMD_DIVERS_VAR_BLOCAG1] != -1) { sprintf_s(szTemp, "C%3d", cmd_divers[CMD_DIVERS_VAR_BLOCAG1]); TextOut(h_dc_mem_cells, x + 2, y + 11, szTemp, 4); }
				if (cmd_divers[CMD_DIVERS_VAR_BLOCAG2] != -1) { sprintf_s(szTemp, "C%3d", cmd_divers[CMD_DIVERS_VAR_BLOCAG2]); TextOut(h_dc_mem_cells, x + 2, y + 19, szTemp, 4); }
				if (cmd_divers[CMD_DIVERS_VAR_BLOCAG3] != -1) { sprintf_s(szTemp, "C%3d", cmd_divers[CMD_DIVERS_VAR_BLOCAG3]); TextOut(h_dc_mem_cells, x + 2, y + 27, szTemp, 4); }
				cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON6], -1);  // valeur du bouton poussoir DEPL = cmd_divers[CMD_DIVERS_VAR_BOUTON]
				// Allume le voyant en haut à gauche. La taille est plus grande en relief.si un 'blocage:' est  en cours
				if (cmd_divers[CMD_DIVERS_OPT6_BLOCAG] == 1) { // valeur du bouton poussoir BLC
					cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON6], BMP_CST_COLOR_ORANGE);
					if (v == 1) TextOut(h_dc_mem_cells, x + 2, y + 19, "INHB", 4);
				}
				TextOut(h_dc_mem_cells, x + 11, y + 3, "BLC", 3);
				SelectObject(h_dc_mem_cells, bmp_stylo_bleuf);
				MoveToEx(h_dc_mem_cells, x + 11, y + 10, NULL); LineTo(h_dc_mem_cells, x + 38, y + 10); // Dessine un trait
				if (cfg_relief > 0) { // Pas de clignotement du voyant, car allumé est un état presque normal.
					if (v == 1) cadre_relief(x + 3, y + 3, x + 10, y + 10, 0, rendu[RENDU_COLOR_INT_ON]);
					else       cadre_relief(x + 3, y + 3, x + 10, y + 10, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				else {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 8, y + 8, 0, rendu[RENDU_COLOR_INT_ON]);
					else       cadre_relief(x + 3, y + 3, x + 8, y + 8, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
			}
			else if (opt == 56) {	// Une case de TCO pour afficher les cantons en 'halte:' et en 'blocag:' = mélange de opt=5 + opt=6 .
				v = 0; j = 0;
				cmd_divers[CMD_DIVERS_VAR_HALT1] = -1;
				cmd_divers[CMD_DIVERS_VAR_HALT2] = -1;
				cmd_divers[CMD_DIVERS_VAR_HALT3] = -1;
				for (i = 0; i < BALAUTO_HALT_NB; i++) { // Pour tous les éléments du tableau.
					if (balauto.balauto_halt_tab[i][BALAUTO_HALT_TAB_IND_CANT_NO] == -1) break; // Dernier élément du tableau.
					if (balauto.balauto_halt_tab[i][BALAUTO_HALT_TAB_IND_ACTION_OK] == 1) {
						v = 1;
						if (j < 3) cmd_divers[CMD_DIVERS_VAR_HALT1 + j] = balauto.balauto_halt_tab[i][BALAUTO_HALT_TAB_IND_CANT_NO];	// On stocke les 3 premiers 'halt:'
						j++;
					}
				}
				for (i = 0; i < BALAUTO_CANT_NB; i++) { // Pour tous les éléments du tableau.
					if (balauto.balauto_cant_tab[i][BALAUTO_CANT_TAB_IND_CANT_NO] == -1) break; // Dernier élément du tableau.
					if (balauto.balauto_cant_tab[i][BALAUTO_CANT_TAB_IND_ACTION_OK] == 2) { // =2 => canton bloqué (=1 => canton ralenti)
						v = 1;
						if (j < 3) cmd_divers[CMD_DIVERS_VAR_HALT1 + j] = balauto.balauto_cant_tab[i][BALAUTO_CANT_TAB_IND_CANT_NO];	// On stocke les 3 premiers 'cant:'
						j++;
					}
				}
				if (cmd_divers[CMD_DIVERS_VAR_HALT1] != -1) { sprintf_s(szTemp, "C%3d", cmd_divers[CMD_DIVERS_VAR_HALT1]); TextOut(h_dc_mem_cells, x + 2, y + 11, szTemp, 4); }
				if (cmd_divers[CMD_DIVERS_VAR_HALT2] != -1) { sprintf_s(szTemp, "C%3d", cmd_divers[CMD_DIVERS_VAR_HALT2]); TextOut(h_dc_mem_cells, x + 2, y + 19, szTemp, 4); }
				if (cmd_divers[CMD_DIVERS_VAR_HALT3] != -1) { sprintf_s(szTemp, "C%3d", cmd_divers[CMD_DIVERS_VAR_HALT3]); TextOut(h_dc_mem_cells, x + 2, y + 27, szTemp, 4); }
				cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON56], -1);  // valeur du bouton poussoir DEPL = cmd_divers[CMD_DIVERS_VAR_BOUTON]
				// Allume le voyant en haut à gauche. La taille est plus grande en relief.si un 'blocage:' est  en cours
				if (cmd_divers[CMD_DIVERS_OPT6_BLOCAG] == 1) { // valeur du bouton poussoir BLC
					cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON56], BMP_CST_COLOR_ORANGE);
					if (v == 1) TextOut(h_dc_mem_cells, x + 2, y + 19, "INHB", 4);
				}
				TextOut(h_dc_mem_cells, x + 11, y + 3, "B-H", 3);
				SelectObject(h_dc_mem_cells, bmp_stylo_bleuf);
				MoveToEx(h_dc_mem_cells, x + 11, y + 10, NULL); LineTo(h_dc_mem_cells, x + 38, y + 10); // Dessine un trait
				if (cfg_relief > 0) {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 10, y + 10, 0, rendu[RENDU_COLOR_INT_ON]);
					else       cadre_relief(x + 3, y + 3, x + 10, y + 10, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				else {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 8, y + 8, 0, rendu[RENDU_COLOR_INT_ON]);
					else       cadre_relief(x + 3, y + 3, x + 8, y + 8, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
			}
			else if (opt == 7) {	// Une case de TCO pour afficher des bargraphe des commandes des trains.
				cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON7], -1);  // valeur du bouton poussoir DEPL = cmd_divers[CMD_DIVERS_VAR_BOUTON]
				// Allume le voyant en haut à gauche. 
				TextOut(h_dc_mem_cells, x + 11, y + 3, "CMD", 3);
				SelectObject(h_dc_mem_cells, bmp_stylo_bleuf);
				MoveToEx(h_dc_mem_cells, x + 11, y + 10, NULL); LineTo(h_dc_mem_cells, x + 38, y + 10); // Dessine un trait
				j = 0;
				for (i = 0; i < NB_TRAIN && j<5; i++) {
					if (abs(train.cons_sans_correction[i])>5) {
						if (cmd_divers[CMD_DIVERS_OPT4_ARRET] == 1 && CLIGNOTE_TRAPIDE) {
							SelectObject(hMemDC, bmp_pinceau_rouge);
							SelectObject(h_dc_mem_cells, bmp_stylo_rouge);
						}
						else {
							SelectObject(hMemDC, bmp_pinceau_gris192);
							SelectObject(h_dc_mem_cells, bmp_stylo_gris128);
						}
						Rectangle(hMemDC, x + 3 + 7 * j, y + 37, x + 3 + 7 * j + 5, y + 35 - (24 * abs(train.cons_sans_correction[i])) / 65);
						j++;
					}
				}
				if (cfg_relief > 0) {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 10, y + 10, 0, rendu[RENDU_COLOR_INT_ON]);
					else      cadre_relief(x + 3, y + 3, x + 10, y + 10, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				else {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 8, y + 8, 0, rendu[RENDU_COLOR_INT_ON]);
					else      cadre_relief(x + 3, y + 3, x + 8, y + 8, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
			}

			else if (opt == 8) {	// Une case de TCO, "INV" bouton poussoir pour faire un raz du 'INVS' des cantons si vitesse == 0.
				TextOut(h_dc_mem_cells, x + 11, y + 3, "INV", 3);
				MoveToEx(h_dc_mem_cells, x + 11, y + 10, NULL); LineTo(h_dc_mem_cells, x + 38, y + 10); // Dessine un trait
				v = 0; j = 0; k = 0;
				cmd_divers[CMD_DIVERS_VAR_INVS1] = -1;
				cmd_divers[CMD_DIVERS_VAR_INVS2] = -1;
				cmd_divers[CMD_DIVERS_VAR_INVS3] = -1;
				for (i = 0; i < NB_CARTE; i++) {
					for (j = 0; j < NB_CANTON; j++) {
						if ((canton.master_selectif[i][j] != 0 || canton.update_selectif[i][j] != 0) && (canton.inv_selectif[i][j] != 0)) {
							v = 1;
							if (k < 3) cmd_divers[CMD_DIVERS_VAR_INVS1 + k] = (100*i)+j;	// On stocke les 3 premiers cantons utilisés et inversés
							k++;
						}
					}
				}
				if (cmd_divers[CMD_DIVERS_VAR_INVS1] != -1) { sprintf_s(szTemp, "V%3d", cmd_divers[CMD_DIVERS_VAR_INVS1]); TextOut(h_dc_mem_cells, x + 2, y + 11, szTemp, 4); }
				if (cmd_divers[CMD_DIVERS_VAR_INVS2] != -1) { sprintf_s(szTemp, "V%3d", cmd_divers[CMD_DIVERS_VAR_INVS2]); TextOut(h_dc_mem_cells, x + 2, y + 19, szTemp, 4); }
				if (cmd_divers[CMD_DIVERS_VAR_INVS3] != -1) { sprintf_s(szTemp, "V%3d", cmd_divers[CMD_DIVERS_VAR_INVS3]); TextOut(h_dc_mem_cells, x + 2, y + 27, szTemp, 4); }
				cadre_relief(x + 1, y + 1, x + 39, y + 39, cmd_divers[CMD_DIVERS_VAR_BOUTON8], -1);  // valeur du bouton poussoir DEPL = cmd_divers[CMD_DIVERS_VAR_BOUTON]
				// Allume le voyant en haut à gauche. La taille est plus grande en relief.
				if (cfg_relief > 0) {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 10, y + 10, 0, rendu[RENDU_COLOR_INT_ON]);
					else       cadre_relief(x + 3, y + 3, x + 10, y + 10, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				else {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 8, y + 8, 0, rendu[RENDU_COLOR_INT_ON]);
					else       cadre_relief(x + 3, y + 3, x + 8, y + 8, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
			}

			break;


		case CELLS_SUBTYPE_CMDVOY_POUSS: // Une case de TCO pour un bouton poussoir rectangulaire. Divers affichage suivant la valeur de 'opt'. si opt > 100 on affiche le voyant.
			v = -1;
			if (v3 != -1)          v = (pio_get_val(v3) + 1) % 2; // V3 = variable a mettre à 0. 
			if (v2 != -1 && v == -1) v = pio_get_val(v2);       // V2 = variable a mettre à 1.
			if (v1 != -1) v = pio_get_val(v1);                // V1 = variable a mettre à 1, tant que le bouton est enfoncé. v1 a le dessus par rapport à v2 ou v3 pour animer le bouton.
			cadre_relief(x + 1, y + 1, x + 39, y + 39, v, -1);
			if (opt != -1 ) dessine_picto(x, y, c1, c2, c3, c4, opt);  // Dessine un pictogramme suivant opt.
			if (opt < 1 || opt > 29) {			// Allume le voyant en haut à gauche. La taille est plus grande en relief. 
				if (cfg_relief > 0) {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 10, y + 10, 0, rendu[RENDU_COLOR_INT_ON]);
					else       cadre_relief(x + 3, y + 3, x + 10, y + 10, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				else {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 8, y + 8, 0, rendu[RENDU_COLOR_INT_ON]);
					else       cadre_relief(x + 3, y + 3, x + 8, y + 8, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
			}
			SelectObject(h_dc_mem_cells, cells_font); // Le texte est toujours supperposé.
			SetBkMode(h_dc_mem_cells, TRANSPARENT);
			SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// Texte en bleu
			TextOut(h_dc_mem_cells, x + 2, y + 3, szTxt, 4);	//EasyTextOut(x+2,y+2,ch);
			TextOut(h_dc_mem_cells, x + 2, y + 11, &szTxt[4], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 19, &szTxt[8], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 27, &szTxt[12], 4);
			break;

		case CELLS_SUBTYPE_CMDVOY_INT: // Une case de TCO pour un bouton interrupteur rectangulaire, change d'état à chaque pression.
			v = -1;
			if (v1 != -1) v = pio_get_val(v1);
			cadre_relief(x + 1, y + 1, x + 39, y + 39, v, -1);
			if (opt != -1 ) dessine_picto(x, y, c1, c2, c3, c4, opt);  // Dessine un pictogramme suivant opt.

			if (cfg_relief > 0) { SelectObject(h_dc_mem_cells, bmp_stylo_gris32); MoveToEx(h_dc_mem_cells, x + 2, y + 18, NULL); LineTo(h_dc_mem_cells, x + 37, y + 18); }
			else { SelectObject(h_dc_mem_cells, bmp_stylo_noir); MoveToEx(h_dc_mem_cells, x + 2, y + 18, NULL); LineTo(h_dc_mem_cells, x + 39, y + 18); }

			// Allume le voyant en haut à gauche. La taille est plus grande en relief. 
			if (opt < 1 || opt > 29) {
				if (cfg_relief > 0) {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 10, y + 10, 0, rendu[RENDU_COLOR_INT_ON]);
					else        cadre_relief(x + 3, y + 3, x + 10, y + 10, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
				else {
					if (v == 1) cadre_relief(x + 3, y + 3, x + 8, y + 8, 0, rendu[RENDU_COLOR_INT_ON]);
					else        cadre_relief(x + 3, y + 3, x + 8, y + 8, 1, rendu[RENDU_COLOR_INT_OFF]);
				}
			}
			SelectObject(h_dc_mem_cells, cells_font); // Le texte est toujours supperposé.
			SetBkMode(h_dc_mem_cells, TRANSPARENT);
			SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// Texte en bleu
			TextOut(h_dc_mem_cells, x + 2, y + 3, szTxt, 4);	//EasyTextOut(x+2,y+2,ch);
			TextOut(h_dc_mem_cells, x + 2, y + 11, &szTxt[4], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 19, &szTxt[8], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 27, &szTxt[12], 4);
			break;


		case CELLS_SUBTYPE_CMDVOY_ITI: // Une case de TCO pour un bouton poussoir rond à Appui/Traction Clic-gauche/Clic-droit. Spécial itinéraire.
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			if (opt == 1) bmp_select_brush(rendu[RENDU_COLOR_IPP_LOCKON]); else bmp_select_brush(rendu[RENDU_COLOR_IPP_LOCKOFF]);
			// Cercle extérieur de verrouillage du poussoir.
			if (cfg_relief > 0) {
				if (opt == 1)cadre_cercle_relief(x + 2 + 18, y + 2 + 18, 16, 20, -1, -1);  // Si verrouillage
				else       cadre_cercle_relief(x + 2 + 18, y + 2 + 18, 16, 21, -2, -2);         // Si pas verrouillage dessine juste un cerle externe
			}
			else           cadre_cercle_relief(x + 2 + 18, y + 2 + 18, 16, 21, -1, -1);

			SelectObject(h_dc_mem_cells, bmp_pinceau_bleu);
			v = 0;
			if (v3 != -1 || v4 != -1) {
				v = 0;
				if (v4 != -1) if (pio_get_val(v4)) v = (cells_tick >> 1) & 1;		// On passe dans ce programme toutes les 80 msec.
				if (v3 != -1) if (pio_get_val(v3)) v = 1;
			}

			if (v3 == -1 && v4 == -1 && v2 == -1 && v1 != -1) v = pio_get_val(v1);
			if (v) bmp_select_brush(rendu[RENDU_COLOR_IPP_ON]); else bmp_select_brush(rendu[RENDU_COLOR_IPP_OFF]);
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);

			i = 0;
			if (v1 >= 6000 && v1 <= 6000 + ITI_TAB_NB) { // 60xx = variable d'itinéraire.
				if (iti_tab[v1 - 6000][ITI_TAB_IND_EXIST] == 1) {
					if (iti_tab[v1 - 6000][ITI_TAB_IND_TYPE] == ITI_CST_DIRECT) i = 1; // Si itinéraire sans verrouillage d'aiguillage
				}
			}
			if (i == 0) cadre_cercle_relief(x + 2 + 18, y + 2 + 18, 12, !v, -1, -1); // cercle intérieur avec relief si verrouillage des aiguillages.
			else      cadre_cercle_relief(x + 2 + 18, y + 2 + 18, 12, -1, -1, -1); // cercle intérieur sans relief si pas de verrouillage des aiguillages.


			SelectObject(h_dc_mem_cells, cells_font);
			SetBkMode(h_dc_mem_cells, TRANSPARENT);
			SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// Texte en bleu
			TextOut(h_dc_mem_cells, x + 2, y + 3, szTxt, 4);
			TextOut(h_dc_mem_cells, x + 2, y + 11, &szTxt[4], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 19, &szTxt[8], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 27, &szTxt[12], 4);
			break;


		case CELLS_SUBTYPE_CMDVOY_VOY1: // Une case de TCO avec un voyant rond ou carré.
			SelectObject(h_dc_mem_cells, cells_font);
			SetBkMode(h_dc_mem_cells, TRANSPARENT);
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			SelectObject(h_dc_mem_cells, bmp_pinceau_rouge);
			v = 0;
			if (v2 != -1) { v = 0; if (pio_get_val(v2)) v = (cells_tick >> 1) & 1; }
			if (v1 != -1) if (pio_get_val(v1) == 1) v=1;
			if (v) {
				if (c1 == -1) { bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]); i = rendu[RENDU_COLOR_VOY_ON]; }
				else { bmp_select_brush(h_dc_mem_cells, c1); i = c1; }
			}
			else {
				if (c2 == -1) { bmp_select_brush(rendu[RENDU_COLOR_VOY_OFF]); i = rendu[RENDU_COLOR_VOY_OFF]; }
				else { bmp_select_brush(h_dc_mem_cells, c2); i = c2; }
			}
			if (opt<1 || opt >6) cadre_cercle_relief(x + 2 + 18, y + 2 + 18, 16, 0, -1, -1); // opt=-1 => Gros voyant rond.
			else if (opt == 1) cadre_cercle_relief(x + 2 + 18, y + 2 + 18, 8, 0, -1, -1); // opt=1 => Petit voyant rond centré.
			else if (opt == 2) cadre_cercle_relief(x + 2 + 18, y + 0 + 14, 8, 0, -1, -1); // opt=2 => petit Voyant rond haut;
			else if (opt == 3) cadre_relief(x + 10, y + 10, x+30, y+30, 0, i);            // opt=3 => Voyant carré dépassant centré.
			else if (opt == 4) cadre_relief(x + 10, y + 5,  x+30, y+25, 0, i);            // opt=4 => Voyant carré dépassant en haut.
			else if (opt == 5) { bmp_select_pen(BMP_CST_COLOR_GRIS128); Rectangle(h_dc_mem_cells, x + 10, y + 10, x + 30, y + 30); } // opt=5 => Voyant carré centré.
			else if (opt == 6) { bmp_select_pen(BMP_CST_COLOR_GRIS128); Rectangle(h_dc_mem_cells, x + 10, y + 5,  x + 30, y + 25); } // opt=6 => Voyant carré en haut.
			SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// Texte en bleu superposé.
			TextOut(h_dc_mem_cells, x + 2, y + 3, szTxt, 4);
			TextOut(h_dc_mem_cells, x + 2, y + 11, &szTxt[4], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 19, &szTxt[8], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 27, &szTxt[12], 4);
			break;


		case CELLS_SUBTYPE_CMDVOY_VOY2: // Une case de TCO avec deux voyants ronds ou carrés.
			SelectObject(h_dc_mem_cells, cells_font);
			SetBkMode(h_dc_mem_cells, TRANSPARENT);
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			SelectObject(h_dc_mem_cells, bmp_pinceau_rouge);
			v = 0;
			if (v2 != -1) { v = 0; if (pio_get_val(v2)) v = (cells_tick >> 1) & 1; }
			if (v1 != -1) if (pio_get_val(v1) == 1) v=1;

			if (v) {
				if (c1 == -1) { bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]); i = rendu[RENDU_COLOR_VOY_ON]; }
				else { bmp_select_brush(h_dc_mem_cells, c1); i = c1; }
			}
			else {
				if (c2 == -1) { bmp_select_brush(rendu[RENDU_COLOR_VOY_OFF]); i = rendu[RENDU_COLOR_VOY_OFF]; }
				else { bmp_select_brush(h_dc_mem_cells, c2); i = c2; }
			}
			if ((v1 != -1 || v2 != -1 || opt < 10) || (v2 == -1 && v3 == -1 && v4 == -1)) {
				if (opt < 1 || opt > 12 || (opt > 2 && opt < 11)) cadre_cercle_relief(x + 2 + 8, y + 2 + 8, 7, 0, -1, -1);       // opt=-1 => Voyant rond.
				else if (opt == 1 || opt == 11) cadre_relief(x + 2, y + 2, x + 18, y + 18, 0, i);        // opt= 1 => Voyant carré dépassant.
				else if (opt == 2 || opt == 12) { bmp_select_pen(BMP_CST_COLOR_GRIS128); Rectangle(h_dc_mem_cells, x + 2, y + 2, x + 18, y + 18); } // opt=2 => Voyant carré simple.
			}

			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			SelectObject(h_dc_mem_cells, bmp_pinceau_rouge);
			v = 0;
			if (v4 != -1) { v = 0; if (pio_get_val(v4)) v = (cells_tick >> 1) & 1; }
			if (v3 != -1) if (pio_get_val(v3) == 1) v=1;
			if (v) {
				if (c3 == -1) { bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]); i = rendu[RENDU_COLOR_VOY_ON]; }
				else { bmp_select_brush(h_dc_mem_cells, c3); i = c3; }
			}
			else {
				if (c4 == -1) { bmp_select_brush(rendu[RENDU_COLOR_VOY_OFF]); i = rendu[RENDU_COLOR_VOY_OFF]; }
				else { bmp_select_brush(h_dc_mem_cells, c4); i = c4; }
			}
			if (v3 != -1 || v4 != -1 || opt < 10) {
				if (opt < 1 || opt > 12 || (opt > 2 && opt < 11)) cadre_cercle_relief(x + 2 + 8, y + 21 + 8, 7, 0, -1, -1);      // opt=-1 => Gros voyant rond.
				else if (opt == 1 || opt == 11) cadre_relief(x + 2, y + 22, x + 18, y + 37, 0, i);       // opt= 1 => Voyant carré dépassant.
				else if (opt == 2 || opt == 12) { bmp_select_pen(BMP_CST_COLOR_GRIS128); Rectangle(h_dc_mem_cells, x + 2, y + 23, x + 18, y + 38); } // opt=2 => Voyant carré simple.
			}

			SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// Texte en bleu superposé.
			TextOut(h_dc_mem_cells, x + 2, y + 3, szTxt, 4);
			TextOut(h_dc_mem_cells, x + 2, y + 11, &szTxt[4], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 19, &szTxt[8], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 27, &szTxt[12], 4);
			break;


		case CELLS_SUBTYPE_CMDVOY_VOY4:		// Une case de TCO avec quatre voyants rectangulaires
			SelectObject(h_dc_mem_cells, cells_font);
			SetBkMode(h_dc_mem_cells, TRANSPARENT);
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			v = 0;
			if ((v1 != -1 || opt < 10) || (v2==-1 && v3==-1 && v4==-1)) {
				if (v1 != -1) {
					v = pio_get_val(v1);		// La variable 'v1' est définie.
					if (v) {
						if (c1 != -1) bmp_select_brush(h_dc_mem_cells, c1);		// La couleur 'c1' est définie.
						else          bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]);
					}
					else bmp_select_brush(rendu[RENDU_COLOR_VOY_OFF]);
				}
				else bmp_select_brush(rendu[RENDU_COLOR_VOY_OFF]);
				if (cfg_relief > 0 && v == 0) bmp_select_brush(BMP_CST_COLOR_GRISWIN);
				if (opt < 1 || opt == 10) {
					Rectangle(h_dc_mem_cells, x + 3, y + 4, x + 9, y + 10);
					cadre_relief(x + 2, y + 3, x + 9, y + 10, !v, -1);      // opt=-1 => petit voyant carré.
				}
				else if (opt == 1 || opt == 11) cadre_cercle_relief(x + 5, y + 6, 4, -1, -1, -1);      // opt=1 => petit voyant rond.
				else if (opt == 2 || opt == 12) { bmp_select_pen(BMP_CST_COLOR_GRIS128); Rectangle(h_dc_mem_cells, x + 2, y + 3, x + 10, y + 11); } // opt=2 => Voyant carré simple.
			}

			v = 0;
			if (v2 != -1 || opt < 10) {
				if (v2 != -1) {
					v = pio_get_val(v2);		// La variable 'v2' est définie.
					if (v) {
						if (c2 != -1) bmp_select_brush(h_dc_mem_cells, c2);		// La couleur 'c2' est définie.
						else       bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]);
					}
					else bmp_select_brush(rendu[RENDU_COLOR_VOY_OFF]);
				}
				else bmp_select_brush(rendu[RENDU_COLOR_VOY_OFF]);
				if (cfg_relief > 0 && v == 0) bmp_select_brush(BMP_CST_COLOR_GRISWIN);
				if (opt < 1 || opt == 10) {
					Rectangle(h_dc_mem_cells, x + 3, y + 12, x + 9, y + 18);
					if (cfg_relief > 0) cadre_relief(x + 2, y + 11, x + 9, y + 18, !v, -1); // opt=-1 => petit voyant carré.
				}
				else if (opt == 1 || opt == 11) cadre_cercle_relief(x + 5, y + 14, 4, -1, -1, -1);        // opt=1 => petit voyant rond.
				else if (opt == 2 || opt == 12) { bmp_select_pen(BMP_CST_COLOR_GRIS128); Rectangle(h_dc_mem_cells, x + 2, y + 11, x + 10, y + 19); } // opt=2 => Voyant carré simple.
			}

			if (v3 != -1 || opt < 10) {
				v = 0;
				if (v3 != -1) {
					v = pio_get_val(v3);		// La variable 'v3' est définie.
					if (v) {
						if (c3 != -1) bmp_select_brush(h_dc_mem_cells, c3);		// La couleur 'c3' est définie.
						else       bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]);
					}
					else bmp_select_brush(rendu[RENDU_COLOR_VOY_OFF]);
				}
				else bmp_select_brush(rendu[RENDU_COLOR_VOY_OFF]);
				if (cfg_relief > 0 && v == 0) bmp_select_brush(BMP_CST_COLOR_GRISWIN);
				if (opt < 1 || opt == 10) {
					Rectangle(h_dc_mem_cells, x + 3, y + 20, x + 9, y + 26);
					if (cfg_relief > 0) cadre_relief(x + 2, y + 19, x + 9, y + 26, !v, -1);// opt=-1 => petit voyant carré.
				}
				else if (opt == 1 || opt == 11) cadre_cercle_relief(x + 5, y + 22, 4, -1, -1, -1);        // opt=1 => petit voyant rond.
				else if (opt == 2 || opt == 12) { bmp_select_pen(BMP_CST_COLOR_GRIS128); Rectangle(h_dc_mem_cells, x + 2, y + 19, x + 10, y + 27); } // opt=2 => Voyant carré simple.
			}


			v = 0;
			if (v4 != -1 || opt < 10) {
				if (v4 != -1) {
					v = pio_get_val(v4);		// La variable 'v4' est définie.
					if (v) {
						if (c4 != -1) bmp_select_brush(h_dc_mem_cells, c4);		// La couleur 'c4' est définie.
						else       bmp_select_brush(rendu[RENDU_COLOR_VOY_ON]);
					}
					else bmp_select_brush(rendu[RENDU_COLOR_VOY_OFF]);
				}
				else bmp_select_brush(rendu[RENDU_COLOR_VOY_OFF]);
				if (cfg_relief > 0 && v == 0) bmp_select_brush(BMP_CST_COLOR_GRISWIN);
				if (opt < 1 || opt == 10) {
					Rectangle(h_dc_mem_cells, x + 3, y + 28, x + 9, y + 34);
					if (cfg_relief > 0) cadre_relief(x + 2, y + 27, x + 9, y + 34, !v, -1);// opt=-1 => petit voyant carré.
				}
				else if (opt == 1 || opt == 11) cadre_cercle_relief(x + 5, y + 30, 4, -1, -1, -1);        // opt=1 => petit voyant rond.
				else if (opt == 2 || opt == 12) { bmp_select_pen(BMP_CST_COLOR_GRIS128); Rectangle(h_dc_mem_cells, x + 2, y + 27, x + 10, y + 35); } // opt=2 => Voyant carré simple.
			}


			SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));		// Texte en bleu
			TextOut(h_dc_mem_cells, x + 2, y + 3, szTxt, 4);	// 4 lignes de texte
			TextOut(h_dc_mem_cells, x + 2, y + 11, &szTxt[4], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 19, &szTxt[8], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 27, &szTxt[12], 4);
			break;


		case CELLS_SUBTYPE_CMDVOY_LABEL: // Une case de TCO pour afficher 4 lignes de texte dans un bloc.
			SelectObject(h_dc_mem_cells, cells_font);
			SetBkMode(h_dc_mem_cells, TRANSPARENT);
			if (opt != -1 ) dessine_picto(x, y, c1, c2, c3, c4, opt);  // Dessine un pictogramme suivant opt.
			if (c1 == -1) { bmp_SetTextColor(rendu[RENDU_COLOR_TEXT]); } // Couleur de texte choisie dans la fenêtre de rendu.
			else {
				if (opt != 27 && opt != 28 && opt != 29) bmp_SetTextColor(c1); // Couleur par défaut pour le texte, car C1 est utilisé comme couleur pour le rectangle.
			}
			TextOut(h_dc_mem_cells, x + 2, y + 3, szTxt, 4);
			TextOut(h_dc_mem_cells, x + 2, y + 11, &szTxt[4], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 19, &szTxt[8], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 27, &szTxt[12], 4);
			break;


		case CELLS_SUBTYPE_CMDVOY_VAL: // Une case de TCO pour afficher 3 lignes de texte et une valeur numérique dans un bloc.
			SelectObject(h_dc_mem_cells, cells_font);
			SetBkMode(h_dc_mem_cells, TRANSPARENT);
			if (c1 == -1) { bmp_SetTextColor(rendu[RENDU_COLOR_TEXT]); } // Couleur de texte choisie dans la fenêtre de rendu.
			else { bmp_SetTextColor(c1); } // Couleur par défaut pour le texte, ou C1 si définie. 
			TextOut(h_dc_mem_cells, x + 2, y + 3, szTxt, 4);	// 3 lignes de texte.
			TextOut(h_dc_mem_cells, x + 2, y + 11, &szTxt[4], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 19, &szTxt[8], 4);
			if (c3 == -1) { bmp_SetTextColor(BMP_CST_COLOR_BLEUF2); } // Couleur de texte ligne du bas.
			else { bmp_SetTextColor(c3); } // Couleur par défaut pour le texte, ou C3 si définie.
			if (v1 != -1) {
				v = pio_get_val(v1);								// La variable 'v1' est définie.
				sprintf_s(szTemp, "%4d", v = pio_get_val(v1));
				TextOut(h_dc_mem_cells, x + 2, y + 31, szTemp, 4);
				SelectObject(h_dc_mem_cells, bmp_stylo_bleuf2);			
				if (c2 == -1) { bmp_select_pen(BMP_CST_COLOR_BLEUF2); } // Dessine un bargraphe de la position du servo
				else { bmp_select_pen(c2); } // Couleur par défaut pour le trait ou C2 si définie.
				MoveToEx(h_dc_mem_cells, x + 2, y + 28, NULL);
				if (v >= 0 && v<1204) LineTo(h_dc_mem_cells, x + 2 + (v * 38) / 1024, y + 28);	// >> Pour diviser par 1024
			}
			else TextOut(h_dc_mem_cells, x + 2, y + 31, "0000", 4);		// Si v1 n'est pas définie,  on affiche '0000'.

			break;


		case CELLS_SUBTYPE_CMDVOY_GO: // Une case de TCO pour afficher un autre écran. Si #1 = 1, 2,  ou 4 dessine autre chose.
			SelectObject(h_dc_mem_cells, bmp_stylo_noir);
			if (cfg_relief > 0) {
				if (n1 == 1 || n1==2) { // n1 = 1 => Coupe le coin en haut à droite.   n1 = 2 => Coupe le coin en haut à droite + texte "VERS".
					bmp_select_pen(BMP_CST_COLOR_GRIS192);
					MoveToEx(h_dc_mem_cells, x + 2, y + 38, NULL); LineTo(h_dc_mem_cells, x + 2, y + 2); LineTo(h_dc_mem_cells, x + 30, y + 2);
					bmp_select_pen(BMP_CST_COLOR_GRIS128);
					LineTo(h_dc_mem_cells, x + 38, y + 10); LineTo(h_dc_mem_cells, x + 38, y + 38); LineTo(h_dc_mem_cells, x + 2, y + 38);
					bmp_select_pen(BMP_CST_COLOR_BLANC);
					MoveToEx(h_dc_mem_cells, x + 1, y + 39, NULL); LineTo(h_dc_mem_cells, x + 1, y + 1); LineTo(h_dc_mem_cells, x + 30, y + 1);
					bmp_select_pen(BMP_CST_COLOR_GRIS64);
					LineTo(h_dc_mem_cells, x + 39, y + 10); LineTo(h_dc_mem_cells, x + 39,  y + 39); LineTo(h_dc_mem_cells, x + 1, y + 39);
				}
				else if (n1 == 3) { // n1 = 3 => Dessine une fléche.
					cadre_relief(x + 1, y + 1, x + 39, y + 39,0,-1 );  
					bmp_select_pen(BMP_CST_COLOR_GRIS64);
					MoveToEx(h_dc_mem_cells, x + 4, y + 6, NULL); LineTo(h_dc_mem_cells, x + 34, y + 6); LineTo(h_dc_mem_cells, x + 30, y + 2);
					MoveToEx(h_dc_mem_cells, x + 4, y + 7, NULL); LineTo(h_dc_mem_cells, x + 34, y + 7); LineTo(h_dc_mem_cells, x + 30, y + 11 );
					MoveToEx(h_dc_mem_cells, x + 35, y + 6, NULL); LineTo(h_dc_mem_cells, x + 31, y + 2);
					MoveToEx(h_dc_mem_cells, x + 35, y + 7, NULL); LineTo(h_dc_mem_cells, x + 31, y + 11 );
				}
				else if (n1 == 4) { // n1 = 4 => Dessine une fléche.
					cadre_relief(x + 1, y + 1, x + 39, y + 39,0,-1 );  
					bmp_select_pen(BMP_CST_COLOR_GRIS64);
					MoveToEx(h_dc_mem_cells, x + 34, y + 6, NULL); LineTo(h_dc_mem_cells, x + 5, y + 3);
					MoveToEx(h_dc_mem_cells, x + 34, y + 6, NULL); LineTo(h_dc_mem_cells, x + 5, y + 9); LineTo(h_dc_mem_cells, x + 5, y + 2);
				}
				else {
					bmp_select_pen(BMP_CST_COLOR_GRIS192);
					MoveToEx(h_dc_mem_cells, x + 2, y + 38, NULL); LineTo(h_dc_mem_cells, x + 2, y + 2); LineTo(h_dc_mem_cells, x + 30, y + 2);
					bmp_select_pen(BMP_CST_COLOR_GRIS128);
					LineTo(h_dc_mem_cells, x + 38, y + 20); LineTo(h_dc_mem_cells, x + 30, y + 38); LineTo(h_dc_mem_cells, x + 2, y + 38);
					bmp_select_pen(BMP_CST_COLOR_BLANC);
					MoveToEx(h_dc_mem_cells, x + 1, y + 39, NULL); LineTo(h_dc_mem_cells, x + 1, y + 1); LineTo(h_dc_mem_cells, x + 30, y + 1);
					bmp_select_pen(BMP_CST_COLOR_GRIS64);
					LineTo(h_dc_mem_cells, x + 39, y + 20); LineTo(h_dc_mem_cells, x + 30, y + 39); LineTo(h_dc_mem_cells, x + 1, y + 39);
				}
			}
			else {
				MoveToEx(h_dc_mem_cells, x + 2, y + 2, NULL); LineTo(h_dc_mem_cells, x + 30, y + 2); LineTo(h_dc_mem_cells, x + 38, y + 20); // Dessine la forme autour.
				LineTo(h_dc_mem_cells, x + 30, y + 38); LineTo(h_dc_mem_cells, x + 2, y + 38); LineTo(h_dc_mem_cells, x + 2, y + 2);
			}
			SelectObject(h_dc_mem_cells, cells_font);
			SetBkMode(h_dc_mem_cells, TRANSPARENT);
			if (c1==-1) bmp_SetTextColor(rendu[RENDU_COLOR_TEXT]);	// Couleur de texte choisie dans la fenêtre de rendu.
			else bmp_SetTextColor(c1);
			TextOut(h_dc_mem_cells, x + 2, y + 3, szTxt, 4);
			TextOut(h_dc_mem_cells, x + 2, y + 11, &szTxt[4], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 19, &szTxt[8], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 27, &szTxt[12], 4);
			if (n1 == 2) {
				bmp_SetTextColor(BMP_CST_COLOR_NOIR);	// Couleur de texte noire.
				TextOut(h_dc_mem_cells, x + 2, y + 3, " GO", 3);
			}

			break;


		case CELLS_SUBTYPE_CMDVOY_SRV: // Une case de TCO avec pour afficher un bouton de commande de servo-moteur
			SelectObject(h_dc_mem_cells, cells_font); SetBkMode(h_dc_mem_cells, TRANSPARENT);
			SetTextColor(h_dc_mem_cells, RGB(0, 0, 128));	// Texte en bleu
			TextOut(h_dc_mem_cells, x + 11, y + 3, "SRV", 3);
			i = -1; j = -1;
			if (v1 != -1) {
				if (v1 >= 8000 && v1 <= 8000 + NB_SERVO) { j = 0; i = v1 - 8000; }	// Cartes UTS 0,1,2 ou 3 .
				if (v1 >= 8100 && v1 <= 8100 + NB_SERVO) { j = 1; i = v1 - 8100; }
				if (v1 >= 8200 && v1 <= 8200 + NB_SERVO) { j = 2; i = v1 - 8200; }
				if (v1 >= 8300 && v1 <= 8300 + NB_SERVO) { j = 3; i = v1 - 8300; }
				if (j != -1 && i != -1) sprintf_s(szTemp, "  %01d%01d", j, i);
				else sprintf_s(szTemp, "  XY"); // Numéro de carte + Numéro de servo
			}
			else sprintf_s(szTemp, "  XY"); // Numéro de carte + Numéro de servo
			v = -1;
			bmp_select_brush(rendu[RENDU_COLOR_INT_OFF]);
			if (v1 != -1){
				if (n1 == -1 && n2 != -1) {
					if (n2 == pio_get_val(v1 - 8000 + 2800)){ bmp_select_brush(rendu[RENDU_COLOR_INT_ON]); v = 1; } // n2 = Position du servo ? dans le cas de plusieurs boutons poussoirs.
				}
				else {
					if (n1 != -1 && n2 != -1) {
						if (n1 == pio_get_val(v1 - 8000 + 2800) || n2 == pio_get_val(v1 - 8000 + 2800)){
							bmp_select_brush(rendu[RENDU_COLOR_INT_ON]); v = 1;
						} // n2 = Position du servo ? dans le cas d'un bouton poussoir à deux positions.
					}
					else {
						v = pio_get_val(v1); // v = Consigne
						if (v == pio_get_val(v1 - 8000 + 2800)) { bmp_select_brush(rendu[RENDU_COLOR_INT_ON]); v = 1; }  // Consigne = Position du servo ?
						else v = 0;
					}
				}
			}
			if (v == -1) v = 0;
			if (n1 == -1 && n2 != -1) cadre_relief(x + 1, y + 1, x + 39, y + 39, v, -1);
			else if (v == 0) cadre_relief(x + 1, y + 1, x + 39, y + 39, 1, -1);
			else           cadre_relief(x + 1, y + 1, x + 39, y + 39, 0, -1);

			TextOut(h_dc_mem_cells, x + 2, y + 11, szTemp, 4);
			TextOut(h_dc_mem_cells, x + 2, y + 19, &szTxt[8], 4);
			TextOut(h_dc_mem_cells, x + 2, y + 27, &szTxt[12], 4);
			// Dessine un bargraphe de la position du servo
			SelectObject(h_dc_mem_cells, bmp_stylo_bleuf2);
			if (v1 != -1) {
				MoveToEx(h_dc_mem_cells, x + 2, y + 35, NULL);
				LineTo(h_dc_mem_cells, x + 2 + (pio_get_val(v1 - 8000 + 2800) * 36) / 1024, y + 35);	// >> Pour diviser par 1024
			}
			// Allume le voyant si la consigne = position du servo
			if (v == 1) cadre_relief(x + 3, y + 3, x + 11, y + 10, 0, rendu[RENDU_COLOR_INT_ON]);
			else       cadre_relief(x + 3, y + 3, x + 11, y + 10, 1, rendu[RENDU_COLOR_INT_OFF]);

			break;
		default: break;
		}
	}
}

// Affiche un dessin sur une case de TCO. Ajoute un pictogramme sur une case une TCO. 
// opt = Type de dessins.
// Fonction appelée pour dessiner dans une case de rail vertical ou horizontal, de texte, de texte + numérique, interrupteur ou Bouton Poussoir.
//
void dessine_picto(int x, int y, int c1, int c2, int c3, int c4, int opt)
{
	int i;
	if (opt == 122) x = x + 2; // Si il y a un voyant, on décale le batiment vers la droite pour ce dessin uniquement.
	if (opt > 100) opt = opt - 100;
	if (opt < 1) return;

	if (opt == 1) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 14, y + 6, NULL); LineTo(h_dc_mem_cells, x + 14, y + 15); // opt=1 => Dessine un haut-parleur.
		LineTo(h_dc_mem_cells, x + 21, y + 15); LineTo(h_dc_mem_cells, x + 21, y + 6); LineTo(h_dc_mem_cells, x + 14, y + 6);
		MoveToEx(h_dc_mem_cells, x + 21, y + 9, NULL); LineTo(h_dc_mem_cells, x + 26, y + 4);
		LineTo(h_dc_mem_cells, x + 26, y + 17); LineTo(h_dc_mem_cells, x + 21, y + 12);
	}
	else if (opt == 2) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 14, y + 6, NULL); LineTo(h_dc_mem_cells, x + 14, y + 16); // opt=2 => Dessine un triangle, sigle de lecture audio.
		LineTo(h_dc_mem_cells, x + 25, y + 10); LineTo(h_dc_mem_cells, x + 14, y + 6);
	}
	else if (opt == 3) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 12, y + 17, NULL); LineTo(h_dc_mem_cells, x + 20, y + 17); // opt=3 => Dessine un lampadaire courbé.
		LineTo(h_dc_mem_cells, x + 16, y + 17); LineTo(h_dc_mem_cells, x + 16, y + 11); LineTo(h_dc_mem_cells, x + 18, y + 5); // Pied.
		MoveToEx(h_dc_mem_cells, x + 19, y + 5, NULL); LineTo(h_dc_mem_cells, x + 23, y + 5);
		MoveToEx(h_dc_mem_cells, x + 23, y + 4, NULL); LineTo(h_dc_mem_cells, x + 27, y + 4); LineTo(h_dc_mem_cells, x + 27, y + 6); // Lampe.
		MoveToEx(h_dc_mem_cells, x + 22, y + 6, NULL); LineTo(h_dc_mem_cells, x + 27, y + 6);
		MoveToEx(h_dc_mem_cells, x + 22, y + 8, NULL); LineTo(h_dc_mem_cells, x + 20, y + 10);   // 3 Rayons lumineux.
		MoveToEx(h_dc_mem_cells, x + 25, y + 8, NULL); LineTo(h_dc_mem_cells, x + 25, y + 10);
		MoveToEx(h_dc_mem_cells, x + 28, y + 8, NULL); LineTo(h_dc_mem_cells, x + 30, y + 10);
	}
	else if (opt == 4) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 16, y + 17, NULL); LineTo(h_dc_mem_cells, x + 24, y + 17); // opt=4 => Dessine un lampadaire droit.
		LineTo(h_dc_mem_cells, x + 20, y + 17); LineTo(h_dc_mem_cells, x + 20, y + 9); // Pied.
		MoveToEx(h_dc_mem_cells, x + 17, y + 7, NULL); LineTo(h_dc_mem_cells, x + 19, y + 5); LineTo(h_dc_mem_cells, x + 21, y + 5); // Lampe.
		LineTo(h_dc_mem_cells, x + 23, y + 7); LineTo(h_dc_mem_cells, x + 23, y + 8);  LineTo(h_dc_mem_cells, x + 21, y + 10);
		LineTo(h_dc_mem_cells, x + 19, y + 10); LineTo(h_dc_mem_cells, x + 16, y + 7); // Lampe.
		MoveToEx(h_dc_mem_cells, x + 25, y + 8, NULL); LineTo(h_dc_mem_cells, x + 28, y + 8);   // 2 Rayons lumineux horizontaux.
		MoveToEx(h_dc_mem_cells, x + 15, y + 8, NULL); LineTo(h_dc_mem_cells, x + 12, y + 8);
		MoveToEx(h_dc_mem_cells, x + 24, y + 4, NULL); LineTo(h_dc_mem_cells, x + 26, y + 2);   // 2 Rayons lumineux Haut.
		MoveToEx(h_dc_mem_cells, x + 16, y + 4, NULL); LineTo(h_dc_mem_cells, x + 14, y + 2);
		MoveToEx(h_dc_mem_cells, x + 24, y + 11, NULL); LineTo(h_dc_mem_cells, x + 26, y + 13); // 2 Rayons lumineux Bas.
		MoveToEx(h_dc_mem_cells, x + 16, y + 11, NULL); LineTo(h_dc_mem_cells, x + 14, y + 13);
	}
	else if (opt == 5) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 4, y + 3, NULL); LineTo(h_dc_mem_cells, x + 36, y + 3); // opt=5 => Dessine un rectangle en haut.
		LineTo(h_dc_mem_cells, x + 36, y + 15); LineTo(h_dc_mem_cells, x + 4, y + 15); LineTo(h_dc_mem_cells, x + 4, y + 3);
	}
	else if (opt == 6) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 4, y + 23, NULL); LineTo(h_dc_mem_cells, x + 36, y + 23); // opt=6 => Dessine un rectangle en bas.
		LineTo(h_dc_mem_cells, x + 36, y + 36); LineTo(h_dc_mem_cells, x + 4, y + 36); LineTo(h_dc_mem_cells, x + 4, y + 23);
	}
	else if (opt == 7) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 3, y + 4, NULL); LineTo(h_dc_mem_cells, x + 15, y + 4); // opt=7 => Dessine un rectangle à gauche.
		LineTo(h_dc_mem_cells, x + 15, y + 36); LineTo(h_dc_mem_cells, x + 3, y + 36); LineTo(h_dc_mem_cells, x + 3, y + 3);
	}
	else if (opt == 8) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 23, y + 4, NULL); LineTo(h_dc_mem_cells, x + 36, y + 4); // opt=8 => Dessine un rectangle à droite.
		LineTo(h_dc_mem_cells, x + 36, y + 36); LineTo(h_dc_mem_cells, x + 23, y + 36); LineTo(h_dc_mem_cells, x + 23, y + 3);
	}
	else if (opt == 9) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		for (i = 0; i < 4; i++) {
			MoveToEx(h_dc_mem_cells, x + 4, y + 3 + (4 * i), NULL); LineTo(h_dc_mem_cells, x + 37, y + 3 + (4 * i)); // opt=9 => Dessine un quadrillage en haut.
		}
		for (i = 0; i < 9; i++) { MoveToEx(h_dc_mem_cells, x + 4 + (4 * i), y + 3, NULL); LineTo(h_dc_mem_cells, x + 4 + (4 * i), y + 15); }
	}
	else if (opt == 10) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		for (i = 0; i < 4; i++) {
			MoveToEx(h_dc_mem_cells, x + 4, y + 24 + (4 * i), NULL); LineTo(h_dc_mem_cells, x + 37, y + 24 + (4 * i)); // opt=10 => Dessine un quadrillage en bas.
		}
		for (i = 0; i < 9; i++) { MoveToEx(h_dc_mem_cells, x + 4 + (4 * i), y + 24, NULL); LineTo(h_dc_mem_cells, x + 4 + (4 * i), y + 37); }
	}
	else if (opt == 11) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		for (i = 0; i < 4; i++) {
			MoveToEx(h_dc_mem_cells, x + 3 + (4 * i), y + 4, NULL); LineTo(h_dc_mem_cells, x + 3 + (4 * i), y + 37);  // opt=11 => Dessine un quadrillage à gauche.
		}
		for (i = 0; i < 9; i++) { MoveToEx(h_dc_mem_cells, x + 3, y + 4 + (4 * i), NULL); LineTo(h_dc_mem_cells, x + 15, y + 4 + (4 * i)); }
	}
	else if (opt == 12) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		for (i = 0; i < 4; i++) {
			MoveToEx(h_dc_mem_cells, x + 24 + (4 * i), y + 4, NULL); LineTo(h_dc_mem_cells, x + 24 + (4 * i), y + 37); // opt=12 => Dessine un quadrillage à droite.
		}
		for (i = 0; i < 9; i++) { MoveToEx(h_dc_mem_cells, x + 24, y + 4 + (4 * i), NULL); LineTo(h_dc_mem_cells, x + 37, y + 4 + (4 * i)); }
	}
	else if (opt == 13) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 11, y + 3, NULL); LineTo(h_dc_mem_cells, x + 29, y + 3); // opt=13 => Dessine un toit de maison en haut.
		LineTo(h_dc_mem_cells, x + 29, y + 15);       LineTo(h_dc_mem_cells, x + 11, y + 15); LineTo(h_dc_mem_cells, x + 11, y + 3);
		MoveToEx(h_dc_mem_cells, x + 11, y + 3, NULL); LineTo(h_dc_mem_cells, x + 17, y + 9); LineTo(h_dc_mem_cells, x + 11, y + 15);
		MoveToEx(h_dc_mem_cells, x + 29, y + 3, NULL); LineTo(h_dc_mem_cells, x + 23, y + 9); LineTo(h_dc_mem_cells, x + 29, y + 15);
		MoveToEx(h_dc_mem_cells, x + 17, y + 9, NULL); LineTo(h_dc_mem_cells, x + 23, y + 9);
		MoveToEx(h_dc_mem_cells, x + 21, y + 6, NULL); LineTo(h_dc_mem_cells, x + 21, y + 7); // Cheminée
		LineTo(h_dc_mem_cells, x + 22, y + 7);         LineTo(h_dc_mem_cells, x + 22, y + 6); LineTo(h_dc_mem_cells, x + 21, y + 6);
	}
	else if (opt == 14) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 11, y + 24, NULL); LineTo(h_dc_mem_cells, x + 29, y + 24); // opt=14 => Dessine un toit de maison en bas.
		LineTo(h_dc_mem_cells, x + 29, y + 36);        LineTo(h_dc_mem_cells, x + 11, y + 36); LineTo(h_dc_mem_cells, x + 11, y + 24);
		MoveToEx(h_dc_mem_cells, x + 11, y + 24, NULL); LineTo(h_dc_mem_cells, x + 17, y + 30); LineTo(h_dc_mem_cells, x + 11, y + 36);
		MoveToEx(h_dc_mem_cells, x + 29, y + 24, NULL); LineTo(h_dc_mem_cells, x + 23, y + 30); LineTo(h_dc_mem_cells, x + 29, y + 36);
		MoveToEx(h_dc_mem_cells, x + 17, y + 30, NULL); LineTo(h_dc_mem_cells, x + 23, y + 30);
		MoveToEx(h_dc_mem_cells, x + 21, y + 32, NULL); LineTo(h_dc_mem_cells, x + 21, y + 33); // Cheminée
		LineTo(h_dc_mem_cells, x + 22, y + 33);         LineTo(h_dc_mem_cells, x + 22, y + 32); LineTo(h_dc_mem_cells, x + 21, y + 32);
	}
	else if (opt == 15) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 3, y + 11, NULL); LineTo(h_dc_mem_cells, x + 3, y + 29); // opt=15 => Dessine un toit de maison à gauche.
		LineTo(h_dc_mem_cells, x + 15, y + 29);       LineTo(h_dc_mem_cells, x + 15, y + 11); LineTo(h_dc_mem_cells, x + 3, y + 11);
		MoveToEx(h_dc_mem_cells, x + 3, y + 11, NULL); LineTo(h_dc_mem_cells, x + 9, y + 17); LineTo(h_dc_mem_cells, x + 15, y + 11);
		MoveToEx(h_dc_mem_cells, x + 3, y + 29, NULL); LineTo(h_dc_mem_cells, x + 9, y + 23); LineTo(h_dc_mem_cells, x + 15, y + 29);
		MoveToEx(h_dc_mem_cells, x + 9, y + 17, NULL); LineTo(h_dc_mem_cells, x + 9, y + 23);
		MoveToEx(h_dc_mem_cells, x + 6, y + 21, NULL); LineTo(h_dc_mem_cells, x + 7, y + 21); // Cheminée
		LineTo(h_dc_mem_cells, x + 7, y + 22);         LineTo(h_dc_mem_cells, x + 6, y + 22); LineTo(h_dc_mem_cells, x + 6, y + 21);
	}
	else if (opt == 16) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 24, y + 11, NULL); LineTo(h_dc_mem_cells, x + 24, y + 29); // opt=16 => Dessine un toit de maison à droite.
		LineTo(h_dc_mem_cells, x + 36, y + 29);        LineTo(h_dc_mem_cells, x + 36, y + 11); LineTo(h_dc_mem_cells, x + 24, y + 11);
		MoveToEx(h_dc_mem_cells, x + 24, y + 11, NULL); LineTo(h_dc_mem_cells, x + 30, y + 17);  LineTo(h_dc_mem_cells, x + 36, y + 11);
		MoveToEx(h_dc_mem_cells, x + 24, y + 29, NULL); LineTo(h_dc_mem_cells, x + 30, y + 23);  LineTo(h_dc_mem_cells, x + 36, y + 29);
		MoveToEx(h_dc_mem_cells, x + 30, y + 17, NULL); LineTo(h_dc_mem_cells, x + 30, y + 23);
		MoveToEx(h_dc_mem_cells, x + 32, y + 21, NULL); LineTo(h_dc_mem_cells, x + 33, y + 21); // Cheminée
		LineTo(h_dc_mem_cells, x + 33, y + 22);         LineTo(h_dc_mem_cells, x + 32, y + 22);  LineTo(h_dc_mem_cells, x + 32, y + 21);
	}
	else if (opt == 17) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 4, y + 3, NULL);  LineTo(h_dc_mem_cells, x + 36, y + 3); // opt=17 => Dessine un toit de bâtiment en haut.
		LineTo(h_dc_mem_cells, x + 36, y + 15);       LineTo(h_dc_mem_cells, x + 4, y + 15);  LineTo(h_dc_mem_cells, x + 4, y + 3);
		MoveToEx(h_dc_mem_cells, x + 4, y + 3, NULL);  LineTo(h_dc_mem_cells, x + 10, y + 9);   LineTo(h_dc_mem_cells, x + 4, y + 15);
		MoveToEx(h_dc_mem_cells, x + 36, y + 3, NULL); LineTo(h_dc_mem_cells, x + 30, y + 9);   LineTo(h_dc_mem_cells, x + 36, y + 15);
		MoveToEx(h_dc_mem_cells, x + 10, y + 9, NULL); LineTo(h_dc_mem_cells, x + 30, y + 9);
		MoveToEx(h_dc_mem_cells, x + 26, y + 6, NULL); LineTo(h_dc_mem_cells, x + 26, y + 7); // Cheminée
		LineTo(h_dc_mem_cells, x + 27, y + 7);         LineTo(h_dc_mem_cells, x + 27, y + 6);   LineTo(h_dc_mem_cells, x + 26, y + 6);
	}
	else if (opt == 18) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 4, y + 24, NULL);  LineTo(h_dc_mem_cells, x + 36, y + 24); // opt=18 => Dessine un toit de bâtiment en bas.
		LineTo(h_dc_mem_cells, x + 36, y + 36);        LineTo(h_dc_mem_cells, x + 4, y + 36);  LineTo(h_dc_mem_cells, x + 4, y + 24);
		MoveToEx(h_dc_mem_cells, x + 4, y + 24, NULL);  LineTo(h_dc_mem_cells, x + 10, y + 30);  LineTo(h_dc_mem_cells, x + 4, y + 36);
		MoveToEx(h_dc_mem_cells, x + 36, y + 24, NULL); LineTo(h_dc_mem_cells, x + 30, y + 30);  LineTo(h_dc_mem_cells, x + 36, y + 36);
		MoveToEx(h_dc_mem_cells, x + 10, y + 30, NULL); LineTo(h_dc_mem_cells, x + 30, y + 30);
		MoveToEx(h_dc_mem_cells, x + 26, y + 32, NULL); LineTo(h_dc_mem_cells, x + 26, y + 33); // Cheminée
		LineTo(h_dc_mem_cells, x + 27, y + 33);         LineTo(h_dc_mem_cells, x + 27, y + 32);  LineTo(h_dc_mem_cells, x + 26, y + 32);
	}
	else if (opt == 19) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 3, y + 4, NULL);  LineTo(h_dc_mem_cells, x + 3, y + 36); // opt=19 => Dessine un toit de bâtiment à gauche.
		LineTo(h_dc_mem_cells, x + 15, y + 36);       LineTo(h_dc_mem_cells, x + 15, y + 4);  LineTo(h_dc_mem_cells, x + 3, y + 4);
		MoveToEx(h_dc_mem_cells, x + 3, y + 4, NULL);  LineTo(h_dc_mem_cells, x + 9, y + 10);   LineTo(h_dc_mem_cells, x + 15, y + 4);
		MoveToEx(h_dc_mem_cells, x + 3, y + 36, NULL); LineTo(h_dc_mem_cells, x + 9, y + 30);   LineTo(h_dc_mem_cells, x + 15, y + 36);
		MoveToEx(h_dc_mem_cells, x + 9, y + 10, NULL); LineTo(h_dc_mem_cells, x + 9, y + 30);
		MoveToEx(h_dc_mem_cells, x + 6, y + 26, NULL); LineTo(h_dc_mem_cells, x + 7, y + 26); // Cheminée
		LineTo(h_dc_mem_cells, x + 7, y + 27);         LineTo(h_dc_mem_cells, x + 6, y + 27);   LineTo(h_dc_mem_cells, x + 6, y + 26);
	}
	else if (opt == 20) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 24, y + 4, NULL);  LineTo(h_dc_mem_cells, x + 24, y + 36); // opt=20 => Dessine un toit de bâtiment à droite.
		LineTo(h_dc_mem_cells, x + 36, y + 36);        LineTo(h_dc_mem_cells, x + 36, y + 4);  LineTo(h_dc_mem_cells, x + 24, y + 4);
		MoveToEx(h_dc_mem_cells, x + 24, y + 4, NULL);  LineTo(h_dc_mem_cells, x + 30, y + 10);  LineTo(h_dc_mem_cells, x + 36, y + 4);
		MoveToEx(h_dc_mem_cells, x + 24, y + 36, NULL); LineTo(h_dc_mem_cells, x + 30, y + 30);  LineTo(h_dc_mem_cells, x + 36, y + 36);
		MoveToEx(h_dc_mem_cells, x + 30, y + 10, NULL); LineTo(h_dc_mem_cells, x + 30, y + 30);
		MoveToEx(h_dc_mem_cells, x + 32, y + 26, NULL); LineTo(h_dc_mem_cells, x + 33, y + 26); // Cheminée
		LineTo(h_dc_mem_cells, x + 33, y + 27);         LineTo(h_dc_mem_cells, x + 32, y + 27);  LineTo(h_dc_mem_cells, x + 32, y + 26);
	}

	else if (opt == 21) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 14, y + 8, NULL); LineTo(h_dc_mem_cells, x + 14, y + 17); // opt=21 => Dessine une maison.
		LineTo(h_dc_mem_cells, x + 25, y + 17); LineTo(h_dc_mem_cells, x + 25, y + 8); LineTo(h_dc_mem_cells, x + 14, y + 8);
		MoveToEx(h_dc_mem_cells, x + 13, y + 9, NULL);  LineTo(h_dc_mem_cells, x + 19, y + 3); LineTo(h_dc_mem_cells, x + 20, y + 3); LineTo(h_dc_mem_cells, x + 27, y + 10);
	}

	else if (opt == 22) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 10, y + 8, NULL); LineTo(h_dc_mem_cells, x + 10, y + 17); // opt=22 => Dessine un batiment.
		LineTo(h_dc_mem_cells, x + 29, y + 17); LineTo(h_dc_mem_cells, x + 29, y + 8); LineTo(h_dc_mem_cells, x + 10, y + 8);
		MoveToEx(h_dc_mem_cells, x + 9, y + 9, NULL);  LineTo(h_dc_mem_cells, x + 14, y + 4); LineTo(h_dc_mem_cells, x + 25, y + 4); LineTo(h_dc_mem_cells, x + 31, y + 10);
	}
	else if (opt == 23 || opt == 24) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 10, y + 13, NULL); LineTo(h_dc_mem_cells, x + 10, y + 15); // opt=23 => Dessine une loco électrique. opt24 => Idem avec abris.
		LineTo(h_dc_mem_cells, x + 29, y + 15); LineTo(h_dc_mem_cells, x + 29, y + 12); // Caisse haut.
		MoveToEx(h_dc_mem_cells, x + 10, y + 11, NULL); LineTo(h_dc_mem_cells, x + 10, y + 10); // Caisse bas.
		LineTo(h_dc_mem_cells, x + 29, y + 10); LineTo(h_dc_mem_cells, x + 29, y + 12);
		MoveToEx(h_dc_mem_cells, x + 13, y + 9, NULL); LineTo(h_dc_mem_cells, x + 15, y + 9); // Pantographes.
		MoveToEx(h_dc_mem_cells, x + 25, y + 9, NULL); LineTo(h_dc_mem_cells, x + 27, y + 9);
		MoveToEx(h_dc_mem_cells, x + 11, y + 12, NULL); LineTo(h_dc_mem_cells, x + 13, y + 12); // Fenêtres.
		MoveToEx(h_dc_mem_cells, x + 27, y + 12, NULL); LineTo(h_dc_mem_cells, x + 29, y + 12);
		MoveToEx(h_dc_mem_cells, x + 11, y + 16, NULL); LineTo(h_dc_mem_cells, x + 12, y + 17); // Roues gauche.
		LineTo(h_dc_mem_cells, x + 13, y + 17); LineTo(h_dc_mem_cells, x + 14, y + 16); LineTo(h_dc_mem_cells, x + 15, y + 17);
		LineTo(h_dc_mem_cells, x + 16, y + 17); LineTo(h_dc_mem_cells, x + 18, y + 15);
		MoveToEx(h_dc_mem_cells, x + 22, y + 16, NULL); LineTo(h_dc_mem_cells, x + 23, y + 17); // Roues droite
		LineTo(h_dc_mem_cells, x + 24, y + 17); LineTo(h_dc_mem_cells, x + 25, y + 16); LineTo(h_dc_mem_cells, x + 26, y + 17);
		LineTo(h_dc_mem_cells, x + 27, y + 17); LineTo(h_dc_mem_cells, x + 29, y + 15);
		if (opt == 24) {
			MoveToEx(h_dc_mem_cells, x + 11, y + 5, NULL); LineTo(h_dc_mem_cells, x + 33, y + 5); LineTo(h_dc_mem_cells, x + 33, y + 18); // opt=24 => Dessine un abris.
		}
	}
	else if (opt == 25 || opt == 26) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		MoveToEx(h_dc_mem_cells, x + 23, y + 11, NULL); LineTo(h_dc_mem_cells, x + 11, y + 11); // opt=25 => Dessine une loco vapeur. opt26 => Idem avec abris.
		LineTo(h_dc_mem_cells, x + 11, y + 15); LineTo(h_dc_mem_cells, x + 29, y + 15); LineTo(h_dc_mem_cells, x + 29, y + 8);
		MoveToEx(h_dc_mem_cells, x + 30, y + 8, NULL); LineTo(h_dc_mem_cells, x + 21, y + 8); // 
		MoveToEx(h_dc_mem_cells, x + 23, y + 9, NULL); LineTo(h_dc_mem_cells, x + 23, y + 15); //
		MoveToEx(h_dc_mem_cells, x + 26, y + 10, NULL); LineTo(h_dc_mem_cells, x + 26, y + 13); // Fenêtre.
		MoveToEx(h_dc_mem_cells, x + 14, y + 10, NULL); LineTo(h_dc_mem_cells, x + 14, y + 8); // Cheminée.
		LineTo(h_dc_mem_cells, x + 16, y + 8); LineTo(h_dc_mem_cells, x + 16, y + 11);
		MoveToEx(h_dc_mem_cells, x + 12, y + 16, NULL); LineTo(h_dc_mem_cells, x + 13, y + 17); // Roues gauche.
		LineTo(h_dc_mem_cells, x + 14, y + 17); LineTo(h_dc_mem_cells, x + 15, y + 16); LineTo(h_dc_mem_cells, x + 16, y + 17);
		MoveToEx(h_dc_mem_cells, x + 18, y + 16, NULL); LineTo(h_dc_mem_cells, x + 19, y + 17); // Roues milieu.
		LineTo(h_dc_mem_cells, x + 20, y + 17); LineTo(h_dc_mem_cells, x + 21, y + 16); LineTo(h_dc_mem_cells, x + 22, y + 17);
		MoveToEx(h_dc_mem_cells, x + 24, y + 16, NULL); LineTo(h_dc_mem_cells, x + 25, y + 17); // Roues droite.
		LineTo(h_dc_mem_cells, x + 26, y + 17); LineTo(h_dc_mem_cells, x + 27, y + 16); LineTo(h_dc_mem_cells, x + 28, y + 17);
		if (opt == 26) {
			MoveToEx(h_dc_mem_cells, x + 11, y + 5, NULL); LineTo(h_dc_mem_cells, x + 33, y + 5); LineTo(h_dc_mem_cells, x + 33, y + 18); // opt=26 => Dessine un abris.
		}
	}
	else if (opt == 27) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		cadre_relief(x + 5, y + 5, x + 35, y + 9, -1, c1); // opt=27 => Dessine un petit rectangle de couleur c1.
	}
	else if (opt == 28) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		cadre_relief(x + 5, y + 5, x + 35, y + 20, -1, c1); // opt=28 => Dessine un grand rectangle de couleur c1.
	}
	else if (opt == 29) {
		bmp_select_pen(BMP_CST_COLOR_GRIS64);
		if (c1 != -1) {
			bmp_select_pen(c1);
			cadre_relief(x + 3, y + 3, x + 37, y + 18, -1, c1);  // opt=29 => Dessine un très grand rectangle de couleur=c1, sans bordures=-1, sur la moitié haute du bouton.
		}
		if (c2 != -1) {
			bmp_select_pen(c2);
			cadre_relief(x + 3, y + 19, x + 37, y + 37, -1, c2); // opt=29 => Dessine un très grand rectangle de couleur=c2, sans bordures=-1, sur la moitié basse du bouton.
		}
		if (c3 != -1) {
			bmp_select_pen(c3);
			cadre_relief(x + 3, y + 3, x + 19, y + 37, -1, c3);  // opt=29 => Dessine un très grand rectangle de couleur=c1, sans bordures=-1, sur la moitié gauche du bouton.
		}
		if (c4 != -1) {
			bmp_select_pen(c4);
			cadre_relief(x + 19, y + 3, x + 37, y + 37, -1, c4); // opt=29 => Dessine un très grand rectangle de couleur=c2, sans bordures=-1, sur la moitié droite du bouton.
		}
	}
	return;
}