AutoHotkey Community

It is currently May 27th, 2012, 12:13 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 54 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject:
PostPosted: November 2nd, 2008, 3:44 pm 
Offline

Joined: July 29th, 2005, 5:32 pm
Posts: 179
majkinetor wrote:
The only thing I didn't wrap are notification handlers for text change, button clicks etc. This is fairly trivial to add, but I didn't have time now.
I was recently using this control for something, & needed to wrap the notification interface for some simple stuff.

Code:
;----------------------------------------------------------------------------------------------------
; Function: SetEvents
;         Set notification events
;
; Parameters:
;         func   - Subroutine that will be called on events.
;         e      - White space separated list of events to monitor (by default, null).
;
; Globals:
;         RG_EVENT   - Specifies event that occurred. Event must be registered to be able to monitor them.
;     RG_ROW    - String containing zero based row number.
;     RG_COLUMN - String containing zero based column number.

; Events & Infos:
;         HEADERCLICK   - Sent when user clicks header.
;         BUTTONCLICK - Sent when user clicks the button in a button cell.
;         CHECKCLICK - Sent when user double clicks the checkbox in a checkbox cell.
;         IMAGECLICK - Sent when user double clicks the image in an image cell.
;         BEFORESELCHANGE - (not implemented) Sent when user request a selection change.
;         AFTERSELCHANGE - Sent after a selection change.
;         BEFOREEDIT - Sent before the cell edit control shows.
;         AFTEREDIT - Sent when the cell edit control is about to close.
;         BEFOREUPDATE - (not implemented) Sent before a cell updates grid data.
;         AFTERUPDATE - (not implemented) Sent after grid data has been updated.
;         USERCONVERT - (not implemented) Sent when user cell needs to be converted.
;
; Returns:
;         "OK" if succesiful, error string otherwise
;
RG_SetEvents(hGrd, func, e=""){
   local old, hmask
  static GN_HEADERCLICK=0x1,GN_BUTTONCLICK=0x2,GN_CHECKCLICK=0x3,GN_IMAGECLICK=0x4
        ,GN_BEFORESELCHANGE=0x5,GN_AFTERSELCHANGE=0x6,GN_BEFOREEDIT=0x7,GN_AFTEREDIT=0x8
        ,GN_BEFOREUPDATE=0x9,GN_AFTERUPDATE=0xa,GN_USERCONVERT=0xb, WM_NOTIFY:=0x4E
  static events="HEADERCLICK,BUTTONCLICK,CHECKCLICK,IMAGECLICK,BEFORESELCHANGE,AFTERSELCHANGE,BEFOREEDIT,AFTEREDIT,BEFOREUPDATE,AFTERUPDATE,USERCONVERT"

   if !IsLabel(func)
      return "Err: label doesn't exist`n`n" func

  RG_%hGrd%_mask := "" ; clear any previous set mask
   loop, parse, e, %A_Tab%%A_Space%
   {
      IfEqual, A_LoopField, , continue
      if A_LoopField not in %events%
         return "Err: unknown event - '" A_LoopField "'"
      RG_%hGrd%_mask .= RG_%hGrd%_mask ? "," . GN_%A_LOOPFIELD% : GN_%A_LOOPFIELD%
   }
   IfEqual, RG_%hGrd%_mask,, return   ; not monitoring any events


   old := OnMessage(WM_NOTIFY, "RG_onNotify") ; set RaGrid msg handler and remember old one
   if (old != "RG_onNotify")
      RG_oldNotify := RegisterCallback(old)    ; store callable old message handler

  hGrd += 0
   RG_%hGrd%_func := func
   return "OK"
}


