Sign in to follow this  
Followers 0
Wollf

hoe to zip files and 1 more question

14 posts in this topic

i want to make a box that i want user to drag an item from deskpot and drop it inside a box in the windowbut i dont know how to make the box and how make it able for users to drag and drop also how can i make files to rar files?

Share this post


Link to post
Share on other sites



i want to make a box that i want user to drag an item from deskpot and drop it inside a box in the windowbut i dont know how to make the box and how make it able for users to drag and drop also how can i make files to rar files?

Example:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Drag & drop demo", 300, 200, -1, -1, -1, $WS_EX_ACCEPTFILES)

$cListBox = GUICtrlCreateList("", 10, 10, 280, 180)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            GUICtrlSetData($cListBox, @GUI_DRAGFILE & @CRLF, 1)
    EndSwitch
WEnd

:)

Share this post


Link to post
Share on other sites

Here is an example Lazycat gave a while ago.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global Const $WM_DROPFILES = 0x233
Global $gaDropFiles[1]

#Region ### START Koda GUI section ### Form=
$hGUI = GUICreate("", 137, 131, -1, -1, BitOR($WS_DLGFRAME,$WS_POPUP,$WS_CLIPSIBLINGS), BitOR($WS_EX_ACCEPTFILES,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetBkColor(0xFFFFFF)
$hList = GUICtrlCreateLabel("Drop files here", 0, 0, 135, 121, BitOR($SS_CENTER,$SS_CENTERIMAGE), $GUI_WS_EX_PARENTDRAG)
GUICtrlSetState ($hList, $GUI_DROPACCEPTED)
$hContext = GUICtrlCreateContextMenu($hList)
$hExit = GUICtrlCreateMenuItem("Exit", $hContext)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg ($WM_DROPFILES, "WM_DROPFILES_FUNC")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $hExit
            Exit
        Case $GUI_EVENT_DROPPED
            For $i = 0 To UBound($gaDropFiles) - 1
                ConsoleWrite($gaDropFiles[$i] & @CR)
            Next
    EndSwitch
WEnd

Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i+1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next
EndFunc

Share this post


Link to post
Share on other sites

Example:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Drag & drop demo", 300, 200, -1, -1, -1, $WS_EX_ACCEPTFILES)

$cListBox = GUICtrlCreateList("", 10, 10, 280, 180)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            GUICtrlSetData($cListBox, @GUI_DRAGFILE & @CRLF, 1)
    EndSwitch
WEnd

:)

thanks for the example but what exactly it does when you drag file with that order? ($cListBox, @GUI_DRAGFILE & @CRLF, 1)

Share this post


Link to post
Share on other sites

because with the first example i only see i can drag files into the list and then their location appear after that to change it do i need to guictrlread the list and then run(guictrlread($clist)) ?

Share this post


Link to post
Share on other sites

thanks for help i tried something now but after i did it doesnt anymore saw the file into the list. Also how can i make files rar instead of run file i want to rar it

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1) 
$hGUI = GUICreate("Drag & drop demo", 300, 300, -1, -1, -1, $WS_EX_ACCEPTFILES)
$Button1 = GUICtrlCreateButton("button",200,200,50,50)
GUICtrlSetOnEvent(-1, "Button1")
$cListBox = GUICtrlCreateList("", 10, 10, 280, 180)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
Func button1()
    run(@GUI_DRAGFILE)
    EndFunc
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            GUICtrlSetData($cListBox, @GUI_DRAGFILE & @CRLF, 1)
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

what i do wrong in the code in previous post?\

Share this post


Link to post
Share on other sites

1) don't bump in less then 24 hours from your last post.

2) it doesn't work because you are using a while loop with on event mode. Look up the differences in the help file.


Giggity

Share this post


Link to post
Share on other sites

ah yes i see but if i remove on event mode i wont be able to use buttons because i dont know any other way make buttons function yet. what else i can use instead of onevent mode to make buttons work?

also how i can make a normal file i have at list to .rar file?

Share this post


Link to post
Share on other sites

for the buttons do something like.

$but1 = GuiCtrlCreateButton("button 1", 10, 10)

while 1
      $msg = Guigetmsg()
      if $msg = $but1 then
            msgbox(0, "","Button 1 pressed"
      endif
wend

Look it up in the help file, there is all kinds of ways to get a button to work.

Share this post


Link to post
Share on other sites

ah yes ty now i now 2 ways to make buttons functions now i need to know how to zip files in list and make them .rar files

Share this post


Link to post
Share on other sites

is there a way to do that with winrar or i must use 7-zip

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0