Jump to content

GUICtrlSetData fails to set time in a "Date" control


Recommended Posts

Hi everyone,

I am bit stumped as to why I am not able to set the time in the Date control :wacko:

#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("My GUI get date", 200, 200, 800, 200)
    Local $idDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20, $DTS_TIMEFORMAT)

    ; to select a specific default format
    Local $sStyle = "HH:mm:ss"
    GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle)

    ; Set time
    Local $iRet = GUICtrlSetData($idDate, '13:33:37')
    ConsoleWrite('GUICtrlSetData returned ' & ($iRet = 1 ? 'success' : 'failure') & @CRLF)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While GUIGetMsg() <> $GUI_EVENT_CLOSE
    WEnd

    MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate))
EndFunc   ;==>Example

The documentation for GUICtrlSetData clearly mentions that it uses the same format as GUICtrlRead:

Quote

For Date controls:
The date and time is in the format defined by the regional settings. GUICtrlRead() use the same default format.

But I get failure :(

What gives?

Thanks for the help in advance!

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

I know I gave you this in HexChat, but I should add here in this topic.

What one of my programs uses.

$Group_from = GuiCtrlCreateGroup("Update From", 10, 10, 190, 55)
    $Date_from = GuiCtrlCreateDate($now, 20, 30, 90, 20)
    $Date_fromtime = GuiCtrlCreateDate($time, 120, 30, 70, 20, $DTS_TIMEFORMAT)
    $DTM_SETFORMAT_ = 0x1032
    $style = "yyyy/MM/dd"
    GUICtrlSendMsg($Date_from, $DTM_SETFORMAT_, 0, $style)
    $style = "HH:mm:ss"
    GUICtrlSendMsg($Date_fromtime, $DTM_SETFORMAT_, 0, $style)

Hope it helps.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to post
Share on other sites

@TheSaint Thanks for posting, but I am having issues with GUICtrlSetData where I attempt to set the time in the control, do you have code which sets data?

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

At the risk of going overboard, here is a related function.

Func DatesGUI($combo, $now)
    Local $Button_apply, $Button_x3, $Date_from, $Date_fromtime, $Date_to, $Date_totime, $Group_from, $Group_to
    ;
    Local $d1, $d2, $DatesGUI, $time
    ;
    $now = StringSplit($now, " ", 1)
    If $now[0] = 2 Then
        $time = $now[2]
        $now = $now[1]
    Else
        $time = ""
        $now = ""
    EndIf
    ;MsgBox(262192, "$now $time", $now & @LF & $time, 0, $DatesGUI)
    ; Script generated by AutoBuilder 0.9 Prototype
    $DatesGUI = GuiCreate("Dates", 280, 150, $left, -1, $WS_OVERLAPPED + $WS_CAPTION + $WS_SYSMENU _
                        + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_MINIMIZEBOX, $WS_EX_TOPMOST, $SBSgetGUI)
    ; CONTROLS
    $Group_from = GuiCtrlCreateGroup("Date From", 10, 10, 190, 55)
    If $combo = $Combo_from Then
        $Date_from = GuiCtrlCreateDate($now, 20, 30, 90, 20)
        $Date_fromtime = GuiCtrlCreateDate($time, 120, 30, 70, 20, $DTS_TIMEFORMAT)
    Else
        If $period = "...select..." Then
            $d1 = IniRead($inifle, "Date From", "select", "")
            $d1 = StringSplit($d1, " ", 1)
            If $d1[0] = 2 Then
                $d2 = $d1[2]
                $d1 = $d1[1]
            Else
                $d1 = "2000/01/01"
                $d2 = "00:00:00"
            EndIf
        Else
            $d1 = "2000/01/01"
            $d2 = "00:00:00"
        EndIf
        $Date_from = GuiCtrlCreateDate($d1, 20, 30, 90, 20)
        $Date_fromtime = GuiCtrlCreateDate($d2, 120, 30, 70, 20, $DTS_TIMEFORMAT)
    EndIf
    $DTM_SETFORMAT_ = 0x1032
    $style = "yyyy/MM/dd"
    GUICtrlSendMsg($Date_from, $DTM_SETFORMAT_, 0, $style)
    $style = "HH:mm:ss"
    GUICtrlSendMsg($Date_fromtime, $DTM_SETFORMAT_, 0, $style)
    ;
    $Group_to = GuiCtrlCreateGroup("Date To", 10, 75, 190, 55)
    If $combo = $Combo_to Then
        $Date_to = GuiCtrlCreateDate($now, 20, 95, 90, 20)
        $Date_totime = GuiCtrlCreateDate($time, 120, 95, 70, 20, $DTS_TIMEFORMAT)
    Else
        If $perend = "...select..." Then
            $d1 = IniRead($inifle, "Date To", "select", "")
            $d1 = StringSplit($d1, " ", 1)
            If $d1[0] = 2 Then
                $d2 = $d1[2]
                $d1 = $d1[1]
            Else
                $d1 = "2000/01/01"
                $d2 = "00:00:00"
            EndIf
        Else
            $d1 = "2000/01/01"
            $d2 = "00:00:00"
        EndIf
        $Date_to = GuiCtrlCreateDate($d1, 20, 95, 90, 20)
        $Date_totime = GuiCtrlCreateDate($d2, 120, 95, 70, 20, $DTS_TIMEFORMAT)
    EndIf
    $style = "yyyy/MM/dd"
    GUICtrlSendMsg($Date_to, $DTM_SETFORMAT_, 0, $style)
    $style = "HH:mm:ss"
    GUICtrlSendMsg($Date_totime, $DTM_SETFORMAT_, 0, $style)
    ;
    $Button_apply = GuiCtrlCreateButton("Apply", 210, 15, 60, 50)
    GUICtrlSetFont($Button_apply, 9, 600)
    GUICtrlSetTip($Button_apply, "Apply the currently set date & time!")
    ;
    $Button_x3 = GuiCtrlCreateButton("EXIT", 210, 80, 60, 50, $BS_ICON)
    GUICtrlSetTip($Button_x3, "Exit / Close / Quit the window!")
    ;
    ; SETTINGS
    GUICtrlSetImage($Button_x3, $explorer, $icoX, 1)
    ;
    If $combo = $Combo_from Then
        GUICtrlSetState($Date_to, $GUI_DISABLE)
        GUICtrlSetState($Date_totime, $GUI_DISABLE)
    ElseIf $combo = $Combo_to Then
        GUICtrlSetState($Date_from, $GUI_DISABLE)
        GUICtrlSetState($Date_fromtime, $GUI_DISABLE)
        GUICtrlSetData($Date_to, $now)
        GUICtrlSetData($Date_totime, $time)
    EndIf
    

    GuiSetState()
    While 1
        $msg = GuiGetMsg()
        Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_x3
            ; Exit / Close / Quit the window
            GUIDelete($DatesGUI)
            ExitLoop
        Case $msg = $Button_apply
            ; Apply the currently set date & time
            If $combo = $Combo_from Then
                $date = GUICtrlRead($Date_from) & " " & GUICtrlRead($Date_fromtime)
            ElseIf $combo = $Combo_to Then
                $date = GUICtrlRead($Date_to) & " " & GUICtrlRead($Date_totime)
            EndIf
            MsgBox(262192, "Date Check", $date, 0, $DatesGUI)
            GUIDelete($DatesGUI)
            ExitLoop
        Case Else
            ;;;
        EndSelect
    WEnd
EndFunc ;=> DatesGUI

I will let you nut it out with my code. I am suffering from brain drain and tiredness right now.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to post
Share on other sites

@TheSaint Can you give more info on the $now parameter in your function? It looks like an array which contains the time that you set:

$time = $now[2]
; ...
GUICtrlSetData($Date_totime, $time)

 

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

Well the clue is in the first line of the following.

$now = StringSplit($now, " ", 1)
    If $now[0] = 2 Then
        $time = $now[2]
        $now = $now[1]
    Else
        $time = ""
        $now = ""
    EndIf

That space is the divider between DATE and TIME, probably as returned by the _Now() function.

So have a try with $now = _Now() before that line ... or replace $now with _Now()

$now = StringSplit(_Now(), " ", 1)

Don't ask me why I am using $now instead of $date, but I imagine $date is in use as a variable elsewhere in my script.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to post
Share on other sites

@TheSaint Thanks, that clears about what $now is, but unfortunately the string returned by _Now is locale-specific, meaning it changes across different regions :(

Quote

Returns Current Date and Time in PC's format.

But I want to set the time in my format, not the PC's format...

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

Well isn't it as simple as converting?

If the Date control requires the date or time to be in a specific format, then you are limited to that.

That means you have to sanitize what you send by CtrlSetData

 

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to post
Share on other sites
12 minutes ago, TheSaint said:

Well isn't it as simple as converting?

It is as simple as converting, but conversion is the hard part, and there is no standard reference that can be used, nor is there any Windows API that I can use to convert time and date between different locales... so practically impossible unless I limit myself to a specific version of Windows in specific regional settings.

--

I did find a promising alternative function (_GUICtrlDTP_SetSystemTime) that I could use to set the time, but that too didn't work:

#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("My GUI get date", 200, 200, 800, 200)
    Local $idDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20, $DTS_TIMEFORMAT)

    ; to select a specific default format
    Local $sStyle = "HH:mm:ss"
    GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle)

    ; Set time
    Local $aDate[7] = [True, 0, 0, 0, 13, 33, 37]
    Local $hDate = GUICtrlGetHandle($idDate)
    Local $bRet = _GUICtrlDTP_SetSystemTime($hDate, $aDate)
    ConsoleWrite('_GUICtrlDTP_SetSystemTime returned ' & ($bRet ? 'success' : 'failure') & @CRLF)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While GUIGetMsg() <> $GUI_EVENT_CLOSE
    WEnd

    MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate))
