Page 1 of 1

window locks

Posted: Mon Apr 05, 2004 8:25 pm
by BongMong

Code: Select all

Result = InitNetwork() 
If Result = 0 
MessageRequester("Error","No Connection Found",0) 
EndIf 

Enumeration
  #Window_0
EndEnumeration

Ip$ = "127.0.0.1" 

Enumeration
  #Listview_0
EndEnumeration

OpenWindow(#Window_0, 329, 114, 219, 178,  #PB_Window_SystemMenu | #PB_Window_TitleBar , "Scanner")
CreateGadgetList(WindowID())
ListViewGadget(#Listview_0, 5, 5, 210, 170)
For A=135 To 65536 
B = OpenNetworkConnection(Ip$,A)
If B
AddGadgetItem (#Listview_0,-1,"Item "+Str(A)+" of the Listview") 
EndIf 
Next 
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 
anybody help me?
the listview won't show, unless im disconnected

Posted: Mon Apr 05, 2004 8:32 pm
by Kris_a
While the program is trying to connect, no messages will reach the window telling it to redraw, so if anything changes you won't see until the for...next loop is broken. Try using a thread to get around this:

Code: Select all


Result = InitNetwork() 
If Result = 0 
   MessageRequester("Error","No Connection Found",0) 
EndIf 

Enumeration 
  #Window_0 
EndEnumeration 

Ip$ = "127.0.0.1" 

Enumeration 
  #Listview_0 
EndEnumeration 

Procedure Network()
   For A=135 To 65536 
      B = OpenNetworkConnection(Ip$,A) 
      If B 
         AddGadgetItem (#Listview_0,-1,"Item "+Str(A)+" of the Listview") 
      EndIf
   Next 
EndProcedure

OpenWindow(#Window_0, 329, 114, 219, 178,  #PB_Window_SystemMenu | #PB_Window_TitleBar , "Scanner") 
CreateGadgetList(WindowID())

ListViewGadget(#Listview_0, 5, 5, 210, 170) 

NetworkThread = CreateThread(@Network(),0)

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 
you could also do something like this, although I don't quite like it as much (I think that network systems should never share threads with the rest of a program)

Code: Select all

A = 135

Repeat
  event = WindowEvent()
  
  If event
    Select event
      Case #PB_Event_CloseWindow
        End
    EndSelect
  Else
      If A < 65536
        B = OpenNetworkConnection(Ip$,A) 
        If B 
           AddGadgetItem (#Listview_0,-1,"Port "+Str(A)+" open") 
        EndIf
        A = A + 1
      endif
  EndIf
forever

Posted: Mon Apr 05, 2004 8:56 pm
by Paul
Most people just force a refresh after adding an item...

AddGadgetItem (#Listview_0,-1,"Item "+Str(A)+" of the Listview")
While WindowEvent():Wend

Posted: Tue Apr 06, 2004 6:36 am
by BongMong
thanks for the help people
:> :) :>