Mon tout petit programme mais le 1er

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
guismoman33
Messages : 19
Inscription : jeu. 24/déc./2009 11:20

Mon tout petit programme mais le 1er

Message par guismoman33 »

Voila mon premier programme :

Code : Tout sélectionner

;
; ------------------------------------------------------------
;
;   PureBasic - Window example file
;
;    (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;

;
; Open a window, and do some stuff with it...
;

If OpenWindow(0, 100, 200, 195, 260, "Programme Vincent", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)

  ; This is the 'event loop'. All the user actions are processed here.
  ; It's very easy to understand: when an action occurs, the EventID
  ; isn't 0 and we just have to see what have happened...
ButtonGadget(1,10,10,50,50,"chercher")

  Repeat
    Event = WaitWindowEvent()

    If Event = #PB_Event_CloseWindow  ; If the user has pressed on the close button
      Quit = 1
    EndIf
 If Event = #PB_Event_Gadget  ; If the user has pressed on the button
      If EventGadget() = 1
        OpenConsole()
        InitNetwork()
        ExamineIPAddresses()
        Repeat
        ip=NextIPAddress() 
        If IPString(ip)<>"0.0.0.0"
        CloseConsole()
        TextGadget(2,70,2,100,50, IPString(ip) )
 
        EndIf
        Until ip=0
        
      EndIf
 EndIf

  Until Quit = 1
  
EndIf

End   ; All the opened windows are closed automatically by PureBasic

Il y a un petit soucis, appuyer deux fois sur chercher et regarder, une erreur apparaît comment rectifier cela?
Mais j'aimerai avancer. Je voudrais savoir comment mettre l'adresse ip dans une case et pas dans l'espace comme ça.

Et comment je pourrai modifier l'adresse IP?

Merci pour vos prochaine réponse et cordialement.
Avatar de l’utilisateur
venom
Messages : 3128
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: Mon tout petit programme mais le 1er

Message par venom »

Salut,

pour rectifier ton code voici la procedure :

Code : Tout sélectionner

;
InitNetwork()
If OpenWindow(0, 100, 200, 195, 260, "Programme Vincent", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)

	; This is the 'event loop'. All the user actions are processed here.
	; It's very easy to understand: when an action occurs, the EventID
	; isn't 0 and we just have to see what have happened...
ButtonGadget(1,10,10,50,50,"chercher")

	Repeat
		Event = WaitWindowEvent()

		If Event = #PB_Event_CloseWindow  ; If the user has pressed on the close button
			Quit = 1
		EndIf
If Event = #PB_Event_Gadget  ; If the user has pressed on the button
			If EventGadget() = 1
				OpenConsole()
				
				ExamineIPAddresses()
				Repeat
				ip=NextIPAddress() 
				If IPString(ip)<>"0.0.0.0"
				CloseConsole()
				TextGadget(2,70,2,100,50, IPString(ip) )

				EndIf
				Until ip=0
				
			EndIf
EndIf

	Until Quit = 1
	
EndIf

End   ; All the opened windows are closed automatically by PureBasic
ou cela pour afficher l'ip dans in endroit précis :

Code : Tout sélectionner

;- Window Constants
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
Enumeration
  #IPAddress_0
  #Button_0
EndEnumeration
InitNetwork()

  If OpenWindow(#Window_0, 216, 0, 150, 70, "",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
      StringGadget(#IPAddress_0, 10, 10, 125, 20, "")
      ButtonGadget(#Button_0, 10, 35, 125, 20, "Afficher l'ip")

  EndIf

  Repeat
   EventID = WaitWindowEvent()
    If EventID = #PB_Event_Gadget
      Select EventGadget()
        
       Case #Button_0
        ip=ExamineIPAddresses()
         ip=NextIPAddress()
          SetGadgetText(#IPAddress_0, IPString(ip))
           
        
      EndSelect
    EndIf
  Until EventID = #PB_Event_CloseWindow
pour ceux qui est de la modifier je n'est jamais fait mais sa doit être possible :wink:






@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Avatar de l’utilisateur
TazNormand
Messages : 1297
Inscription : ven. 27/oct./2006 12:19
Localisation : Calvados (14)

Re: Mon tout petit programme mais le 1er

Message par TazNormand »

L'utilisation des commandes console est inutile, ça marche aussi sans !!!
Image
Image
Avatar de l’utilisateur
venom
Messages : 3128
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: Mon tout petit programme mais le 1er

Message par venom »

oui comme j'ai fait :)





@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
guismoman33
Messages : 19
Inscription : jeu. 24/déc./2009 11:20

Re: Mon tout petit programme mais le 1er

Message par guismoman33 »

Déja un grand merci pour vos réponse. Je viens d'apprendre que l'ouverture de la console n'est pas obligatoire mais aussi que SetGadgetText() existait.
Par contre maintenant il faut que je trouve le moyen de la modifier. Ca va être plus dure.
Avatar de l’utilisateur
Ar-S
Messages : 9539
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: Mon tout petit programme mais le 1er

Message par Ar-S »

de modifier quoi ? la console ?
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Avatar de l’utilisateur
venom
Messages : 3128
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: Mon tout petit programme mais le 1er

Message par venom »

Ar-S a écrit :de modifier quoi ? la console ?
non modifier l'ip depuis purebasic me semble t'il







@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Avatar de l’utilisateur
Ar-S
Messages : 9539
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: Mon tout petit programme mais le 1er

Message par Ar-S »

alors MakeIPAddress(Champ0, Champ1, Champ2, Champ3) devrait faire l'affaire.
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
guismoman33
Messages : 19
Inscription : jeu. 24/déc./2009 11:20

Re: Mon tout petit programme mais le 1er

Message par guismoman33 »

Oui changer l'ip...
Répondre