Iczer Posted March 22, 2015 Posted March 22, 2015 i have some troubles with WM_PAINT work on tabs (it wont redraw pic on tab item change) and also with resetting image place holder to default colour before drawing new pic in to it (previous pic can be seen if it aspect ratio is different from new)... what i'm doing wrong? see: expandcollapse popup#AutoIt3Wrapper_Version=Beta #include <File.au3> #include <Array.au3> #include <GuiListBox.au3> #include <GDIPlus.au3> #include <WinAPIGdi.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GuiStatusBar.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> Global $hBitmap_Scaled, $hGraphics #Region ### START Koda GUI section ### Form= $ChoiserGUI = GUICreate("Choiser GUI", 623, 449, 192, 114) $Tab1 = GUICtrlCreateTab(8, 32, 609, 385) $TabSheet1 = GUICtrlCreateTabItem("first tab") $Group1 = GUICtrlCreateGroup("Selector", 16, 64, 329, 193) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Prewiev", 352, 64, 257, 313) Global $aPrewievPic[4] = [360, 80, 244, 292] $PrewievPic = GUICtrlCreatePic("", 360, 80, 244, 292, BitOR($GUI_SS_DEFAULT_PIC,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE,$GUI_WS_EX_PARENTDRAG)) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Choise", 16, 264, 329, 113) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button_Next = GUICtrlCreateButton("Next", 456, 384, 75, 25) $TabSheet2 = GUICtrlCreateTabItem("second tab") $TabSheet3 = GUICtrlCreateTabItem("third tab") GUICtrlCreateTabItem("") $StatusBar1 = _GUICtrlStatusBar_Create($ChoiserGUI) GUIRegisterMsg($WM_PAINT,"WM_PAINT_PrewievPic") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _GDIPlus_Startup() $hDC = _WinAPI_GetDC ( $ChoiserGUI ) $BkColor = _WinAPI_GetBkColor ( $hDC ) ConsoleWrite($BkColor&@crlf) _WinAPI_ReleaseDC($ChoiserGUI, $hDC) $hBrush = _GDIPlus_BrushCreateSolid($BkColor) Global $hImage, $hBitmap_Scaled, $hGraphics $sSourceFolder = "C:\WINDOWS" $picExtentions = "*.jpeg;*.jpg;*.png;*.tiff;*.tif;*.gif;*.tga;*.bmp;*.pcx;*.jpe;*.jif;*.jfif;*.jfi;*.dib;*.tpic" $fl = _FileListToArrayRec($sSourceFolder,$picExtentions,Default,Default,Default, 2 ) $spath = $fl[Random(1,$fl[0],1)] QQQ($spath) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_Shutdown() Exit Case $Button_Next QQQ($fl[Random(1,$fl[0],1)]) EndSwitch WEnd Func QQQ($spath) Local $iW, $iH, $iAspect, $iAspectFrame, $iH_new, $iW_new _GDIPlus_BitmapDispose($hImage) _GDIPlus_BitmapDispose($hBitmap_Scaled) $hImage = _GDIPlus_ImageLoadFromFile($spath) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $iAspect = $iW/$iH $iAspectFrame = $aPrewievPic[2]/$aPrewievPic[3] Select Case $iAspectFrame >= $iAspect $iH_new = $aPrewievPic[3] $iW_new = $iH_new*$iAspect Case $iAspectFrame < $iAspect $iW_new = $aPrewievPic[2] $iH_new = $iW_new/$iAspect EndSelect $hBitmap_Scaled = _GDIPlus_ImageResize($hImage, $iW_new-8, $iH_new-8) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($ChoiserGUI) _GDIPlus_GraphicsFillRect($hGraphics, $aPrewievPic[0]+4, $aPrewievPic[1]+4, $aPrewievPic[2]-8, $aPrewievPic[3]-8, $hBrush) _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, $aPrewievPic[0]+4, $aPrewievPic[1]+4) EndFunc Func WM_PAINT_PrewievPic($hWnd,$wParam,$lParam) #forceref $hWnd,$wParam,$lParam _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, $aPrewievPic[0]+4, $aPrewievPic[1]+4) Return $GUI_RUNDEFMSG EndFunc
Yashied Posted March 22, 2015 Posted March 22, 2015 Why do not use Pic control? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Iczer Posted March 22, 2015 Author Posted March 22, 2015 it only have support for bmp, jpg and gif but i also need support for png and tif at least...
Yashied Posted March 24, 2015 Posted March 24, 2015 Look at example for _WinAPI_GetThemeColor() function. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
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