RG_onNotify(wparam, lparam, msg, hwnd) {
   local code, hw, row,col,mask
  static pInfo
  static GN_HEADERCLICK=0x1,GN_BUTTONCLICK=0x2,GN_CHECKCLICK=0x3,GN_IMAGECLICK=0x4
        ,GN_BEFORESELCHANGE=0x5,GN_AFTERSELCHANGE=0x6,GN_BEFOREEDIT=0x7
        ,GN_AFTEREDIT=0x8,GN_BEFOREUPDATE=0x9,GN_AFTERUPDATE=0xa,GN_USERCONVERT=0xb

  ; Call previous set WM_NOTIFY
  RG_oldNotify ? DllCall(RG_oldNotify, "uint", wparam, "uint", lparam, "uint", msg, "uint", hwnd) : ""

   hw    := NumGet(lparam+0)   ; control sending the message - this RaGrid
  mask := RG_%hw%_mask       ; current events monitoring for

  SetFormat, integer, hex
   code   :=  NumGet(lparam+8)   ;-
  SetFormat, integer, d

  if code not in %mask%
    return

  RG_ROW := NumGet(lparam+16),  RG_COLUMN := NumGet(lparam+12)

   if (code = GN_HEADERCLICK) {
      RG_EVENT := "HEADERCLICK", RG_ROW := ""
      GoSub % RG_%hw%_func
      return
   }

   if (code = GN_BUTTONCLICK) {
      RG_EVENT := "BUTTONCLICK"
      GoSub % RG_%hw%_func
      return
   }

   if (code = GN_CHECKCLICK) {
      RG_EVENT := "CHECKCLICK"
      GoSub % RG_%hw%_func
      return
   }

   if (code = GN_IMAGECLICK) {
      RG_EVENT := "IMAGECLICK"
      GoSub % RG_%hw%_func
      return
   }

;    if (code = GN_BEFORESELCHANGE) {
;       RG_EVENT := "BEFORESELCHANGE"
;       GoSub % RG_%hw%_func
;       return
;    }

   if (code = GN_AFTERSELCHANGE) {
    IfEqual, pInfo, %RG_ROW%|%RG_COLUMN%, return  ; filter out mutiple dup message calls
    pInfo = %RG_ROW%|%RG_COLUMN%                  ; store info for comparison in next iteration
      RG_EVENT := "AFTERSELCHANGE"
      GoSub % RG_%hw%_func
      return
   }

   if (code = GN_BEFOREEDIT) {
      RG_EVENT := "BEFOREEDIT"
      GoSub % RG_%hw%_func
      return
   }

   if (code = GN_AFTEREDIT) {
      RG_EVENT := "AFTEREDIT"
      GoSub % RG_%hw%_func
      return
   }

;    if (code = GN_BEFOREUPDATE) {
;       RG_EVENT := "BEFOREUPDATE"
;       GoSub % RG_%hw%_func
;       return
;    }

;    if (code = GN_AFTERUPDATE) {
;       RG_EVENT := "AFTERUPDATE"
;       GoSub % RG_%hw%_func
;       return
;    }

}


I tried implementing your stacking techniques, as not to screw up any other wrappers that use WM_NOTIFY message. It seems to test out okay, but you may want to double check it though, to make sure I got it right (if you get a chance that is..) :wink:

Code:
#Include RaGrid.ahk
#SingleInstance, force

   Gui, +LastFound 
   hwnd := WinExist()

;EDITTEXT,EDITLONG,   CHECKBOX,   COMBOBOX,   HOTKEY,   BUTTON,   IMAGE,   DATE,   TIME,   USER,   EDITBUTTON
   hGrd := RG_Add(hwnd, 0, 30, 800, 500, "GRIDFRAME VGRIDLINES NOSEL" )

   RG_AddColumn(hGrd, "cap=zero" , "w=150", "ha=1", "ca=0", "type=EditText" )
   RG_AddColumn(hGrd, "cap=one"  , "w=150" ,"ha=1", "ca=0", "type=EditText" )
   RG_AddColumn(hGrd, "cap=two"  , "w=180" ,"ha=1", "ca=0", "type=EditText" )
   RG_AddColumn(hGrd, "cap=three", "w=150" ,"ha=1", "ca=0", "type=EditText" )
   RG_SetFont(hGrd, "s10 bold, Arial")
   RG_SetHdrHeight(hGrd, 30), RG_SetRowHeight(hGrd, 22)

  Loop, 20
  {
    aCol1 := aCol2 := aCol3 := aCol4 := "Row=" A_Index - 1 "  Col="
    aCol1 .= 0, aCol2 .= 1, aCol3 .= 2, aCol4 .= 3
    RG_AddRow(hGrd, "aCol")
  }
   Gui, Show, h500 w800
   
; -- Set events...
; "HEADERCLICK,BUTTONCLICK,CHECKCLICK,IMAGECLICK,BEFORESELCHANGE,AFTERSELCHANGE,BEFOREEDIT
; ,AFTEREDIT,BEFOREUPDATE,AFTERUPDATE,USERCONVERT"
  RG_SetEvents(hGrd, "OnRgEvent", "HEADERCLICK AFTERSELCHANGE BEFOREEDIT AFTEREDIT")


