winmessage PEM_ADDPROPERTY   ;(0, ptrPropInfo)
winmessage PEM_CLEARALL      ;(0, 0)
winmessage PEM_SETCOUNT      ;(count, 0)

winmessage PEM_SETCONTROL    ; (ptrTBaseWin, ptrPropInfo)
winmessage PEM_GETCONTROL    ; (0, 0): ptrBaseWin

winmessage PEM_SETSELECTION  ; (iProp, 0)
winmessage PEM_UPDATECONTROL ; (0, 0)

winmessage PEM_SETEDITORTEXT ; (0, ptrString)
winmessage PEM_SETUPDATEPROC ; (0, ptrUpdateProc)

;message PEM_FOCUSNEXT   ; (directionFlag, 0)

; properties types

ptByte = 0
ptWord = 1
ptDword = 2
ptText = 3
ptUnsigned = $80000000

; property flags - as bit fields in Tag
pfReadOnly = 1

struct TPropInfo
  .hName      dd ?
  .type       dd ?
  .ofsVal     dd ?   ; The offset of the value in the control data structure (usually TBaseWin)
  .procEditor dd ?
  .Tag        dd ?   ; User defined value, that is used by property editors.
  .Form       dd ?   ; Modal form definition, that will be invoked when user press button on the editor.
ends

macro PropInfo [Name, type, ofsValue, Editor, lParam, form] {
common
  local ..propcount
  ..propcount = 0
forward
  ..propcount = ..propcount + 1
common
        dd      ..propcount
forward
  local ..ptrName, ..ptrValue
        dd      ..ptrName
        dd      type
        dd      ofsValue
        dd      Editor
        dd      lParam
        dd      form
forward
  ..ptrName db Name, 0
}


struct TPropGrid
  .RowCount dd ?
  .iSelected dd ?     ; Index to the selected property TPropInfo data.
  .ptrCtrl  dd ?        ; Pointer to the control data structure.
  .ptrUpdateProc dd ?   ; Pointer to the procedure that updates the control.
  .ptrArray dd ?        ; pointer to array of TPropInfo.
  .hEditor  dd ?        ; Current property editor loaded.
ends



; Commands for procEditor
; the procedure should have following params:
; proc procEditor, ptrCtrl, ptrPropInfo, cmd, hdc, ptrRect
; ptrPropInfo - pointer to TPropInfo structure.
; cmd         - command. see below.
; ptrRect     - pointer to RECT structure.
; lParam      - diferent meaning on different commands.
;
pecDrawValue = 0        ; Draws the given element value.        lParam is HDC
pecGetEditor = 1        ; Get given element editor window.      lParam is hParent
pecRefreshEditor = 2    ; Refresh the editor to the current value of the property. lParam is hEditor
pecUpdateWindow  = 3    ; Refreshes the TWinTemplateDT structure to the current value of editor.
                        ; returns TRUE if the value was changed