PB.Ex GridGadget (Windows)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

PB.Ex GridGadget (Windows)

Post by RSBasic »

Hello

With this library you can create a GridGadget like you know it in .NET Forms.

Screenshot:
Image

Functions:
  • GridGadget()
    • Syntax:

      Code: Select all

      Result = GridGadget(ID, X, Y, Width, Height, Flags, ParentWindowID, @ErrorOutput$)
    • Description: Creates a new GridGadget.
    • Parameter:
      1. ID: A unique number. #PB_Any can be used to generate the number automatically.
      2. X: The position of the gadget on the window.
      3. Y: The position of the gadget on the window.
      4. Width: The width of the gedget on the window.
      5. Height: The height of the gedget on the window.
      6. Flags: The following constants can be used:
        • #PBEx_GridGadget_Flag_AllowAddRows
        • #PBEx_GridGadget_Flag_AllowDeleteRows
        • #PBEx_GridGadget_Flag_AllowOrderColumns
        • #PBEx_GridGadget_Flag_AllowResizeColumns
        • #PBEx_GridGadget_Flag_AllowResizeRows
        • #PBEx_GridGadget_Flag_AllowResizeColumnHeight
        • #PBEx_GridGadget_Flag_AllowResizeRowWidth
        • #PBEx_GridGadget_Flag_HideColumnHeader
        • #PBEx_GridGadget_Flag_HideRowHeader
        • #PBEx_GridGadget_Flag_MultiSelect
        • #PBEx_GridGadget_Flag_ReadOnly
        • #PBEx_GridGadget_Flag_AutoColumnWidth
      7. ParentWindowID: The ID of the window on which the gadget is to be created. The ID of the window can be determined with WindowID().
      8. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful. If #PB_Any is used, the ID is returned.
    • Beispielcode:

      Code: Select all

      ;1.0.1.0
      
      EnableExplicit
      
      Global PBEx_GridGadget
      
      #PBEx_GridGadget_Version$ = "1.0.1.0"
      #PBEx_GridGadget_Flag_AllowAddRows = 1
      #PBEx_GridGadget_Flag_AllowDeleteRows = 2
      #PBEx_GridGadget_Flag_AllowOrderColumns = 4
      #PBEx_GridGadget_Flag_AllowResizeColumns = 8
      #PBEx_GridGadget_Flag_AllowResizeRows = 16
      #PBEx_GridGadget_Flag_AllowResizeColumnHeight = 32
      #PBEx_GridGadget_Flag_AllowResizeRowWidth = 64
      #PBEx_GridGadget_Flag_HideColumnHeader = 128
      #PBEx_GridGadget_Flag_HideRowHeader = 256
      #PBEx_GridGadget_Flag_MultiSelect = 512
      #PBEx_GridGadget_Flag_ReadOnly = 1024
      #PBEx_GridGadget_Flag_AutoColumnWidth = 2048
      #PBEx_GridGadget_Type_Text = 0
      #PBEx_GridGadget_Type_Date = 7
      #PBEx_GridGadget_Type_Lowercase = 12
      #PBEx_GridGadget_Type_Uppercase = 13
      #PBEx_GridGadget_Type_Percent = 15
      #PBEx_GridGadget_Direction_Ascending = 0
      #PBEx_GridGadget_Direction_Descending = 1
      #PBEx_GridGadget_ColumnWidth_AutoColumnWidth = -1
      #PBEx_GridGadget_Attribute_SelectType = 1
      #PBEx_GridGadget_Attribute_SelectType_CellSelect = 1
      #PBEx_GridGadget_Attribute_SelectType_FullRowSelect = 2
      #PBEx_GridGadget_Attribute_SelectType_RowHeaderSelect = 4
      
      CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
        PBEx_GridGadget = OpenLibrary(#PB_Any, "PB.Ex_GridGadget_x86.dll")
      CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64
        PBEx_GridGadget = OpenLibrary(#PB_Any, "PB.Ex_GridGadget_x64.dll")
      CompilerEndIf
      
      If PBEx_GridGadget
        Prototype GridGadget(ID, X, Y, Width, Height, Flags, ParentWindowID, ErrorOutput)
        Global GridGadget.GridGadget = GetFunction(PBEx_GridGadget, "GridGadget")
        Prototype AddGridGadgetColumn(ID, Position, Type, Text.p-Unicode, Width, ErrorOutput)
        Global AddGridGadgetColumn.AddGridGadgetColumn = GetFunction(PBEx_GridGadget, "AddGridGadgetColumn")
        Prototype RemoveGridGadgetColumn(ID, Position, ErrorOutput)
        Global RemoveGridGadgetColumn.RemoveGridGadgetColumn = GetFunction(PBEx_GridGadget, "RemoveGridGadgetColumn")
        Prototype AddGridGadgetItem(ID, Position, Text.p-Unicode, ErrorOutput)
        Global AddGridGadgetItem.AddGridGadgetItem = GetFunction(PBEx_GridGadget, "AddGridGadgetItem")
        Prototype RemoveGridGadgetItem(ID, Position, ErrorOutput)
        Global RemoveGridGadgetItem.RemoveGridGadgetItem = GetFunction(PBEx_GridGadget, "RemoveGridGadgetItem")
        Prototype CountGridGadgetColumns(ID, ErrorOutput)
        Global CountGridGadgetColumns.CountGridGadgetColumns = GetFunction(PBEx_GridGadget, "CountGridGadgetColumns")
        Prototype CountGridGadgetItems(ID, ErrorOutput)
        Global CountGridGadgetItems.CountGridGadgetItems = GetFunction(PBEx_GridGadget, "CountGridGadgetItems")
        Prototype ClearGridGadgetColumns(ID, ErrorOutput)
        Global ClearGridGadgetColumns.ClearGridGadgetColumns = GetFunction(PBEx_GridGadget, "ClearGridGadgetColumns")
        Prototype ClearGridGadgetItems(ID, ErrorOutput)
        Global ClearGridGadgetItems.ClearGridGadgetItems = GetFunction(PBEx_GridGadget, "ClearGridGadgetItems")
        Prototype GetGridGadgetColumnText(ID, Position, Output, ErrorOutput)
        Global GetGridGadgetColumnText.GetGridGadgetColumnText = GetFunction(PBEx_GridGadget, "GetGridGadgetColumnText")
        Prototype SetGridGadgetColumnText(ID, Position, Text.p-Unicode, ErrorOutput)
        Global SetGridGadgetColumnText.SetGridGadgetColumnText = GetFunction(PBEx_GridGadget, "SetGridGadgetColumnText")
        Prototype GetGridGadgetItemText(ID, Position, Column, Output, ErrorOutput)
        Global GetGridGadgetItemText.GetGridGadgetItemText = GetFunction(PBEx_GridGadget, "GetGridGadgetItemText")
        Prototype SetGridGadgetItemText(ID, Position, Column, Text.p-Unicode, ErrorOutput)
        Global SetGridGadgetItemText.SetGridGadgetItemText = GetFunction(PBEx_GridGadget, "SetGridGadgetItemText")
        Prototype FreeGridGadget(ID, ErrorOutput)
        Global FreeGridGadget.FreeGridGadget = GetFunction(PBEx_GridGadget, "FreeGridGadget")
        Prototype GridGadgetWidth(ID, ErrorOutput)
        Global GridGadgetWidth.GridGadgetWidth = GetFunction(PBEx_GridGadget, "GridGadgetWidth")
        Prototype GridGadgetHeight(ID, ErrorOutput)
        Global GridGadgetHeight.GridGadgetHeight = GetFunction(PBEx_GridGadget, "GridGadgetHeight")
        Prototype GridGadgetX(ID, ErrorOutput)
        Global GridGadgetX.GridGadgetX = GetFunction(PBEx_GridGadget, "GridGadgetX")
        Prototype GridGadgetY(ID, ErrorOutput)
        Global GridGadgetY.GridGadgetY = GetFunction(PBEx_GridGadget, "GridGadgetY")
        Prototype GridGadgetID(ID, ErrorOutput)
        Global GridGadgetID.GridGadgetID = GetFunction(PBEx_GridGadget, "GridGadgetID")
        Prototype HideGridGadget(ID, State, ErrorOutput)
        Global HideGridGadget.HideGridGadget = GetFunction(PBEx_GridGadget, "HideGridGadget")
        Prototype IsGridGadget(ID, ErrorOutput)
        Global IsGridGadget.IsGridGadget = GetFunction(PBEx_GridGadget, "IsGridGadget")
        Prototype ResizeGridGadget(ID, X, Y, Width, Height, ErrorOutput)
        Global ResizeGridGadget.ResizeGridGadget = GetFunction(PBEx_GridGadget, "ResizeGridGadget")
        Prototype SortGridGadgetColumn(ID, Column, Direction, ErrorOutput)
        Global SortGridGadgetColumn.SortGridGadgetColumn = GetFunction(PBEx_GridGadget, "SortGridGadgetColumn")
        Prototype DisableGridGadget(ID, State, ErrorOutput)
        Global DisableGridGadget.DisableGridGadget = GetFunction(PBEx_GridGadget, "DisableGridGadget")
        Prototype SetGridGadgetAttribute(ID, Attribute, Value, ErrorOutput)
        Global SetGridGadgetAttribute.SetGridGadgetAttribute = GetFunction(PBEx_GridGadget, "SetGridGadgetAttribute")
        Prototype GetGridGadgetAttribute(ID, Attribute, ErrorOutput)
        Global GetGridGadgetAttribute.GetGridGadgetAttribute = GetFunction(PBEx_GridGadget, "GetGridGadgetAttribute")
        
      EndIf
      
      Global Output$ = Space(1024)
      Global ErrorOutput$ = Space(128)
      Global a
      
      If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
        GridGadget(1, 0, 0, 500, 400, #PBEx_GridGadget_Flag_AllowAddRows | #PBEx_GridGadget_Flag_AllowDeleteRows | #PBEx_GridGadget_Flag_AutoColumnWidth | #PBEx_GridGadget_Flag_MultiSelect, WindowID(0), @ErrorOutput$)
        AddGridGadgetColumn(1, -1, 0, "Column 1", 100, @ErrorOutput$)
        AddGridGadgetColumn(1, -1, 0, "Column 2", 100, @ErrorOutput$)
        AddGridGadgetColumn(1, -1, 0, "Column 3", 100, @ErrorOutput$)
        
        For a=1 To 9
          AddGridGadgetItem(1, -1, "Hello " + Str(a) + Chr(10) + "PureBasic " + Str(a) + Chr(10) + "Friends " + Str(a), @ErrorOutput$)
        Next
        
        Repeat
          Select WaitWindowEvent()
            Case #PB_Event_CloseWindow
              CloseLibrary(PBEx_GridGadget)
              End
          EndSelect
        ForEver
      EndIf
    AddGridGadgetColumn()
    • Syntax:

      Code: Select all

      Result = AddGridGadgetColumn(ID, Position, Type, Text$, Width, @ErrorOutput$)
    • Description: Adds a new column.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: Defines the position that is ascending. The value "-1" can be used to always add the column at the end.
      3. Type: Defines the type of the column. The following constants can be used:
        • #PBEx_GridGadget_Type_Text
        • #PBEx_GridGadget_Type_Date
        • #PBEx_GridGadget_Type_Lowercase
        • #PBEx_GridGadget_Type_Uppercase
        • #PBEx_GridGadget_Type_Percent
      4. Text$: The heading of the column.
      5. Width: The width of the column. If #PBEx_GridGadget_Flag_AutoColumnWidth is used, this parameter is ignored. #PBEx_GridGadget_ColumnWidth_AutoColumnWidth can be used to automatically adjust the column width to the available width.
      6. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    RemoveGridGadgetColumn()
    • Syntax:

      Code: Select all

      Result = RemoveGridGadgetColumn(ID, Position, @ErrorOutput$)
    • Description: Removes an existing column. After deletion, all cell values in this column are also removed.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: The position of the column.
      3. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    AddGridGadgetItem()
    • Syntax:

      Code: Select all

      Result = AddGridGadgetItem(ID, Position, Text$, @ErrorOutput$)
    • Description: Adds a new line.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: Defines the position that is ascending. The value "-1" can be used to always add the line at the end.
      3. Text$: The text for the first cell. Chr(10) can be used to insert texts for other cells.
      4. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    RemoveGridGadgetItem()
    • Syntax:

      Code: Select all

      Result = RemoveGridGadgetItem(ID, Position, @ErrorOutput$)
    • Description: Removes an existing row. All cell values of this row are also deleted.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: The position of the line.
      3. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    CountGridGadgetColumns()
    • Syntax:

      Code: Select all

      Result = CountGridGadgetColumns(ID, @ErrorOutput$)
    • Description: Determines the number of columns.
    • Parameter:
      1. ID: The number of the gadget.
      2. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value: Number of columns.
    CountGridGadgetItems()
    • Syntax:

      Code: Select all

      Result = CountGridGadgetItems(ID, @ErrorOutput$)
    • Description: Determines the number of rows.
    • Parameter:
      1. ID: The number of the gadget.
      2. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value: Number of rows.
    ClearGridGadgetColumns()
    • Syntax:

      Code: Select all

      Result = ClearGridGadgetColumns(ID, @ErrorOutput$)
    • Description: Removes all columns. All rows are also deleted.
    • Parameter:
      1. ID: The number of the gadget.
      2. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    ClearGridGadgetItems()
    • Syntax:

      Code: Select all

      Result = ClearGridGadgetItems(ID, @ErrorOutput$)
    • Description: Removes all rows.
    • Parameter:
      1. ID: The number of the gadget.
      2. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    GetGridGadgetColumnText()
    • Syntax:

      Code: Select all

      Result = GetGridGadgetColumnText(ID, Position, @Output$, @ErrorOutput$)
    • Description: Determines the heading of a column.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: The position of the column.
      3. @Output$: The column heading is stored in this variable. If 0 was passed, the length is returned as the return value.
      4. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    SetGridGadgetColumnText()
    • Syntax:

      Code: Select all

      Result = SetGridGadgetColumnText(ID, Position, Text$, @ErrorOutput$)
    • Description: Changes the heading of a column.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: The position of the column.
      3. Text$: The new heading of the column.
      4. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    GetGridGadgetItemText()
    • Syntax:

      Code: Select all

      Result = GetGridGadgetItemText(ID, Position, Column, @Output$, @ErrorOutput$)
    • Description: Determines the contents of a cell.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: The position of the line.
      3. Column: The position of the column.
      4. @Output$: The contents of the cell are stored in this variable. If 0 was passed, the length is returned as the return value.
      5. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    SetGridGadgetItemText()
    • Syntax:

      Code: Select all

      Result = SetGridGadgetItemText(ID, Position, Column, Text$, @ErrorOutput$)
    • Description: Changes the contents of a cell.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: The position of the line.
      3. Column: The position of the column.
      4. Text$: The new contents of the cell.
      5. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    FreeGridGadget()
    • Syntax:

      Code: Select all

      Result = FreeGridGadget(ID, @ErrorOutput$)
    • Description: Free the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    GridGadgetWidth()
    • Syntax:

      Code: Select all

      Result = GridGadgetWidth(ID, @ErrorOutput$)
    • Description: Determines the width of the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value: The width of the gadget.
    GridGadgetHeight()
    • Syntax:

      Code: Select all

      Result = GridGadgetWidth(ID, @ErrorOutput$)
    • Description: Determines the height of the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value: The height of the gadget.
    GridGadgetX()
    • Syntax:

      Code: Select all

      Result = GridGadgetX(ID, @ErrorOutput$)
    • Description: Determines the position of the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value: The position of the gadget.
    GridGadgetY()
    • Syntax:

      Code: Select all

      Result = GridGadgetY(ID, @ErrorOutput$)
    • Description: Determines the position of the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value: The position of the gadget.
    GridGadgetID()
    • Syntax:

      Code: Select all

      Result = GridGadgetID(ID, @ErrorOutput$)
    • Description: Determines the handle number of the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value: The handle number of the gadget.
    HideGridGadget()
    • Syntax:

      Code: Select all

      Result = HideGridGadget(ID, State, @ErrorOutput$)
    • Description: Hides or displays the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. State:
        • 0: Displays the gadget.
        • 1: Hide the gadget.
      3. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    IsGridGadget()
    • Syntax:

      Code: Select all

      Result = IsGridGadget(ID, @ErrorOutput$)
    • Description: Checks if the gadget is valid.
    • Parameter:
      1. ID: The number of the gadget.
      2. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The gadget is valid.
    ResizeGridGadget()
    • Syntax:

      Code: Select all

      Result = ResizeGridGadget(ID, X, Y, Width, Height, @ErrorOutput$)
    • Description: Changes the position and size of the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. X: The new position of the gadget. #PB_Ignore can be used not to change this value.
      3. Y: The new position of the gadget. #PB_Ignore can be used not to change this value.
      4. Width: The new height of the gadget. #PB_Ignore can be used not to change this value.
      5. Height: The new width of the gadget. #PB_Ignore can be used not to change this value.
      6. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    SortGridGadgetColumn()
    • Syntax:

      Code: Select all

      Result = SortGridGadgetColumn(ID, Column, Direction, @ErrorOutput$)
    • Description: Sorts a column.
    • Parameter:
      1. ID: The number of the gadget.
      2. Column: The position of the column.
      3. Direction: The following constants can be used:
        • #PBEx_GridGadget_Direction_Ascending
        • #PBEx_GridGadget_Direction_Descending
      4. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    DisableGridGadget()
    • Syntax:

      Code: Select all

      Result = DisableGridGadget(ID, State, @ErrorOutput$)
    • Description: Enables or disables the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. State:
        • 0: Gadget is activated.
        • 1: Gadget is deactivated.
      3. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    SetGridGadgetAttribute()
    • Syntax:

      Code: Select all

      Result = SetGridGadgetAttribute(ID, Attribute, Value, @ErrorOutput$)
    • Description: Changes a setting using the attribute.
    • Parameter:
      1. ID: The number of the gadget.
      2. Attribute: The following constants can be used:
        • #PBEx_GridGadget_Attribute_SelectType
      3. Value: The following constants can be used:
        • #PBEx_GridGadget_Attribute_SelectType:
          • #PBEx_GridGadget_Attribute_SelectType_CellSelect: Only individual cells can be selected, not entire rows.
          • #PBEx_GridGadget_Attribute_SelectType_FullRowSelect: Only whole lines can be selected.
          • #PBEx_GridGadget_Attribute_SelectType_RowHeaderSelect: Individual cells and entire rows can be selected.
      4. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    GetGridGadgetAttribute()
    • Syntax:

      Code: Select all

      Result = GetGridGadgetAttribute(ID, Attribute, @ErrorOutput$)
    • Description: Determines the value of the setting using the attribute.
    • Parameter:
      1. ID: The number of the gadget.
      2. Attribute: The following constants can be used:
        • #PBEx_GridGadget_Attribute_SelectType
      3. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • #PBEx_GridGadget_Attribute_SelectType:
        • #PBEx_GridGadget_Attribute_SelectType_CellSelect: Only individual cells can be selected, not entire rows.
        • #PBEx_GridGadget_Attribute_SelectType_FullRowSelect: Only whole lines can be selected.
        • #PBEx_GridGadget_Attribute_SelectType_RowHeaderSelect: Individual cells and entire rows can be selected.
    GetGridGadgetState()
    • Syntax:

      Code: Select all

      Result = GetGridGadgetState(ID, @ErrorOutput$)
    • Description: Determines the position of the first selected line.
    • Parameter:
      1. ID: The number of the gadget.
      2. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value: The position of the first selected row.
    GetGridGadgetItemState()
    • Syntax:

      Code: Select all

      Result = GetGridGadgetItemState(ID, Position, Column, @ErrorOutput$)
    • Description: Checks whether the specified cell is selected.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: The position of the line.
      3. Column: The position of the column.
      4. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The cell is selected.
    SetGridGadgetState()
    • Syntax:

      Code: Select all

      Result = SetGridGadgetState(ID, Position, State, @ErrorOutput$)
    • Description: Selects the specified line.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: The position of the line.
      3. State:
        • 0: Cancels the selection.
        • 1: Select
      4. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    SetGridGadgetItemState()
    • Syntax:

      Code: Select all

      Result = SetGridGadgetItemState(ID, Position, Column, State, @ErrorOutput$)
    • Description: Selects the specified cell.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: The position of the line.
      3. Column: The position of the column.
      4. State:
        • 0: Cancels the selection.
        • 1: Select
      5. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The cell is selected.
    SetGridGadgetColor()
    • Syntax:

      Code: Select all

      Result = SetGridGadgetColor(ID, ColorType, Color, @ErrorOutput$)
    • Description: Changes the color of the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. ColorType: The following constants can be used:
        • #PBEx_GridGadget_ColorType_FrontColor
        • #PBEx_GridGadget_ColorType_BackColor
      3. Color: The color that can be set with RGB().
      4. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    GetGridGadgetColor()
    • Syntax:

      Code: Select all

      Result = GetGridGadgetColor(ID, ColorType, @ErrorOutput$)
    • Description: Determines the color of the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. ColorType: The following constants can be used:
        • #PBEx_GridGadget_ColorType_FrontColor
        • #PBEx_GridGadget_ColorType_BackColor
      3. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value: RGB color
    SetGridGadgetItemColor()
    • Syntax:

      Code: Select all

      Result = SetGridGadgetItemColor(ID, Position, Column, ColorType, Color, @ErrorOutput$)
    • Description: Changes the color of the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: The position of the line.
      3. Column: The position of the column.
      4. ColorType: The following constants can be used:
        • #PBEx_GridGadget_ColorType_FrontColor
        • #PBEx_GridGadget_ColorType_BackColor
      5. Color: The color that can be set with RGB().
      6. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value:
      • 1: The process was successful.
    GetGridGadgetItemColor()
    • Syntax:

      Code: Select all

      Result = GetGridGadgetItemColor(ID, Position, Column, ColorType, @ErrorOutput$)
    • Description: Determines the color of the gadget.
    • Parameter:
      1. ID: The number of the gadget.
      2. Position: The position of the line.
      3. Column: The position of the column.
      4. ColorType: The following constants can be used:
        • #PBEx_GridGadget_ColorType_FrontColor
        • #PBEx_GridGadget_ColorType_BackColor
      5. @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum length of the return is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
    • Return value: RGB color
System requirements:
  • Windows Vista or higher
  • .NET Framework 4.5 or higher
  • Unicode activation (default from PB 5.50)
Licence: This DLL file is free of charge and may be used both privately and commercially.

Download: https://www.rsbasic.de/downloads/downlo ... Gadget.zip
Image

I would be very pleased about feedbacks, improvement suggestions, error messages or wishes. If you want to support me, you can also donate something. Thanks :)
Image
Image
User avatar
Lord
Addict
Addict
Posts: 849
Joined: Tue May 26, 2009 2:11 pm

Re: PB.Ex GridGadget (Windows)

Post by Lord »

Hi,

is resizing not allowed? :shock:
[08:19:24] Warte auf den Start des Executable...
[08:19:24] Executable-Typ: Windows - x64 (64bit, Unicode)
[08:19:24] Executable gestartet.
[08:19:27] [ERROR] PB.Ex_GridGadget.pb (Zeile: 87)
[08:19:27] [ERROR] Das angegebene #Gadget ist nicht initialisiert.
I added also #PBEx_GridGadget_Flag_AllowResizeColumns, #PBEx_GridGadget_Flag_AllowResizeRows
and #PBEx_GridGadget_Flag_AllowResizeRowWidth, but that doesn't help.

Code: Select all

Global Output$ = Space(1024)
Global ErrorOutput$ = Space(128)
Global a

Procedure myResize()
  ResizeGadget(1, #PB_Ignore, #PB_Ignore, WindowWidth(0), WindowHeight(0))
EndProcedure

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
  GridGadget(1, 0, 0, 500, 400, #PBEx_GridGadget_Flag_AllowAddRows | 
                                #PBEx_GridGadget_Flag_AllowDeleteRows |
                                #PBEx_GridGadget_Flag_AutoColumnWidth |
                                #PBEx_GridGadget_Flag_AllowResizeColumns |
                                #PBEx_GridGadget_Flag_AllowResizeRows |
                                #PBEx_GridGadget_Flag_AllowResizeRowWidth,
             WindowID(0), @ErrorOutput$)
  AddGridGadgetColumn(1, -1, 0, "Column 1", 100, @ErrorOutput$)
  AddGridGadgetColumn(1, -1, 0, "Column 2", 100, @ErrorOutput$)
  AddGridGadgetColumn(1, -1, 0, "Column 3", 100, @ErrorOutput$)
  
  For a=1 To 9
    AddGridGadgetItem(1, -1, "Hello " + Str(a) + Chr(10) + "PureBasic " + Str(a) + Chr(10) + "Friends " + Str(a), @ErrorOutput$)
  Next
  
  BindEvent(#PB_Event_SizeWindow, @myResize())
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        CloseLibrary(PBEx_GridGadget)
        End
    EndSelect
  ForEver
EndIf
Image
User avatar
Lord
Addict
Addict
Posts: 849
Joined: Tue May 26, 2009 2:11 pm

Re: PB.Ex GridGadget (Windows)

Post by Lord »

Kiffi wrote:@Lord: Remove #PBEx_GridGadget_Flag_AutoColumnWidth.
...
No, that doesn't work here.
Trying any combination of
#PBEx_GridGadget_Flag_AllowResizeColumns
#PBEx_GridGadget_Flag_AllowResizeRows
#PBEx_GridGadget_Flag_AllowResizeColumnHeight
#PBEx_GridGadget_Flag_AllowResizeRowWidth
with or without #PBEx_GridGadget_Flag_AutoColumnWidth
gives the same result.
Image
User avatar
Kiffi
Addict
Addict
Posts: 1357
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: PB.Ex GridGadget (Windows)

Post by Kiffi »

(my previous posting was nonsense. I misread your question)

@Lord: Use ResizeGridGadget() instead of ResizeGadget()

Greetings ... Peter
Hygge
User avatar
Lord
Addict
Addict
Posts: 849
Joined: Tue May 26, 2009 2:11 pm

Re: PB.Ex GridGadget (Windows)

Post by Lord »

:shock:
Where has Kiffi's posting gone???
Image
User avatar
Lord
Addict
Addict
Posts: 849
Joined: Tue May 26, 2009 2:11 pm

Re: PB.Ex GridGadget (Windows)

Post by Lord »

Kiffi wrote:(my previous posting was nonsense. I misread your question)

@Lord: Use ResizeGridGadget() instead of ResizeGadget()

Greetings ... Peter
OK. Now we are in line. :)

That works. Almost like expected.
But how we get only the last column resized, when the whole grid is resized?
I don't want all columns resized, only the last.
Maybe a switch aka #PBEx_GridGadget_Flag_AutoColumnWidthOnlyLastColumn
or an optional parameter for ResizeGridGadget:
ResizeGridGadget(ID, X, Y, Width, Height, ErrorOutput, Column=#all),
where column can be column number or #all.
Image
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex GridGadget (Windows)

Post by RSBasic »

PB.Ex GridGadget 1.0.1.0 has been released.

Changelog:
  • Added: #PBEx_GridGadget_ColumnWidth_AutoColumnWidth for AddGridGadgetColumn()
  • Added: SetGridGadgetAttribute()
  • Added: GetGridGadgetAttribute()
  • Added: DisableGridGadget()
  • Bugfix: AddGridGadgetItem() now works without #PBEx_GridGadget_Flag_AllowAddRows.
  • Changed: @Output$: If 0 is passed, then the required length for allocating the memory is returned as the return value of the respective function.
Lord wrote:But how we get only the last column resized, when the whole grid is resized
You can now use #PBEx_GridGadget_ColumnWidth_AutoColumnWidth on AddGridGadgetColumn().
Image
Image
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PB.Ex GridGadget (Windows)

Post by RSBasic »

PB.Ex GridGadget 1.0.2.0 has been released.

Changelog:
  • Added: GetGridGadgetState()
  • Added: GetGridGadgetItemState()
  • Added: SetGridGadgetState()
  • Added: SetGridGadgetItemState()
  • Added: SetGridGadgetColor()
  • Added: GetGridGadgetColor()
  • Added: SetGridGadgetItemColor()
  • Added: GetGridGadgetItemColor()
Image
Image
zikitrake
Addict
Addict
Posts: 834
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Re: PB.Ex GridGadget (Windows)

Post by zikitrake »

RSBasic wrote:PB.Ex GridGadget 1.0.2.0 has been released.....
This is wonderful, thank you so much!
Post Reply