DuyAnh

How to create table displays the number on the gui

12 posts in this topic

#1 ·  Posted (edited)

l4HD1mG.png

How to create table displays the number on the gui

Some may choose to 1 as shown in Figure

Sorry for my English is not good

 

Edited by DuyAnh

Share this post


Link to post
Share on other sites



The attachment can't be displayed ("We could not locate the item you are trying to view. ").
Is it just me?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

5 minutes ago, water said:

The attachment can't be displayed ("We could not locate the item you are trying to view. ").
Is it just me?

l4HD1mG.png

Here are pictures

can choose in each cell on the table

Please help me

 

 

Edited by DuyAnh

Share this post


Link to post
Share on other sites

Please have a look at the Table UDF:

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

3 minutes ago, water said:

Please have a look at the Table UDF:

 

I want it to be able to select a number on the board

This udf only allows display, below is my code, but for 2 listview when selected, only one current listview

;~ #NoTrayIcon
#RequireAdmin
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <File.au3>
#include <ComboConstants.au3>
#include <GuiConstants.au3>
#include <GuiEdit.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#include <GuiStatusBar.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiListView.au3>
#include <GuiListBox.au3>
#include <ButtonConstants.au3>
#include <GuiConstantsEx.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>
#include <GuiToolbar.au3>
#include <ToolbarConstants.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>
#include <ListViewConstants.au3>
#include <WinAPI.au3>
#include <Windowsconstants.au3>
#include <Crypt.au3>
#include <FTPEx.au3>
#include <IE.au3>

Global $aHit[2] = [-1, -1]

$Form1 = GUICreate("hihii", 910, 465, -1, -1)



