Autor Beitrag
ebber
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 239
Erhaltene Danke: 1

Win XP, Win 7
C# (VS 2010), Delphi (2007), Expression 4
BeitragVerfasst: Fr 26.12.08 19:25 
Hallo,

ich habe ein ein wenig mysteriöses Problem. Ich habe in mein Programm einen SplashScreen eingebaut. Zuerst dachte ich er funktioniert, aber dann habe ich gemerkt, dass meine Hauptprogrammoberfläche nicht mehr reagiert.

Ich kann jeden Button drücken und der Code dahinter wird auch ausgeführt, aber die Oberfläche wird nicht neu gezeichnet. Also ich sehe nicht dass ich den Button gedrückt habe und ich kann in einer Textbox nicht scrollen.

Das Problem wird mit einem Klick auf das Main Menu behoben. Danach funktioniert wieder alles wie gewohnt. Die Textbox ist danach sogar gescrollt.

Der Splash Screen ist eine ganz normale Form und wird so erstellt:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
  public Window1()
  {
            Splash = new SpScreen();
            Splash.Show();
 
            this.InitializeComponent();
  }

Wenn ich nur die Zeile Splash.Show(); weg lasse, funktioniert alles.

Oder ich schließe den SplashScreen am Ende nicht, dann funktioniert es auch.

Geschlossen wird er irgendwann durch den Aufruf des Hauptprogramms von CloseSoon
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
        public void CloseSoon()
        {
            TimerClose.Tick += new System.EventHandler(TimerClose_Tick);
            TimerClose.Interval = TimeSpan.FromMilliseconds(1000);
            TimerClose.Start();
        }

        void TimerClose_Tick(object sender, System.EventArgs e)
        {
            Close();
        }


Das scheint mir ein sehr mysteriöses und unlösbares Problem, aber vielleicht hat jemand zufällig die Antwort.

MfG
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 26.12.08 20:49 
Ich habe es jetzt gerade einmal ohne Timer ausprobiert, das funktioniert ohne Probleme:
ausblenden Form2.cs
1:
2:
3:
4:
5:
6:
        public void setProgress(String display, int value)
        {
            label1.Text = display;
            progressBar1.Value = value;
            this.Refresh();
        }
ausblenden Form1.cs
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
    public partial class Form1 : Form
    {
        private Form2 splash;

        public Form1()
        {
            splash = new Form2();
            splash.Show(this);
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 20000; i++)
                splash.setProgress(i.ToString(), i / 200);
            splash.Close();
        }
    }
Wobei das aus dem Konstruktor eigentlich auch in Form1_Load könnte und die Variable direkt auch dort deklariert werden könnte, wenn es nicht gerade an der Komponenteninitialisierung liegt, dass der Start so lange braucht, dass ein SplashScreen nötig wird. Alles andere wird ja vermutlich in Form1_Load passieren, und dann kann danach ja auch der SplashScreen wieder weg.


// EDIT: Zu WPF passt das nicht...


Zuletzt bearbeitet von jaenicke am Fr 26.12.08 21:17, insgesamt 2-mal bearbeitet
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Fr 26.12.08 20:53 
Kleiner Hinweis, es geht hier um WPF ;) . Ich finde das Problem aber ebenso mysteriös :nixweiss: .
user profile iconebber hat folgendes geschrieben Zum zitierten Posting springen:
Zuerst dachte ich er funktioniert, aber dann habe ich gemerkt, dass meine Hauptprogrammoberfläche nicht mehr reagiert.
Also auch nach dem Splashscreen?

_________________
>λ=
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 26.12.08 20:54 
Ab .NET 3.5 SP1 kannst Du einem in Dein Projekt eingebundenen Bild übrigens die Build-Action "SplashScreen" verpassen, dann sparst Du Dir den Aufwand :)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 26.12.08 21:16 
user profile iconKha hat folgendes geschrieben Zum zitierten Posting springen:
Kleiner Hinweis, es geht hier um WPF ;)
:autsch: Ich vergesse immer auf das kleine Textchen mit dem Unterforum zu schauen.

Mit einer WPF Anwendung habe ich es jetzt 1:1 kopiert, aber das Problem kann ich nicht nachvollziehen. Auf das Fenster habe ich unter anderem einen Button gelegt, aber der war normal klickbar, auch alles andere sah normal aus. :gruebel:
ebber Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 239
Erhaltene Danke: 1

