PureBasic

Forums PureBasic
Nous sommes le Mer 19/Juin/2019 12:05

Heures au format UTC + 1 heure




Poster un nouveau sujet Répondre au sujet  [ 1 message ] 
Auteur Message
 Sujet du message: Départements et régions françaises JSON avec redim auto
MessagePosté: Dim 26/Fév/2017 8:15 
Hors ligne
Avatar de l’utilisateur

Inscription: Dim 02/Oct/2011 16:17
Messages: 2135
Localisation: 50200 Coutances
Bonjour à tous, pour m'expérimenter à faire des fenêtres qui se redimensionnent selon le contenu, j'ai donc fait ce programme ludique pour mes petits enfants et je le poste au cas où ça pourrait intéresser quelqu'un.

Régions et départements Français.JSON
Code:
[
{"Departement": "Ain", "Region": "Auvergne-Rhône-Alpes", "Prefecture": "Bourg-en-Bresse", "Numero": "01", "SousPrefecture": ["Belley", "Gex", "Nantua", "", "", ""]},
{"Departement": "Aisne", "Region": "Hauts-de-France", "Prefecture": "Laon", "Numero": "02", "SousPrefecture": ["Château-Thierry", "Saint-Quentin", "Soissons", "Vervins", "", ""]},
{"Departement": "Allier", "Region": "Auvergne-Rhône-Alpes", "Prefecture": "Moulins", "Numero": "03", "SousPrefecture": ["Montluçon", "Vichy", "", "", "", ""]},
{"Departement": "Alpes-de-Haute-Provence", "Region": "Provence-Alpes-Côte d'Azur", "Prefecture": "Digne-les-Bains", "Numero": "04", "SousPrefecture": ["Barcelonnette", "Castellane", "Forcalquier", "", "", ""]},
{"Departement": "Hautes-Alpes", "Region": "Provence-Alpes-Côte d'Azur", "Prefecture": "Gap", "Numero": "05", "SousPrefecture": ["Briançoon", "", "", "", "", ""]},
{"Departement": "Alpes-Maritimes", "Region": "Provence-Alpes-Côte d'Azur", "Prefecture": "Nice", "Numero": "06", "SousPrefecture": ["Grasse", "", "", "", "", ""]},
{"Departement": "Ardèche", "Region": "Auvergne-Rhône-Alpes", "Prefecture": "Privas", "Numero": "07", "SousPrefecture": ["Largentière", "Tournon-sur-Rhône", "", "", "", ""]},
{"Departement": "Ardennes", "Region": "Grand-Est", "Prefecture": "Charleville-Mèzières", "Numero": "08", "SousPrefecture": ["Rethel", "Sedan", "Vouziers", "", "", ""]},
{"Departement": "Ariège", "Region": "Occitanie", "Prefecture": "Foix", "Numero": "09", "SousPrefecture": ["Pamiers", "Saint-Girons", "", "", "", ""]},
{"Departement": "Aube", "Region": "Grand-Est", "Prefecture": "Troyes", "Numero": "10", "SousPrefecture": ["Bar-sur-Aube", "Nogent-sur-Seine", "", "", "", ""]},
{"Departement": "Aude", "Region": "Occitanie", "Prefecture": "Carcassonne", "Numero": "11", "SousPrefecture": ["Limoux", "Narbonne", "", "", "", ""]},
{"Departement": "Aveyron", "Region": "Occitanie", "Prefecture": "Rodez", "Numero": "12", "SousPrefecture": ["Millau", "Villefranche-de-Rouergue", "", "", "", ""]},
{"Departement": "Bouches-du-Rhône", "Region": "Provence-Alpes-Côte d'Azur", "Prefecture": "Marseille", "Numero": "13", "SousPrefecture": ["Aix-en-Provence", "Arles", "Istres", "", "", ""]},
{"Departement": "Calvados", "Region": "Normandie", "Prefecture": "Caen", "Numero": "14", "SousPrefecture": ["Bayeux", "Lisieux", "Vire", "", "", ""]},
{"Departement": "Cantal", "Region": "Auvergne-Rhône-Alpes", "Prefecture": "Aurillac", "Numero": "15", "SousPrefecture": ["Mauriac", "Saint-Flour", "", "", "", ""]},
{"Departement": "Charente", "Region": "Nouvelle Aquitaine", "Prefecture": "Angoulême", "Numero": "16", "SousPrefecture": ["Cognac", "Confolens", "", "", "", ""]},
{"Departement": "Charente-Maritime", "Region": "Nouvelle Aquitaine", "Prefecture": "La Rochelle", "Numero": "17", "SousPrefecture": ["Jonzac", "Rochefort", "Saint-Jean-d'Angély", "Saintes", "", ""]},
{"Departement": "Cher", "Region": "Centre-Val de Loire", "Prefecture": "Bourges", "Numero": "18", "SousPrefecture": ["Saint-Amand-Montrond", "Vierzon", "", "", "", ""]},
{"Departement": "Corrèze", "Region": "Nouvelle Aquitaine", "Prefecture": "Tulle", "Numero": "19", "SousPrefecture": ["Brive-la-Gaillarde", "Ussel", "", "", "", ""]},
{"Departement": "Corse-du-Sud", "Region": "Corse", "Prefecture": "Ajaccio", "Numero": "2A", "SousPrefecture": ["Sartène", "", "", "", "", ""]},
{"Departement": "Haute-Corse", "Region": "Corse", "Prefecture": "Bastia", "Numero": "2B", "SousPrefecture": ["Calvi", "Corte", "", "", "", ""]},
{"Departement": "Côte-d'Or", "Region": "Bourgogne-Franche-Comté", "Prefecture": "Dijon", "Numero": "21", "SousPrefecture": ["Beaune", "Montbard", "", "", "", ""]},
{"Departement": "Côtes-d'Armor", "Region": "Bretagne", "Prefecture": "Saint-Brieuc", "Numero": "22", "SousPrefecture": ["Dinan", "Guingamp", "Lannion", "", "", ""]},
{"Departement": "Creuse", "Region": "Nouvelle Aquitaine", "Prefecture": "Guéret", "Numero": "23", "SousPrefecture": ["Aubusson", "", "", "", "", ""]},
{"Departement": "Dordogne", "Region": "Nouvelle Aquitaine", "Prefecture": "Périgueux", "Numero": "24", "SousPrefecture": ["Bergerac", "Nontron", "Sarlat-la-Canéda", "", "", ""]},
{"Departement": "Doubs", "Region": "Bourgogne-Franche-Comté", "Prefecture": "Besançon", "Numero": "25", "SousPrefecture": ["Montbéliard", "Pontarlier", "", "", "", ""]},
{"Departement": "Drôme", "Region": "Auvergne-Rhône-Alpes", "Prefecture": "Valence", "Numero": "26", "SousPrefecture": ["Die", "Nyons", "", "", "", ""]},
{"Departement": "Eure", "Region": "Normandie", "Prefecture": "Evreux", "Numero": "27", "SousPrefecture": ["Les Andelys", "Bernay", "", "", "", ""]},
{"Departement": "Eure-et-Loir", "Region": "Centre-Val de Loire", "Prefecture": "Chartres", "Numero": "28", "SousPrefecture": ["Châteaudun", "Dreux", "Nogent-le-Rotrou", "", "", ""]},
{"Departement": "Finistère", "Region": "Bretagne", "Prefecture": "Quimper", "Numero": "29", "SousPrefecture": ["Brest", "Châteaulin", "Morlaix", "", "", ""]},
{"Departement": "Gard", "Region": "Occitanie", "Prefecture": "Nîmes", "Numero": "30", "SousPrefecture": ["Alès", "Le Vigan", "", "", "", ""]},
{"Departement": "Haute-Garonne", "Region": "Occitanie", "Prefecture": "Toulouse", "Numero": "31", "SousPrefecture": ["Muret", "Saint-Gaudens", "", "", "", ""]},
{"Departement": "Gers", "Region": "Occitanie", "Prefecture": "Auch", "Numero": "32", "SousPrefecture": ["Condom", "Mirande", "", "", "", ""]},
{"Departement": "Gironde", "Region": "Nouvelle Aquitaine", "Prefecture": "Bordeaux", "Numero": "33", "SousPrefecture": ["Arcachon", "Blaye", "Langon", "Lesparre-Médoc", "Libourne", ""]},
{"Departement": "Hérault", "Region": "Occitanie", "Prefecture": "Montpellier", "Numero": "34", "SousPrefecture": ["Béziers", "Lodève", "", "", "", ""]},
{"Departement": "Ille-et-Vilaine", "Region": "Bretagne", "Prefecture": "Rennes", "Numero": "35", "SousPrefecture": ["Fougères", "Redon", "Saint-Malo", "", "", ""]},
{"Departement": "Indre", "Region": "Centre-Val de Loire", "Prefecture": "Châteauroux", "Numero": "36", "SousPrefecture": ["Le Blanc", "La Châtre", "Issoudun", "", "", ""]},
{"Departement": "Indre-et-Loire", "Region": "Centre-Val de Loire", "Prefecture": "Tours", "Numero": "37", "SousPrefecture": ["Chinon", "Loches", "", "", "", ""]},
{"Departement": "Isère", "Region": "Auvergne-Rhône-Alpes", "Prefecture": "Grenoble", "Numero": "38", "SousPrefecture": ["La Tour-du-Pin", "Vienne", "", "", "", ""]},
{"Departement": "Jura", "Region": "Bourgogne-Franche-Comté", "Prefecture": "Lons-le-Saunier", "Numero": "39", "SousPrefecture": ["Dole", "Saint-Claude", "", "", "", ""]},
{"Departement": "Landes", "Region": "Nouvelle Aquitaine", "Prefecture": "Mont-de-Marsan", "Numero": "40", "SousPrefecture": ["Dax", "", "", "", "", ""]},
{"Departement": "Loir-et-Cher", "Region": "Centre-Val de Loire", "Prefecture": "Blois", "Numero": "41", "SousPrefecture": ["Romorantin-Lanthenay", "Vendôme", "", "", "", ""]},
{"Departement": "Loire", "Region": "Auvergne-Rhône-Alpes", "Prefecture": "Saint-Etienne", "Numero": "42", "SousPrefecture": ["Montbrison", "Roanne", "", "", "", ""]},
{"Departement": "Haute-Loire", "Region": "Auvergne-Rhône-Alpes", "Prefecture": "Le Puy-en-Velay", "Numero": "43", "SousPrefecture": ["Brioude", "Yssingeaux", "", "", "", ""]},
{"Departement": "Loire-Atlantique", "Region": "Pays de la Loire", "Prefecture": "Nantes", "Numero": "44", "SousPrefecture": ["Ancenis", "Châteaubriant", "Saint-Nazaire", "", "", ""]},
{"Departement": "Loiret", "Region": "Centre-Val de Loire", "Prefecture": "Orléans", "Numero": "45", "SousPrefecture": ["Montargis", "Pithiviers", "", "", "", ""]},
{"Departement": "Lot", "Region": "Occitanie", "Prefecture": "Cahors", "Numero": "46", "SousPrefecture": ["Figeac", "Gourdon", "", "", "", ""]},
{"Departement": "Lot-et-Garonne", "Region": "Nouvelle Aquitaine", "Prefecture": "Agen", "Numero": "47", "SousPrefecture": ["Marmande", "Nérac", "Villeneuve-sur-Lot", "", "", ""]},
{"Departement": "Lozère", "Region": "Occitanie", "Prefecture": "Mende", "Numero": "48", "SousPrefecture": ["Florac", "", "", "", "", ""]},
{"Departement": "Maine-et-Loire", "Region": "Pays de la Loire", "Prefecture": "Angers", "Numero": "49", "SousPrefecture": ["Cholet", "Saumur", "Segré", "", "", ""]},
{"Departement": "Manche", "Region": "Normandie", "Prefecture": "Saint-Lô", "Numero": "50", "SousPrefecture": ["Avranches", "Cherbourg", "Coutances", "", "", ""]},
{"Departement": "Marne", "Region": "Grand-Est", "Prefecture": "Châlons-en-Champagne", "Numero": "51", "SousPrefecture": ["Epernay", "Reims", "Sainte-Menehould", "Vitry-le-François", "", ""]},
{"Departement": "Haute-Marne", "Region": "Grand-Est", "Prefecture": "Chaumont", "Numero": "52", "SousPrefecture": ["Langres", "Saint-Dizier", "", "", "", ""]},
{"Departement": "Mayenne", "Region": "Pays de la Loire", "Prefecture": "Laval", "Numero": "53", "SousPrefecture": ["Château-Gontier", "Mayenne", "", "", "", ""]},
{"Departement": "Meurthe-et-Moselle", "Region": "Grand-Est", "Prefecture": "Nancy", "Numero": "54", "SousPrefecture": ["Briey", "Lunéville", "Toul", "", "", ""]},
{"Departement": "Meuse", "Region": "Grand-Est", "Prefecture": "Bar-le-Duc", "Numero": "55", "SousPrefecture": ["Commercy", "Verdun", "", "", "", ""]},
{"Departement": "Morbihan", "Region": "Bretagne", "Prefecture": "Vannes", "Numero": "56", "SousPrefecture": ["Lorient", "Pontivy", "", "", "", ""]},
{"Departement": "Moselle", "Region": "Grand-Est", "Prefecture": "Metz", "Numero": "57", "SousPrefecture": ["Forbach", "Sarrebourg", "Sarreguemines", "Thionville", "", ""]},
{"Departement": "Nièvre", "Region": "Bourgogne-Franche-Comté", "Prefecture": "Nevers", "Numero": "58", "SousPrefecture": ["Château-Chinon (Ville)", "Clamecy", "Cosne-Cours-sur-Loire", "", "", ""]},
{"Departement": "Nord", "Region": "Hauts-de-France", "Prefecture": "Lille", "Numero": "59", "SousPrefecture": ["Avesnes-sur-Helpe", "Cambrai", "Douai", "Dunkerque", "Valenciennes", ""]},
{"Departement": "Oise", "Region": "Hauts-de-France", "Prefecture": "Beauvais", "Numero": "60", "SousPrefecture": ["Clermont", "Compiègne", "Senlis", "", "", ""]},
{"Departement": "Orne", "Region": "Normandie", "Prefecture": "Alençon", "Numero": "61", "SousPrefecture": ["Argentan", "Mortagne-au-Perche", "", "", "", ""]},
{"Departement": "Pas-de-Calais", "Region": "Hauts-de-France", "Prefecture": "Arras", "Numero": "62", "SousPrefecture": ["Béthune", "Boulogne-sur-Mer", "Calais", "Lens", "Montreuil", "Saint-Omer"]},
{"Departement": "Puy-de-Dôme", "Region": "Auvergne-Rhône-Alpes", "Prefecture": "Clermont-Ferrand", "Numero": "63", "SousPrefecture": ["Ambert", "Issoire", "Riom", "Thiers", "", ""]},
{"Departement": "Pyrénées-Atlantiques", "Region": "Nouvelle Aquitaine", "Prefecture": "Pau", "Numero": "64", "SousPrefecture": ["Bayonne", "Oloron-Sainte-Marie", "", "", "", ""]},
{"Departement": "Hautes-Pyrénées", "Region": "Occitanie", "Prefecture": "Tarbes", "Numero": "65", "SousPrefecture": ["Argelès-Gazost", "Bagnières-de-Bigorre", "", "", "", ""]},
{"Departement": "Pyrénées-Orientales", "Region": "Occitanie", "Prefecture": "Perpignan", "Numero": "66", "SousPrefecture": ["Céret", "Prades", "", "", "", ""]},
{"Departement": "Bas-Rhin", "Region": "Grand-Est", "Prefecture": "Strasbourg", "Numero": "67", "SousPrefecture": ["Haguenau", "Molsheim", "Saverne", "Sélestat", "", ""]},
{"Departement": "Haut-Rhin", "Region": "Grand-Est", "Prefecture": "Colmar", "Numero": "68", "SousPrefecture": ["Altkirch", "Mulhouse", "Thann", "", "", ""]},
{"Departement": "Rhône", "Region": "Auvergne-Rhône-Alpes", "Prefecture": "Lyon", "Numero": "69", "SousPrefecture": ["Villefranche-sur-Saône", "", "", "", "", ""]},
{"Departement": "Haute-Saône", "Region": "Bourgogne-Franche-Comté", "Prefecture": "Vesoul", "Numero": "70", "SousPrefecture": ["Lure", "", "", "", "", ""]},
{"Departement": "Saône-et-Loire", "Region": "Bourgogne-Franche-Comté", "Prefecture": "Mâcon", "Numero": "71", "SousPrefecture": ["Autun", "Chalon-sur-Saône", "Charolles", "Louhans", "", ""]},
{"Departement": "Sarthe", "Region": "Pays de la Loire", "Prefecture": "Le Mans", "Numero": "72", "SousPrefecture": ["La Flèche", "Mamers", "", "", "", ""]},
{"Departement": "Savoie", "Region": "Auvergne-Rhône-Alpes", "Prefecture": "Chambéry", "Numero": "73", "SousPrefecture": ["Albertville", "Saint-Jean-de-Maurienne", "", "", "", ""]},
{"Departement": "Haute-Savoie", "Region": "Auvergne-Rhône-Alpes", "Prefecture": "Annecy", "Numero": "74", "SousPrefecture": ["Bonneville", "Saint-Julien-en-Genevois", "Thonon-les-Bains", "", "", ""]},
{"Departement": "Paris", "Region": "Île-de-France", "Prefecture": "Paris", "Numero": "75", "SousPrefecture": ["", "", "", "", "", ""]},
{"Departement": "Seine-Maritime", "Region": "Normandie", "Prefecture": "Rouen", "Numero": "76", "SousPrefecture": ["Dieppe", "Le Havre", "", "", "", ""]},
{"Departement": "Seine-et-Marne", "Region": "Île-de-France", "Prefecture": "Melun", "Numero": "77", "SousPrefecture": ["Fontainebleau", "Meaux", "Provins", "Torcy", "", ""]},
{"Departement": "Yvelines", "Region": "Île-de-France", "Prefecture": "Versailles", "Numero": "78", "SousPrefecture": ["Mantes-la-Jolie", "Rambouillet", "Saint-Germain-en-Laye", "", "", ""]},
{"Departement": "Deux-Sèvres", "Region": "Nouvelle Aquitaine", "Prefecture": "Niort", "Numero": "79", "SousPrefecture": ["Bressuire", "Parthenay", "", "", "", ""]},
{"Departement": "Somme", "Region": "Hauts-de-France", "Prefecture": "Amiens", "Numero": "80", "SousPrefecture": ["Abbeville", "Montdidier", "Péronne", "", "", ""]},
{"Departement": "Tarn", "Region": "Occitanie", "Prefecture": "Albi", "Numero": "81", "SousPrefecture": ["Castres", "", "", "", "", ""]},
{"Departement": "Tarn-et-Garonne", "Region": "Occitanie", "Prefecture": "Montauban", "Numero": "82", "SousPrefecture": ["Castelsarrasin", "", "", "", "", ""]},
{"Departement": "Var", "Region": "Provence-Alpes-Côte d'Azur", "Prefecture": "Toulon", "Numero": "83", "SousPrefecture": ["Brignoles", "Draguignan", "", "", "", ""]},
{"Departement": "Vaucluse", "Region": "Provence-Alpes-Côte d'Azur", "Prefecture": "Avignon", "Numero": "84", "SousPrefecture": ["Apt", "Carpentras", "", "", "", ""]},
{"Departement": "Vendée", "Region": "Pays de la Loire", "Prefecture": "La Roche-sur-Yon", "Numero": "85", "SousPrefecture": ["Fontenay-le-Comte", "Les Sables-d'Olonne", "", "", "", ""]},
{"Departement": "Vienne", "Region": "Nouvelle Aquitaine", "Prefecture": "Poitiers", "Numero": "86", "SousPrefecture": ["Châtellerault", "Montmorillon", "", "", "", ""]},
{"Departement": "Haute-Vienne", "Region": "Nouvelle Aquitaine", "Prefecture": "Limoges", "Numero": "87", "SousPrefecture": ["Bellac", "Rochechouart", "", "", "", ""]},
{"Departement": "Vosges", "Region": "Grand-Est", "Prefecture": "Epinal", "Numero": "88", "SousPrefecture": ["Neufchâteau", "Saint-Dié-des-Vosges", "", "", "", ""]},
{"Departement": "Yonne", "Region": "Bourgogne-Franche-Comté", "Prefecture": "Auxerre", "Numero": "89", "SousPrefecture": ["Avallon", "Sens", "", "", "", ""]},
{"Departement": "Territoire de Belfort", "Region": "Bourgogne-Franche-Comté", "Prefecture": "Belfort", "Numero": "90", "SousPrefecture": ["", "", "", "", "", ""]},
{"Departement": "Essonne", "Region": "Île-de-France", "Prefecture": "Évry", "Numero": "91", "SousPrefecture": ["Étampes", "Palaiseau", "", "", "", ""]},
{"Departement": "Hauts-de-Seine", "Region": "Île-de-France", "Prefecture": "Nanterre", "Numero": "92", "SousPrefecture": ["Antony", "Boulogne-Billancourt", "", "", "", ""]},
{"Departement": "Seine-Saint-Denis", "Region": "Île-de-France", "Prefecture": "Bobigny", "Numero": "93", "SousPrefecture": ["Le Raincy", "Saint-Denis", "", "", "", ""]},
{"Departement": "Val-de-Marne", "Region": "Île-de-France", "Prefecture": "Créteil", "Numero": "94", "SousPrefecture": ["L'Haÿ-les-Roses", "Nogent-sur-Marne", "", "", "", ""]},
{"Departement": "Val-d'Oise", "Region": "Val-d'Oise", "Prefecture": "Cergy, (chef-lieu à Pontoise)", "Numero": "95", "SousPrefecture": ["Argenteuil", "Pontoise", "Sarcelles", "", "", ""]},
{"Departement": "Guadeloupe", "Region": "Guadeloupe", "Prefecture": "Basse-Terre", "Numero": "971", "SousPrefecture": ["Pointe-à-Pitre", "", "", "", "", ""]},
{"Departement": "Martinique", "Region": "Martinique", "Prefecture": "Fort-de-France", "Numero": "972", "SousPrefecture": ["La Trinité", "Le Marin", "Saint-Pierre", "", "", ""]},
{"Departement": "Guyane", "Region": "Guyane", "Prefecture": "Cayenne", "Numero": "973", "SousPrefecture": ["Saint-Laurent-du-Maroni", "", "", "", "", ""]},
{"Departement": "La Réunion", "Region": "La Réunion", "Prefecture": "Saint-Denis", "Numero": "974", "SousPrefecture": ["Saint-Benoît", "Saint-Paul", "Saint-Pierre", "", "", ""]},
{"Departement": "Mayotte", "Region": "Mayotte ", "Prefecture": "Mamoudzou", "Numero": "976", "SousPrefecture": ["", "", "", "", "", ""]}
]