;-- Demonstrate that WM_NOTIFY events are stacked: Experiment w/ the order to see
  Alternate_WM_NOTIFY(func, 1, 0, 0)
  RG_SetEvents(hGrd, "OnRgEvent", "AFTERSELCHANGE AFTEREDIT") ; Change previous set event notifiers
  Alternate_WM_NOTIFY2(func, 1, 0, 0)


;   RG_SetEvents(hGrd, "OnRgEvent", "") ; Turn event notification off (or change)
return

^l::reload

OnRgEvent:
  ToolTip, % A_Now " - " RG_EVENT " | " RG_ROW "  " RG_COLUMN, 20, 40, 1
;   OutputDebug % RG_EVENT " | " RG_ROW "  " RG_COLUMN
return


Alternate_WM_NOTIFY(wparam, lparam, msg, hwnd){
  static WM_NOTIFY := 0x4E, old=0, user

  if !old {
    old := OnMessage(WM_NOTIFY, "Alternate_WM_NOTIFY"), user := wparam
    old := old = "Alternate_WM_NOTIFY" ? "-" : RegisterCallback(old, "", 4)
    return
  }
  if old != -
    DllCall(old, "uint", wparam, "uint", lparam, "uint", msg, "uint", hwnd)

  ;Test message handler here ....
  ToolTip, % A_Now " - Message stacking test notifier", 20, 20, 2
}
Alternate_WM_NOTIFY2(wparam, lparam, msg, hwnd){
  static WM_NOTIFY := 0x4E, old=0, user

  if !old {
    old := OnMessage(WM_NOTIFY, "Alternate_WM_NOTIFY2"), user := wparam
    old := old = "Alternate_WM_NOTIFY2" ? "-" : RegisterCallback(old, "", 4)
    return
  }
  if old != -
    DllCall(old, "uint", wparam, "uint", lparam, "uint", msg, "uint", hwnd)

  ;Test message handler here ....
  ToolTip, % A_Now " - Message stacking test notifier2", 20, 60, 3
}


;- still used within in RaGrid.ahk..
InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
{
    Loop %pSize%  ; Copy each byte in the integer into the structure as raw binary data.
        DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF)
}

ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
{
    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)
}

_________________
.o0[ corey ]0o.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2008, 3:18 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Thanks man. I added this info on first page for now.
Thx for following stacking principle too. :)

I will merge this as soon as I have time to get back to AHK.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2009, 9:36 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Version 2.0.1.6-1
+ Entire RaGrid API available.
+ All globals removed.
+ Documentation

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject: ResetColumns missing
PostPosted: October 13th, 2009, 1:07 pm 
Offline

Joined: July 30th, 2004, 8:50 pm
Posts: 192
The ResetColumns function is missing.

:) Skrommel

Code:
/*
  Function: ResetColumns
    Reset columns of the control.
*/
RG_ResetColumns(hGrd) {
  static GM_RESETCOLUMNS=0x429
  SendMessage,GM_RESETCOLUMNS,,,, ahk_id %hGrd%
  return ErrorLevel
}

_________________
www.1HourSoftware.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 13th, 2009, 1:23 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Thx Ill add it.

I thought there is no big difference to Reset function but I guess it un-dos user settings.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2009, 8:45 pm 
Offline
User avatar

Joined: July 17th, 2008, 12:58 am
Posts: 270
why isnt the grid showing? what am i doing wrong?

Code:
#NoEnv
SetWorkingDir %A_ScriptDir%
#SingleInstance, force

#Include Data\RaGrid.ahk

  GoSub MAINGUI
RETURN


MAINGUI:
  Gui 1: +LastFound +Resize
  MLWIN_ID := WinExist()
  Gui 1: Show,h401 w520 Center, Test Script
  hGrd := RG_Add(MLWIN_ID, "5", "20", "410", "336", "HGRIDLINES VGRIDLINES", "RAGridEvents")
  RG_SetFont(hGrd, "s8, Courier New")
   
  RG_SetHdrHeight(hGrd, 20), RG_SetRowHeight(hGrd, 20)   
 
  RG_AddColumn(hGrd, "txt=Title",  "w=490", "hdral=1",   "txtal=0", "type=EditText")
  RG_AddColumn(hGrd, "txt=Path",  "w=150", "hdral=1",   "txtal=0", "type=EditButton")
  RG_AddColumn(hGrd, "txt=IMDb",  "w=100", "hdral=1",   "txtal=0", "type=EditText")
  RG_AddColumn(hGrd, "txt=Type",  "w=100", "hdral=1",   "txtal=0", "type=ComboBox", "items=Action|Adventure|Comedy|War|Drama|TV Series|Animation|Fantasy|History|Biography|Horror|Mystery|Romance|Thriller|Western|Crime|Family|Documentary|XXX")
  RG_AddColumn(hGrd, "txt=Year",  "w=100", "hdral=1",   "txtal=0", "type=EditText")
  RG_AddColumn(hGrd, "txt=Quality",  "w=100", "hdral=1",   "txtal=0", "type=ComboBox", "items=DVD Rip|R5|BD Rip|TV Rip|Cam|DVD Screener|Screener|Telesync|VHS Rip|Telecine|Workprint|Blu Ray|DVD|High Definition")
  RG_AddRow(hGrd, 0, "C1", "C1", "C1", "C1", "C1", "C1")
RETURN

RAGridEvents(HCtrl, Event, Col, Row, Data="") {
   static s
   ;SB_SetText( s .= " | " col " " row " " event )
   if StrLen(s)>120
      s := ""
      
   if (Event = "BeforeEdit")
      ;SetTimer, ResizeTimer, -1      ;resize editing control
   
   if (Event = "HeaderClick")
      RG_Sort(HCtrl, Col)
    if (Event = "ButtonClick")
    msgbox you clicked a button
}


_________________
QuickSubs | Popcorn Movie Db
All my scripts are just in AutoHotkey v1.0.48.05


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2009, 11:27 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Its showing. Add more rows then 1 to see it.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2009, 11:43 am 
Offline
User avatar

Joined: July 17th, 2008, 12:58 am
Posts: 270
majkinetor wrote:
Its showing. Add more rows then 1 to see it.


i did but its still not showing...
but why is this happening?
on another example i have no rows at all and it still showed

_________________
QuickSubs | Popcorn Movie Db
All my scripts are just in AutoHotkey v1.0.48.05


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2009, 1:15 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
I don't know. It shows here normally woth code you gave.

Quote:
on another example i have no rows at all and it still showed

I don't know how that happens. Grid lines show only up to the point where there are rows, which is normal. Parts of control that don't have rows are blank with no grid lines.

I suggest you try it on another computer

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2009, 1:38 pm 
Offline
User avatar

Joined: July 17th, 2008, 12:58 am
Posts: 270
i found the problem.
on the example i posted here i used #Include RaGrid.ahk but on my pc i have #Include Data\RaGrid.ahk thats why it didnt work(i supposed it would work with both as it does everytime i have used #include by now)
you have any idea why this is happening?

on the script im making i want to have all includes and other stuff in the folder Data and not in the same dir as the main script

_________________
QuickSubs | Popcorn Movie Db
All my scripts are just in AutoHotkey v1.0.48.05


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2009, 2:17 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
That can only mean that RaGrid control wasn't created at all since dll wasnt found.

If you put both dll and module in the same dir u should include it as:

Code:
#include Data
#include RaGrid.ahk


or, if you keep them separate then you need to specify last parameter of Add function.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2009, 2:35 pm 
Offline
User avatar

Joined: July 17th, 2008, 12:58 am
Posts: 270
ok thanks :)

this custom control is great btw...many thanks for it and for you great work
im thinking of using it instead of listview in my movie database script

_________________
QuickSubs | Popcorn Movie Db
All my scripts are just in AutoHotkey v1.0.48.05


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 26th, 2010, 8:45 am 
Offline

Joined: January 26th, 2010, 8:44 am
Posts: 1
first of all, thank you very much for RAGrid!

I believe I've found a problem with using the DATE type and RG_AddRow.

in RG_AddRow the line
Code:
if type in COMBOBOX,CHECKBOX,EDITLONG,IMAGE

should be
Code:
if type in COMBOBOX,CHECKBOX,DATE,EDITLONG,IMAGE


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2010, 11:33 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Ty

Version 2.0.1.6-3
! Bug in RG_AddRow with DATE,TIME & HOTKEY fixed.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2010, 1:49 pm 
Offline
User avatar

Joined: July 17th, 2008, 12:58 am
Posts: 270
i dont know if im missing something but is there a way to make the combobox behave like the autohotkeys combobox?...where you can also type in data? the combobox in ragrid behaves more like a drop down list

_________________
QuickSubs | Popcorn Movie Db
All my scripts are just in AutoHotkey v1.0.48.05


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 54 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Rajat and 54 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