AutoHotkey Community

It is currently May 26th, 2012, 9:05 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 219 posts ]  Go to page Previous  1 ... 10, 11, 12, 13, 14, 15  Next
Author Message
 Post subject:
PostPosted: April 15th, 2007, 1:43 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Ofcourse.
I will send you PM as soon as I can.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2007, 10:21 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
hi Micha,

I have started writing some wrappers for the grid control. I have come up with a feature request:

you have set it up so that you can change the color of every column in a row by setting the column to -1. This is quite nice. Can you also change SetGridCtrlRowColCountID to only modify the number of rows if the colum is set to -1?

Also, some function to get properties back from the control? (number of rows, cols, etc)

Thanks,
--engunneer

Here is a very early version of the wrapper code:

GridControl.ahk:
Code:
;GridControl.ahk
;Functions to wrap around Micha's excellent grid control

CtrlInit(GUItitle, CtrlDllPath="")
{
  WinGet, HWND, ID, %GUItitle%

  If (CtrlDllPath ="")
    CtrlDllPath = AHKCtrlSupport.dll
  ; Load the dll to speed up the following calls
  hModule := DllCall("LoadLibrary", "str", CtrlDllPath)

  nRC = 0
 
  DetectHiddenWindows, On
  MainHWND := WinExist(A_ScriptFullPath . " ahk_class AutoHotkey")
  nRC := DllCall("AHKCtrlSupport\Init", int, MainHWND, int, HWND, int, hModule, "Cdecl Int")
  If (Errorlevel <> 0) || (nRC = 0)
  {
       MsgBox, Error while calling Init Errorlevel: %Errorlevel% - RC: %nRC%
       Return
  }

  Return HWND
}

CtrlGridCreate(GUItitle, ByRef GridCtrlHwnd, ByRef nID, options = "")
{
  ;Needed for Copy/Paste of grid-control
  DllCall("ole32\OleInitialize", "Uint", 0)

  ; --------------- default options ---------------------------------------
  ; -----------------------------------------------------------------------
  width = 300
  height = 300
  x = 5
  y = 5
 
  ; --------------- parse options -----------------------------------------
  ; -----------------------------------------------------------------------
  Stringsplit option, options, %A_space%`,
  loop %option0% {
    Stringleft, option, option%A_index%, 1
    Stringtrimleft, value, option%A_index%, 1
    if (option = "w")
      width := value
    if (option = "h")
      height := value
    if (option = "x")
      x := value
    if (option = "y")
      y := value
  }
 
  ; --------------- Create a Grid Ctrl ------------------------------------
  ; -----------------------------------------------------------------------
  dwexStyle = 0
  nID = 2
 
  WinGet, HWND, ID, %GUItitle%
  GridCtrlHwnd := DllCall("AHKCtrlSupport\CreateGridCtrl"
                        , int, dwexStyle
                        , int, x
                        , int, y
                        , int, width
                        , int, height
                        , int, HWND
                        , int, nID
                        , "Cdecl Int")
  If (Errorlevel <> 0) || (GridCtrlHwnd = 0)
    {
       MsgBox, Error while calling CreateGridCtrl Errorlevel: %Errorlevel% - RC: %GridCtrl%
       Return
    }
 
  Return nID

}

CtrlGridSetRowColCount(nID, options = "")
{
  ;default to not changing, then the options can change one or both
  GCrows = -1
  GCcols = -1
 
  ; --------------- parse options -----------------------------------------
  ; -----------------------------------------------------------------------
  Stringsplit option, options, %A_space%`,
  loop %option0% {
    Stringleft, option, option%A_index%, 1
    Stringtrimleft, value, option%A_index%, 1
    if (option = "r")
      GCrows := value
    if (option = "c")
      GCcols := value
  }
 
  ; --------------- Set Row and Columncount. rows, cols -------------------
  ; -----------------------------------------------------------------------
  ;
  nRC := DllCall("AHKCtrlSupport\SetGridCtrlRowColCountID"
                                   , int, nID
                                   , int, GCrows
                                   , int, GCcols
                        , "Cdecl Int")
  If (Errorlevel <> 0) || (nRC = 0)
    {
       MsgBox, Error while calling SetGridCtrlRowColCountID Errorlevel: %Errorlevel% - RC: %nRC%
       Return
    }
}