Departements et regions francaises JSON avec redimensionnement automatique.pb
Code:
;Departements et regions francaises JSON avec redimensionnement automatique

Enumeration Fenetres
  #Fenetre_principale
EndEnumeration

Enumeration Gadgets
  #Cnv_0
  #Cnv_1
  #Txt_Numero
  #Txt_Departement
  #Txt_Prefecture
  #Txt_SP_1
  #Txt_SP_2
  #Txt_SP_3
  #Txt_SP_4
  #Txt_SP_5
  #Txt_SP_6
  #Txt_Region
  #Str_Numero
  #Str_Departement
  #Str_Prefecture
  #Str_SP_1
  #Str_SP_2
  #Str_SP_3
  #Str_SP_4
  #Str_SP_5
  #Str_SP_6
  #Str_Region
EndEnumeration

Enumeration Fichier
  #FichierJson
EndEnumeration

Structure Departement
  Numero.s
  Departement.s
  Prefecture.s
  SousPrefecture.s[6]
  Region.s
EndStructure

Global Dim Etat.Departement(100), Dim monTableau.s(0)
Global.s NomFichier = "D:\Programmation\Donnees\Regions et departements francais.Json", i$
Global Evenement, i

Procedure CentrerTitreFenetre(TitreFenetre.s, NumeroFenetre) ; permet de centre le titre de la fenêtre
  Protected NCM.NonClientMetrics, ValeurRetournee, DcSauve, AncObjet
  Protected hFonteConsole, HdcCourant, TailleTs.SIZE
  Protected Espace_a_remplir, RectFenetre.Rect, NbrEspaceDemandes
 
  NCM\cbSize = SizeOf(NCM)
  ValeurRetournee = SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, 0, @NCM, 0)
  hFonteConsole = CreateFontIndirect_(@NCM\lfCaptionFont)
  If hFonteConsole <> 0
    HdcCourant = GetDC_(WindowID(NumeroFenetre))
    DcSauve = SaveDC_(HdcCourant)
    AncObjet = SelectObject_(HdcCourant, hFonteConsole)
    ValeurRetournee = GetWindowRect_(WindowID(NumeroFenetre), @RectFenetre)
    ValeurRetournee = GetTextExtentPoint32_(HdcCourant, @TitreFenetre, Len(TitreFenetre), @TailleTs)
    Espace_a_remplir = RectFenetre\right - RectFenetre\left - 1 * NCM\iCaptionWidth - TailleTs\cx
    ValeurRetournee = GetTextExtentPoint32_(HdcCourant, " ", 1, @TailleTs)
    NbrEspaceDemandes = (Espace_a_remplir / TailleTs\cx)/2
    If NbrEspaceDemandes > 0
      TitreFenetre = Space(NbrEspaceDemandes) + TitreFenetre
    EndIf   
  EndIf
  ValeurRetournee = SetWindowText_(WindowID(NumeroFenetre), TitreFenetre)
  ValeurRetournee = RestoreDC_(HdcCourant, DcSauve) ; mettre en ordre
  ValeurRetournee = DeleteObject_(hFonteConsole)
  ReleaseDC_(WindowID(NumeroFenetre), HdcCourant) 
