Witam uprzejmie
VistaAltFix, mam ten .pas pobrany. Teraz nie wiem, czy ja to dobrze zrozumiałem. Moja przygoda z Delphi to dokładnie 14 dni.
Odpaliłem Delphi 7 Personal i tam w Component>Install Component>Into New Package
Teraz wybieram ten vistaaltfix.pas, nadaję nazwę dla Package file name i naciskam OK.
Następnie w Componentach dodaje mi się zakładka MEP i jest tam do wyboru już VistaAltFix, drag and drop na mój Frame (tak samo jak komponent XPMan).
Dodaje mi się do Uses i dopisuję jedną linijkę do mojego:
Kopiuj
procedure TForm1.FormCreate(Sender: TObject);
begin
TVistaAltFix.Create(Self);
end;
Kompiluję, buduję, odpalam i kupa, dalej ALT powoduje znikanie.
Kod VistaAltFixUnit.pas:
Kopiuj
unit VistaAltFixUnit;
interface
uses
ExtCtrls, Classes, Contnrs, AppEvnts;
type
TVistaAltFix = class(TComponent)
private
FList: TObjectList;
FApplicationEvents: TApplicationEvents;
FRepaintAll: Boolean;
procedure ApplicationEventsIdle(Sender: TObject; var Done: Boolean);
function VistaWithTheme: Boolean;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property RepaintAll: Boolean read FRepaintAll write FRepaintAll default True;
end;
procedure Register;
implementation
uses
Forms, Windows, Messages, Buttons, ComCtrls, Controls, StdCtrls, Themes;
type
TFormObj = class(TObject)
private
procedure WndProc(var Message: TMessage);
public
Form: TForm;
OrgProc: TWndMethod;
Used: Boolean;
NeedRepaint: Boolean;
RepaintAll: Boolean;
constructor Create(aForm: TForm; aRepaintAll: Boolean);
procedure DoRepaint;
end;
procedure Register;
begin
RegisterComponents('MEP', [TVistaAltFix]);
end;
procedure TVistaAltFix.ApplicationEventsIdle(Sender: TObject;
var Done: Boolean);
var
I: Integer;
J: Integer;
TestForm: TForm;
begin
for I := 0 to FList.Count - 1 do
TFormObj(FList[i]).Used := False;
for I := 0 to Screen.FormCount - 1 do
begin
TestForm := Screen.Forms[i];
for J := 0 to FList.Count - 1 do
begin
if TFormObj(FList[J]).Form = TestForm then
begin
TFormObj(FList[J]).Used := True;
TestForm := nil;
Break;
end;
end;
if Assigned(TestForm) then
FList.Add(TFormObj.Create(TestForm, RepaintAll));
end;
for I := FList.Count - 1 downto 0 do
begin
if not TFormObj(FList[i]).Used then
FList.Delete(i)
else
TFormObj(FList[i]).DoRepaint;
end;
end;
constructor TVistaAltFix.Create(AOwner: TComponent);
begin
inherited;
FRepaintAll := True;
if VistaWithTheme and not (csDesigning in ComponentState) then
begin
FList := TObjectList.Create;
FApplicationEvents := TApplicationEvents.Create(nil);
FApplicationEvents.OnIdle := ApplicationEventsIdle;
end;
end;
destructor TVistaAltFix.Destroy;
begin
FApplicationEvents.Free;
FList.Free;
inherited;
end;
function TVistaAltFix.VistaWithTheme: Boolean;
var
OSVersionInfo: TOSVersionInfo;
begin
OSVersionInfo.dwOSVersionInfoSize := SizeOf(OSVersionInfo);
if GetVersionEx(OSVersionInfo) and
(OSVersionInfo.dwMajorVersion >= 6) and
ThemeServices.ThemesEnabled then
Result := True
else
Result := False;
end;
constructor TFormObj.Create(aForm: TForm; aRepaintAll: Boolean);
begin
inherited Create;
Form := aForm;
RepaintAll := aRepaintAll;
Used := True;
OrgProc := Form.WindowProc;
Form.WindowProc := WndProc;
end;
procedure TFormObj.DoRepaint;
procedure RepaintBtnControls(TheCtrl: TControl);
var
i: integer;
begin
if not (TheCtrl is TWinControl) or (TheCtrl is TBitBtn) then
exit;
if (TheCtrl is TButtonControl) or (TheCtrl is TStaticText) then
begin
TWinControl(TheCtrl).Repaint;
exit;
end;
for i := 0 to TWinControl(TheCtrl).ControlCount - 1 do
begin
if (TheCtrl is TTabSheet) and
(TTabSheet(TheCtrl).PageIndex <> TTabSheet(TheCtrl).PageControl.ActivePageIndex) then
continue;
RepaintBtnControls(TWinControl(TheCtrl).Controls[i]);
end;
end;
procedure DoRepaint(Ctrl: TControl);
var
i: integer;
begin
if (Ctrl is TWinControl) then
begin
TWinControl(Ctrl).Repaint;
for i := 0 to TWinControl(Ctrl).ControlCount - 1 do
DoRepaint(TWinControl(Ctrl).Controls[i]);
end;
end;
begin
if NeedRepaint then
begin
NeedRepaint := False;
if RepaintAll then
DoRepaint(Form)
else
RepaintBtnControls(Form);
end;
end;
procedure TFormObj.WndProc(var Message: TMessage);
begin
OrgProc(Message);
if (Message.Msg = WM_UPDATEUISTATE) then
NeedRepaint := True;
end;
end.
Jest tam kawałek informacji:
Kopiuj
Usage:
If you want to use this as an component you have to install it into the Delphi IDE.
If you don't want to do that just add this code in your main form OnCreate:
procedure TMainForm.FormCreate(Sender: TObject);
begin
TVistaAltFix.Create(Self);
end;
Ja właśnie chyba zrobiłem: If you want to use this as an component you have to install it into the Delphi IDE.
...jednak nie działa.
Prosiłbym o pomoc, jak zastosować ten plik .pas
U mnie problem występuję na TPageControl.
Z poważaniem