$XBoot_Timer_H = GUICtrlCreateListView("x|y|z|a|y", 100, 200, 200, 95, $LVS_NOCOLUMNHEADER, 0)
$XBoot_Timer_hH = GUICtrlGetHandle($XBoot_Timer_H)
_GUICtrlListView_SetExtendedListViewStyle($XBoot_Timer_H, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_SetColumnWidth($XBoot_Timer_hH, 0, 40)
_GUICtrlListView_SetColumnWidth($XBoot_Timer_hH, 1, 40)
_GUICtrlListView_SetColumnWidth($XBoot_Timer_hH, 2, 40)
_GUICtrlListView_SetColumnWidth($XBoot_Timer_hH, 3, 40)
_GUICtrlListView_SetColumnWidth($XBoot_Timer_hH, 4, 40)
_GUICtrlListView_JustifyColumn($XBoot_Timer_hH, 0, 2)
_GUICtrlListView_JustifyColumn($XBoot_Timer_hH, 1, 2)
_GUICtrlListView_JustifyColumn($XBoot_Timer_hH, 2, 2)
_GUICtrlListView_JustifyColumn($XBoot_Timer_hH, 3, 2)
_GUICtrlListView_JustifyColumn($XBoot_Timer_hH, 4, 2)
_GUICtrlListView_DeleteAllItems($XBoot_Timer_H)
GUICtrlCreateListViewItem("01|02|03|04|05", $XBoot_Timer_H)
GUICtrlCreateListViewItem("06|07|08|09|10", $XBoot_Timer_H)
For $i = 11 To 20
    GUICtrlCreateListViewItem($i & "|" & $i + 1 & "|" & $i + 2 & "|" & $i + 3 & "|" & $i + 4, $XBoot_Timer_H)
    $i = $i + 5
Next
GUICtrlCreateListViewItem("21|22|23|24", $XBoot_Timer_H)

$XBoot_Timer_P = GUICtrlCreateListView("x|y|z|a|e|l", 400, 200, 240, 190, $LVS_NOCOLUMNHEADER, 0)
$XBoot_Timer_hP = GUICtrlGetHandle($XBoot_Timer_P)
_GUICtrlListView_SetExtendedListViewStyle($XBoot_Timer_P, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_SetColumnWidth($XBoot_Timer_hP, 0, 40)
_GUICtrlListView_SetColumnWidth($XBoot_Timer_hP, 1, 40)
_GUICtrlListView_SetColumnWidth($XBoot_Timer_hP, 2, 40)
_GUICtrlListView_SetColumnWidth($XBoot_Timer_hP, 3, 40)
_GUICtrlListView_SetColumnWidth($XBoot_Timer_hP, 4, 40)
_GUICtrlListView_SetColumnWidth($XBoot_Timer_hP, 5, 40)
_GUICtrlListView_SetColumnWidth($XBoot_Timer_hP, 6, 40)
_GUICtrlListView_JustifyColumn($XBoot_Timer_hP, 0, 2)
_GUICtrlListView_JustifyColumn($XBoot_Timer_hP, 1, 2)
_GUICtrlListView_JustifyColumn($XBoot_Timer_hP, 2, 2)
_GUICtrlListView_JustifyColumn($XBoot_Timer_hP, 3, 2)
_GUICtrlListView_JustifyColumn($XBoot_Timer_hP, 4, 2)
_GUICtrlListView_JustifyColumn($XBoot_Timer_hP, 5, 2)
_GUICtrlListView_JustifyColumn($XBoot_Timer_hP, 6, 2)
_GUICtrlListView_DeleteAllItems($XBoot_Timer_P)
GUICtrlCreateListViewItem("00|01|02|03|04|05", $XBoot_Timer_P)
GUICtrlCreateListViewItem("06|07|08|09|10|11", $XBoot_Timer_P)
For $i = 12 To 57
    GUICtrlCreateListViewItem($i & "|" & $i + 1 & "|" & $i + 2 & "|" & $i + 3 & "|" & $i + 4 & "|" & $i + 5, $XBoot_Timer_P)
    $i = $i + 5
Next


GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")


GUISetState()
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
;~      Case $iButton
;~          MsgBox(0, "Info", "Cell selected: " & _GUICtrlListView_GetItemText($hListview, $aHit[0], $aHit[1]) & @CR, 0, $hGUI)
    EndSwitch
WEnd


Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $tNMHDR, $hWndFrom, $iCode
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom

        Case $XBoot_Timer_hH
            Switch $iCode
                Case $LVN_ITEMCHANGED
                    Local $tNMLISTVIEW, $iItem, $aInfo
                    $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam)
                    $iItem = DllStructGetData($tNMLISTVIEW, "Item")
                    _GUICtrlListView_SetItemSelected($XBoot_Timer_hH, $iItem, False)
                    Local $aInfo = GUIGetCursorInfo($Form1)
                    If $aInfo[2] Then
                        $aInfo = _GUICtrlListView_SubItemHitTest($XBoot_Timer_hH, $aInfo[0] - 100, $aInfo[1] - 200) ; Upper left = ( 2, 2 )
                        If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then
                            If $aHit[0] > -1 Then _GUICtrlListView_RedrawItems($XBoot_Timer_hH, $aHit[0], $aHit[0])
                            If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then
                                $aHit[0] = $aInfo[0] ; Row
                                $aHit[1] = $aInfo[1] ; Col
                            Else
                                $aHit[0] = -1 ; Row
                                $aHit[1] = -1 ; Col
                            EndIf
                            _GUICtrlListView_RedrawItems($XBoot_Timer_hH, $iItem, $iItem)
                        EndIf
                    EndIf
                Case $NM_CUSTOMDRAW
                    Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                    Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage")
                    Switch $dwDrawStage ; Holds a value that specifies the drawing stage
                        Case $CDDS_PREPAINT ; Before the paint cycle begins
                            Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations
                        Case $CDDS_ITEMPREPAINT ; Before painting an item
                            Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations
                        Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem
                            Local $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index
                            Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index
                            Local $uItemState = DllStructGetData($tNMLVCUSTOMDRAW, "uItemState") ; Item state
                            If $dwItemSpec = $aHit[0] Then ; Marked row
                                Switch $iSubItem
                                    Case $aHit[1] ; Marked column
                                        DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF) ; Forecolor white
                                        DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600) ; Backcolor dark blue, BGR
                                    Case Else ; Other columns
                                        DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) ; Forecolor black
                                        DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) ; Backcolor white
                                EndSwitch
                            Else ; Other rows
                                DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000)
                                DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF)
                            EndIf
                            Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors
                    EndSwitch
            EndSwitch


        Case $XBoot_Timer_hP
            Switch $iCode
                Case $LVN_ITEMCHANGED
                    Local $tNMLISTVIEW, $iItem, $aInfo
                    $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam)
                    $iItem = DllStructGetData($tNMLISTVIEW, "Item")
                    _GUICtrlListView_SetItemSelected($XBoot_Timer_hP, $iItem, False)
                    Local $aInfo = GUIGetCursorInfo($Form1)
                    If $aInfo[2] Then
                        $aInfo = _GUICtrlListView_SubItemHitTest($XBoot_Timer_hP, $aInfo[0] - 400, $aInfo[1] - 200) ; Upper left = ( 2, 2 )
                        If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then
                            If $aHit[0] > -1 Then _GUICtrlListView_RedrawItems($XBoot_Timer_hP, $aHit[0], $aHit[0])
                            If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then
                                $aHit[0] = $aInfo[0] ; Row
                                $aHit[1] = $aInfo[1] ; Col
                            Else
                                $aHit[0] = -1 ; Row
                                $aHit[1] = -1 ; Col
                            EndIf
                            _GUICtrlListView_RedrawItems($XBoot_Timer_hP, $iItem, $iItem)
                        EndIf
                    EndIf
                Case $NM_CUSTOMDRAW
                    Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                    Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage")
                    Switch $dwDrawStage ; Holds a value that specifies the drawing stage
                        Case $CDDS_PREPAINT ; Before the paint cycle begins
                            Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations
                        Case $CDDS_ITEMPREPAINT ; Before painting an item
                            Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations
                        Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem
                            Local $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index
                            Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index
                            Local $uItemState = DllStructGetData($tNMLVCUSTOMDRAW, "uItemState") ; Item state
                            If $dwItemSpec = $aHit[0] Then ; Marked row
                                Switch $iSubItem
                                    Case $aHit[1] ; Marked column
                                        DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF) ; Forecolor white
                                        DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600) ; Backcolor dark blue, BGR
                                    Case Else ; Other columns
                                        DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) ; Forecolor black
                                        DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) ; Backcolor white
                                EndSwitch
                            Else ; Other rows
                                DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000)
                                DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF)
                            EndIf
                            Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors
                    EndSwitch
            EndSwitch






    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

 

Edited by DuyAnh

Share this post


Link to post
Share on other sites

Maybe the GUIListViewEX UDF is what you are looking for:

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
9 minutes ago, water said:

Maybe the GUIListViewEX UDF is what you are looking for:

 

please let me demo :(

Share this post


Link to post
Share on other sites

Did you read the thread I pointed you to?

Quote

Here is the UDF, with 6 examples and the guide, in zip format: GUIListViewEx.zip

We do not spoon feed users here. You need to show some effort yourself ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
5 minutes ago, water said:

Did you read the thread I pointed you to?

We do not spoon feed users here. You need to show some effort yourself ;)

All 6 example are not in line with my idea to do :(I've tried both 6 example

Share this post


Link to post
Share on other sites
5 minutes ago, water said:

Did you read the thread I pointed you to?

We do not spoon feed users here. You need to show some effort yourself ;)

All 6 example are not in line with my idea to do :(I've tried both 6 example

Share this post


Link to post
Share on other sites

DuyAnh,

A quick example of using an input control to present numbers in tabular format.

#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <array.au3>

#AutoIt3Wrapper_Add_Constants=n

; create array to hold control ids and randomly generated numbers

Local $aCtl[100][2]
For $1 = 0 To 99
    $aCtl[$1][1] = Random(1, 100, 1)
Next

Local $cell_h = 20  ;   cell height
Local $cell_w = 20  ;   cell width

; number of rows and columns can contain any number you like but num*col cannot exceed 100 (size of the control array)

Local $num_r = 5    ;   number of rows
Local $num_c = 20   ;   number of columns

Local $left = 0     ;   starting left offset for control position
Local $top = 0      ;   starting top offset for control position
Local $idx = 0      ;   starting array index

Local $gui010 = GUICreate('Grid Test', $cell_w * $num_c, $cell_h * $num_r)

; create and populate an input control for each entry in $aCtl

For $1 = 1 To $num_r
    For $2 = 1 To $num_c
        $aCtl[$idx][0] = GUICtrlCreateInput('', $left, $top, $cell_w, $cell_h)
        GUICtrlSetData($aCtl[$idx][0], $aCtl[$idx][1])
        $left += $cell_w
        $idx += 1
    Next
    $left = 0
    $top += $cell_h
Next

GUISetState()

GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')

Local $msg

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $gui_event_close
            Exit
    EndSwitch
WEnd

; dedtects when an edit/input control gains kb focus

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    Switch BitAND($wParam, 0xFFFF)
        Case $aCtl[0][0] To $aCtl[UBound($aCtl) - 1][0]
            Switch BitShift($wParam, 16)
                Case $EN_setfocus
                    ConsoleWrite('You pressed ' & GUICtrlRead(BitAND($wParam, 0xFFFF)) & @CRLF)
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_COMMAND

Note - proof of concept only.  You will have to adapt it to you needs.

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

Share this post


Link to post
Share on other sites
On 8/16/2016 at 5:27 AM, kylomas said:

DuyAnh,

A quick example of using an input control to present numbers in tabular format.

#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <array.au3>

#AutoIt3Wrapper_Add_Constants=n

; create array to hold control ids and randomly generated numbers

Local $aCtl[100][2]
For $1 = 0 To 99
    $aCtl[$1][1] = Random(1, 100, 1)
Next

Local $cell_h = 20  ;   cell height
Local $cell_w = 20  ;   cell width

; number of rows and columns can contain any number you like but num*col cannot exceed 100 (size of the control array)

Local $num_r = 5    ;   number of rows
Local $num_c = 20   ;   number of columns

Local $left = 0     ;   starting left offset for control position
Local $top = 0      ;   starting top offset for control position
Local $idx = 0      ;   starting array index

Local $gui010 = GUICreate('Grid Test', $cell_w * $num_c, $cell_h * $num_r)

; create and populate an input control for each entry in $aCtl

For $1 = 1 To $num_r
    For $2 = 1 To $num_c
        $aCtl[$idx][0] = GUICtrlCreateInput('', $left, $top, $cell_w, $cell_h)
        GUICtrlSetData($aCtl[$idx][0], $aCtl[$idx][1])
        $left += $cell_w
        $idx += 1
    Next
    $left = 0
    $top += $cell_h
Next

GUISetState()

GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')

Local $msg

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $gui_event_close
            Exit
    EndSwitch
WEnd

; dedtects when an edit/input control gains kb focus

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    Switch BitAND($wParam, 0xFFFF)
        Case $aCtl[0][0] To $aCtl[UBound($aCtl) - 1][0]
            Switch BitShift($wParam, 16)
                Case $EN_setfocus
                    ConsoleWrite('You pressed ' & GUICtrlRead(BitAND($wParam, 0xFFFF)) & @CRLF)
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_COMMAND

Note - proof of concept only.  You will have to adapt it to you needs.

kylomas

thanks you :D

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