Jump to content

hoe to zip files and 1 more question


Wollf
 Share

Recommended Posts

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?

Link to comment
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

:)

Link to comment
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
Link to comment
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)
Link to comment
Share on other sites

Why would you use GUICtrlRead() to get a value you already have? Remember that you already have the file in @GUI_DRAGFILE so simply do:

Run(@GUI_DRAGFILE)
Link to comment
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
Link to comment
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?

Link to comment
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.

Link to comment
Share on other sites

  • 4 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...