EndFunc   ;==>Example

 

Edited by TheDcoder

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

Yep, you can set the full date, time or just date.

But that is not his issue.

His issue is to do with locales ... though it seems to me he is making it more complex than it needs to be.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to post
Share on other sites

@Danp2 You are right about having to include date along with the time, but like TheSaint has said, the format of date + time depends on the locale of the machine and I need my script to work in various locales, not only English-like ones.

At this point I am pretty sure GUICtrlSetData only takes the region-specific string as valid input, but what stumps me is why _GUICtrlDTP_SetSystemTime also doesn't seem to work?

@TheSaint Thanks for clarifying on my behalf.

2 hours ago, TheSaint said:

... though it seems to me he is making it more complex than it needs to be.

Depends on how you see it, if I compromise with not properly supporting all locales, I can definitely just hardcode the English string an use a fake date to set the time. But I'd rather not do that.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites
1 hour ago, TheDcoder said:

but what stumps me is why _GUICtrlDTP_SetSystemTime also doesn't seem to work?

Like I expected, I overlooked something simple, I had the date in the wrong order in my example, I was using DMY instead of YMD.

#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("My GUI get date", 200, 200, 800, 200)
    Local $idDate = GUICtrlCreateDate("", 10, 10, 185, 20, $DTS_TIMEFORMAT)
    Local $hDate = GUICtrlGetHandle($idDate)

    ; to select a specific default format
    Local $sStyle = "HH:mm:ss"
    GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle)

    ; Set time
    Local $aDate[7] = [False, 2020, 1, 1, 13, 33, 37]
    Local $bRet = _GUICtrlDTP_SetSystemTime($hDate, $aDate)
    ConsoleWrite('_GUICtrlDTP_SetSystemTime returned ' & ($bRet ? 'success' : 'failure') & @CRLF)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While GUIGetMsg() <> $GUI_EVENT_CLOSE
    WEnd

    MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate))
