Virgilio1 Posted February 7, 2012 Share Posted February 7, 2012 Hi Friends in a gui using the ddl RAGrid. I can't intercept the click on the cell, can you help me? the code that I use at the moment is this: expandcollapse popupomiss..... Global $Appuntamenti = GUICreate("Appuntamenti", 435, 380, -1, -1, -1, -1, $Form1) Global $chiudiappuntamenti = GUICtrlCreateButton("Chiudi", 200, 335, 100, 41, $BS_NOTIFY) $hLib = DllOpen(@ScriptDir & "\RAGrid.dll") If $hLib <> -1 Then Global $TabellaAppuntamenti = _GUICtrlRAGrid_Create($Appuntamenti, "", 10, 10, 410, 300) GridSetup($Appuntamenti) Else MsgBox(0, "Errore", "Non Carico la DLL") EndIf GUISetState(@SW_SHOW, $Form1) Load() While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[0] Case $GUI_EVENT_CLOSE If $nMsg[1] = $Form1 Then Exit ElseIf $nMsg[1] = $impostazioni Then GUISetState(@SW_HIDE, $impostazioni) GUISetState(@SW_SHOW, $Form1) ElseIf $nMsg[1] = $Archivio Then GUISetState(@SW_HIDE, $Archivio) GUISetState(@SW_SHOW, $Form1) ElseIf $nMsg[1] = $Appuntamenti Then GUISetState(@SW_HIDE, $Appuntamenti) GUISetState(@SW_SHOW, $Form1) EndIf Case $ButtonInvito If GUICtrlRead($elencoRevisioni) Then $file = @ScriptDir & "\ispezioni\Revisione-" & GUICtrlRead($elencoRevisioni) & ".xml" $datiIncarico = LoadDati($file) CreaInvito($datiIncarico) Else MsgBox(64, "Avviso", "Devi Prima Selezionare un Incarico") EndIf Case $ButtonChiudi Exit Case $ButtonRinomina Rinomina() Load() Case $ButtonImpostazioni GUISetState(@SW_HIDE, $Form1) GUICtrlSetData($Revisore, $AImpostazioni[$CRevisore]) GUICtrlSetData($Cellulare, $AImpostazioni[$CCellulare]) GUICtrlSetData($Ufficio, $AImpostazioni[$CUfficio]) GUICtrlSetData($Email, $AImpostazioni[$CEmail]) GUICtrlSetState($Logo, $AImpostazioni[$CLogo]) GUISetState(@SW_SHOW, $impostazioni) Case $Salva SalvaImpostazioni() GUISetState(@SW_HIDE, $impostazioni) GUISetState(@SW_SHOW, $Form1) Case $ButtonArchivia ArchiviaRevisione() Case $ButtonArchiviaAccertamento ArchiviaAccertamenti() Case $ButtonApriArchivio GUISetState(@SW_HIDE, $Form1) LoadArchivio() GUISetState(@SW_SHOW, $Archivio) Case $chiudiarchivio GUISetState(@SW_HIDE, $Archivio) GUISetState(@SW_SHOW, $Form1) Case $ripristina RipristinaRevisione() Case $ripristinaAccertamento RipristinaAccertamento() Case $ButtonFolium If GUICtrlRead($elencoRevisioniConcluse) Then CaricaVerbale(@ScriptDir & "\ispezioni\" & "Revisione-" & GUICtrlRead($elencoRevisioniConcluse) & ".xml") Else MsgBox(0, "Avviso", "Devi Selezionare una Revisione") EndIf Case $ButtonFolium1 If GUICtrlRead($elencoAccertamentiConclusi) Then CaricaVerbale(@ScriptDir & "\ispezioni\" & "Accertamento-" & GUICtrlRead($elencoAccertamentiConclusi) & ".xml") Else MsgBox(0, "Avviso", "Devi Selezionare un Accertamento") EndIf Case $ButtonFolium2 ElencoFolium("4") Case $ButtonFolium21 ElencoFolium("7") Case $ButtonApripdf VerificaPdf("Rev", $elencoRevisioni, "A") Case $ButtonApripdfDefinito VerificaPdf("Rev", $elencoRevisioniConcluse, "A") Case $ButtonStampapdfDefinito VerificaPdf("Rev", $elencoRevisioniConcluse, "P") Case $ButtonApripdfAccertamento VerificaPdf("Acc", $elencoAccertamentiConclusi, "A") Case $ButtonStampapdfAccertamento VerificaPdf("Acc", $elencoAccertamentiConclusi, "P") Case $ButtonAppuntamenti LoadAppuntamenti() GUISetState(@SW_HIDE, $Form1) GUISetState(@SW_SHOW, $Appuntamenti) Case $chiudiappuntamenti GUISetState(@SW_HIDE, $Appuntamenti) GUISetState(@SW_SHOW, $Form1) EndSwitch WEnd GUIDelete($Form1) GUIDelete($impostazioni) EndFunc ;==>__Main omiss.... Func GridSetup($hwnd) Local $lpzhdrtext, $lpsz, $r, $c, $z Local $col = DllStructCreate($tagRAGRIDCOLUMN) ; Colonna Data $lpzhdrtext = DllStructCreate("char[4]") DllStructSetData($lpzhdrtext, 1, "Data") DllStructSetData($col, "colwt", 100) DllStructSetData($col, "lpszhdrtext", DllStructGetPtr($lpzhdrtext)) DllStructSetData($col, "halign", $GA_ALIGN_CENTER) DllStructSetData($col, "calign", $GA_ALIGN_CENTER) DllStructSetData($col, "ctype", $TYPE_EDITTEXT) DllStructSetData($col, "ctextmax", 31) DllStructSetData($col, "lpszformat", 0) DllStructSetData($col, "himl", 0) DllStructSetData($col, "hdrflag", 0) _GUICTRLRaGrid_ADDCOL($TabellaAppuntamenti, $col) ; Colonna Cooperativa $lpzhdrtext = DllStructCreate("char[11]") DllStructSetData($lpzhdrtext, 1, "Cooperativa") DllStructSetData($col, "colwt", 430) DllStructSetData($col, "lpszhdrtext", DllStructGetPtr($lpzhdrtext)) DllStructSetData($col, "halign", $GA_ALIGN_LEFT) DllStructSetData($col, "calign", $GA_ALIGN_LEFT) DllStructSetData($col, "ctype", $TYPE_EDITTEXT) DllStructSetData($col, "ctextmax", 100) DllStructSetData($col, "lpszformat", 0) DllStructSetData($col, "himl", 0) DllStructSetData($col, "hdrflag", 0) _GUICTRLRaGrid_ADDCOL($TabellaAppuntamenti, $col) DllStructSetData($lf, "Height", -12) ; Our grid will use 10 point Arial font DllStructSetData($lf, "FaceName", "Arial") $hFont = _WinAPI_CreateFontIndirect($lf) _SendMessage($TabellaAppuntamenti, $WM_SETFONT, $hFont, 0) EndFunc ;==>GridSetup Link to comment Share on other sites More sharing options...
funkey Posted February 8, 2012 Share Posted February 8, 2012 (edited) Look at the demo script. WM_COMMAND is used for interaction with the control. expandcollapse popup;Adapted from BCX Demo by Kevin Diggins ;http://www.allbasic.info/forum/index.php?topic=448.0 #include[/url] <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Color.au3> #include "RAGrid_UDF.au3" Global $Form Global $hGrid Global $hLib Global $hFont Global $lf = DllStructCreate($tagLOGFONT) Global Const $IDC_GRID = 101 Global $hWndSaveFocus = 0 ;take a little time to fill grid on startup with a large number Global Const $iRows = 500 Main() Func Main() FormLoad() If @error = 0 Then WinFlash($Form) GUIRegisterMsg($WM_NCACTIVATE, "MY_WM_COMMAND") GUIRegisterMsg($WM_NOTIFY, "MY_WM_COMMAND") GUIRegisterMsg($WM_DESTROY, "MY_WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $IDC_GRID WinFlash($Form) EndSwitch WEnd GUIRegisterMsg($WM_NCACTIVATE, "") GUIRegisterMsg($WM_NOTIFY, "") GUIRegisterMsg($WM_DESTROY, "") EndIf $lf =0 EndFunc ;==>Main Func FormLoad() Local $wx = 700 Local $wh = 500 $Form = GUICreate("RAGrid Sample Program", $wx, $wh, 0, 0) $hLib = DllOpen(@ScriptDir & "libragrid.dll") If $hLib <> -1 Then Local $style = BitOR($WS_CHILD, $WS_VISIBLE, $STYLE_HGRIDLINES, $STYLE_VGRIDLINES, $STYLE_GRIDFRAME, $STYLE_NOSEL) $hGrid = _WinAPI_CreateWindowEx(0, "RAGRID", "", $style, 10, 10, $wx - 15, $wh - 35, $Form, $IDC_GRID) If $hGrid Then GridSetup($hGrid) ColorTheGrid($hGrid, $iRows) EndIf Else MsgBox(266288, "Error", "RaGrid.dll failed to load") GUIDelete($Form) Return SetError(1, 0, 0) EndIf GUISetState(@SW_SHOW) EndFunc ;==>FormLoad Func MY_WM_COMMAND($hWnd, $CBMSG, $wParam, $lParam) Switch $CBMSG Case $WM_NCACTIVATE If Not $wParam Then ; Save control focus $hWndSaveFocus = _WinAPI_GetFocus() ElseIf $hWndSaveFocus Then ; Restore control focus _WinAPI_SetFocus($hWndSaveFocus) $hWndSaveFocus = 0 EndIf Case $WM_NOTIFY ; Process grid notifications Local $pnmh = DllStructCreate($tagRAGRIDGRIDNOTIFY, $lParam) If DllStructGetData($pnmh, "hwndFrom") = $hGrid Then Switch DllStructGetData($pnmh, "Code") Case $GN_HEADERCLICK ; Sort the grid by column, invert sorting order _SendMessage($hGrid, $GM_COLUMNSORT, DllStructGetData($pnmh, "col"), $SORT_INVERT) ColorTheGrid($hGrid, $iRows) EndSwitch EndIf Case $WM_DESTROY _WinAPI_DeleteObject($hFont) EndSwitch EndFunc ;==>MY_WM_COMMAND Func GridSetup($hWnd) Local $lpzhdrtext, $lpsz, $r, $c, $z Local $col = DllStructCreate($tagRAGRIDCOLUMN) For $i = 1 To 5 ; Create and format 5 columns $lpzhdrtext = DllStructCreate("wchar") DllStructSetData($lpzhdrtext, 1, Chr(64 + $i)) DllStructSetData($col, "colwt", 130) DllStructSetData($col, "lpszhdrtext", DllStructGetPtr($lpzhdrtext)) DllStructSetData($col, "halign", $GA_ALIGN_CENTER) DllStructSetData($col, "calign", $GA_ALIGN_CENTER) DllStructSetData($col, "ctype", $TYPE_EDITTEXT) DllStructSetData($col, "ctextmax", 31) DllStructSetData($col, "lpszformat", 0) DllStructSetData($col, "himl", 0) DllStructSetData($col, "hdrflag", 0) _SendMessage($hWnd, $GM_ADDCOL, 0, DllStructGetPtr($col)) Next DllStructSetData($lf, "Height", -12) ; Our grid will use 10 point Arial font DllStructSetData($lf, "FaceName", "Arial") $hFont = _WinAPI_CreateFontIndirect($lf) _SendMessage($hGrid, $WM_SETFONT, $hFont, 0) For $i = 1 To $iRows ; Create 32,765 blank rows _SendMessage($hGrid, $GM_ADDROW, 0, 0) Next For $r = 0 To $iRows - 1; Fill our grid with some data For $c = 0 To 4 $z = String(Random(0,$iRows)) $lpsz = DllStructCreate("char[" & StringLen($z) + 1 & "]") DllStructSetData($lpsz, 1, $z) _SendMessage($hGrid, $GM_SETCELLDATA, _WinAPI_MakeLong($c, $r), DllStructGetPtr($lpsz)) Next Next EndFunc ;==>GridSetup Func ColorTheGrid($hWnd, $Rows) Local $grc = DllStructCreate($tagRAGRIDROWCOLOR); DllStructSetData($grc, "backcolor", _MakeRGB(0, 240, 230)) DllStructSetData($grc, "textcolor", 0) For $i = 0 To $Rows - 1 Step 2 _SendMessage($hWnd, $GM_SETROWCOLOR, $i, DllStructGetPtr($grc)) Next DllStructSetData($grc, "backcolor", _MakeRGB(255, 255, 255)) DllStructSetData($grc, "textcolor", 0) For $i = 1 To $Rows Step 2 _SendMessage($hWnd, $GM_SETROWCOLOR, $i, DllStructGetPtr($grc)) Next $grc = 0 EndFunc ;==>ColorTheGrid Func _MakeRGB($b, $g, $r) Dim $aRGB[3] $aRGB[0] = $r $aRGB[1] = $g $aRGB[2] = $b Return _ColorSetRGB($aRGB) EndFunc ;==>_MakeRGB This are the notifications: Global Const $__RAGRIDCONSTANT_DEFAULT_GUI_FONT = 17 Global Const $GN_HEADERCLICK = 1 ;User clicked header Global Const $GN_BUTTONCLICK = 2 ;Sendt when user clicks the button in a button cell Global Const $GN_CHECKCLICK = 3 ;Sendt when user double clicks the checkbox in a checkbox cell Global Const $GN_IMAGECLICK = 4 ;Sendt when user double clicks the image in an image cell Global Const $GN_BEFORESELCHANGE = 5 ;Sendt when user request a selection change Global Const $GN_AFTERSELCHANGE = 6 ;Sendt after a selection change Global Const $GN_BEFOREEDIT = 7 ;Sendt before the cell edit control shows Global Const $GN_AFTEREDIT = 8 ;Sendt when the cell edit control is about to close Global Const $GN_BEFOREUPDATE = 9 ;Sendt before a cell updates grid data Global Const $GN_AFTERUPDATE = 10 ;Sendt after grid data has been updated Global Const $GN_USERCONVERT = 11 ;Sendt when user cell needs to be converted. Edited February 8, 2012 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
adouros Posted December 10, 2013 Share Posted December 10, 2013 Hello. I am interesting for the RaGrid.dll Where can i find the "RAGrid_UDF.au3" file? Best regards. Thanos Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now