Jump to content

_GUICtrlEdit_Create font size


JayT
 Share

Recommended Posts

Hello, I am in desperate need to find out how to change the size and font for a chat like service. it is more of a one way notification service. like a "now serving # 2897" system. But using _GUICtrlEdit_Create the font is way to small and no one can see the message.

Link to comment
Share on other sites

tedesco,

And we are anxiously awaiting the code in question, or a reproducer.

In the mean time, check out guictrlsetfont() in the help file.

kylomas

edit: disregard, just looked at the udf for _guictrledit_create

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

here is the code. I dont see any text when I send a message. it is just a grey screen. It does make a .way sound so i know it is comunicating. and if I use the _GUICtrlEdit_Create it works.

#include <GUIConstantsEx.au3>

#include <GuiEdit.au3>

#include <GUIConstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()

Local $szIPADDRESS = @IPAddress1

Local $nPORT = 33891

Local $MainSocket, $Gui, $edit, $ConnectedSocket, $szIP_Accepted, $ConnectedSocket2

Local $msg, $recv, $btn, $input, $input2, $nic

Local $font

TCPStartup()

$MainSocket = TCPListen($szIPADDRESS, $nPORT)

If $MainSocket = -1 Then Exit

$font = "Comic Sans MS"

$Gui = GUICreate("Now Serving... [" & $szIPADDRESS & "]", 380, 123)

GUICtrlCreateLabel("Serving Ticket #:", 10, 5, 150, 15)

;$edit = _GUICtrlEdit_Create($Gui, "", 10, 25, 380, 80)

GUISetFont (60, 10, 1, $font)

$edit = GUICtrlCreateLabel("", 100, 15)

;GUICtrlSetFont(-1, 9, 400, -1, "Tahoma")

GUISetState()

$ConnectedSocket = -1

While 1

$msg = GUIGetMsg()

$ConnectedSocket = TCPAccept($MainSocket)

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

$recv = TCPRecv($ConnectedSocket, 2048)

If $recv <> "" Then

If _GUICtrlEdit_GetText ($edit) <> "" Then

_GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & @CRLF & $recv)

Else

_GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & $recv)

EndIf

If Not WinActive($Gui) Then WinFlash($Gui)

SoundPlay(@WindowsDir & "MediaDing.wav")

_GUICtrlEdit_LineScroll ($edit,_GUICtrlEdit_GetLineCount ($edit)+1,_GUICtrlEdit_GetLineCount ($edit)+1)

EndIf

WEnd

If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)

TCPShutdown()

Exit

EndFunc ;==>Example

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <FontConstants.au3>
#include <WinAPI.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $szIPADDRESS = @IPAddress1
    Local $nPORT = 33891
    Local $MainSocket, $Gui, $edit, $ConnectedSocket, $szIP_Accepted, $ConnectedSocket2
    Local $msg, $recv, $btn, $input, $input2, $nic
    Local $font, $hFont

    TCPStartup()
    $MainSocket = TCPListen($szIPADDRESS, $nPORT)

    If $MainSocket = -1 Then Exit
    $font = "Comic Sans MS"

    $Gui = GUICreate("Now Serving... [" & $szIPADDRESS & "]", 380, 123)
    GUICtrlCreateLabel("Serving Ticket #:", 10, 5, 150, 15)

;~     ############################################################################################
    $edit = _GUICtrlEdit_Create($Gui, "", 10, 25, 380, 80)
    $hFont = _WinAPI_CreateFont(20, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _    ; Change size as you like
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Tahoma')
    _WinAPI_SetFont($edit,$hFont,True)
    ;~     ############################################################################################
    GUISetFont (60, 10, 1, $font)
    $edit = GUICtrlCreateLabel("", 100, 15)
    ;GUICtrlSetFont(-1, 9, 400, -1, "Tahoma")


    GUISetState()

    $ConnectedSocket = -1

    While 1
    $msg = GUIGetMsg()
    $ConnectedSocket = TCPAccept($MainSocket)

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

    $recv = TCPRecv($ConnectedSocket, 2048)
    If $recv <> "" Then
    If _GUICtrlEdit_GetText ($edit) <> "" Then
    _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & @CRLF & $recv)
    Else
    _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & $recv)
    EndIf
    If Not WinActive($Gui) Then WinFlash($Gui)
    SoundPlay(@WindowsDir & "MediaDing.wav")
    _GUICtrlEdit_LineScroll ($edit,_GUICtrlEdit_GetLineCount ($edit)+1,_GUICtrlEdit_GetLineCount ($edit)+1)
    EndIf


    WEnd

    If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
    TCPShutdown()
    _WinAPI_DeleteObject($hFont)   ;<<-------------------- DON'T FORGET THIS LINE
    Exit
EndFunc   ;==>Example

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

Andreik Thank you for your input. It seems a little better. however I still dont see anything when I send text to the remote machine? here is the code from the console.

[/b]

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $szIPADDRESS = @IPAddress1
Local $nPORT = 33891
Local $MainSocket, $Gui, $edit, $ConnectedSocket, $szIP_Accepted, $ConnectedSocket2
Local $msg, $recv, $btn, $input, $input2, $nick
TCPStartup()
$MainSocket = TCPListen($szIPADDRESS, $nPORT)
If $MainSocket = -1 Then Exit
$Gui = GUICreate("Now Serving... [" & $szIPADDRESS & "]", 300, 323)
GUICtrlCreateLabel("Serving:", 10, 5, 100, 15)
$nick = GUICtrlCreateInput("Now Serving Ticket #:", 10, 20, 280, 21)
GUICtrlCreateLabel("Enter Ticket#:", 10, 45, 70, 45)
$input = GUICtrlCreateInput("", 10, 60, 280, 22)
GUICtrlSetFont(-1, 9, -1, -1, "Tahoma")
GUICtrlSetState(-1, $GUI_FOCUS)
$btn = GUICtrlCreateButton("Send...", 10, 290, 100, 25, 0x0001)
GUICtrlCreateLabel("IP: ", 175, 295, 12, 35)
$input2 = GUICtrlCreateInput("", 190, 290, 125, 25, 0x0001)
GUICtrlSetData(-1, $szIPADDRESS)
GUICtrlSetFont(-1, 9, -1, -1, "Tahoma")
GUISetState()
$ConnectedSocket = -1
While 1
     $msg = GUIGetMsg()
     $ConnectedSocket = TCPAccept($MainSocket)
     If $msg = $GUI_EVENT_CLOSE Then ExitLoop
     $recv = TCPRecv($ConnectedSocket, 2048)
     If $recv <> "" Then
         If _GUICtrlEdit_GetText ($edit) <> "" Then
             _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & @CRLF & $recv)
         Else
             _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & $recv)
         EndIf
         If Not WinActive($Gui) Then WinFlash($Gui)
         SoundPlay(@WindowsDir & "MediaDing.wav")
         _GUICtrlEdit_LineScroll ($edit,_GUICtrlEdit_GetLineCount ($edit)+1,_GUICtrlEdit_GetLineCount ($edit)+1)
     EndIf

     If $msg = $btn Then
         If GUICtrlRead($nick) = "" Or GUICtrlRead($input) = "" Then
             MsgBox(48, "Error", "Please Enter in ""Ticket #""!")
             ContinueLoop
         EndIf
         $szIPADDRESS = GUICtrlRead($input2)
         If StringRegExp($szIPADDRESS, "d.d.d.d") Then
             $ConnectedSocket2 = TCPConnect($szIPADDRESS, $nPORT)
             If $ConnectedSocket2 <> -1 Then
                 TCPSend($ConnectedSocket2, GUICtrlRead($nick) & ": " & GUICtrlRead($input))
                 If _GUICtrlEdit_GetText ($edit) <> "" Then
                     _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & @CRLF & GUICtrlRead($nick) & ": " & GUICtrlRead($input))
                 Else
                     _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & GUICtrlRead($nick) & ": " & GUICtrlRead($input))
                 EndIf
                 GUICtrlSetData($input, "")
             _GUICtrlEdit_LineScroll ($edit,_GUICtrlEdit_GetLineCount ($edit)+1,_GUICtrlEdit_GetLineCount ($edit)+1)
                 GUICtrlSetState($input, $GUI_FOCUS)
             Else
                 MsgBox(0, "Error!", "Couldn't connect " & $szIPADDRESS & "!" & @CRLF & "Make sure IP is exist!")
                 GUICtrlSetState($input2, $GUI_FOCUS)
             EndIf
         EndIf
     EndIf
WEnd
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
TCPShutdown()
Exit
EndFunc ;==>Example

Edited by JayT
Link to comment
Share on other sites

tadesco,

Using the code that Andreik gave you, this works. I adjusted the position of the edit control so that it is not overlaying your 2nd input control.

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <FontConstants.au3>
#include <WinAPI.au3>

