Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Delphi Seltsames verhalten mit Units DC (https://www.delphipraxis.net/197666-seltsames-verhalten-mit-units-dc.html)

EWeiss 25. Aug 2018 18:05

Seltsames verhalten mit Units DC
 
Portiere grade meine Projekte nach 64Bit.
Manchmal bekomme ich die Meldung das die Unit Graphics nicht gefunden wird.
Dann wiederum scheint es egal zu sein bzw. sie wird gefunden.

Gut mit vor angehängter VCL. gibt es keine Probleme.
Nur warum wird sie einmal gefunden und dann wieder nicht.

Stört mich nicht weiter aber schon wieder so ein seltsames Problem.

gruss

KodeZwerg 25. Aug 2018 21:44

AW: Seltsames verhalten mit Units DC
 
Benutze doch einfach so eine Compilers.inc von den Jedis und ändere Deine Uses darauf hin ab, nur so eine Idee.

Uwe Raabe 25. Aug 2018 21:53

AW: Seltsames verhalten mit Units DC
 
Eventuell fehlende Unit-Prefixe werden durch den Eintrag in Unit-Gültigkeitsbereichsnamen ergänzt. Eventuell sind nicht in allen Build-Konfigurationen bzw. Zielplattformen die passenden Einträge drin.

EWeiss 25. Aug 2018 22:01

AW: Seltsames verhalten mit Units DC
 
Zitat:

Zitat von Uwe Raabe (Beitrag 1411649)
Eventuell fehlende Unit-Prefixe werden durch den Eintrag in Unit-Gültigkeitsbereichsnamen ergänzt. Eventuell sind nicht in allen Build-Konfigurationen bzw. Zielplattformen die passenden Einträge drin.

Ok!
Wollte das nur mitteilen das es ein für mich komisches verhalten ist.. kann aber damit leben.
Eventuell ein Fehler innerhalb der IDE.. wenn nicht vergesst es.

gruss

Uwe Raabe 25. Aug 2018 22:49

AW: Seltsames verhalten mit Units DC
 
Die IDE tut (zumindest in diesem Fall) was man ihr sagt. Fehlen diese Einträge oder sind sie nicht korrekt, kann das auch nicht funktionieren.

Bei neuen Projekten werden zwar schon bestimmte Vorgaben gemacht, die in den meisten Fällen passen sollten. Falls nicht, kann man das ja dann kontrollieren und gegebenenfalls korrigieren. Insbesondere wenn Projekte aus alten Delphi-Versionen übernommen werden, in denen die neuen Plattformen nicht vorhanden waren, kann schon mal der passende Eintrag fehlen.

EWeiss 25. Aug 2018 22:57

AW: Seltsames verhalten mit Units DC
 
Zitat:

Fehlen diese Einträge oder sind sie nicht korrekt, kann das auch nicht funktionieren.
Nur zur Klarstellung..

Meine aktuellen Uses
Delphi-Quellcode:
uses Windows, Messages, Classes, Graphics, SysUtils, uTMDB, uGlobal, Math,
  RT_KVideoPlayer, SKAeroAPI, Types, Generics.Collections;
Die IDE btw. Compiler meckert NUR bei Graphics also geändert!
Delphi-Quellcode:
uses Windows, Messages, Classes, VCL.Graphics, SysUtils, uTMDB, uGlobal, Math,
  RT_KVideoPlayer, SKAeroAPI, Types, Generics.Collections;
Nun schon seltsam oder?
Bei euch ist immer alles so klar wenn man hier was mitteilt was Delphi betrifft.

Dann frage ich mich warum der Compiler sich nur über die UNIT Graphics beschwert und über die anderen nicht.
Also das verhalten ist so nicht korrekt. (Aber ich denke ihr findet wieder etwas was es schön redet)
Ist irgendwo widersprüchlich das ganze.

OK! Wie gesagt ich komme damit klar und von mir aus muss da nichts geändert werden.
Ich brauche die Namespace nicht wenn es auch so geht.

gruss

Schokohase 25. Aug 2018 23:49

AW: Seltsames verhalten mit Units DC
 
Einigen ist es klar, weil diese die Dokumentation gelesen haben

Unit-Gültigkeitsbereichsnamen

In deinem Projekt sind wohl die folgenden Einträge enthalten
Code:
Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;System;Xml;Data;Datasnap;Web;Soap
aber es fehlt der Eintrag
Code:
VCL
und darum meckert der Compiler, denn eine Unit Graphics gibt es gar nicht, dafür aber die Unit VCL.Graphics und die Unit FMX.Graphics.

Schau dir auch die anderen Units an:
Code:
Windows => Winapi.Windows
Classes => System.Classes
usw.
die meisten davon lauten im Original anders und werden nur gefunden weil die Unit-Gültigkeitsbereichsnamen korrekt gesetzt sind.

EWeiss 25. Aug 2018 23:55

AW: Seltsames verhalten mit Units DC
 
Zitat:

Einigen ist es klar, weil diese die Dokumentation gelesen haben
Wenn du das sagst..
Fakt ist jedoch das in unterschiedlichen Projekten der Compiler auch bei Graphics ohne VCL nicht meckert.
War oder ist dir das bewusst?
Und ja ich kann es nachvollziehen da ich alle meine Projekte gerade umstelle.

Warum also! :)

gruss

Schokohase 26. Aug 2018 00:01

AW: Seltsames verhalten mit Units DC
 
Werde ich dir gerne beantworten, sobald du mir dieses Verhalten an einem Beispielprojekt für Delphi 10.2.3 zeigst.

(MCVE - Minimal, Complete and Verifiable Example)

EWeiss 26. Aug 2018 00:05

AW: Seltsames verhalten mit Units DC
 
Zitat:

Zitat von Schokohase (Beitrag 1411658)
Werde ich dir gerne beantworten, sobald du mir dieses Verhalten an einem Beispielprojekt für Delphi 10.2.3 zeigst.

(MCVE - Minimal, Complete and Verifiable Example)

Mein Mixer Projekt zum Beispiel..
Delphi-Quellcode:
unit uMain;

interface

{$R '_resources\Mixer.res' '_resources\Mixer.rc'}

{$IFDEF WIN64}
  {$R '_resources\Manifest64.res'}
{$ELSE}
  {$R '_resources\Manifest.res'}
{$ENDIF}

{$REGION 'Uses'}

uses Classes, Windows, Messages, ShellApi, CommCtrl, StrUtils, ShlObj, SysUtils, SKAeroAPI, ActiveX,
  uGlobal, Graphics, uControls, uIni, Dialogs, mmsystem, AudioVolume, StdCtrls, MMDevice, Math,
  SimpleAudioVolume, AudioSessionControl, AudioSessionControl2, ProcessList;
{$ENDREGION}
Kann ich ohne Namespace kompilieren.

gruss

Schokohase 26. Aug 2018 00:10

AW: Seltsames verhalten mit Units DC
 
Und dein Mixer-Projekt hat keine Projekt-Datei (*.dpr/*.dproj)?

Ich sehe dort auch kein
Delphi-Quellcode:
implementation
oder ein
Delphi-Quellcode:
end.
in deinem Code-Schnipsel, somit ist das weit entfernt von komplett.

Also bitte ein komplettes Beispiel (wohl am besten in einer zip-Datei).

EWeiss 26. Aug 2018 00:13

AW: Seltsames verhalten mit Units DC
 
Zitat:

Zitat von Schokohase (Beitrag 1411660)
Und dein Mixer-Projekt hat keine Projekt-Datei (*.dpr/*.dproj)?

Ich sehe dort auch kein
Delphi-Quellcode:
implementation
oder ein
Delphi-Quellcode:
end.
in deinem Code-Schnipsel, somit ist das weit entfernt von komplett.

Also bitte ein komplettes Beispiel (wohl am besten in einer zip-Datei).

Ach lass mal.. Ich sehe hier und weis was los ist von daher ist das Thema für mich erledigt.
Mein bestreben war nur das verhalten mitzuteilen ich muss hier nichts beweisen.
Wie ich schon sagte mir ist es egal.

Aber hier dein implementation und end Beispiel.

Delphi-Quellcode:
{ ' UNIT uMain.pas
  '--------------------------- uMain -----------------------------
  ' Sample for SKAero API Module.. Main Application
  ' Copyright © 2018 BrewIdeas@Emil Weiss, All Rights Reserved
  '
  ' Author(s) of this Unit: Emil Weiss
  '
  '---------------------------------------------------------------------------- }

unit uMain;

interface

{$R '_resources\Mixer.res' '_resources\Mixer.rc'}

{$IFDEF WIN64}
  {$R '_resources\Manifest64.res'}
{$ELSE}
  {$R '_resources\Manifest.res'}
{$ENDIF}

{$REGION 'Uses'}

uses Classes, Windows, Messages, ShellApi, CommCtrl, StrUtils, ShlObj, SysUtils, SKAeroAPI, ActiveX,
  uGlobal, Graphics, uControls, uIni, Dialogs, mmsystem, AudioVolume, StdCtrls, MMDevice, Math,
  SimpleAudioVolume, AudioSessionControl, AudioSessionControl2, ProcessList;
{$ENDREGION}
{$REGION 'Functions / Procedures'}
function WinMain(hInstance: HINST; hPrevInstance: HINST; lpCmdLine: PChar; nCmdShow: integer)
  : LRESULT; stdcall;
procedure DetectBackground;
function WndProc(WinHandle: HWND; Msg: UINT; wP: WParam; lP: LParam): LRESULT; stdcall;
procedure PlaySoundSlide;
procedure PlaySoundPush;
procedure PlaySoundBlup;
// AudioVolume
{$ENDREGION}
// TMainClass
{$REGION 'TMainClass'}

type
  TMainClass = class
    procedure MasterDefaultDeviceChange(NewDefaultDevice: TDeviceInfo);
    procedure MasterDeviceStateChange(DeviceId: string; NewDeviceState: Cardinal);
    procedure MasterVolumeEvent(Volume: Single; Mute: Boolean);
    procedure AudioVolumeInitialize;
    function CreateHBitmapFromImg(Img: LONG_PTR; var imgW, imgH: integer): HBitmap;
    procedure CreateMasterIcon(x, y: integer; IconHandle: UINT = 0);
    procedure CreateSessionIcon(Index: integer; x, y: integer; IconHandle: UINT = 0);
    function CreateImgFromIcon(wsFile: WideString; IconHandle: UINT = 0): LONG_PTR;
    procedure CreateSession;
    function GetHIconFromFile(AFileName: String; ASmall: Boolean = false; AIndex: integer = 0)
      : HICON;
    procedure SessionCreated(const NewSession: IAudioSessionControl);
    procedure SessionDisconnectedEvent(Sender: TCustomAudioVolume; DisconnectReason: UINT);
    procedure SessionStateEvent(Sender: TCustomAudioVolume; NewState: integer);
    procedure SessionVolumeEvent(Sender: TCustomAudioVolume; Volume: Single; Mute: Boolean);
    procedure PropertyIconChanged(IconPath: string);
    procedure ShowOutputAttribute;
    procedure RemovefromList(DeviceId: string);
  private
    OldMute: Boolean;
    { private-Deklarationen }
    OldSessionMute: Boolean;
    SimpleVolume: ISimpleAudioVolume;
    tmpAudioVolume: TAudioVolume;
  public
    { public-Deklarationen }
    DeviceName: string;
    Hint: WideString;
  end;
{$ENDREGION}
{$REGION 'Global Variable'}

var
  MainClass: TMainClass;
  //  MyThread: TSessionThread;
  bMyVolSet: BOOL;
  bAttribute: BOOL;
  AudioVolume1: TAudioVolume;
  AudioVolumeArr: array of TAudioVolume;
  GotChannelCount: Boolean = false;
  ChannelCount: UINT;
  Peaks: array of Single;
  lRes: integer;
  Restart: BOOL;
  m_Initialize: BOOL;
  Second: DWORD;
{$ENDREGION}

implementation

// Animation
{$REGION 'RenderClock'}

procedure RenderClock;
var
  Tick: DWORD;
begin

  Tick := GetTickCount;
  if (Second = 0) then
    Second := Tick + 1000;

  if (Tick > Second) then
  begin
    Second := 0;
    gSprBackground.GD_SetObjectTextEx(ID_TIME_FRONT, PWideChar(TimeToStr(Now)), true);
  end;
end;
{$ENDREGION}
// Sound
{$REGION 'Sound'}
Ich schreibe bestimmt jetzt keine neue Anwendung extra für dich sorry..
Könnte das end. jetzt noch anhängen aber 45K hier rein zu klatschen wäre Schwachsinn.

gruss

Schokohase 26. Aug 2018 00:41

AW: Seltsames verhalten mit Units DC
 
Ich denke mal du verstehst den Begriff komplett nicht.

Komplett bedeutet minimal eine *.dpr und eine *.dproj Datei. Eine wilde Anwendung ist da gar nicht notwendig, sondern eher mit ein paar Klicks erledigt.

Beispiel:

mcve.dproj
XML-Code:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <Base>True</Base>
        <AppType>Console</AppType>
        <Config Condition="'$(Config)'==''">Debug</Config>
        <FrameworkType>None</FrameworkType>
        <MainSource>mcve.dpr</MainSource>
        <Platform Condition="'$(Platform)'==''">Win32</Platform>
        <ProjectGuid>{D051179F-2FDA-4DF0-B901-0DEBE384F9E6}</ProjectGuid>
        <ProjectVersion>18.4</ProjectVersion>
        <TargetedPlatforms>1</TargetedPlatforms>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
        <Base_Win32>true</Base_Win32>
        <CfgParent>Base</CfgParent>
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
        <Cfg_1>true</Cfg_1>
        <CfgParent>Base</CfgParent>
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
        <Cfg_1_Win32>true</Cfg_1_Win32>
        <CfgParent>Cfg_1</CfgParent>
        <Cfg_1>true</Cfg_1>
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
        <Cfg_2>true</Cfg_2>
        <CfgParent>Base</CfgParent>
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Base)'!=''">
        <SanitizedProjectName>mcve</SanitizedProjectName>
        <DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput>
        <DCC_ExeOutput>.\$(Platform)\$(Config)</DCC_ExeOutput>
        <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
        <DCC_UsePackage>RESTComponents;FireDAC;FireDACSqliteDriver;soaprtl;FireDACIBDriver;soapmidas;FireDACCommon;RESTBackendComponents;soapserver;CloudService;FireDACCommonDriver;inet;$(DCC_UsePackage)</DCC_UsePackage>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Base_Win32)'!=''">
        <BT_BuildType>Debug</BT_BuildType>
        <DCC_ConsoleTarget>true</DCC_ConsoleTarget>
        <DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
        <DCC_UsePackage>DBXSqliteDriver;IndyIPCommon;bindcompdbx;DBXInterBaseDriver;vcl;IndyIPServer;vclactnband;vclFireDAC;IndySystem;tethering;svnui;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;vclimg;vcltouch;vcldb;bindcompfmx;svn;FireDACPgDriver;inetdb;DbxCommonDriver;fmx;fmxdae;xmlrtl;fmxobj;vclwinx;rtl;DbxClientDriver;fdk;CustomIPTransport;vcldsnap;IndyCore;dbexpress;vclx;bindcomp;appanalytics;dsnap;TDD.Lib;IndyIPClient;bindcompvcl;VCLRESTComponents;dbxcds;VclSmp;adortl;vclie;bindengine;DBXMySQLDriver;dsnapxml;FireDACMySQLDriver;dbrtl;IndyProtocols;inetdbxpress;FireDACCommonODBC;fmxase;$(DCC_UsePackage)</DCC_UsePackage>
        <UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150>
        <UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44>
        <VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
        <VerInfo_Locale>1033</VerInfo_Locale>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_1)'!=''">
        <DCC_DebugDCUs>true</DCC_DebugDCUs>
        <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
        <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
        <DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
        <DCC_Optimize>false</DCC_Optimize>
        <DCC_RemoteDebug>true</DCC_RemoteDebug>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
        <DCC_RemoteDebug>false</DCC_RemoteDebug>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_2)'!=''">
        <DCC_DebugInformation>0</DCC_DebugInformation>
        <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
        <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
        <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
    </PropertyGroup>
    <ItemGroup>
        <DelphiCompile Include="$(MainSource)">
            <MainSource>MainSource</MainSource>
        </DelphiCompile>
        <BuildConfiguration Include="Base">
            <Key>Base</Key>
        </BuildConfiguration>
        <BuildConfiguration Include="Debug">
            <Key>Cfg_1</Key>
            <CfgParent>Base</CfgParent>
        </BuildConfiguration>
        <BuildConfiguration Include="Release">
            <Key>Cfg_2</Key>
            <CfgParent>Base</CfgParent>
        </BuildConfiguration>
    </ItemGroup>
    <ProjectExtensions>
        <Borland.Personality>Delphi.Personality.12</Borland.Personality>
        <Borland.ProjectType>Application</Borland.ProjectType>
        <BorlandProject>
            <Delphi.Personality>
                <Source>
                    <Source Name="MainSource">mcve.dpr</Source>
                </Source>
            </Delphi.Personality>
            <Deployment Version="3">
                <DeployFile LocalName="Win32\Debug\mcve.exe" Configuration="Debug" Class="ProjectOutput">
                    <Platform Name="Win32">
                        <RemoteName>mcve.exe</RemoteName>
                        <Overwrite>true</Overwrite>
                    </Platform>
                </DeployFile>
                <DeployClass Name="AdditionalDebugSymbols">
                    <Platform Name="Win32">
                        <RemoteDir>Contents\MacOS</RemoteDir>
                        <Operation>0</Operation>
                    </Platform>
                </DeployClass>
                <DeployClass Name="DebugSymbols">
                    <Platform Name="Win32">
                        <Operation>0</Operation>
                    </Platform>
                </DeployClass>
                <DeployClass Name="DependencyFramework">
                    <Platform Name="Win32">
                        <Operation>0</Operation>
                    </Platform>
                </DeployClass>
                <DeployClass Name="DependencyModule">
                    <Platform Name="Win32">
                        <Operation>0</Operation>
                        <Extensions>.dll;.bpl</Extensions>
                    </Platform>
                </DeployClass>
                <DeployClass Required="true" Name="DependencyPackage">
                    <Platform Name="Win32">
                        <Operation>0</Operation>
                        <Extensions>.bpl</Extensions>
                    </Platform>
                </DeployClass>
                <DeployClass Name="File">
                    <Platform Name="Win32">
                        <Operation>0</Operation>
                    </Platform>
                </DeployClass>
                <DeployClass Required="true" Name="ProjectOutput">
                    <Platform Name="Win32">
                        <Operation>0</Operation>
                    </Platform>
                </DeployClass>
                <DeployClass Name="ProjectUWPManifest">
                    <Platform Name="Win32">
                        <Operation>1</Operation>
                    </Platform>
                </DeployClass>
                <DeployClass Name="UWP_DelphiLogo150">
                    <Platform Name="Win32">
                        <RemoteDir>Assets</RemoteDir>
                        <Operation>1</Operation>
                    </Platform>
                </DeployClass>
                <DeployClass Name="UWP_DelphiLogo44">
                    <Platform Name="Win32">
                        <RemoteDir>Assets</RemoteDir>
                        <Operation>1</Operation>
                    </Platform>
                </DeployClass>
                <ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
            </Deployment>
            <Platforms>
                <Platform value="Android">False</Platform>
                <Platform value="OSX32">False</Platform>
                <Platform value="Win32">True</Platform>
                <Platform value="Win64">False</Platform>
                <Platform value="iOSDevice32">False</Platform>
                <Platform value="iOSDevice64">False</Platform>
                <Platform value="iOSSimulator">False</Platform>
            </Platforms>
        </BorlandProject>
        <ProjectFileVersion>12</ProjectFileVersion>
    </ProjectExtensions>
    <Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
    <Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
    <Import Project="$(MSBuildProjectName).deployproj" Condition="Exists('$(MSBuildProjectName).deployproj')"/>
</Project>
mcve.dpr
Delphi-Quellcode:
program mcve;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  SysUtils;

begin
  try
    { TODO -oUser -cConsole Main : Code hier einfügen }
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
Und in der dproj Zeile 47 DCC_NAMESPACE sorgt dafür, dass
Delphi-Quellcode:
SysUtils
gefunden wird, obwohl die Unit eigentlich
Delphi-Quellcode:
System.Sysutils
heißt.

Also gib mir so ein Beipiel, wo es nicht funktioniert und ich sage dir wo der Fehler liegt.


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:10 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