CtrlGridSetFixedRowColCount(nID, options = "")
{
  global GCfrows, GCfcols     ;global so they can be static
 
  ; --------------- parse options -----------------------------------------
  ; -----------------------------------------------------------------------
  Stringsplit option, options, %A_space%`,
  loop %option0% {
    Stringleft, option, option%A_index%, 1
    Stringtrimleft, value, option%A_index%, 1
    if (option = "r")
      GCfrows := value
    if (option = "c")
      GCfcols := value
  }

  ; --------------- Set fixed Rows and Columns. ---------------------------
  ; --------- 1. parameter = rows, second parameter cols-------------------
  ; -------------- row and column are 1 based !!
  ;
  nRC := DllCall("AHKCtrlSupport\SetGridCtrlFixedRowColCountID"
                                   , int, nID
                                   , int, GCfrows
                                   , int, GCfcols
                        , "Cdecl Int")
  If (Errorlevel <> 0) || (nRC = 0)
    {
       MsgBox, Error while calling SetGridCtrlFixedRowColCountID Errorlevel: %Errorlevel% - RC: %nRC%
       Return
    }
}

CtrlGridSetCellText(GridCtrlHwnd, row, col, Text = "")
{
  ; -------------- row and column are 0 based !!
   nRC := DllCall("AHKCtrlSupport\SetGridItemText"
                                    , int, GridCtrlHwnd
                                    , int, row
                                    , int, col
                                    , str, Text
                         , "Cdecl Int")
   If (Errorlevel <> 0) || (nRC = 0)
     {
        MsgBox, Error while calling SetItemText Errorlevel: %Errorlevel% - RC: %nRC%
        Return
     }
}

CtrlGridSetRowHeight(GridCtrlHwnd, Row2Change, HeightofRow = 20, Refresh = 1)
{
  ; --------------- Set height of row in pixels----------------------------
  ; -----------------------------------------------------------------------
  ; --------------- Causes grid refresh by default ------------------------
  nRC := DllCall("AHKCtrlSupport\SetGridRowHeight"
                                   , int, GridCtrlHwnd
                                   , int, Row2Change
                                   , int, HeightofRow
                        , "Cdecl Int")
  If (Errorlevel <> 0) || (nRC = 0)
    {
       MsgBox, Error while calling SetGridRowHeight Errorlevel: %Errorlevel% - RC: %nRC%
       Return
    }
   
  If (Refresh = 1)
    CtrlGridRefresh(GridCtrlHwnd)
 
}

CtrlGridSetColWidth(GridCtrlHwnd, Col2Change, WidthOfRow = 60, Refresh = 1)
{
  ; --------------- Set width of colum in pixels---------------------------
  ; -----------------------------------------------------------------------
  ; --------------- Causes grid refresh by default ------------------------
  nRC := DllCall("AHKCtrlSupport\SetGridColumnWidth"
                                   , int, GridCtrlHwnd
                                   , int, Col2Change
                                   , int, WidthOfRow
                        , "Cdecl Int")
  If (Errorlevel <> 0) || (nRC = 0)
    {
       MsgBox, Error while calling SetGridColumnWidth Errorlevel: %Errorlevel% - RC: %nRC%
       Return
    }
  If (Refresh = 1)
    CtrlGridRefresh(GridCtrlHwnd)
 
}

CtrlGridRefresh(GridCtrlHwnd)
{
; --------------- After changing height, width and other things ---------
; ----------------the grid must be redrawn. Call this function-----------
; ----------------to refresh the grid------------------------------------
nRC := DllCall("AHKCtrlSupport\GridRefresh"
                                 , int, GridCtrlHwnd
                      , "Cdecl Int")
If (Errorlevel <> 0) || (nRC = 0)
  {
     MsgBox, Error while calling GridRefresh Errorlevel: %Errorlevel% - RC: %nRC%
     Return
  }
}

CtrlGridSetLines(GridCtrlHwnd, options = "")
{

  nValh = 0
  nValv = 0
  ; --------------- parse options -----------------------------------------
  ; -----------------------------------------------------------------------
  Stringsplit option, options, %A_space%`,
  loop %option0% {
    Stringleft, option, option%A_index%, 1
    Stringtrimleft, value, option%A_index%, 1
    if (option = "h")
      if (value = 1)
        nValh = 1
      else
        nValh = 0
    if (option = "v")
      if (value = 1)
        nValv = 2
      else
        nValv = 0
  }
  nVal := nValh + nValv
 
  ;Set both lines: 0= none; 1=horizontal, 2=vertical, 3=both
  ; --------------- How to draw lines of the grid--------------------------
  ; -----------------------------------------------------------------------
  nRC := DllCall("AHKCtrlSupport\SetGridLines"
                                   , int, GridCtrlHwnd
                                   , int, nVal
                        , "Cdecl Int")
  If (Errorlevel <> 0) || (nRC = 0)
    {
       MsgBox, Error while calling SetGridLines Errorlevel: %Errorlevel% - RC: %nRC%
       Return
    }
}