Opt('MustDeclareVars', 1)
Example()
Func Example()
    Local $szIPADDRESS = @IPAddress1
    Local $nPORT = 33891
    Local $MainSocket, $Gui, $edit, $ConnectedSocket, $szIP_Accepted, $ConnectedSocket2, $hfont
    Local $msg, $recv, $btn, $input, $input2, $nick
    TCPStartup()
    $MainSocket = TCPListen($szIPADDRESS, $nPORT)
    If $MainSocket = -1 Then Exit
    $Gui = GUICreate("Now Serving... [" & $szIPADDRESS & "]", 300, 323)
    GUICtrlCreateLabel("Incoming messages:", 10, 5, 150, 15)
    $edit = _GUICtrlEdit_Create($Gui, "", 10, 90, 280, 180)

    $hFont = _WinAPI_CreateFont(20, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _    ; Change size as you like
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Tahoma')
    _WinAPI_SetFont($edit,$hFont,True)

    GUICtrlSetFont(-1, 9, -1, -1, "Tahoma")
    GUICtrlCreateLabel("Serving:", 10, 5, 100, 15)
    $nick = GUICtrlCreateInput("Now Serving Ticket #:", 10, 20, 280, 21)
    GUICtrlCreateLabel("Enter Ticket#:", 10, 45, 70, 45)
    $input = GUICtrlCreateInput("", 10, 60, 280, 22)
    GUICtrlSetFont(-1, 9, -1, -1, "Tahoma")
    GUICtrlSetState(-1, $GUI_FOCUS)
    $btn = GUICtrlCreateButton("Send...", 10, 290, 100, 25, 0x0001)
    GUICtrlCreateLabel("IP: ", 175, 295, 12, 35)
    $input2 = GUICtrlCreateInput("", 190, 290, 125, 25, 0x0001)
    GUICtrlSetData(-1, $szIPADDRESS)
    GUICtrlSetFont(-1, 9, -1, -1, "Tahoma")
    GUISetState()
    $ConnectedSocket = -1
    While 1
        $msg = GUIGetMsg()
        $ConnectedSocket = TCPAccept($MainSocket)
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        $recv = TCPRecv($ConnectedSocket, 2048)
        If $recv <> "" Then
            If _GUICtrlEdit_GetText ($edit) <> "" Then
                _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & @CRLF & $recv)
            Else
                _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & $recv)
            EndIf
            If Not WinActive($Gui) Then WinFlash($Gui)
            SoundPlay(@WindowsDir & "MediaDing.wav")
            _GUICtrlEdit_LineScroll ($edit,_GUICtrlEdit_GetLineCount ($edit)+1,_GUICtrlEdit_GetLineCount ($edit)+1)
        EndIf

        If $msg = $btn Then
            If GUICtrlRead($nick) = "" Or GUICtrlRead($input) = "" Then
                MsgBox(48, "Error", "Please Enter in ""Ticket #""!")
                ContinueLoop
            EndIf
            $szIPADDRESS = GUICtrlRead($input2)
            If StringRegExp($szIPADDRESS, "d.d.d.d") Then
                $ConnectedSocket2 = TCPConnect($szIPADDRESS, $nPORT)
                If $ConnectedSocket2 <> -1 Then
                    TCPSend($ConnectedSocket2, GUICtrlRead($nick) & ": " & GUICtrlRead($input))
                    If _GUICtrlEdit_GetText ($edit) <> "" Then
                        _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & @CRLF & GUICtrlRead($nick) & ": " & GUICtrlRead($input))
                    Else
                        _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & GUICtrlRead($nick) & ": " & GUICtrlRead($input))
                    EndIf
                    GUICtrlSetData($input, "")
                _GUICtrlEdit_LineScroll ($edit,_GUICtrlEdit_GetLineCount ($edit)+1,_GUICtrlEdit_GetLineCount ($edit)+1)
                    GUICtrlSetState($input, $GUI_FOCUS)
                Else
                    MsgBox(0, "Error!", "Couldn't connect " & $szIPADDRESS & "!" & @CRLF & "Make sure IP is exist!")
                    GUICtrlSetState($input2, $GUI_FOCUS)
                EndIf
            EndIf
        EndIf
    WEnd
    If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
    TCPShutdown()
    Exit
EndFunc   ;==>Example

kylomas

edit - additional info

I still dont see anything when I send text to the remote machine?

This is because you commented out the edit control.

edit - I see you found your mistake and corrected it. It is customary to explain topic edits so that poeple reading the topic can follow what is happening

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...