Duda $GUI_DROPACCEPTED
Publicado: 14 Abr 2010, 23:20
Hola gente, bueno soy nuevo en este foro,(aunque llevo una temporada leyendolo) y me gustaría preguntaros que se os ocurre para este "block de notas" casero. Soy novatillo, asi que no se como solucionarlo por mi cuenta...
El problema es el siguiente, tenemos el block de notas, la acción que quiero agregar es la de poder arrastrar archivos y que sean leidos por el "Edit" -> $GUI_DROPACCEPTED, pero no se como agregarlo... Lo más que llega actualmente el código es a introducir la "url" del archivo soltado.
El script en funciones...
Gracias de antemano y espero que me ayuden!
PD: Espero haberlo posteado en el lugar correcto
El problema es el siguiente, tenemos el block de notas, la acción que quiero agregar es la de poder arrastrar archivos y que sean leidos por el "Edit" -> $GUI_DROPACCEPTED, pero no se como agregarlo... Lo más que llega actualmente el código es a introducir la "url" del archivo soltado.
El script en funciones...
Código: Seleccionar todo
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=File-txt.ico
#AutoIt3Wrapper_Res_Comment=Text editor
#AutoIt3Wrapper_Res_Description=ZeroTheAprendice
#AutoIt3Wrapper_Res_Fileversion=1.0.0
#AutoIt3Wrapper_Res_LegalCopyright=ZeroTheAprendice
#AutoIt3Wrapper_Res_Language=1034
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Region Declaraciones previas
#NoTrayIcon
Global $pid = 0
_Singleton($pid)
#EndRegion Declaraciones previas
#Region Include
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#EndRegion Include
#Region GUI
$GUI = GUICreate("Editor de texto", 578, 447, 192, 124, Default, $WS_EX_ACCEPTFILES) ; formulario
$Archivo = GUICtrlCreateMenu("Archivo") ; menu
$New = GUICtrlCreateMenuItem("Nuevo Ctrl+N", $Archivo) ; submenu
$Open = GUICtrlCreateMenuItem("Abrir... Ctrl+A", $Archivo) ; submenu
$SaveAs = GUICtrlCreateMenuItem("Guardar como... Ctrl+G", $Archivo) ; submenu
$Print = GUICtrlCreateMenuItem("Imprimir Ctrl+P", $Archivo) ; submenu
$Exit = GUICtrlCreateMenuItem("Salir", $Archivo) ; submenu
$Edicion = GUICtrlCreateMenu("Edición") ; menu
$Undo = GUICtrlCreateMenuItem("Deshacer Ctrl+Z", $Edicion) ; submenu
$Paste = GUICtrlCreateMenuItem("Pegar Ctrl+V", $Edicion) ; submenu
$Copyall = GUICtrlCreateMenuItem("Copiar todo al portapapeles Ctrl+T", $Edicion) ; submenu
$Mas = GUICtrlCreateMenu("Más") ; menu
$Ayuda = GUICtrlCreateMenuItem("Ayuda F1", $Mas) ; submenu
$About = GUICtrlCreateMenuItem("Acerca de...", $Mas) ; submenu
$Edit = GUICtrlCreateEdit("", 0, 0, 577, 425) ; edit
GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; aceptar drag files~/INCOMPLETO
GUISetState(@SW_SHOW)
#EndRegion GUI
#Region Eventos
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "GUIClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "GUIMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "GUIMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "GUIRestore")
GUICtrlSetOnEvent($New, "_nuevo")
GUICtrlSetOnEvent($Open, "_open")
GUICtrlSetOnEvent($SaveAs, "_guardar")
GUICtrlSetOnEvent($Print, "_print")
GUICtrlSetOnEvent($Exit, "GUIClose")
GUICtrlSetOnEvent($Ayuda, "_ayuda")
GUICtrlSetOnEvent($About, "_about")
GUICtrlSetOnEvent($Undo, "_Undo")
GUICtrlSetOnEvent($Copyall, "_putclip")
GUICtrlSetOnEvent($Paste, "_paste")
#EndRegion Eventos
#Region hotkey
HotKeySet("^n", "_nuevo") ; ctrl+n -> _nuevo()
HotKeySet("^a", "_open") ; ctrl+a -> _open()
HotKeySet("^g", "_guardar") ; ctrl+g -> _guardar()
HotKeySet("^p", "_print") ; ctrl+p -> _print()
HotKeySet("^t", "_putclip") ; ctrl+t -> _putclip()
HotKeySet("{F1}", "_ayuda") ; F1 -> _ayuda()
#EndRegion hotkey
#Region Bucle
While 1
Sleep(100)
If GUICtrlRead($Edit) = "" Then
GUICtrlSetState($SaveAs, $GUI_DISABLE)
Else
GUICtrlSetState($SaveAs, $GUI_ENABLE)
EndIf
Sleep(100)
WEnd
#EndRegion Bucle
#Region GUI FUNC
Func GUIClose()
If Not GUICtrlRead($Edit) = "" Then
If Not IsDeclared("BoxAnswer") Then Local $BoxAnswer
$BoxAnswer = MsgBox(324, "Editor de texto", "¿Seguro que desea salir? ")
Select
Case $BoxAnswer = 6
Exit 0
Case $BoxAnswer = 7
Return
EndSelect
Else
Exit 0
EndIf
EndFunc ;==>GUIClose
Func GUIMaximize()
GUISetState($GUI, @SW_MAXIMIZE)
EndFunc ;==>GUIMaximize
Func GUIMinimize()
GUISetState($GUI, @SW_MINIMIZE)
EndFunc ;==>GUIMinimize
Func GUIRestore()
GUISetState($GUI, @SW_RESTORE)
EndFunc ;==>GUIRestore
#EndRegion GUI FUNC
#Region FUNC
Func _guardar()
If GUICtrlRead($Edit) = "" Then Return
$Guardar = FileSaveDialog("Guardar como", @WorkingDir, "Archivos de texto (*.txt)|Todos los tipos (*.*)", 16)
If @error Then Return
$Data = FileOpen($Guardar & ".txt", 10)
FileWriteLine($Data, GUICtrlRead($Edit))
FileClose($Data)
Return
EndFunc ;==>_guardar
Func _open()
$OpenDialog = FileOpenDialog("Abrir", @WorkingDir, "Archivos de texto (*.txt)|Todos los tipos (*.*)", 1)
If @error Then Return
$Read = FileRead($OpenDialog)
GUICtrlSetData($Edit, $Read)
EndFunc ;==>_open
Func _nuevo()
GUICtrlSetData($Edit, "")
EndFunc ;==>_nuevo
Func _ayuda()
MsgBox(32, "Ayuda", "Editor de texto simple." & @CRLF & "Posibles errores no declarados.")
EndFunc ;==>_ayuda
Func _putclip()
ClipPut(GUICtrlRead($Edit))
EndFunc ;==>_putclip
Func _about()
MsgBox(64, "Acerca de...", "Por ZeroTheAprendice" & @CRLF & @CRLF & "Por esas tardes muertas...")
EndFunc ;==>_about
Func _Undo()
Send("^z")
EndFunc ;==>_Undo
Func _paste()
Send("^v")
EndFunc ;==>_paste
Func _print()
Local $ToPrint = @TempDir & "\ .txt"
$DataP = FileOpen($ToPrint, 1)
FileWriteLine($DataP, GUICtrlRead($Edit))
FileClose($DataP)
_FilePrint($ToPrint)
EndFunc ;==>_print
Func _FilePrint($s_File, $i_Show = @SW_HIDE) ; ->File.au3
Local $a_Ret = DllCall("shell32.dll", "int", "ShellExecuteW", _
"hwnd", 0, _
"wstr", "print", _
"wstr", $s_File, _
"wstr", "", _
"wstr", "", _
"int", $i_Show)
If @error Then Return SetError(@error, @extended, 0)
If $a_Ret[0] <= 32 Then Return SetError(10, $a_Ret[0], 0)
Return 1
EndFunc ;==>_FilePrint
Func _Singleton($sOccurenceName, $iFlag = 0) ; ->Misc.au3
Local Const $ERROR_ALREADY_EXISTS = 183
Local Const $SECURITY_DESCRIPTOR_REVISION = 1
Local $pSecurityAttributes = 0
Global Const $tagSECURITY_ATTRIBUTES = "dword Length;ptr Descriptor;bool InheritHandle" ; ->StructureConstants.au3
If BitAND($iFlag, 2) Then
Local $tSecurityDescriptor = DllStructCreate("dword[5]")
Local $pSecurityDescriptor = DllStructGetPtr($tSecurityDescriptor)
Local $aRet = DllCall("advapi32.dll", "bool", "InitializeSecurityDescriptor", _
"ptr", $pSecurityDescriptor, "dword", $SECURITY_DESCRIPTOR_REVISION)
If @error Then Return SetError(@error, @extended, 0)
If $aRet[0] Then
$aRet = DllCall("advapi32.dll", "bool", "SetSecurityDescriptorDacl", _
"ptr", $pSecurityDescriptor, "bool", 1, "ptr", 0, "bool", 0)
If @error Then Return SetError(@error, @extended, 0)
If $aRet[0] Then
Local $structSecurityAttributes = DllStructCreate($tagSECURITY_ATTRIBUTES)
DllStructSetData($structSecurityAttributes, 1, DllStructGetSize($structSecurityAttributes))
DllStructSetData($structSecurityAttributes, 2, $pSecurityDescriptor)
DllStructSetData($structSecurityAttributes, 3, 0)
$pSecurityAttributes = DllStructGetPtr($structSecurityAttributes)
EndIf
EndIf
EndIf
Local $handle = DllCall("kernel32.dll", "handle", "CreateMutexW", "ptr", $pSecurityAttributes, "bool", 1, "wstr", $sOccurenceName)
If @error Then Return SetError(@error, @extended, 0)
Local $lastError = DllCall("kernel32.dll", "dword", "GetLastError")
If @error Then Return SetError(@error, @extended, 0)
If $lastError[0] = $ERROR_ALREADY_EXISTS Then
If BitAND($iFlag, 1) Then
Return SetError($lastError[0], $lastError[0], 0)
Else
Exit -1
EndIf
EndIf
Return $handle[0]
EndFunc ;==>_Singleton
#EndRegion FUNC
PD: Espero haberlo posteado en el lugar correcto