CtrlGridCopyPasteMode(GridCtrlHwnd, allowCommaDelimiter)
{
  ; --------------- When pasting 2,3 or 2{tab}3 the result is splitted-----
  ; ----------------into 2 different cells---------------------------------
  ; allowCommaDelimiter = 0 means only Tab to delimit!
  nRC := DllCall("AHKCtrlSupport\GridIgnoreCommaDotPaste"
                                , int, GridCtrlHwnd
                                , int, allowCommaDelimiter
                      , "Cdecl Int")
  If (Errorlevel <> 0) || (nRC = 0)
    {
       MsgBox, Error while calling SetEditible Errorlevel: %Errorlevel% - RC: %nRC%
       Return
    }
}

CtrlGridSetCellType(GridCtrlHwnd, nRow, nCol, nType = -1)
{
  ; --------------- Set the new type of a cell. Syntax:  -----------------------
  ; --------------- 1: Text, 2: Checkbox, 3: DateTime, 4: URL, 5: Combo, 6: Numeric
  ; --------------- You can pass either the number or name of desired type
 
  If nType = Text
      nType = 1
  If nType = CheckBox
      nType = 2
  If nType = DateTime
      nType = 3
  If nType = URL
      nType = 4
  If nType = Combo
      nType = 5
  If nType = Numeric
      nType = 6
 
  if nType = -1
      return
  nRC := DllCall("AHKCtrlSupport\GridSetCellType"
                                   , int, GridCtrlHwnd
                                   , int, nRow
                                   , int, nCol
                                   , int, nType
                        , "Cdecl Int")
  If (Errorlevel <> 0) || (nRC = 0)
  {
       MsgBox, Error while calling GridSetCellType off Errorlevel: %Errorlevel% - RC: %nRC%
       Return
  }
}

