SkellySoul Posted August 10, 2009 Posted August 10, 2009 (edited) I first want to start off by saying sorry to whoever reads this because I have not slept in the last 24 hours.What I been trying to do is this... - + ¶ make up my GUI - = Width ¶ = HeightYou can't see this but a FolderOpenDialog popups and and asks for the folder you want that has the pictures and than it jumps to A The A that is labeled in my GUI is a listview/editbox this is the box that has lots of pictures 40x40 with a scroll bar to scroll down to see other pictures with the sizes 40x40 it gets it's pictures from the folder you selected.B is a picture control so when you a click on a object from A it shows the original size of the picture in BSo Basically what I am looking for is a image viewer that searches a folder and outputs all the pictures to a list/edit control and when clicked on displays it on a picture control. Edited August 10, 2009 by SkellySoul
SkellySoul Posted August 12, 2009 Author Posted August 12, 2009 ok so I worked on something today but how can I do an action when the picture is clicked expandcollapse popup#include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("Form1", 400, 200) ;Make Loop when not about to pass out... $oIE = _IECreateEmbedded() $oIE_Object = GUICtrlCreateObj($oIE, 0, 0, 80 , 200) $File = GUICtrlCreateMenu("File") $File_Open = GUICtrlCreateMenuItem("Open" , $File) $File_Sep = GUICtrlCreateMenuItem("" , $File) $File_Save = GUICtrlCreateMenuItem("Save" , $File) $File_Sep = GUICtrlCreateMenuItem("" , $File) $File_Exit = GUICtrlCreateMenuItem("Exit" , $File) ;_IENavigate ($oIE, "about:blank") _IENavigate ($oIE, "C:\Documents and Settings\User\Desktop\Map\Grass\4_1.gif") $Pic1 = GUICtrlCreatePic("", 100, 0, 100, 100) $Button1 = GUICtrlCreateButton("Button1", 328, 360, 75, 25, 0) GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $File_Exit Exit Case $File_Open FileSelectFolder("Tile Folder" , @ScriptDir) Case $File_Save ;;; EndSwitch WEnd
smashly Posted August 14, 2009 Posted August 14, 2009 Hi, good to see your working it out. I don't know if this helps or notexpandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #include <EditConstants.au3> #include <Constants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) Global $sExtFilter = "bmp|gif|jpeg|jpg|png|tif|tiff" Global $hGui, $Path, $BRowse, $LV, $Pic, $Msg Global $hImageList, $sCur, $sLast, $iDX, $iPicState = 0 $hGui = GUICreate(":-)", 330, 310) GUICtrlCreateGroup("Browse for folder containing pictures", 5, 5, 320, 55) $Path = GUICtrlCreateInput("", 15, 25, 230, 20, $ES_READONLY) GUICtrlSetBkColor(-1, 0xFFFFFF) $BRowse = GUICtrlCreateButton("Browse", 255, 25, 60, 20) $LV = GUICtrlCreateListView("", 5, 70, 82, 234, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER)) _GUICtrlListView_SetView($LV, 1) _GUICtrlListView_SetIconSpacing($LV, 60, 30) GUICtrlCreateGroup("Preview", 94, 65, 232, 241) $Pic = GUICtrlCreatePic("", 100, 80, 220, 220) GUISetState(@SW_SHOW, $hGui) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $BRowse _Browse() Case Else _LVEvent() EndSwitch WEnd Func _Browse() Local $FSF, $FL2A, $hBmp, $sTmp = '', $aTmp, $iCnt = 0 $FSF = FileSelectFolder("Browse for folder containing pictures", "", "", $hGui) If Not @error And FileExists($FSF) Then If StringRight($FSF, 1) <> "\" Then $FSF &= "\" $FL2A = _FileListToArray($FSF, "*", 1) If Not @error Then If IsPtr($hImageList) Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV)) _GUIImageList_Destroy($hImageList) $hImageList = "" _hBmpToPicControl($Pic, $hBmp) GUICtrlSetImage($Pic, "") $iDX = -1 $iPicState = 0 $sCur = "" $sLast = "" EndIf $hImageList = _GUIImageList_Create(60, 60, 5, 3) _GUICtrlListView_SetImageList($LV, $hImageList, 0) For $i = 1 To $FL2A[0] If StringRegExp($FL2A[$i], "(?i)\.(" & $sExtFilter & ")", 0) Then $hBmp = _GetImage($FSF & $FL2A[$i], 60) _GUIImageList_Add($hImageList, $hBmp) _WinAPI_DeleteObject($hBmp) _GUICtrlListView_AddItem($LV, $FL2A[$i], $iCnt) _GUICtrlListView_SetItemImage($LV, $iCnt, $iCnt) $iCnt += 1 EndIf Next GUICtrlSetData($Path, $FSF) EndIf WinSetTitle($hGui, "", "Images Found: " & $iCnt) EndIf EndFunc ;==>_Browse Func _LVEvent() Local $hBmp If $iDX <> -1 Then $sCur = GUICtrlRead($Path) & _GUICtrlListView_GetItemText($LV, $iDX) If $sCur <> $sLast Then $hBmp = _GetImage($sCur, 220, BitOR(0xFF000000, _GetGuiBkColor(_WinAPI_GetForegroundWindow()))) _hBmpToPicControl($Pic, $hBmp, 1) $sLast = $sCur $iPicState = 1 EndIf $iDX = -1 ElseIf $iDX = -1 And _GUICtrlListView_GetNextItem($LV) = -1 And $iPicState Then _hBmpToPicControl($Pic, $hBmp) $iPicState = 0 $sCur = "" $sLast = "" EndIf EndFunc ;==>_LVEvent Func _GetImage($sFile, $iWH, $iBkClr = 0xFFFFFF) Local $hBmp1, $hBitmap, $hGraphic, $hImage, $iW, $iH, $aGS, $hBmp2 _GDIPlus_Startup() $hBmp1 = _WinAPI_CreateBitmap($iWH, $iWH, 1, 32) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp1) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap) _WinAPI_DeleteObject($hBmp1) _GDIPlus_GraphicsClear($hGraphic, BitOR(0xFF000000, $iBkClr)) $hImage = _GDIPlus_ImageLoadFromFile($sFile) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $aGS = _GetScale($iW, $iH, $iWH) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, $aGS[0], $aGS[1], $aGS[2], $aGS[3]) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphic) $hBmp2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Return $hBmp2 EndFunc ;==>_GetImage Func _GetScale($iW, $iH, $iWH) Local $aRet[4] If $iW <= $iWH And $iH <= $iWH Then $aRet[2] = $iW $aRet[3] = $iH $aRet[0] = ($iWH - $aRet[2]) / 2 $aRet[1] = ($iWH - $aRet[3]) / 2 ElseIf $iW > $iH Then $aRet[2] = $iWH $aRet[3] = $iH / ($iW / $iWH) $aRet[0] = 0 $aRet[1] = ($iWH - $aRet[3]) / 2 ElseIf $iW < $iH Then $aRet[2] = $iW / ($iH / $iWH) $aRet[3] = $iWH $aRet[0] = ($iWH - $aRet[2]) / 2 $aRet[1] = 0 ElseIf $iW = $iH Then $aRet[2] = $iWH $aRet[3] = $iWH $aRet[0] = 0 $aRet[1] = 0 EndIf Return $aRet EndFunc ;==>_GetScale Func _GetGuiBkColor($hWnd) Local $hDC, $aBGR $hDC = _WinAPI_GetDC($hWnd) $aBGR = DllCall('gdi32.dll', 'int', 'GetBkColor', 'hwnd', $hDC) _WinAPI_ReleaseDC($hWnd, $hDC) Return BitOR(BitAND($aBGR[0], 0x00FF00), BitShift(BitAND($aBGR[0], 0x0000FF), -16), BitShift(BitAND($aBGR[0], 0xFF0000), 16)) EndFunc ;==>_GetGuiBkColor Func _hBmpToPicControl($iCID, ByRef $hBmp, $iFlag = 0) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local $hOldBmp $hOldBmp = GUICtrlSendMsg($iCID, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp) If $hOldBmp Then _WinAPI_DeleteObject($hOldBmp) If $iFlag Then _WinAPI_DeleteObject($hBmp) EndFunc ;==>_hBmpToPicControl Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $aIDX $hWndListView = GUICtrlGetHandle($LV) $tNMHDR = DllStructCreate("hwnd hWndFrom;int_ptr IDFrom;int Code", $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK $iDX = _GUICtrlListView_GetNextItem($hWndListView) Case $LVN_KEYDOWN $tInfo = DllStructCreate("hwnd hWndFrom;int_ptr IDFrom;int Code;int_ptr VKey;int Flags", $ilParam) Switch BitAND(DllStructGetData($tInfo, "VKey"), 0xFFFF) Case $VK_UP $iDX = _GUICtrlListView_GetNextItem($hWndListView) - 1 If $iDX < 0 Then $iDX = 0 Case $VK_DOWN $iDX = _GUICtrlListView_GetNextItem($hWndListView) + 1 If $iDX >= _GUICtrlListView_GetItemCount($hWndListView) Then $iDX -= 1 EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Cheers
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