CDN_SELCHANGE:
begin
if hWndPreview <> 0
then
begin
df := Sendmessage(POFNotify(lp)^.hdr.hwndFrom, CDM_GETFILEPATH, SizeOf(picFilePath),
LParam(@picFilePath));
if df > 0
then
begin
picFileName := LeftStr(picFilePath,
df - 1);
So := InStr(-1, picFileName, '
.');
if So <> 0
then
begin
ImgType := ExtractFileExt(picFileName);
ImageType := InStr(IMAGETYPES, ImgType);
if ImageType <> 0
then
begin
Skinengine.FUpdateWindow(hWndPreview, TRUE);
GdipLoadImageFromFile(PWideChar(picFileName), NewImage);
GDIP_GetImageSize(NewImage, ImgW, ImgH);
if GdipCreateFromHDC(GetDC(hWndPreview), Graphics) = OK
then
begin
MaxHeight := 230; MaxWidth := 230;
Width := ImgW; Height := ImgH;
if (ImgW > MaxWidth)
or (ImgH > MaxHeight)
then
begin
Percent := (MaxWidth / Width) * 100;
If (Height * Percent / 100) > MaxHeight
then
begin
Percent := (MaxHeight / Height) * 100;
MaxWidth := Width / 100 * Percent;
end else
MaxHeight := Height / 100 * Percent;
GdipDrawImageRectI(Graphics, NewImage, (230 - round(MaxWidth))
div 2,
(230 - round(MaxHeight))
div 2,
round(MaxWidth), round(MaxHeight));
end else
begin
GdipDrawImageRectRectI(Graphics, NewImage, (230 - ImgW)
div 2,
(230 - ImgH)
div 2, ImgW, ImgH, 0, 0, ImgW, ImgH, 2,
nil, false,
nil)
end;
SendMessage(hWndPreview, STM_SETIMAGE, IMAGE_ENHMETAFILE, LPARAM(NewImage));
end;
GDIPDeleteGraphics(Graphics);
GdipDisposeImage(NewImage);
end;
end;
end;