Win XP, Win 7
C# (VS 2010), Delphi (2007), Expression 4
BeitragVerfasst: Fr 26.12.08 21:52 
user profile iconKha hat folgendes geschrieben Zum zitierten Posting springen:
Also auch nach dem Splashscreen?

Erst wenn er geschlossen wurde geht nichts mehr. Wie ich oben erwähnt hatte, funktioniert alles wenn er offen bleibt, als 2. Fenster.


user profile iconChristian S. hat folgendes geschrieben Zum zitierten Posting springen:
Ab .NET 3.5 SP1 kannst Du einem in Dein Projekt eingebundenen Bild übrigens die Build-Action "SplashScreen" verpassen, dann sparst Du Dir den Aufwand :)

Das habe ich auch gemerkt. Ich wollte das auch mal ausprobieren, aber komischerweise kann ich bei Build-Action nicht SplashScreen auswählen. Ich habe extra nochmal versucht .Net 3.5 Sp1 zu installieren, aber das meinte ich habe es schon.
Soviel ich weis geht das sowieso nur mit Bildern?


user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:

Mit einer WPF Anwendung habe ich es jetzt 1:1 kopiert, aber das Problem kann ich nicht nachvollziehen. Auf das Fenster habe ich unter anderem einen Button gelegt, aber der war normal klickbar, auch alles andere sah normal aus. :gruebel:


Aussehen tut bei mir auch alles normal und Buttons klicken kann ich auch. Es kommt bloß keine Animation beim Button klicken oder sonst irgendwie verändert sich auch nur das geringste auf dem Fenster.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 26.12.08 22:01 
user profile iconebber hat folgendes geschrieben Zum zitierten Posting springen:
Aussehen tut bei mir auch alles normal und Buttons klicken kann ich auch. Es kommt bloß keine Animation beim Button klicken oder sonst irgendwie verändert sich auch nur das geringste auf dem Fenster.
Der Button geht ganz normal runter und wieder hoch bei mir, das meinte ich.
ebber Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 239
Erhaltene Danke: 1

Win XP, Win 7
C# (VS 2010), Delphi (2007), Expression 4
BeitragVerfasst: Sa 27.12.08 15:52 
Nach einigem rumprobieren konnte ich es in gewisser Weise nachstellen.

Es muss wohl am SplashScreen liegen. Als ich seinen xaml Code in einem neuen Projekt benutzt habe ist der Fehler wieder aufgetreten.

Er ist ein wenig lang, aber ich habe keine Ahnung woran es liegen könnte. Vielleicht fällt jemandem gerade zufällig was auf.

