1. Tải bản cài đặt AutoIT mới nhất

    Chào Khách. Nếu bạn mới tham gia và chưa cài đặt AutoIT.
    Vui lòng vào topic trên để tải bản AutoIT mới nhất nhé
    Dismiss Notice
  2. Quy định và nội quy

    Chào Khách. Vui lòng đọc kỹ nội quy và quy định của diễn đàn
    Để tránh bị ban một cách đáng tiếc nhé!
    Dismiss Notice
  3. Hướng dẫn chèn mã AutoIT trong diễn đàn

    Chào Khách. Vui lòng xem qua bài viết này
    Để biết cách chèn mã AutoIT trong diễn đàn bạn nhé :)
    Dismiss Notice

Hỏi đáp Hỏi cách thay đổi size chử trong GUICtrlCreateEdit

Thảo luận trong 'Thảo luận chung - Hỏi đáp' bắt đầu bởi mmovn.no1, 23/1/19.

  1. mmovn.no1

    mmovn.no1 Thành viên mới
    • 3/6

    Tham gia ngày:
    20/11/16
    Bài viết:
    3
    Đã được thích:
    1
    - hi
    - mình có làm 1 đoạn code để đọc truyện = mấy file txt.
    - nhưng mình không có cách nào thêm phần thay đổi size của nó.
    - mấy bạn có biết lệnh nào thì chỉ cho mình với.

    - còn phần gui thì mình làm cho nó xem được ở các loại màn hình ( nhưng thấy hơi kì kì)
    - các bạn có cách nào thì chỉ dùm mình luôn nha

    - cám ơn nhiều

    Mã (AutoIt):
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <FontConstants.au3>

    Global $sochuan_ngang = @DesktopWidth/1366
    Global $sochuan_doc   = @DesktopHeight/768
    Global $fontsize
    Global $doisize = GUICtrlRead($fontsize)

    #Region ### START Koda GUI section ### Form=

    ;Form_Ebookoffline=======================
    $Form_Ebookoffline = GUICreate("Ebook offline", $sochuan_ngang * 1310,$sochuan_doc* 695, 0, 0)

    $Edit = GUICtrlCreateEdit("", $sochuan_ngang *8, $sochuan_doc* 38, $sochuan_ngang *1302, $sochuan_doc* 645, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
    GUICtrlSetData(-1, "Edit")
    GUICtrlSetFont(-1,24,400,1)

    $label_chuong = GUICtrlCreatelabel(" Chương", $sochuan_ngang *216, $sochuan_doc* 6, $sochuan_ngang *100, $sochuan_doc* 21)
    GUICtrlSetFont($label_chuong, 14, $FW_NORMAL, $GUI_FONTUNDER)

    $Input_duongdan = GUICtrlCreateInput("đường dẫn", $sochuan_ngang *8, $sochuan_doc* 8, $sochuan_ngang *200, $sochuan_doc* 21)
    $Input_chuong = GUICtrlCreateInput("", $sochuan_ngang *296,$sochuan_doc* 8, $sochuan_ngang *40, $sochuan_doc* 21)

    $Button_mo = GUICtrlCreateButton("mở", $sochuan_ngang *636, $sochuan_doc* 6, $sochuan_ngang *50, $sochuan_doc* 25)
    $Button_chuongtruoc = GUICtrlCreateButton("chương trước",$sochuan_ngang *528,6, $sochuan_ngang *100, $sochuan_doc* 25)
    $Button_chuongsau = GUICtrlCreateButton("chương sau",$sochuan_ngang *694, $sochuan_doc* 6, $sochuan_ngang *100, $sochuan_doc* 25)
    $Button_doifontsize = GUICtrlCreateButton("đổi font size",$sochuan_ngang *907, $sochuan_doc* 6, $sochuan_ngang *100, $sochuan_doc* 25)

    #Region UPDOWN
    $fontsize = GUICtrlCreateInput("30", $sochuan_ngang *1015, $sochuan_doc*  8, $sochuan_ngang *40, $sochuan_doc* 20)
    GUICtrlSetTip(-1, '#Region UPDOWN - Input')
    GUICtrlCreateUpdown(-1)
    GUICtrlSetTip(-1, '#Region UPDOWN - Updown')
    #EndRegion UPDOWN

    $Button_luumo = GUICtrlCreateButton("lưu/mở truyện đang đọc",$sochuan_ngang *1064,$sochuan_doc*  6, $sochuan_ngang *130, $sochuan_doc* 25)
    $Button_taofiletruyen = GUICtrlCreateButton("tạo file truyện",$sochuan_ngang *1202, $sochuan_doc* 6, $sochuan_ngang *100, $sochuan_doc* 25)

    GUISetState(@SW_SHOW)

    ;Form_luughinho=======================
    $Form_luughinho = GUICreate("lưu / mở ghi nhớ", $sochuan_ngang *333,$sochuan_doc*40, $sochuan_ngang *967, $sochuan_doc*68)
    $Button_luughinho = GUICtrlCreateButton("lưu",$sochuan_ngang *8, $sochuan_doc*6, $sochuan_ngang *90, $sochuan_doc*25)
    $Button_moghinho = GUICtrlCreateButton("mở",$sochuan_ngang *106, $sochuan_doc*6, $sochuan_ngang *90, $sochuan_doc*25)
    $Combolistghinho =   GUICtrlCreateCombo("truyện đang đọc",$sochuan_ngang *204, $sochuan_doc*8, $sochuan_ngang *120, $sochuan_doc*25)
    GUICtrlSetData($Combolistghinho,"ghi nhớ 1|ghi nhớ 2|ghi nhớ 3", "")
    GUICtrlSetFont(-1,9,100,2)
    GUISetState(@SW_HIDE)

    ;Form_taofiletuyenmoi=======================
    $Form_taofiletuyenmoi = GUICreate("tạo file tuyện mới", $sochuan_ngang *445, $sochuan_doc*74, $sochuan_ngang *859, $sochuan_doc*64)
    $Input_duongdanluufile = GUICtrlCreateInput("đường dẫn lưu file ( bấm nút địa chỉ) ", $sochuan_ngang *8, $sochuan_doc*8, $sochuan_ngang *337, $sochuan_doc*21)
    $Input_tentruyen = GUICtrlCreateInput("viết tên truyện",$sochuan_ngang *92, $sochuan_doc*40, $sochuan_ngang *252, $sochuan_doc*21)
    $Button_coppychuong = GUICtrlCreateButton("coppy chương", $sochuan_ngang *8, $sochuan_doc*38, $sochuan_ngang *75, $sochuan_doc*25)
    $Button_diachi = GUICtrlCreateButton("địa chỉ", $sochuan_ngang *352, $sochuan_doc*6, $sochuan_ngang *75, $sochuan_doc*25)
    $Buttonluufile = GUICtrlCreateButton("lưu file", $sochuan_ngang *352, $sochuan_doc*38, $sochuan_ngang *75, $sochuan_doc*25)
    GUISetState(@SW_HIDE)

    #EndRegion ### END Koda GUI section ###

    Global $sFileOpenDialog

    ;file ghi nhớ 1=====================================
    $fileghinho1= @ScriptDir &'\dulieu\ghinho1.txt'
    If FileExists($fileghinho1)= 0 Then                 ; Nếu file dữ liệu không tồn tại thì
        FileOpen($fileghinho1,2+128)                    ; Tạo file dữ liệu cho chương trình
    EndIf

    ;file ghi nhớ 2=====================================
    $fileghinho2= @ScriptDir &'\dulieu\ghinho2.txt'
    If FileExists($fileghinho2)= 0 Then
        FileOpen($fileghinho2,2+128)
    EndIf

    ;file ghi nhớ 3=====================================
    $fileghinho3= @ScriptDir &'\dulieu\ghinho3.txt'
    If FileExists($fileghinho3)= 0 Then
        FileOpen($fileghinho3,2+128)
    EndIf

    ;file name=====================================
    $filename= @ScriptDir &'\dulieu\ghinhotrangdangdoc.txt'
    If FileExists($filename)= 0 Then
        FileOpen($filename,2+128)
    EndIf
    ;__auto_load()

    While 1
             $Msg = GUIGetMsg(1)
             $iMsg=$Msg [ 0 ]
        Switch $Msg[ 1 ]
    ;==========khu vực gui chính ;;;;;;;
          Case $Form_Ebookoffline
             Switch  $iMsg
                Case $GUI_EVENT_CLOSE
                         __save_ghinho()
                   Exit

                Case $Button_mo
                         $sFileOpenDialog=FileOpenDialog("explorer.exe ", @ScriptDir & "\truyen","All (*.*)")
                         __run()

                Case $Button_chuongsau
                         $sFileOpenDialog= GUICtrlRead($Input_duongdan) & GUICtrlRead($Input_chuong ) + 1 & ".txt"
                         __run()

                Case $Button_chuongtruoc
                         $sFileOpenDialog= GUICtrlRead($Input_duongdan) & GUICtrlRead($Input_chuong ) - 1 & ".txt"
                         __run()

                Case $Button_doifontsize
                      MsgBox(0,'Thông báo','mình không làm được, làm ơn giúp mình phần này')

                Case $Button_luumo
                      GUISetState (@SW_SHOW , $Form_luughinho)

                Case $Button_taofiletruyen
                      GUISetState (@SW_SHOW , $Form_taofiletuyenmoi)

             EndSwitch


    ;==========khu vực gui phụ ;;;;luughinho;;;
             Case  $Form_luughinho
                Switch  $iMsg
                   Case  $GUI_EVENT_CLOSE
                         GUISetState (@SW_HIDE , $Form_luughinho)
                   Case $Button_luughinho
                         if  GUICtrlRead($Combolistghinho) = "ghi nhớ 1" then
                               FileDelete($fileghinho1)
                               FileOpen($fileghinho1)
                               FileWrite($fileghinho1,GUICtrlRead($Input_chuong) & @CRLF )
                               sleep(100)
                               FileWrite($fileghinho1,GUICtrlRead($Input_duongdan) & @CRLF)
                               FileClose($fileghinho1)
                         ElseIf GUICtrlRead($Combolistghinho) = "ghi nhớ 2" Then
                               FileDelete($fileghinho2)
                               FileOpen($fileghinho2)
                               FileWrite($fileghinho2,GUICtrlRead($Input_chuong) & @CRLF )
                               sleep(100)
                               FileWrite($fileghinho2,GUICtrlRead($Input_duongdan) & @CRLF)
                               FileClose($fileghinho2)
                         ElseIf GUICtrlRead($Combolistghinho) = "ghi nhớ 3" Then
                               FileDelete($fileghinho3)
                               FileOpen($fileghinho3)
                               FileWrite($fileghinho3,GUICtrlRead($Input_chuong) & @CRLF )
                               sleep(100)
                               FileWrite($fileghinho3,GUICtrlRead($Input_duongdan) & @CRLF)
                               FileClose($fileghinho3)
                         Else
                               MsgBox("", "", "bạn chưa chọn loại ghi nhớ để lưu")
                         endif
                   Case $Button_moghinho
                         if  GUICtrlRead($Combolistghinho) = "ghi nhớ 1" then
                               $gettext_chuong = FileReadLine($fileghinho1,1)
                               GUICtrlSetData($Input_chuong,$gettext_chuong)
                               sleep(100)
                               $gettext_duongdan = FileReadLine($fileghinho1,2)
                               GUICtrlSetData($Input_duongdan,$gettext_duongdan)

                               $sFileOpenDialog= GUICtrlRead($Input_duongdan) & GUICtrlRead($Input_chuong ) & ".txt"
                               FileChangeDir($sFileOpenDialog)
                               GUICtrlSetData($Edit,FileRead($sFileOpenDialog))

                         ElseIf GUICtrlRead($Combolistghinho) = "ghi nhớ 2" Then
                               $gettext_chuong = FileReadLine($fileghinho2,1)
                               GUICtrlSetData($Input_chuong,$gettext_chuong)
                               sleep(100)
                               $gettext_duongdan = FileReadLine($fileghinho2,2)
                               GUICtrlSetData($Input_duongdan,$gettext_duongdan)

                               $sFileOpenDialog= GUICtrlRead($Input_duongdan) & GUICtrlRead($Input_chuong ) & ".txt"
                               FileChangeDir($sFileOpenDialog)
                               GUICtrlSetData($Edit,FileRead($sFileOpenDialog))
                         ElseIf GUICtrlRead($Combolistghinho) = "ghi nhớ 3" Then
                               $gettext_chuong = FileReadLine($fileghinho3,1)
                               GUICtrlSetData($Input_chuong,$gettext_chuong)
                               sleep(100)
                               $gettext_duongdan = FileReadLine($fileghinho3,2)
                               GUICtrlSetData($Input_duongdan,$gettext_duongdan)

                               $sFileOpenDialog= GUICtrlRead($Input_duongdan) & GUICtrlRead($Input_chuong ) & ".txt"
                               FileChangeDir($sFileOpenDialog)
                               GUICtrlSetData($Edit,FileRead($sFileOpenDialog))
                         Else
                               MsgBox("", "", "bạn chưa chọn loại ghi nhớ để mở")
                         endif
                EndSwitch

    ;==========khu vực gui phụ ;;;;tạo file truyện mới;;;
             Case  $Form_taofiletuyenmoi
                Switch  $iMsg
                   Case  $GUI_EVENT_CLOSE
                         GUISetState (@SW_HIDE , $Form_taofiletuyenmoi)

                   Case  $Button_coppychuong
                      GUICtrlSetData($Input_tentruyen,GUICtrlRead($Input_chuong))

                   Case  $Button_diachi
                      $FileSelectFolder=FileSelectFolder("Select a folder", "")
                      GUICtrlSetData($Input_duongdanluufile,$FileSelectFolder)

                   Case  $Buttonluufile
                      $filename_luu = GUICtrlRead($Input_tentruyen)
                      $file_luu =GUICtrlRead($Input_duongdanluufile) & "\"&$filename_luu &".txt"

                      FileOpen($file_luu,2+128)
                      $noidung_luu = GUICtrlRead($Edit)
                      FileWrite($file_luu,$noidung_luu)
                      FileClose($file_luu)
                      sleep(200)
                      FileMove($file_luu,GUICtrlRead($Input_duongdanluufile) & "\"& $filename_luu &".txt",1)

                EndSwitch
        EndSwitch
    WEnd





    ;run ===============================================================================
    Func __run()
                            FileChangeDir(@ScriptDir)
                            $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)
                            GUICtrlSetData($Edit,FileRead($sFileOpenDialog))

                            If StringInStr($sFileOpenDialog, "\", 0, 2) = "0" Then
                               $result = StringInStr($sFileOpenDialog, "\", 0, 1)
                               $a = StringLeft($sFileOpenDialog, $result )
                               $b = StringTrimLeft($sFileOpenDialog, $result)
                               $c=StringTrimRight($b,4)
                            ElseIf StringInStr($sFileOpenDialog, "\", 0, 3) = "0" Then
                               $result = StringInStr($sFileOpenDialog, "\", 0, 2)
                               $a = StringLeft($sFileOpenDialog, $result )
                               $b = StringTrimLeft($sFileOpenDialog, $result)
                               $c=StringTrimRight($b,4)
                            ElseIf StringInStr($sFileOpenDialog, "\", 0, 4) = "0" Then
                               $result = StringInStr($sFileOpenDialog, "\", 0, 3)
                               $a = StringLeft($sFileOpenDialog, $result )
                               $b = StringTrimLeft($sFileOpenDialog, $result)
                               $c=StringTrimRight($b,4)
                            ElseIf StringInStr($sFileOpenDialog, "\", 0, 5) = "0" Then
                               $result = StringInStr($sFileOpenDialog, "\", 0, 4)
                               $a = StringLeft($sFileOpenDialog, $result )
                               $b = StringTrimLeft($sFileOpenDialog, $result)
                               $c=StringTrimRight($b,4)
                            ElseIf StringInStr($sFileOpenDialog, "\", 0, 6) = "0" Then
                               $result = StringInStr($sFileOpenDialog, "\", 0, 5)
                               $a = StringLeft($sFileOpenDialog, $result )
                               $b = StringTrimLeft($sFileOpenDialog, $result)
                               $c=StringTrimRight($b,4)
                            EndIf

                            GUICtrlSetData($Input_duongdan,$a)
                            GUICtrlSetData($Input_chuong,$c)

    EndFunc

    ; save_ghinho===============================================================================
    Func __save_ghinho()
                   FileDelete($filename)

                   FileOpen($filename)
                   FileWrite($filename,GUICtrlRead($Input_chuong) & @CRLF )
                   sleep(100)
                   FileWrite($filename,GUICtrlRead($Input_duongdan) & @CRLF)
                   FileClose($filename)

    EndFunc

    ;auto load===============================================
    Func __auto_load()

       $gettext_chuong = FileReadLine($filename,1)
       GUICtrlSetData($Input_chuong,$gettext_chuong)
       sleep(100)
       $gettext_duongdan = FileReadLine($filename,2)
       GUICtrlSetData($Input_duongdan,$gettext_duongdan)

       $sFileOpenDialog= GUICtrlRead($Input_duongdan) & GUICtrlRead($Input_chuong ) & ".txt"
       FileChangeDir($sFileOpenDialog)
       GUICtrlSetData($Edit,FileRead($sFileOpenDialog))
    EndFunc
     

Chia sẻ trang này

Đang tải...