EndFunc   ;==>Example

This works perfectly and it doesn't even depend on strings, let alone have regional issues! I am happy :D

Edit: Just noticed another helpful tidbit, remember to set the first element of the time/date array to False, otherwise it won't work! At-least it did not for me.

Edited by TheDcoder

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites
1 hour ago, Danp2 said:

Hmmm... are you sure? His code runs correctly for me by making that one change. I can't find an example where GUICtrlSetData works when supplying time only.

I didn't run his code, and I was very tired last night, and probably shouldn't have bothered replying, but he asked me in HexChat and I remembered I had some code from years ago that probably did close to what he wanted ... it was very specific though and didn't need to cater for regions.

In my code in the 4th post (my second reply) you can see I use the following.

GUICtrlSetData($Date_to, $now)
        GUICtrlSetData($Date_totime, $time)

And you can see from earlier in the code, where I set the controls up.

$style = "yyyy/MM/dd"
    GUICtrlSendMsg($Date_to, $DTM_SETFORMAT_, 0, $style)
    $style = "HH:mm:ss"
    GUICtrlSendMsg($Date_totime, $DTM_SETFORMAT_, 0, $style)

Be aware though, that I did this a few years ago with an older version of AutoIt.

 

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By NassauSky
      Hi all,
      The more projects I work on, the harder it is to find old scripts I created with certain techniques in them. I'd like to leave this here for others to get an idea from and it will be available now by keyword searching in this forum.
      This project needed an evenly distributed button grid setup on a touch screen with half decent sized buttons and spacing so the user would be less likely to press the key beside it. Here is one quick example to give anyone an idea of a way to handle it.
      #include <GUIConstants.au3> GUICreate("Button Grid", 1080, 100) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box ;--Create and Position Controls Dim $btnActivated[1][2] ;Col 1 is button id, Col 2 is True/False used in 1 example as depressed Dim $btnArray[100][2] ;Col 1 is button id, Col 2 is True/False used in 1 example as depressed $num = 0 $btnActivated[0][0] = GUICtrlCreateButton("Activated", 0, 0, 100, 100) ;x,y,w,h $btnActivated[0][1] = True GUICtrlSetBkColor(-1,0x00ff00) GUICtrlSetColor(-1,0x005500) GUICtrlSetFont(-1,14) For $Y = 0 To 1 For $X = 0 To 7 ConsoleWrite( ($X * 100) + ($X*20) + 120 & @CRLF) If $Y=0 Then $btnArray[$num][0] = GUICtrlCreateButton($num + 1, ($X * 100) + ($X*20) + 120, 0, 100, 40) ;x,y,w,h Else $btnArray[$num][0] = GUICtrlCreateButton($num + 1, ($X * 100) + ($X*20) + 120, ($Y * 40) + $Y*20, 100, 40) ;x,y,w,h EndIf GUICtrlSetBkColor($btnArray[$num][0], 0xFFFFFF) $num += 1 Next Next ;--Set Button Names GUICtrlSetData($btnArray[0][0],"Autoit") GUICtrlSetData($btnArray[1][0],"Is") GUICtrlSetData($btnArray[2][0],"Cool") ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $btnActivated[0][0] $btnActivated[0][1] = NOT $btnActivated[0][1] If $btnActivated[0][1] Then GUICtrlSetBkColor($btnActivated[0][0],0x00ff00) GUICtrlSetColor($btnActivated[0][0],0x005500) GUICtrlSetData($btnActivated[0][0],"Activated") GUICtrlSetFont($btnActivated[0][0],14) Else GUICtrlSetBkColor($btnActivated[0][0],0xFF9999) GUICtrlSetColor($btnActivated[0][0],0x550000) GUICtrlSetData($btnActivated[0][0],"DeActivated") GUICtrlSetFont($btnActivated[0][0],13) EndIf Case $btnArray[0][0] If $btnActivated[0][1] Then MsgBox(0,"Notice","Btn1",1) EndIf Case $btnArray[1][0] If $btnActivated[0][1] Then MsgBox(0,"Notice","Btn2",1) EndIf Case $btnArray[2][0] If $btnActivated[0][1] Then MsgBox(0,"Notice","Btn3",1) EndIf EndSwitch WEnd I couldn't find one of my old projects that broke the button array into more columns that included the actual button name in the field. Feel free to share your own or share a more flexible version of this simple example.

    • By It_is_me_Me
      I am making some GUI with combobox for the Baudrates communications and I listed 9600, 57600, 115200. 
      I wrote the code to be defaulted to 57600 like this:
      GUICtrlSetData($comboBox_opticalBaudRate, "9600|57600|115200", "57600")
      But I wanted the GUI to remember the last item the user picks so the baudrates will NOT be defaulted to 57600.
      Example, I pick 9600 as my baudrates, then I close the GUI, after opening it, it always prompt 57600 since that is what I did in my code. But I want that if I choose 9600 and close the GUI, opening it again will show 9600 now instead of 57600.
      Is there a way to do it in GUI setting?
       
      Thanks.
    • By ashraful089
      #include <ButtonConstants.au3>
      #include <ComboConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <WindowsConstants.au3>
      #Region ### START Koda GUI section ### Form=C:\Users\Engr. Ashraful\Videos\koda_1.7.3.0\Forms\ProgramPlayer\FormProgamToOpen.kxf
      $FormInput = GUICreate("Input", 302, 205, 454, 285)
      $Resolution = GUICtrlCreateCombo("Resolution", 80, 24, 145, 25)
      GUICtrlSetData(-1, "1920|VM1920|1366")
      $ComboProgramType = GUICtrlCreateCombo("Program Type Selection", 80, 64, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
      GUICtrlSetData(-1, "Multimedia|Official|Design|Web")
      $ButtonEnter = GUICtrlCreateButton("Enter", 104, 104, 75, 25)
      GUISetState(@SW_SHOW)
      #EndRegion ### END Koda GUI section ###
      While 1
          $nMsg = GUIGetMsg()
          Switch $nMsg
              Case $GUI_EVENT_CLOSE
                  Exit
          EndSwitch
      WEnd
       
      please help me to read combo box input and use the value for another function/ work
       
    • By Aapjuh
      Hi,
      I am having a problem properly saving the Width of a resizable Gui.
      When a user resizes the Gui it gets saved in an ini when the Gui closes to then restore the new Width upon reopening the app.
      with GUICreate("myGui",300,200,Default,Default,$WS_SIZEBOX)
      WinGetPos($hGUI) returns 314, and WinGetClientSize($hGUI) returns 298
      when its then saved in the ini the gui keeps expanding or shrinking every time its opened by +14 or -2
      I figure it has to do with borders etc, but i also guess borders depend on the window theme and whatnot or is user specific, so i can't just do $GuiWidth = $GetGuiWidth[arr] -14 or +2 right?

      is there a proper way of doing this?
      Thanks in advance,
      Aapjuh
    • By ahha
      Newbie to _GUICtrlListView_RegisterSortCallBack and can't get it to sort properly on date in format MM/DD/YYYY.
      Example code below.  Q - How do I get the date to sort properly?
      ;#AutoIt3Wrapper_run_debug_mode=Y #include <GUIConstantsEx.au3> #include <GuiListView.au3> Global $g_id_ListView Example() Exit Func Example() Local $idRow1, $idRow2, $idRow3 GUICreate("ListView Sort Question", 300, 200) $g_id_ListView = GUICtrlCreateListView("Row#|Name|Date", 10, 10, 280, 180) $id_Row1 = GUICtrlCreateListViewItem("#1|Alice|01/15/2022", $g_id_ListView) $id_Row2 = GUICtrlCreateListViewItem("#2|Bob|02/22/2021", $g_id_ListView) $id_Row3 = GUICtrlCreateListViewItem("#3|Carol|03/13/2021", $g_id_ListView) $id_Row10 = GUICtrlCreateListViewItem("#10|Dave|10/09/2021", $g_id_ListView) $id_Row11 = GUICtrlCreateListViewItem("#11|Eve|11/21/2021", $g_id_ListView) GUISetState(@SW_SHOW) ;$vCompareType = 0 ;not ok as Row# sort #1, #10, and want #1, #2, ;$vCompareType = 1 ;not ok as Row# sort #1, #10, and want #1, #2, $vCompareType = 2 ;Row# okay but Date messed up _GUICtrlListView_RegisterSortCallBack($g_id_ListView, $vCompareType) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $g_id_ListView ;MsgBox(0,"","col="&GUICtrlGetState($g_id_ListView)) _GUICtrlListView_SortItems($g_id_ListView, GUICtrlGetState($g_id_ListView)) EndSwitch WEnd _GUICtrlListView_UnRegisterSortCallBack($g_id_ListView) GUIDelete($g_id_ListView) EndFunc ;Func Example()  
×
×
  • Create New...