Sub Item_Bitmap.Destroy() ID = "" : Title = "" DestroyWindow(whwnd) Using GDIPLUS GdipDisposeImage Origin DeleteObject(Image) Origin = 0 Image = 0 whwnd = 0 End Sub Function CreateImageItem(byref ItemHandle as Item, byref ImageHandle as HBITMAP, byval px as Integer, byval py as Integer, byval iWidth as UInteger = 0, byval iHeight as UInteger = 0) as Item Dim as UInteger Style = SS_NOTIFY OR SS_BITMAP OR WS_CHILD OR WS_VISIBLE OR WS_CLIPSIBLINGS OR WS_CLIPCHILDREN If ItemHandle = 0 Then return NULL If (ItemHandle = 0) Then return NULL Dim as RECT prect Dim as HWND phwnd Dim as Integer rx, ry If (ItemHandle -> ID = WindowID) Then phwnd = ItemHandle -> whwnd rx = px : ry = py ElseIf (ItemHandle -> ID = GroupBoxID) Then phwnd = GetParent(ItemHandle -> whwnd) GetClientRect(ItemHandle -> whwnd, @prect) MapWindowPoints(ItemHandle -> whwnd, phwnd, Cast(LPPOINT, @prect),2) rx = prect.left + px : ry = prect.top + py Else LOGSTRING(Time & " | ERROR | Parent is not an valid Item.") Return NULL End If Using GDIPLUS Dim as Item_Bitmap ptr NewBitmapItem = NEW Item_Bitmap Dim as Integer nWidth, nHeight Dim as Integer oWidth, oHeight Dim as GPBITMAP ptr TempImage NewBitmapItem -> Origin = CreateCopy_WINImage_As_GDIImage(ImageHandle) GdipGetImageWidth(NewBitmapItem -> Origin, @oWidth) GdipGetImageHeight(NewBitmapItem -> Origin, @oHeight) nWidth = oWidth : nHeight = oHeight If iWidth Then nWidth = IIF(iWidth<=oWidth, iWidth, oWidth) If iHeight Then nHeight = IIF(iHeight<=oHeight, iHeight, oHeight) TempImage = GetRect_From_GDIImage(NewBitMapItem -> Origin, 0, 0, nWidth, nHeight) NewBitMapItem -> Image = CreateCopy_GDIImage_As_WINImage(TempImage) GdipDisposeImage TempImage NewBitmapItem -> whwnd = CreateWindowEx( 0, "static", 0, Style, _ rx, ry, nWidth, nHeight, phwnd, NULL, Globals.hInstance, NewBitmapItem) If (NewBitmapItem -> whwnd = 0) Then GdipDisposeImage NewBitmapItem -> Origin DeleteObject(NewBitMapItem -> Image) Delete NewBitmapItem LOGSTRING(Time & " | ERROR | Failed to create " & BitmapID) MessageBox(NULL,"Failed to create " & BitmapID, "Error", NULL) Return 0 End If SendMessage(NewBitmapItem -> whwnd, STM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM, NewBitMapItem -> Image)) NewBitmapItem -> ID = BitmapID NewBitmapItem -> Title = "w" & str(nWidth) & " h" & str(nHeight) NewBitmapItem -> cWidth = nWidth NewBitmapItem -> cHeight = nHeight NewBitmapItem -> parent = ItemHandle SetWindowLongPtr(NewBitmapItem -> whwnd, GWLP_USERDATA, Cast(LONG_PTR, NewBitmapItem)) 'LOGSTRING(Time & " | INFO | " & BitmapID & " created.") LOGSTRING(Time & " | INFO | " & BitmapID & " " & NewBitmapItem -> Title & " created on " & ItemHandle -> ID & " " & ItemHandle -> Title & ".") Globals.ItemList.AddItem(NewBitmapItem) return NewBitmapItem End Function Function ResizeImageItem(byref ItemHandle as Item, byval newWidth as UInteger = 0, byval newHeight as Uinteger = 0) as Integer If (ItemHandle = 0) orelse ItemHandle -> ID <> BitmapID Then return Not(NULL) 'error Using GDIPLUS Dim as GPBITMAP ptr TempImage Dim as HBITMAP NewImage Dim as Integer nWidth, nHeight Dim as Integer oWidth, oHeight GdipGetImageWidth(Cast(Item_Bitmap ptr, ItemHandle) -> Origin, @oWidth) GdipGetImageHeight(Cast(Item_Bitmap ptr, ItemHandle) -> Origin, @oHeight) If newWidth Then nWidth = IIF(newWidth<=oWidth, newWidth, oWidth) If newHeight Then nHeight = IIF(newHeight<=oHeight, newHeight, oHeight) TempImage = GetRect_From_GDIImage(Cast(Item_Bitmap ptr, ItemHandle) -> Origin, 0, 0, nWidth, nHeight) 'get rect NewImage = CreateCopy_GDIImage_As_WINImage(TempImage) SendMessage(ItemHandle -> whwnd, STM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM, NewImage)) DeleteObject(Cast(Item_Bitmap ptr, ItemHandle) -> Image) 'Delete Old Image Cast(Item_Bitmap ptr, ItemHandle) -> Image = NewImage 'Set Cast(Item_Bitmap ptr, ItemHandle) -> Title = "w" & str(nWidth) & " h" & str(nHeight) oWidth = Cast(Item_Bitmap ptr, ItemHandle) -> cWidth oHeight = Cast(Item_Bitmap ptr, ItemHandle) -> cHeight Cast(Item_Bitmap ptr, ItemHandle) -> cWidth = nWidth Cast(Item_Bitmap ptr, ItemHandle) -> cHeight = nHeight If oWidth<>nWidth or oHeight<>nHeight Then LOGSTRING(Time & " | INFO | " & BitmapID & " resized. " & Cast(Item_Bitmap ptr, ItemHandle) -> Title) Return NULL 'error End Function Function ReplaceImageItem(byref ItemHandle as Item, byval newImage as HBITMAP) as Integer If (ItemHandle = 0) orelse ItemHandle -> ID <> BitmapID orelse newImage = 0 Then return Not(NULL) 'error Using GDIPLUS Dim as GPBITMAP ptr TempImage = CreateCopy_WINImage_As_GDIImage(newImage) GdipDisposeImage Cast(Item_Bitmap ptr, ItemHandle) -> Origin Cast(Item_Bitmap ptr, ItemHandle) -> Origin = TempImage LOGSTRING(Time & " | INFO | " & BitmapID & " replaced.") ResizeImageItem(ItemHandle, Cast(Item_Bitmap ptr, ItemHandle) -> cWidth, Cast(Item_Bitmap ptr, ItemHandle) -> cHeight) End Function