CtrlGridSetCellFont(GridCtrlHwnd, options = "", Refresh = 1)
{
  ;defaults
  Row2Change = -1
  Col2Change = -1
  Height = -1
  Width = -1
  Escapement = -1
  Orientation = -1
  Weight = -1
  Italic = -1
  Underline = -1
  Strikeout = -1
  CharSet = -1
  OutPrec = -1
  ClipPrec = -1
  Quality = -1
  Pitch = -1
  GridFontName = -1


  ; --------------- parse options -----------------------------------------
  ; -----------------------------------------------------------------------
  Stringsplit option, options, %A_space%`,
  loop %option0% {
    Stringleft, option, option%A_index%, 1
    Stringtrimleft, value, option%A_index%, 1
    if (option = "r")
      Row2Change := value
    if (option = "c")
      Col2Change := value
    if (option = "h")
      Height := value
    if (option = "w")
      Width := value
    if (option = "b")
      Weight := value
    if (option = "i")
      Italic := value
    if (option = "u")
      Underline := value
    if (option = "s")
      Strikeout := value
    if (option = "o")
      Orientation := value
    if (option = "e")
      Escapement := value
    if (option = "q")
      Quality := value
    if (option = "p")
      Pitch := value
    if (option = "f")
      {
        GridFontName := value
        StringReplace, GridFontName, GridFontName, _ , %A_space%, All
      }
  }
  ; Prototype (DWORD hWnd, DWORD nRow, DWORD nCol, DWORD Height, DWORD Width,
  ; DWORD Escapement, DWORD Orientation, DWORD Weight, DWORD Italic,
  ; DWORD Unterline, DWORD Strikeout, DWORD CharSet, DWORD OutPrec,
  ; DWORD ClipPrec, DWORD Quality, DWORD Pitch, LPCTSTR fontname)
  nRC := DllCall("AHKCtrlSupport\SetGridItemFont"
                                   , int, GridCtrlHwnd
                                   , int, Row2Change
                                   , int, Col2Change
                                   , int, Height
                                   , int, Width
                                   , int, Escapement
                                   , int, Orientation
                                   , int, Weight
                                   , int, Italic
                                   , int, Underline
                                   , int, Strikeout
                                   , int, CharSet
                                   , int, OutPrec
                                   , int, ClipPrec
                                   , int, Quality
                                   , int, Pitch
                                   , str, GridFontName
                        , "Cdecl Int")
  If (Errorlevel <> 0) || (nRC = 0)
    {
       MsgBox, Error while calling SetGridItemFont Errorlevel: %Errorlevel% - RC: %nRC%
       Return
    }
  If (Refresh = 1)
    CtrlGridRefresh(GridCtrlHwnd)

}

;not yet working!!
CtrlGridSetCellFormat(GridCtrlHwnd, options = "", Refresh = 1)
{

  ;default
  GridCellFormat = 0
  ; --------------- parse options -----------------------------------------
  ; -----------------------------------------------------------------------
  Stringsplit option, options, %A_space%`,
  loop %option0% {
    Stringleft, option, option%A_index%, 1
    Stringtrimleft, value, option%A_index%, 1
    if (option = "r")
      Row2Change := value
    if (option = "c")
      Col2Change := value
    if (option = "h")
      if (InStr(value ,"l")=1)
        GridCellFormat += 0
      else if (InStr(value ,"c")=1)
        GridCellFormat += 1                 
      else if (InStr(value ,"r")=1)
        GridCellFormat += 2
    if (option = "c")
      if (value = "t")
        GridCellFormat += 0
      else if (value = "c")     ;center
        GridCellFormat += 1                 
      else if (value = "m")     ;middle = center
        GridCellFormat += 1                 
      else if (value = "b")
        GridCellFormat += 2
    if (option = "a")   ;advanced
      GridCellFormat += value
  }
 
  msgbox, %GridCellFormat%
  ; -----------------------------------------------------------------------
  ; --------------- Set cell format ---------------------------------------
  ; -----------------------------------------------------------------------
  /*
  See MSDN for more informataion
  #define DT_TOP                      0x00000000
  #define DT_LEFT                     0x00000000
  #define DT_CENTER                   0x00000001
  #define DT_RIGHT                    0x00000002
  #define DT_VCENTER                  0x00000004
  #define DT_BOTTOM                   0x00000008
  #define DT_WORDBREAK                0x00000010
  #define DT_SINGLELINE               0x00000020
  #define DT_EXPANDTABS               0x00000040
  #define DT_TABSTOP                  0x00000080
  #define DT_NOCLIP                   0x00000100
  #define DT_EXTERNALLEADING          0x00000200
  #define DT_CALCRECT                 0x00000400
  #define DT_NOPREFIX                 0x00000800
  #define DT_INTERNAL                 0x00001000
  */
  GuiControlGet, Row2Change, , GroupRow
  GuiControlGet, Col2Change, , GroupCol
  GuiControlGet, GridCellFormat, , GridCellFormat
  ;MsgBox, %GridCellFormat% - %Col2Change% - %Row2Change%
  nRC := DllCall("AHKCtrlSupport\SetGridCellFormat"
                                   , int, GridCtrlHwnd
                                   , int, Row2Change
                                   , int, Col2Change
                                   , int, GridCellFormat
                        , "Cdecl Int")
  If (Errorlevel <> 0) || (nRC = 0)
    {
       MsgBox, Error while calling SetGridCellFormat Errorlevel: %Errorlevel% - RC: %nRC%
       Return
    }
  If (Refresh = 1)
    CtrlGridRefresh(GridCtrlHwnd)

}
 