EndProcedure

Procedure Lire_les_donnees()
  If ReadFile(#FichierJson, NomFichier)
    CloseFile(#FichierJson)
   
    ;Lire un fichier JSON (Analyser les données JSON à partir d'un fichier)
    LoadJSON(#FichierJson, NomFichier)
   
    ;Extraire les éléments dans le tableau spécifié
    ExtractJSONArray(JSONValue(#FichierJson), Etat())
  Else
    MessageRequester("ATTENTION","Impossible de charger le fichier")
  EndIf
EndProcedure

Procedure Ouvrir_Fenetre_principale()
  If OpenWindow(#Fenetre_principale, 0, 0, 510, 280, "Départements et régions françaises", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
    StickyWindow(#Fenetre_principale, 1)
    CanvasGadget(#Cnv_0, 0, 0, 510, 30, #PB_Canvas_Container)
    TextGadget(#Txt_Numero,         10,  12, 165, 20, "Numéro minéralogique:")
    StringGadget(#Str_Numero,      165,  10,  35, 20, "", #ES_CENTER)
    TextGadget(#Txt_Departement,   208,  12,  95, 20, "Département:")
    StringGadget(#Str_Departement, 300,  10, 200, 20, "", #PB_String_ReadOnly)
    CloseGadgetList()
   
    CanvasGadget(#Cnv_1, 0, 30, WindowWidth(#Fenetre_principale), WindowHeight(#Fenetre_principale), #PB_Canvas_Container)
    TextGadget(#Txt_Prefecture,     10,  12,  75, 20, "Préfecture:")
    StringGadget(#Str_Prefecture,   85,  10, 415, 20, "", #PB_String_ReadOnly)
    TextGadget(#Txt_SP_1,           10,  42, 125, 20, "Sous-Préfecture 1:")
    StringGadget(#Str_SP_1,        135,  40, 365, 20, "", #PB_String_ReadOnly)
    TextGadget(#Txt_SP_2,           10,  72, 125, 20, "Sous-Préfecture 2:")
    StringGadget(#Str_SP_2,        135,  70, 365, 20, "", #PB_String_ReadOnly)
    TextGadget(#Txt_SP_3,           10, 102,  125, 20, "Sous-Préfecture 3:")
    StringGadget(#Str_SP_3,        135, 100,  365, 20, "", #PB_String_ReadOnly)
    TextGadget(#Txt_SP_4,           10, 132, 125, 20, "Sous-Préfecture 4:")
    StringGadget(#Str_SP_4,        135, 130, 365, 20, "", #PB_String_ReadOnly)
    TextGadget(#Txt_SP_5,           10, 162, 125, 20, "Sous-Préfecture 5:")
    StringGadget(#Str_SP_5,        135, 160, 365, 20, "", #PB_String_ReadOnly)
    TextGadget(#Txt_SP_6,           10, 192, 125, 20, "Sous-Préfecture 6:")
    StringGadget(#Str_SP_6,        135, 190, 365, 20, "", #PB_String_ReadOnly)
    StringGadget(#Str_Region,       10, WindowHeight(#Fenetre_principale) - 60, 495, 20, "")
    CloseGadgetList()
    ; Polices Gadgets
    Police = LoadFont(#PB_Any, "DejaVu Sans", 10, #PB_Font_HighQuality)
    For i = #Txt_Numero To #Txt_Region
      SetGadgetFont(i, FontID(Police))
    Next i
    Police_Gras = LoadFont(#PB_Any, "DejaVu Sans", 10, #PB_Font_Bold)
    For i = #Str_Numero To #Str_Region
      SetGadgetFont(i, FontID(Police_Gras))
    Next i
    ;Cacher les gadgets
    For i = #Txt_SP_1 To #Txt_SP_6
      HideGadget(i, 1)
    Next i
    For i = #Str_SP_1 To #Str_SP_6
      HideGadget(i, 1)
    Next i
    SetActiveGadget(#Str_Numero)
    SetGadgetText(#Str_Numero, "50")
  EndIf
EndProcedure

Lire_les_donnees()
Ouvrir_Fenetre_principale()
CentrerTitreFenetre("Départements et régions françaises", #Fenetre_principale)

Procedure Vider() 
  SetGadgetText(#Str_Departement, "")
  SetGadgetText(#Str_Prefecture, "")
  SetGadgetText(#Str_SP_1, "")
  SetGadgetText(#Str_SP_2, "")
  SetGadgetText(#Str_SP_3, "")
  SetGadgetText(#Str_SP_4, "")
  SetGadgetText(#Str_SP_5, "")
  SetGadgetText(#Str_SP_6, "")
  SetGadgetText(#Str_Region, "")
EndProcedure

Procedure RemplirTableau(i)
  Z = 0
  If Etat(i)\Departement
      monTableau(Z) = Etat(i)\Departement
      Z + 1
      ReDim monTableau(Z)
      monTableau(Z) = "Région: " + Etat(i)\Region
      Z + 1
      ReDim monTableau(Z)
      monTableau(Z) = Etat(i)\Prefecture
      Z + 1
    If Etat(i)\SousPrefecture[0] <> ""
      ReDim monTableau(Z)
      monTableau(Z) = Etat(i)\SousPrefecture[0]
    EndIf
    If Etat(i)\SousPrefecture[1] <> ""
      Z + 1
      ReDim monTableau(Z)
      monTableau(Z) = Etat(i)\SousPrefecture[1]
    EndIf
    If Etat(i)\SousPrefecture[2] <> ""
      Z + 1
      ReDim monTableau(Z)
      monTableau(Z) = Etat(i)\SousPrefecture[2]
    EndIf
    If Etat(i)\SousPrefecture[3] <> ""
      Z + 1
      ReDim monTableau(Z)
      monTableau(Z) = Etat(i)\SousPrefecture[3]
    EndIf
    If Etat(i)\SousPrefecture[4] <> ""
      Z + 1
      ReDim monTableau(Z)
      monTableau(Z) = Etat(i)\SousPrefecture[4]
    EndIf
    If Etat(i)\SousPrefecture[5] <> ""
      Z + 1
      ReDim monTableau(Z)
      monTableau(Z) = Etat(i)\SousPrefecture[5]
    EndIf
  EndIf
EndProcedure

Procedure RemplirStringGadgets()
 
  If ArraySize(monTableau())  <= 0
    RemplirTableau(i)
  EndIf
 
  ResizeWindow(#Fenetre_principale, #PB_Ignore, #PB_Ignore, #PB_Ignore, ((ArraySize(monTableau()))*30)+40)
  ResizeGadget(#Cnv_1, 0, 30, WindowWidth(#Fenetre_principale), WindowHeight(#Fenetre_principale)+30)
  StringGadget(#Str_Region,      10, GadgetHeight(#Cnv_1) - 60, 490, 20, "")
 
  If ArraySize(monTableau()) > 1
    HideGadget(4, 0)
    HideGadget(14, 0)
    SetGadgetText(#Str_Prefecture, monTableau(2))
  Else
    HideGadget(4, 1)
    HideGadget(14, 1) 
  EndIf
 
  If ArraySize(monTableau()) > 2 
    SetGadgetText(#Str_SP_1, monTableau(3))
    HideGadget(5, 0)
    HideGadget(15, 0)
  Else
    HideGadget(5, 1)
    HideGadget(15, 1)
  EndIf
  If ArraySize(monTableau()) > 3
    HideGadget(6, 0)
    HideGadget(16, 0)
    SetGadgetText(#Str_SP_2, monTableau(4))
  Else
    HideGadget(6, 1)
    HideGadget(16, 1)
  EndIf 
  If ArraySize(monTableau()) > 4 
    HideGadget(7, 0)
    HideGadget(17, 0)
    SetGadgetText(#Str_SP_3, monTableau(5))
  Else
    HideGadget(7, 1)
    HideGadget(17, 1)         
  EndIf 
  If ArraySize(monTableau()) > 5 
    HideGadget(8, 0)
    HideGadget(18, 0)
    SetGadgetText(#Str_SP_4, monTableau(6))
  Else
    HideGadget(8, 1)
    HideGadget(18, 1) 
  EndIf 
  If ArraySize(monTableau()) > 6 
    HideGadget(9, 0)
    HideGadget(19, 0)
    SetGadgetText(#Str_SP_5, monTableau(7))
  Else
    HideGadget(9, 1)
    HideGadget(19, 1) 
  EndIf 
  If ArraySize(monTableau()) > 7 
    HideGadget(10, 0)
    HideGadget(20, 0)
    SetGadgetText(#Str_SP_6, monTableau(8))
  Else
    HideGadget(10, 1)
    HideGadget(20, 1) 
  EndIf
 
  SetGadgetText(#Str_Departement, monTableau(0))
  SetGadgetText(#Str_Region, monTableau(1))
EndProcedure

Procedure ChoisirNumero()
          If Len(GetGadgetText(#Str_Numero)) > 1
            i$ = GetGadgetText(#Str_Numero)
            Select i$
              Case "01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19"
                i = Val(GetGadgetText(#Str_Numero))-1
              Case "2a", "2A"
                i = 19
              Case "2b", "2B"
                i = 20
              Case "21","22","23","24","25","26","27","28","29",
                   "30","31","32","33","34","35","36","37","38","39",
                   "40","41","42","43","44","45","46","47","48","49",
                   "50","51","52","53","54","55","56","57","58","59",
                   "60","61","62","63","64","65","66","67","68","69",
                   "70","71","72","73","74","75","76","77","78","79",
                   "80","81","82","83","84","85","86","87","88","89",
                   "90","91","92","93","94","95"
                i = Val(GetGadgetText(#Str_Numero))
              Case "96","97","98", "99", "975"
                Vider()
              Case "971"
                i = 96
              Case "972"
                i= 97
              Case "973"
                i = 98
              Case "974"
                i = 99
              Case "976"
                i = 100
              Default
                Vider()
            EndSelect
          EndIf
EndProcedure

; Boucle événementielle
Repeat
  Evenement = WaitWindowEvent()
 
  Select Evenement
    Case #PB_Event_Gadget
     
      Select EventGadget()
        Case #Str_Numero
         
          Select EventType()
            Case #PB_EventType_Change
              Vider()
              For z = 0 To ArraySize(monTableau())
                monTableau(z) = ""
              Next z 
              FreeArray(monTableau())
              Dim monTableau(0)
          EndSelect
         
          ChoisirNumero()
         
          RemplirStringGadgets()
         
      EndSelect
     
    Case #PB_Event_CloseWindow
      Select EventWindow()
        Case #Fenetre_principale
          CloseWindow(#Fenetre_principale)
          Break
      EndSelect
  EndSelect
ForEver



Il est peut-être possible d'optimiser ce code.

_________________
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce GT 640 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.62, 5.70 LTS
Un homme doit être poli, mais il doit aussi être libre !


Haut
 Profil  
Répondre en citant le message  
Afficher les messages postés depuis:  Trier par  
Poster un nouveau sujet Répondre au sujet  [ 1 message ] 

Heures au format UTC + 1 heure


Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 1 invité


Vous ne pouvez pas poster de nouveaux sujets
Vous ne pouvez pas répondre aux sujets
Vous ne pouvez pas éditer vos messages
Vous ne pouvez pas supprimer vos messages

Rechercher:
Aller à:  

 


Powered by phpBB © 2008 phpBB Group | Traduction par: phpBB-fr.com
subSilver+ theme by Canver Software, sponsor Sanal Modifiye