Page 1 sur 1

Mon tout petit programme mais le 1er

Publié : jeu. 24/déc./2009 13:05
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.

Re: Mon tout petit programme mais le 1er

Publié : jeu. 24/déc./2009 14:25
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:






@++

Re: Mon tout petit programme mais le 1er

Publié : jeu. 24/déc./2009 14:27
par TazNormand
L'utilisation des commandes console est inutile, ça marche aussi sans !!!

Re: Mon tout petit programme mais le 1er

Publié : jeu. 24/déc./2009 18:43
par venom
oui comme j'ai fait :)





@++

Re: Mon tout petit programme mais le 1er

Publié : lun. 28/déc./2009 9:25
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.

Re: Mon tout petit programme mais le 1er

Publié : lun. 28/déc./2009 15:26
par Ar-S
de modifier quoi ? la console ?

Re: Mon tout petit programme mais le 1er

Publié : lun. 28/déc./2009 18:31
par venom
Ar-S a écrit :de modifier quoi ? la console ?
non modifier l'ip depuis purebasic me semble t'il







@++

Re: Mon tout petit programme mais le 1er

Publié : mar. 29/déc./2009 1:46
par Ar-S
alors MakeIPAddress(Champ0, Champ1, Champ2, Champ3) devrait faire l'affaire.

Re: Mon tout petit programme mais le 1er

Publié : mar. 29/déc./2009 8:56
par guismoman33
Oui changer l'ip...