ausblenden volle Höhe XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
<Window x:Class="RSHe.SpScreen"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="SplashScreen" Height="247" Width="599" AllowsTransparency="True" WindowStyle="None" BorderThickness="4,0,4,0" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic" WindowStartupLocation="CenterScreen" x:Name="SplashScreenWin" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Topmost="True">
  <Window.Resources>
    <DrawingBrush x:Key="Brush1" Stretch="Fill" TileMode="FlipX" Viewbox="0,0,20,20" ViewboxUnits="Absolute">
      <DrawingBrush.Drawing>
        <DrawingGroup>
          <GeometryDrawing Brush="#FFD3D3D3">
            <GeometryDrawing.Geometry>
              <RectangleGeometry Rect="0,0,20,20"/>
            </GeometryDrawing.Geometry>
          </GeometryDrawing>
          <GeometryDrawing Brush="#FF000000">
            <GeometryDrawing.Geometry>
              <EllipseGeometry Center="0,0" RadiusX="10" RadiusY="10"/>
            </GeometryDrawing.Geometry>
          </GeometryDrawing>
          <GeometryDrawing Brush="#FF000000">
            <GeometryDrawing.Geometry>
              <EllipseGeometry Center="20,20" RadiusX="10" RadiusY="10"/>
            </GeometryDrawing.Geometry>
          </GeometryDrawing>
          <GeometryDrawing Brush="#FFFFFFFF">
            <GeometryDrawing.Geometry>
              <EllipseGeometry Center="20,0" RadiusX="10" RadiusY="10"/>
            </GeometryDrawing.Geometry>
          </GeometryDrawing>
          <GeometryDrawing Brush="#FFFFFFFF">
            <GeometryDrawing.Geometry>
              <EllipseGeometry Center="0,20" RadiusX="10" RadiusY="10"/>
            </GeometryDrawing.Geometry>
          </GeometryDrawing>
        </DrawingGroup>
      </DrawingBrush.Drawing>
    </DrawingBrush>
    <LinearGradientBrush x:Key="Brush2" EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#FFFF8C00" Offset="0.558"/>
      <GradientStop Color="#FFF69E33" Offset="0.47"/>
      <GradientStop Color="#FFCD7000" Offset="0"/>
    </LinearGradientBrush>
    <Style x:Key="ProgressBarStyle1" TargetType="{x:Type ProgressBar}">
      <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
      <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
      <Setter Property="BorderBrush">
        <Setter.Value>
          <SolidColorBrush/>
        </Setter.Value>
      </Setter>
      <Setter Property="BorderThickness" Value="1,1,1,1"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type ProgressBar}">
            <Microsoft_Windows_Themes:ClassicBorderDecorator BorderStyle="ThinPressed" BorderThickness="{TemplateBinding BorderThickness}">
              <Microsoft_Windows_Themes:ClassicBorderDecorator.BorderBrush>
                <LinearGradientBrush EndPoint="1.009,0.5" StartPoint="-0.006,0.5">
                  <GradientStop Color="#FFFFFFFF" Offset="0"/>
                  <GradientStop Color="#FFFFFFFF" Offset="1"/>
                  <GradientStop Color="#00FFFFFF" Offset="0.093"/>
                  <GradientStop Color="#00FFFFFF" Offset="0.907"/>
                </LinearGradientBrush>
              </Microsoft_Windows_Themes:ClassicBorderDecorator.BorderBrush>
              <DockPanel Margin="0,0,2,2" x:Name="PART_Track" LastChildFill="False">
                <Rectangle x:Name="PART_Indicator" Fill="{TemplateBinding Foreground}">
                  <Rectangle.OpacityMask>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                      <GradientStop Color="#5FFFFFFF" Offset="0"/>
                      <GradientStop Color="#FFFFFFFF" Offset="1"/>
                    </LinearGradientBrush>
                  </Rectangle.OpacityMask>
                </Rectangle>
              </DockPanel>
            </Microsoft_Windows_Themes:ClassicBorderDecorator>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
      <Style.Triggers>
        <Trigger Property="Orientation" Value="Vertical">
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="{x:Type ProgressBar}">
                <Microsoft_Windows_Themes:ClassicBorderDecorator Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderStyle="ThinPressed" BorderThickness="{TemplateBinding BorderThickness}">
                  <DockPanel Margin="0,0,2,2" x:Name="PART_Track" LastChildFill="False">
                    <Decorator x:Name="PART_Indicator" DockPanel.Dock="Bottom">
                      <Rectangle>
                        <Rectangle.LayoutTransform>
                          <RotateTransform Angle="-90"/>
                        </Rectangle.LayoutTransform>
                        <Rectangle.Fill>
                          <MultiBinding UpdateSourceTrigger="Default" StringFormat="{x:Null}">
                            <MultiBinding.Converter>
                              <Microsoft_Windows_Themes:ProgressBarBrushConverter/>
                            </MultiBinding.Converter>
                            <Binding Path="Foreground" RelativeSource="{RelativeSource TemplatedParent}" StringFormat="{x:Null}"/>
                            <Binding Path="IsIndeterminate" RelativeSource="{RelativeSource TemplatedParent}" StringFormat="{x:Null}"/>
                            <Binding Path="ActualHeight" ElementName="PART_Indicator" StringFormat="{x:Null}"/>
                            <Binding Path="ActualWidth" ElementName="PART_Indicator" StringFormat="{x:Null}"/>
                            <Binding Path="ActualHeight" ElementName="PART_Track" StringFormat="{x:Null}"/>
                          </MultiBinding>
                        </Rectangle.Fill>
                      </Rectangle>
                    </Decorator>
                  </DockPanel>
                </Microsoft_Windows_Themes:ClassicBorderDecorator>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Trigger>
      </Style.Triggers>
    </Style>
    <Storyboard x:Key="OnLoaded1" AutoReverse="True" RepeatBehavior="Forever">
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PrBLoad" Storyboard.TargetProperty="(TextElement.Foreground).(GradientBrush.GradientStops)[4].(GradientStop.Offset)">
        <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="0.981" KeySpline="0.573,0,0.405,1"/>
        <SplineDoubleKeyFrame KeyTime="00:00:03.2000000" Value="0.089" KeySpline="0.586,0,0.434,1"/>
      </DoubleAnimationUsingKeyFrames>
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PrBLoad" Storyboard.TargetProperty="(TextElement.Foreground).(GradientBrush.GradientStops)[3].(GradientStop.Offset)">
        <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="0.949" KeySpline="0.573,0,0.405,1"/>
        <SplineDoubleKeyFrame KeyTime="00:00:03.2000000" Value="0.052" KeySpline="0.586,0,0.434,1"/>
      </DoubleAnimationUsingKeyFrames>
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PrBLoad" Storyboard.TargetProperty="(TextElement.Foreground).(GradientBrush.GradientStops)[2].(GradientStop.Offset)">
        <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="0.916" KeySpline="0.573,0,0.405,1"/>
        <SplineDoubleKeyFrame KeyTime="00:00:03.2000000" Value="0.019" KeySpline="0.586,0,0.434,1"/>
      </DoubleAnimationUsingKeyFrames>
    </Storyboard>
    <Storyboard x:Key="OnLoaded2">
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="{x:Null}" Storyboard.TargetProperty="(UIElement.Opacity)">
        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
        <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
      </DoubleAnimationUsingKeyFrames>
    </Storyboard>
  </Window.Resources>
  <Window.Triggers>
    <EventTrigger RoutedEvent="FrameworkElement.Loaded" SourceName="PrBLoad">
      <BeginStoryboard Storyboard="{StaticResource OnLoaded1}"/>
    </EventTrigger>
    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
      <BeginStoryboard Storyboard="{StaticResource OnLoaded2}" x:Name="OnLoaded2_BeginStoryboard"/>
    </EventTrigger>
  </Window.Triggers>
  <Window.Background>
    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#00000000" Offset="0"/>
      <GradientStop Color="#00000000" Offset="1"/>
      <GradientStop Color="#F2000000" Offset="0.344"/>
      <GradientStop Color="#FF000000" Offset="0.66"/>
    </LinearGradientBrush>
  </Window.Background>
  <Window.BorderBrush>
    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#00FF6900" Offset="0.084"/>
      <GradientStop Color="#00FF6900" Offset="0.921"/>
      <GradientStop Color="#FFFF6900" Offset="0.475"/>
      <GradientStop Color="#FFFF6900" Offset="0.521"/>
    </LinearGradientBrush>
  </Window.BorderBrush>
    <Grid>
        
      <ProgressBar Margin="24,0,25,80" Style="{DynamicResource ProgressBarStyle1}" VerticalAlignment="Bottom" Height="10" Value="75" x:Name="PrBLoad" >
        <ProgressBar.Foreground>
          <LinearGradientBrush EndPoint="-0.005,0.5" StartPoint="1.004,0.5">
            <GradientStop Color="#FFFF8900" Offset="0"/>
            <GradientStop Color="#FFFF8900" Offset="1"/>
            <GradientStop Color="#FFFF8A00" Offset="0.038"/>
            <GradientStop Color="#FFFFFFFF" Offset="0.066"/>
            <GradientStop Color="#FFFF8900" Offset="0.098"/>
          </LinearGradientBrush>
        </ProgressBar.Foreground>
      </ProgressBar>
      <Label Margin="253,89,150,94" Content="Rs He" FontFamily="./Fonts\#Calibri" FontSize="36" Foreground="#FFFFFFFF">
        <Label.BitmapEffect>
          <OuterGlowBitmapEffect GlowColor="#FFFF9600" GlowSize="8"/>
        </Label.BitmapEffect>
      </Label>
        <TextBlock Margin="139.772,0,127.74,56.427" VerticalAlignment="Bottom" Height="19.573" Text="Loading ..." TextWrapping="Wrap" TextAlignment="Center" Foreground="#FFFFFFFF" x:Name="LblStatus"/>
    </Grid>
</Window>


Mir ist nicht ganz klar, wie der xaml Code ein anderes Fenster auf diese Weise beeinflussen kann.

MfG