window locks

Just starting out? Need help? Post your questions and find answers here.
BongMong
User
User
Posts: 31
Joined: Sat Jan 03, 2004 6:50 pm

window locks

Post 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
1300 @ 1450mhz, DDR400, MX440, XP pro / 2000Pro
Kris_a
User
User
Posts: 92
Joined: Sun Feb 15, 2004 8:04 pm
Location: Manchester, UK

Post 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
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1252
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post 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
Image Image
BongMong
User
User
Posts: 31
Joined: Sat Jan 03, 2004 6:50 pm

Post by BongMong »

thanks for the help people
:> :) :>
1300 @ 1450mhz, DDR400, MX440, XP pro / 2000Pro
Post Reply