CtrlUnInit()
{
  nRC := DllCall("AHKCtrlSupport\UnInit", "Cdecl Int")
  If (Errorlevel <> 0) || (nRC = 0)
    {
       MsgBox, Error while calling UnInit Errorlevel: %Errorlevel% - RC: %nRC%
       Return
    }

}


And a script that uses the wrapper
Code:
;ScheduleDisplayer
#Persistent
#Include GridControl.ahk

OnExit, ExitScript



GUItitle = Test Script


Gui, Show, w610 h510, %GUItitle%

CtrlInit(GUItitle)
CtrlGridCreate(GUItitle, GridCtrlHwnd, GridID,"w600 h500 x5 y5")

;these functions use GridID, and as such are 1 based
CtrlGridSetRowColCount(GridID, "r5 c5")
sleep, 750
CtrlGridSetRowColCount(GridID, "r7")
sleep, 750
CtrlGridSetRowColCount(GridID, "c7")

CtrlGridSetFixedRowColCount(GridID, "r1 c1")

;These functions use GridCtrlHwnd, and as such are 0 based
CtrlGridSetCellText(GridCtrlHwnd, 5, 5, "Cell (5,5)")
;Write Data to the grid
loop, 6
{
 nCol := a_index
 loop, 6
 {
    Text = Cell(%a_index%,%nCol%)
  CtrlGridSetCellText(GridCtrlHwnd, A_index, nCol, Text)

 }
}
loop, 6
{
  CtrlGridSetRowHeight(GridCtrlHwnd, A_index - 1, 35 ,0) ;do not refresh
}
loop, 6
{
  CtrlGridSetColWidth(GridCtrlHwnd, A_index - 1, 100 ,0) ;do not refresh
}
CtrlGridRefresh(GridCtrlHwnd)     ;now refresh

Loop, 1
{
  CtrlGridSetLines(GridCtrlHwnd, "v1")
  sleep, 250
  CtrlGridSetLines(GridCtrlHwnd, "")     ;h0 and v0 also supported
  sleep, 250
  CtrlGridSetLines(GridCtrlHwnd, "h1")
  sleep, 250
  CtrlGridSetLines(GridCtrlHwnd, "h1 v1")
  sleep, 250
}

;change cell types
Loop, 6
{
  CtrlGridSetCellType(GridCtrlHwnd, A_index, 1, A_index)
}

;populate the Combo control



;set fonts
CtrlGridSetCellText(GridCtrlHwnd, 1, 2, "Strikethrough")
CtrlGridSetCellFont(GridCtrlHwnd, "r1 c2 s1")

CtrlGridSetCellText(GridCtrlHwnd, 2, 2, "Italic")
CtrlGridSetCellFont(GridCtrlHwnd, "r2 c2 i1")

CtrlGridSetCellText(GridCtrlHwnd, 3, 2, "Underline")
CtrlGridSetCellFont(GridCtrlHwnd, "r3 c2 u1")

CtrlGridSetCellText(GridCtrlHwnd, 4, 2, "Courier New")
CtrlGridSetCellFont(GridCtrlHwnd, "r4 c2 fCourier_New")

CtrlGridSetCellText(GridCtrlHwnd, 5, 2, "Tahoma")
CtrlGridSetCellFont(GridCtrlHwnd, "r5 c2 fTahoma")

CtrlGridSetCellText(GridCtrlHwnd, 6, 2, "Arial")
CtrlGridSetCellFont(GridCtrlHwnd, "r6 c2 fArial")

;set formats (Not yet working)
CtrlGridSetCellText(GridCtrlHwnd, 1, 3, "Left")
CtrlGridSetCellFormat(GridCtrlHwnd, "r1 c3 hl")

CtrlGridSetCellText(GridCtrlHwnd, 2, 3, "Center")
CtrlGridSetCellFormat(GridCtrlHwnd, "r2 c3 hc")

CtrlGridSetCellText(GridCtrlHwnd, 3, 3, "Right")
CtrlGridSetCellFormat(GridCtrlHwnd, "r3 c3 hr")

CtrlGridSetCellText(GridCtrlHwnd, 4, 3, "Top")
CtrlGridSetCellFormat(GridCtrlHwnd, "r4 c3 vt")

CtrlGridSetCellText(GridCtrlHwnd, 5, 3, "Middle")
CtrlGridSetCellFormat(GridCtrlHwnd, "r5 c3 hc")

CtrlGridSetCellText(GridCtrlHwnd, 6, 3, "Bottom")
CtrlGridSetCellFormat(GridCtrlHwnd, "r6 c3 hb")

return

GuiClose:
Exitscript:
CtrlUnInit()
ExitApp







EDIT: Updated code 2007/04/17 - 7:21 PDT
EDIT: Updated code 2007/04/18 - 5:11 PDT

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Last edited by engunneer on April 19th, 2007, 1:11 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2007, 6:33 am 
Offline

Joined: November 15th, 2005, 11:15 am
Posts: 537
Location: Germany
Hi engunneer,
thank you for the wrappers.
Quote:
Can you also change SetGridCtrlRowColCountID to only modify the number of rows if the colum is set to -1?

DONE
Quote:
Also, some function to get properties back from the control? (number of rows, cols, etc)

Why do you need it? (Just wonder). In your script you are setting the row/col the grid should display. Why do you want the grid to tell you again how much rows/cols it currenty displays. You should know it :-)

For the other properties: The grid sends messages to the parent.
SKAN:
Have you succeeded in parsing the value (ExtractInteger) of the message?
Ciao
Micha


Last edited by Micha on April 18th, 2007, 1:25 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2007, 9:30 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Micha wrote:
SKAN:
Have you succeeded in parsing the value (ExtractInteger) of the message?


I have sent you a PM. Thanks. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2007, 3:24 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
Micha wrote:
thank you for the wrappers.

I have updated them in my post above.
Quote:
I will change it

Thanks. I think alot of the functions may be useful with this sort of extension, for both rows and cols, if it is available.
Quote:
Why do you need it? (Just wonder). In your script you are setting the row/col the grid should display. Why do you want the grid to tell you again how much rows/cols it currently displays. You should know it :-)

I wanted to write a wrapper for relative changes, among other things. This way I don't have to keep track of a global variable, when I could just ask the control.
Quote:
For the other properties: The grid sends messages to the parent.

I need to learn about this. is there a basic example? What can I do with these messages?

Thank you for all your work on this grid control.

One last question - please see my code above - why are some of the commands 1 based, and others are 0 based? I think I have found the pattern, but just curious. I an somewhat tempted to make my wrapper change them all to 1 based, or maybe something more clever. Please let me know what you think.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2007, 12:33 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
Micha,

for "AHKCtrlSupport\GridSetCellType", is there something special I need to do to get Combo (type 5) to work? I can't figure out what delimiter to send to the cell as text to get the options in the dropdown. Is this not implemented?

Additional requests:
For "AHKCtrlSupport\SetGridItemFont", can it be made so that -1 (if available) means "don't change"., then my wrapper can be used as:
Code:
;underline cell xPos yPos
CtrlGridSetCellFormat(GridCtrlHwnd, "x" xPos " y" Ypos " u1")

otherwise, my wrapper has to keep a bunch of global variables, since there is no "static" option for local variables.

I guess this is a general request for -1 to not change things, or to be able to read all this stuff somehow. I stilll don't understand the message part, unfortunately.

Thanks!

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2007, 1:21 pm 
Offline

