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:
AutoIt
#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