AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi GetLayeredWindowAttributes funktioniert nicht noch Resize
Thema durchsuchen
Ansicht
Themen-Optionen

GetLayeredWindowAttributes funktioniert nicht noch Resize

Ein Thema von virus82 · begonnen am 21. Okt 2009 · letzter Beitrag vom 22. Feb 2010
 
Benutzerbild von himitsu
himitsu
Online

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.753 Beiträge
 
Delphi 12 Athens
 
#2

Re: GetLayeredWindowAttributes funktioniert nicht noch Resiz

  Alt 21. Okt 2009, 09:07
Zitat von virus82:
Ach ja ich nutze Delphi2009, auf Windows XP Professional SP3.
Selbes System (32 Bit) ... keine Probleme (egal ob eigenes Fenster oder Notepad minimiert wurde)



Außerdem: GetLastError sollte man sich gleich holen und nicht erst irgendwas anderes ziwschendurch machen, welches den Wert verändern könnte.


Also selbst wenn SetLayeredWindowAttributes fehlschlägt und dann aber GetLayeredWindowAttributes erfolgreich ist und auch noch den Fehler-Code zurück/neu setzt, dann würdest du da nie einen Fehler von SetLayeredWindowAttributes erhalten.

Delphi-Quellcode:
procedure TestAlphaBlend;
var
  hHandle: THandle;
  ExStyle: DWORD;
  bResSet: Boolean;
  bResGet: Boolean;
  AlphaValue: Byte;
  TranspColor: COLORREF;
  Flags: DWORD;
  Error: Cardinal;
  s: String;
begin
  s := 'nix';
  AlphaValue := 0;
  Flags := 0;
  hHandle := FindWindowEx(0, 0, 'Notepad', nil); //Fensterhandle von einem Notepad
  if ((hHandle <> INVALID_HANDLE_VALUE) and //gültiges Handle
      (IsWindowVisible(hHandle))) then //Fenster sichtbar
    begin
      s := '';
      ExStyle := GetWindowLong(hHandle, GWL_EXSTYLE); //Extended Style holen
      if ((ExStyle and WS_EX_LAYERED) = 0) then //wenn kein Layered Fenster
        SetWindowLong(hHandle, GWL_EXSTYLE, ExStyle or WS_EX_LAYERED); //dann Layered setzen

      bResSet := SetLayeredWindowAttributes(hHandle, 0, 200, LWA_ALPHA); //AlphaBlend mit Wert 200 setzen
      if bResSet then
        s := s + 'SetLayeredWindowAttributes erfolgreich' + #10#13
      else
        begin
          Error := GetLastError; //Fehler holen
          s := s + 'SetLayeredWindowAttributes nicht erfolgreich' + #10#13; //kommt nie vor
          if (Error = 0) then
            s := s + 'GetLastError = 0' + #10#13
          else
            s := s + 'GetLastError = ' + IntToStr(Error) + #10#13;
        end;

      bResGet := GetLayeredWindowAttributes(hHandle, TranspColor, AlphaValue, Flags); //AlphaBlend ermitteln

      if bResGet then
        begin
          s := s + 'GetLayeredWindowAttributes erfolgreich' + #10#13;
          if ((Flags and LWA_ALPHA) > 0) then //ob AlphaBlend gesetzt ist
            s := s + 'AlphaBlend = True' + #10#13
          else
            s := s + 'AlphaBlend = False' + #10#13
        end
      else
        begin
          Error := GetLastError; //Fehler holen
          s := s + 'GetLayeredWindowAttributes nicht erfolgreich' + #10#13;
          if (Error = 0) then
            s := s + 'GetLastError = 0' + #10#13
          else
            s := s + 'GetLastError = ' + IntToStr(Error) + #10#13;
        end;

      s := s + 'AlphaBlendValue = ' + IntToStr(AlphaValue) + #10#13; //einfach immer ausgeben
    end;

  ShowMessage(s);
end;
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:01 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz