Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Delphi Static Window (https://www.delphipraxis.net/192765-static-window.html)

EWeiss 17. Mai 2017 19:59

Static Window
 
Ich erstelle ein STATIC Window vergleichbar mit einem Image.
Daher bin ich mir jetzt nicht sicher ob ich in diesen Window den Hintergrund mit einem Farbverlauf bemalen kann.

weiß jemand was darüber?

Delphi-Quellcode:
procedure TOpenDialog.PrepareImageWindow(WinHandle: HWND);
var
  dwExStyle: DWORD;
  dwStyle: DWORD;
  rc: TRect;
begin

  GetClientRect(hSysListView, rc);

  dwStyle := SS_BITMAP or SS_CENTERIMAGE or WS_CHILD or WS_VISIBLE;
  dwExStyle := WS_EX_STATICEDGE;
  hWndPreview := CreateWindowEx(dwExStyle, 'STATIC', '', dwStyle, rc.Right + 18, 5,
    230, 230, WinHandle, 0, hInstance, nil);

end;
Delphi-Quellcode:
          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;
Mit dieser Befehlszeile wird das Window mit dem Image gefüllt.
Delphi-Quellcode:
SendMessage(hWndPreview, STM_SETIMAGE, IMAGE_ENHMETAFILE, LPARAM(NewImage));


alles kein Problem..

Wenn ich den Hintergrund mit einem Farbverlauf füllen könnte.
Oder geht das mit einem STATIC Window nicht ?
Es geht um das Fenster wo das Bild gezeichnet wird ;) der Hintergrund soll mit einem Farbverlauf gefüllt werden.

gruss


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:41 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz