Sign in to follow this  
Followers 0
CodyBarrett

Problem with TCP chat GUI

3 posts in this topic

ok well i forget what i did to make this happen... but what used to happen was it would have pictures, and when the user hit file>change picture it would show a opendialog box... then it would automaticaly reset the picture as the selected picture. NOW it doesnt automatically change, you have to resetartr the exe why is this?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#Include <Misc.au3> 
#Include <GuiEdit.au3>
#Include <Date.au3>
#Include <File.au3>

Global $Admin_Name, $Server, $Menu, $Load_Pic, $Exit, $PN, $S, $C_Name, $CPicture, $A_Name, $SPicture, $G_IP, $Status, $Disconnect, $In_Comming, $Out_Going, $Enter , $MainSocket, $Change_Name , $NG, $NI, $NE

If FileExists("C:\TCP\Server.ini")  then
Else
    DirCreate("C:\TCP\")
    IniWrite("C:\TCP\Server.ini","#On Load","SPicture","")
    IniWrite("C:\TCP\Server.ini","#On Load","CPicture","")
    IniWrite("C:\TCP\Server.ini","#Admin","Name","New User")
    
EndIf

$Admin_Name = IniRead("C:\TCP\Server.ini","#Admin","Name","")
$Client_Name = "None"
$Server = GUICreate("Server",580,400)

$Menu = GUICtrlCreateMenu ("File")
$Change_Name = GUICtrlCreateMenuItem("Change Display Name",$Menu)
$Load_Pic = GUICtrlCreateMenuItem("Load Picture",$Menu)
$Exit = GUICtrlCreateMenuItem("Exit",$Menu)
$S = TCPAccept( $MainSocket)

$C_Name = GUICtrlCreateLabel($Client_Name & " :" ,470,20,120,140)
$CPicture = GUICtrlCreatePic(IniRead("C:\TCP\Server.ini","#On Load","CPicture",""),470,40,100,100)

$A_Name = GUICtrlCreateLabel($Admin_Name & " :" ,470,160,120,20)
$SPicture = GUICtrlCreatePic(IniRead("C:\TCP\Server.ini","#On Load","SPicture",""),470,180,100,100)

$g_IP = GUICtrlCreateLabel(@IPAddress1,10,4,90,20)
$Disconnect = GUICtrlCreateButton("Disconnect",100,0,100,20)

$In_Comming = GUICtrlCreateEdit("",10,30,450,250 ,BitOR($ES_WANTRETURN, $WS_VSCROLL))
GUICtrlSetBkColor($In_Comming,0xfff000)
GUICtrlSetColor($In_Comming,0x000000)
$Out_Going = GUICtrlCreateEdit("",10,290,450,80, BitOR($ES_WANTRETURN, $WS_VSCROLL))
GUICtrlSetBkColor($Out_Going,0x000000)
GUICtrlSetColor($Out_Going,0xffffff)

$Enter = GUICtrlCreateButton("Enter",470,290,100,30) 
GUISetState()

        $NG = GUICreate("",200,20)
        $NI = GUICtrlCreateInput("",0,0,150,20)
        $NE = GUICtrlCreateButton("Enter",150,0,50,20)

TCPStartUp()
$ConnectedSocket = TCPAccept( $MainSocket)

While 1 
    $MainSocket = TCPListen($g_IP, 65432,  100 )
    TCPRecv( $MainSocket, 1000000)
    
    $msg = GUIGetMsg()
    FileDelete ( "C:\TCP\Serverlog.txt" )
    FileWriteLine("C:\TCP\Serverlog.txt", GUICtrlRead($In_Comming))
    
    If $msg = $gui_event_close Then
        Exit
    EndIf
    
    If $ConnectedSocket >= 0 Then
        GUICtrlSetBkColor($In_Comming,0x000000)
        GUICtrlSetColor($In_Comming,0xffffff)
    EndIf
    
    If $msg = $Disconnect Then
        TCPShutdown()
    EndIf
    
    If $msg = $Load_Pic Then
    $PN = FileOpenDialog("Load Piture","My Pictures","All (*.*)")
    GUICtrlDelete($SPicture)
    $SPicture = GUICtrlCreatePic($PN,470,180,100,100)
    IniWrite("C:\TCP\Server.ini","#On Load","SPicture",$PN)
    EndIf


    If $msg = $Change_Name Then
        GUISetState(@SW_SHOW,$NG)
        GUISetState(@SW_HIDE,$Server)
        
    EndIf
    If $msg = $NE Then
            GUICtrlSetData($A_Name,guictrlread($NI))
            IniWrite("C:\TCP\Server.ini","#Admin","Name",GUICtrlRead($NI))
            GUISetState(@SW_SHOW,$Server)
            GUISetState(@SW_HIDE,$NG)
        EndIf
        
    
    If $msg = $Exit Then
        Exit
    EndIf

    If $msg = $Enter Then
    TCPSend ($MainSocket,$Out_Going)
    _GUICtrlEdit_LineScroll ($In_Comming, 1, _GUICtrlEdit_GetLineCount ($In_Comming) - 1)
    GUICtrlSetData($In_Comming, FileRead("C:\TCP\Serverlog.txt") &  _NowTime() &": "& $Admin_Name & ": "& GUICtrlRead($Out_Going))
    GUICtrlSetData($Out_Going,"")
    GUICtrlSetState($Out_Going, $GUI_FOCUS)
    EndIf
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

After you create the control use:

GUICtrlSetState($SPicture,@SW_SHOW)

Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

same thing happens

EDIT

maybe could it be the second GUI i added for the change name?... ill try that and change the change name gui to an input and button that apears

EDIT#2

lol i fixed it.. now to start with the TCP stuff ill POST again in this section later if i gotts anymore questions :)

Edited by bob00037

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0