Manifest w Delphi 7 - Windows XP, Vista, 7

0

Witam uprzejmie

Proszę o informację, w jaki sposób sprawić, by stworzona aplikacja w Delphi 7 i uruchomiona na Windows 7, miała styl okienek, przycisków i wygląd jak w Windows 7?

Sprawa w Windows XP jest o tyle prosta, że można stworzyć <nazwa_aplikacji>.exe.manifest i odpalić lub skompilować wewnątrz z plikiem .RES.
Niestety nie działa taka metoda z Windows 7 albo coś źle robię. Czy ktoś z Was próbował bawić się z Delphi 7 i manifestem pod Windows 7 i uzyskał zadawalający efekt?

Byłbym wdzięczny za pomoc.
Pozdrawiam serdecznie.

Z poważaniem

0

dla w7 jest inny manifest - poszukaj

0

Witam uprzejmie

Dziękuję za informację, ale o tym już wiem, niestety nie działa ten manifest dla Windows 7.

Opisany: http://msdn.microsoft.com/en-us/library/dd371711%28v=vs.85%29.aspx

Dlatego pytam, czy komuś się udało wdrożyć w Delphi 7 manifest z Windows 7.
Pozdrawiam serdecznie.

Z poważaniem

0

Komponent XPMafinest (czy jakoś tak)....

0

Witam uprzejmie

XPMan z Delphi 7? Hmm, działa też na Vista i 7?
To byłbym w domu! :) Muszę to przetestować po powrocie do domu.
Na XP działa, to wiem, bo testowałem przed chwilą.
Dziękuję i pozdrawiam serdecznie.

Z poważaniem

0

XPManifest powinien działać. Jeżeli nie, trzeba by go przerobić — Vista i Win7 nie lubi plików .manifest osobno poza exekiem (często je olewa).

0

Ja daję XPMan i całość działa OK na Windows 7...

0

Witam uprzejmie

Właśnie zauważyłem, że po wciśnięciu klawisza ALT, znikają RadioButton, Button, Edit, ComboBox hmm...
Czy u Was też tak jest pod Windows 7? Po XP o dziwo nic się nie dzieje takiego.
Program robię na Delphi 7.

Próbowałem OnKeyDown, Key=VK_MENU zrobić jakiś myk, ale w pierwszej kolejności robi ten myk, a potem i tak znikają.
Prosiłbym o podpowiedź.
Pozdrawiam serdecznie.

Z poważaniem

0

Tak się po prostu dzieje... Prawdopodobnie u wszystkich (z tego, co zauważyłem).
Nie ma na to lekarstwa (chyba, że jestem jakiś zacofany :D)

0

Żebym dobrze zrozumiał. Czy program skompilowany pod Delphi 7 na przykład Personal z manifestem XP uruchomiony pod Windows 7 64 bit po naciśnięciu Alta spowoduje znikanie komponentów? To samo po dodaniu manifestu wymuszającego monit UAC o konieczności uzyskania podwyższonych uprawnień. Bo rozumiem, że nie pod IDE tylko w trakcie działania to się zdarza to znikanie. Bo niedługo zmieniam system i komputer na nowy i tą informacją mnie trochę zmartwiliście, bo wolał bym zostać przy tworzeniu programów pod wspomnianą wersją Delphi.

2

Tak się dzieje pod każdą wersją Delphi (możecie przetestować programy czy na to reagują). Z tego co wyczytałem, to Delphi nie jest winne.
I jest na to poprawka, tzn.: VistaAltFix

http://www.koders.com/delphi/fid46DB71DE69DB5D536E9A1EA93FD28F5470B438B0.aspx?s=server

0

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:

procedure TForm1.FormCreate(Sender: TObject);
begin
TVistaAltFix.Create(Self);
{mój kod dalej}
end;

Kompiluję, buduję, odpalam i kupa, dalej ALT powoduje znikanie.

Kod VistaAltFixUnit.pas:

{
Copyright © Norstedts Juridik AB
Made by Per-Erik Andersson, inspired by J Hamblin - Qtools Software.
Author grants unrestricted use of this software code.
All use is on your own risk.

J Hamblin has made a component TjhALTBugFix to solve a problem in Vista.
It can be downloaded from CodeGear Quality centre here:
http://qc.codegear.com/wc/qcmain.aspx?d=37403
Below is the text J Hamblin wrote that describes the problem:

** Quote **************
There seems to be a problem with THEMES support in Delphi, in which
TButton, TCheckBox, TRadioButton and TStaticText standard controls
vanish in VISTA when the ALT key is pressed. (only TStaticText vanishes in XP).
If the OS is set to default, pressing the ALT key in XP and Vista has the
behavior of displaying the underline under the accelerator keys.

The mentioned controls vanish the first time ALT is pressed. They can be
restored by repainting the control in code. Once restored, they are not
affected by subsequent ALT key presses -- unless a pagecontrol on the form
changes to a new tabsheet, then all affected controls, both on the tabsheet
and on the form, will vanish on next ALT press. Due to the pagecontrol issue
there is no way to set a flag to do the repaint op only once. In MDI applications,
an ALT key press has the same affect on all child forms at the same time.
** End quote **************

The TjhALTBugFix needs to be put on each form in the application which
is a problem in many large applications. Therefore I made this component
that can be dropped on the main form and then handles all delphi forms
that are created.

The component works like this: In Idle it goes through the list of existing
Delphi forms in TScreen. When a new form is found, its WindowProc is replaced
with a hook that listens for the event WM_UPDATEUISTATE which is the
message triggering the error.
When a form has got an WM_UPDATEUISTATE it gets a flag the says it needs to
be redrawn. The next time the application enters Idle a repaint is made,
depending on the property RepaintAll. If it is true all TWinControls on the
form gets a repaint. If its false only the component that probably needs a
repaint is repainted (that code mady by J Hamblin).
The "repaint all" is an precausion for third part components that might behave in
the same way. RepaintAll is default true.
Note that this component is only active in Vista. If you want it to
handle the TStaticText in XP you have to remove the VistaWithTheme check
in TVistaAltFix.Create.

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;

}

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;

{ TVistaAltFix }

procedure TVistaAltFix.ApplicationEventsIdle(Sender: TObject;
  var Done: Boolean);
var
  I: Integer;
  J: Integer;
  TestForm: TForm;
begin
  // Initialize
  for I := 0 to FList.Count - 1 do
    TFormObj(FList[i]).Used := False;

  // Check for new forms
  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;

  // Remove destroyed forms, repaint others if needed.
  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;

{ TFormObj }

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);
  // This method made by J Hamblin - Qtools Software.
  var
    i: integer;
  begin
    if not (TheCtrl is TWinControl) or (TheCtrl is TBitBtn) then
      exit;

    // repaint only controls of affected type
    if (TheCtrl is TButtonControl) or (TheCtrl is TStaticText) then
    begin
      TWinControl(TheCtrl).Repaint;
      exit; // TButtonControls, TStaticText do not contain controls so skip rest
    end;

    //

    for i := 0 to TWinControl(TheCtrl).ControlCount - 1 do
    begin
      // only paint controls on active tabsheet of page control
      if (TheCtrl is TTabSheet) and
          (TTabSheet(TheCtrl).PageIndex <> TTabSheet(TheCtrl).PageControl.ActivePageIndex) then
        continue;
      // recurse
      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:

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

0

Podłączę się do wątku i zapytam, jak w aplikacji sprawdzić, czy użytkownik w ogóle włączył sobie kompozycje windows XP, bo przecież mógł ustawić klasyczną lub nawet uruchomić program w Win98.
Przyciski w kompozycji XP i klasycznej wyglądają inaczej, zajmują inne miejsce, trzeba więc pisać aplikacje w dwóch wersjach.

I inne pytanie - jeśli dodajemy pliki manifest to możemy sobie kompozycje XP dodawać lub odejmować. Nawet z programu dodając mała procedurkę usuwania i tworzenia owego pliku. Jeśli przy Win 7 to nie działa to czy można to samo zrobić sobie w aplikacji dodając komponent manifest XP?
Czy raz dodany komponent raz na zawsze pozbawia mnie możliwości klasycznego wyglądu.

0
Per-Erik Andersson napisał(a)

There seems to be a problem with THEMES support in Delphi, in which TButton, TCheckBox, TRadioButton and TStaticText standard controls vanish in VISTA when the ALT key is pressed. (only TStaticText vanishes in XP). If the OS is set to default, pressing the ALT key in XP and Vista has the behavior of displaying the underline under the accelerator keys.

Ach, to dlatego nigdy nie zaobserwowałem błędu: zawsze wyłączam to durne ustawienie ukrywania podkreśleń.
Nauczka na przyszłość: ostateczne testy programu prowadzić na świeżym systemie bez własnej konfiguracji i innych udziwnień.

0

Dopiszę do tematu, że bez problemu można używać XPMan z manifestem Vista / Seven (oby dwa działają na obydwu systemach)

Wystarczy odnaleźć plik *.res komponentu XPManifest w folderze Delphi/LIB/WindowsXP.res i edytować go przez jakiś edytor zasobów (np RESHacker), zmienić manifest na dowolny i zapisać.

PRzy każdej kompilacji programu nasz nowy manifest Windows Vista/7 będzie dodawany, jeżeli doday komponent XPMan

0

Witam uprzejmie

Legalnl napisał(a)

Dopiszę do tematu, że bez problemu można używać XPMan z manifestem Vista / Seven (oby dwa działają na obydwu systemach)

Wystarczy odnaleźć plik *.res komponentu XPManifest w folderze Delphi/LIB/WindowsXP.res i edytować go przez jakiś edytor zasobów (np RESHacker), zmienić manifest na dowolny i zapisać.

PRzy każdej kompilacji programu nasz nowy manifest Windows Vista/7 będzie dodawany, jeżeli doday komponent XPMan

WindowsXP.res wygląda tak w ResHack:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
  	type="win32"
    name="DelphiApplication"
    version="1.0.0.0" 
  	processorArchitecture="*"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        publicKeyToken="6595b64144ccf1df"
        language="*"
        processorArchitecture="*"/>
    </dependentAssembly>
  </dependency>
</assembly>
  1. Jak wygląda zatem konkretny prawidłowy manifest dla Windows 7?
  2. Czy jak wpiszę Windows 7 manifest, to czy Windows Vista i XP z niego skorzystają bez problemów?
  3. Jeżeli drugie pytanie brzmi nie, to jak zrobić hybrydę Windows XP z Vista z 7?

VistaAltFix zadziałał dopiero, jak przeładowałem system. To już drugi u mnie taki przypadek, raz z ikonkami nie chciał mi widzieć, a teraz z tym komponentem.
Działa bez problemu VistaAltFix.

Prosiłbym o odpowiedź na powyższe 3 pytania.

Pozdrawiam serdecznie.

Z poważaniem

0

Ja używam takiego:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" 
          manifestVersion="1.0"> 
<dependency> 
    <dependentAssembly> 
        <assemblyIdentity 
            type="win32" 
            name="Microsoft.Windows.Common-Controls" 
            version="6.0.0.0" 
            processorArchitecture="X86" 
            publicKeyToken="6595b64144ccf1df" 
            language="*" 
        /> 
    </dependentAssembly> 
</dependency> 
<v3:trustInfo xmlns:v3="urn:schemas-microsoft-com:asm.v3">
  <v3:security>
    <v3:requestedPrivileges>
      <v3:requestedExecutionLevel level="requireAdministrator" />
    </v3:requestedPrivileges>
  </v3:security>
</v3:trustInfo>
</assembly>

Pewne wartości możesz sobie modyfikować, m.in:

            1: version="6.0.0.0"
            2: <v3:requestedExecutionLevel level="requireAdministrator" /> 

AD1: dla Seven jest to 6.1.0.0
AD2: podwyższanie uprawnień. JEżeli chcesz by Twoj program wymuszał prawa administratora przy uruchomieniu to zostaw tak jak jest, w przeciwnym razie podajesz inną wartość, są 3, jakie to nie pamiętam ;p (odsyłam do google)

Tutaj masz jeszcze o manifestach : Zrozumieć User Account Control
Ogólnie jaki sobie nie znajdziesz to resztę robisz tak jak Ci napisałem, po czym umeiszczasz komponent XPMan na formie ;)

Zrozumieć User Account Control

// manifest z Windows Vista / 7 działa poprawnie na XP, w artykule powyżej poprawka dotyczy Visual Studio 2005

0

Witam,
mam pytanie, czy i jak zrobić, żeby wysokość wierszy w ListView była taka sama pod Win 7 jak pod XP. Obok każdego wiersza na ListView mam ustawiony ComboBox, z pozycją o 14 większą. Na Win 7, top 17 jest za mały a 18 za duży przy dużej liczbie błędów.

0

Napisałem 2 moduły które wystarczy wrzucić do Uses dowolnej aplikacji w Delphi, by przyznać jej uprawnienia admina. Może się komuś przyda, jeżeli znajdziecie jakieś błędy albo będziecie mieli sugestie to napiszcie.

http://www12.zippyshare.com/v/97080490/file.html

PS. czy na 4programmers jest jakaś baza plików? Bo bym mógł tam dorzucić.

1 użytkowników online, w tym zalogowanych: 0, gości: 1