Joined: November 15th, 2005, 11:15 am
Posts: 537
Location: Germany
Hi,
engunneer wrote:
you have set it up so that you can change the color of every column in a row by setting the column to -1. This is quite nice. Can you also change SetGridCtrlRowColCountID to only modify the number of rows if the colum is set to -1?

DONE


engunneer wrote:
Also, some function to get properties back from the control? (number of rows, cols, etc)

I have to implement each small function so what do you really need?

Ciao
Micha


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2007, 1:32 pm 
Offline

Joined: November 15th, 2005, 11:15 am
Posts: 537
Location: Germany
engunneer wrote:
One last question - please see my code above - why are some of the commands 1 based, and others are 0 based? I think I have found the pattern, but just curious. I an somewhat tempted to make my wrapper change them all to 1 based, or maybe something more clever. Please let me know what you think.


For me it's not important if they are 0/1-based. It's like C.
Array are beginning with index 0. The count of the array is one bigger than the index. The same applies to the grid
The first cell is 0/0.
The size of a grid is i.e. 6/6. The biggest cell is 5/5.

It's just like it is :-)

Ciao
Micha


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2007, 1:36 pm 
Offline

Joined: November 15th, 2005, 11:15 am
Posts: 537
Location: Germany
engunneer wrote:
for "AHKCtrlSupport\GridSetCellType", is there something special I need to do to get Combo (type 5) to work? I can't figure out what delimiter to send to the cell as text to get the options in the dropdown. Is this not implemented?


Now it is. Please wait, till I have uploaded the new dll. I'll change the version number of my first post to 1.32

engunneer wrote:
Additional requests:
For "AHKCtrlSupport\SetGridItemFont", can it be made so that -1 (if available) means "don't change"., then my wrapper can be used as:

Done (but untested)

Ciao
Micha


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2007, 1:51 pm 
Offline

Joined: November 15th, 2005, 11:15 am
Posts: 537
Location: Germany
Hi,
engunneer wrote:
I stilll don't understand the message part, unfortunately


I'll upload a new script with more functions.
There's also an example for message-processing:
BE WARNED: The example function seems to lasts to long. The marker in the grid is slower than the selection. If you comment out the message processing, everything is fine again.
Activate the "OnNotify" function only for testing!

Code:
OnNotify(wp, lp, msg)
{
 if wp != 2
    return
   
 HWNDFrom := GetInteger(lp)
 IdFrom := GetInteger(lp,4)
 nCode := GetInteger(lp,8, true)
 nRow := GetInteger(lp,12)
 nCol := GetInteger(lp,16)
  if nCode = -2
      nCode = Click
 else if nCode = -3
      nCode = DblClick
 else if nCode = -100
      nCode = ItemChanging
 else if nCode = -101
      nCode = ItemChanged
 else if nCode = -102
      nCode = InsertItem
 else if nCode = -103
      nCode = DeleteItem
 else if nCode = -104
      nCode = DeleteAllItems
 else if nCode = -105
      nCode = BeginEdit
 else if nCode = -175
      nCode = BeginEditW
 else if nCode = -106
      nCode = EndEdit
 else if nCode = -176
      nCode = EndEditW
 else if nCode = -100
      nCode = ItemChanging
 else if nCode = -108
      nCode = ColumnClick
 else if nCode = -109
      nCode = BeginDrag
 else if nCode = -111
      nCode = BeginRDrag
 else if nCode = -114
      nCode = ItemActive

 ToolTip, HwndFrom:%HWNDFrom% IDFrom:%idFrom% nCode:%nCode% Row:%nRow% Col:%nCol%
 return
}
return

GetInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
; pSource is a string (buffer) whose memory area contains a raw/binary integer at pOffset.
; The caller should pass true for pSigned to interpret the result as signed vs. unsigned.
; pSize is the size of PSource's integer in bytes (e.g. 4 bytes for a DWORD or Int).
; pSource must be ByRef to avoid corruption during the formal-to-actual copying process
; (since pSource might contain valid data beyond its first binary zero).
{
    Loop %pSize%  ; Build the integer by adding up its bytes.
        result += *(pSource + pOffset + A_Index-1) << 8*(A_Index-1)
    if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
        return result  ; Signed vs. unsigned doesn't matter in these cases.
    ; Otherwise, convert the value (now known to be 32-bit) to its signed counterpart:
    return -(0xFFFFFFFF - result + 1)
}


There's a GetInteger-function. It's ALMOST the same as the well known ExtractInteger function. The only difference is, that the pSource is already a pointer and you must not use & infront of it

Ciao
Micha


Last edited by Micha on April 18th, 2007, 7:48 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2007, 4:01 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
Thank you for the updates. I should not be requesting too many other things, I should think. Once my wrapper is in good shape, I will start a new topic for it, so it is easy to find.

Thanks.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2007, 7:37 am 
Offline

Joined: November 15th, 2005, 11:15 am
Posts: 537
Location: Germany
engunneer wrote:
Thank you for the updates. I should not be requesting too many other things, I should think.

Well, of course it's no problem if you have wishes !
Please tell me, if you need something.
Ciao
Micha


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 18th, 2008, 4:20 am 
Offline

Joined: June 23rd, 2007, 2:44 am
Posts: 136
is there a way to have a transparent background with RotStatic


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 18th, 2008, 7:09 pm 
viciouskinid wrote:
is there a way to have a transparent background with RotStatic

Hi, you can just use the features of the original control:
http://www.codeproject.com/KB/static/rotated_bevel.aspx
Ciao
Micha


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 13th, 2008, 6:13 pm 
Offline

Joined: July 12th, 2007, 10:24 pm
Posts: 103
Location: Hawaii, USA
Hi Micha. I know I am responding to an ancient post of yours here. I am just wondering -- is it possible to apply Transparency to a video control? :D I was experimenting with the concept. It seems after I apply transparency the video will disappear :( Any ideas on how to solve? :D


Micha wrote:
Video Control
Image

After downloading the 300MB DirectX-SDK I've added a video control.
You can play Avi's or MPegs.
The example in the ZIP-file is named "Video_CtrlSupport.ahk".

If you are using the dll and now having problems (i.e. your script does not run anymore) please contact me.

The dll has dependencies to directx now. If you have problems, I have to create two seperate dlls. One for the controls I made so far and one extra dll for the video control to get rid of the dependencies.
--------------
How to use the control:

Create the GUI with an edit control. The control will be removed by the dll and on that space the new video control will be created.
Code:
nRC = 0
Gui, Add, edit, x10 y10  w600 h500
Gui, Show, w650 h550, this is a unique title
WinGet, HWND, ID, this is a unique title


Retrieve the handle of the edit control
Code:
Text1HWnd := GetChildHWND(HWND, "Edit1") ;Get HWND of an existing button


Initialize the dll as usual
Code:
DetectHiddenWindows On
MainHWND := WinExist(A_ScriptFullPath . " ahk_class AutoHotkey")
nRC := DllCall("AHKCtrlSupport\Init", int, MainHWND, int, HWND, int, hModule, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
   MsgBox error while calling Init Errorlevel: %errorlevel% - RC: %nRC%
   return
}


Call the CreateVideoCtrlID function.
1. parameter: pass the handle to the dialog
2. pass the handle to the edit control
3. pass the name of the video file
4. pass 1 to keep aspect ratio of the video otherwise 0
Code:
nRC := DllCall("AHKCtrlSupport\CreateVideoCtrlID", int, HWND, int, Text1HWnd, str, "E:\world.mpeg", int, 1, "Cdecl Int")


Voila the video should play.
To play another (or the same) video on that place use
Code:
nRC := DllCall("AHKCtrlSupport\VideoCtrlPlay", str, "E:\world.mpeg", int, 0, "Cdecl Int")


To stop the video call
VideoCtrlStop without parameters

Ciao
Micha


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 219 posts ]  Go to page Previous  1 ... 10, 11, 12, 13, 14, 15  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Klark92, Stigg and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group