Autor Beitrag
CarpeDiem
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 128

WIN XP
Borland C++ 2002, CodeGear C++ 2007, C# (VS 2008)
BeitragVerfasst: Fr 28.03.08 20:47 
Hallo, das Bildschirmschoner-Thema ist zwar schon zur Genüge durchgekaut, aber ich dachte, daß beim Erstellen der *.scr mit folgendem
ausblenden volle Höhe C#-Quelltext
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:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("Bildschirmschoner_Startseite.cpp", Form_Startseite);
USEFORM("Bildschirmschoner_Einstellungen.cpp", Form_Einstellungen);
USEFORM("Bildschirmschoner_DM.cpp", DM); /* TDataModule: File Type */
USEFORM("Bildschirmschoner_Vorschau.cpp", Form_Vorschau);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
  try
  {
    Application->Initialize();
    SetApplicationMainFormOnTaskBar(Application, true);
.    // Parameter Bildschirmschoner starten
    if (ParamStr(1).UpperCase() == "/S")
      {
      Application->CreateForm(__classid(TForm_Startseite), &Form_Startseite);
      }
    // Parameter Bildschirmschoner-Einstellungen starten
    if (ParamStr(1).UpperCase() == "/C")
      {
      Application->CreateForm(__classid(TForm_Einstellungen), &Form_Einstellungen);
      }
    // Parameter Bildschirmschoner-Vorschau starten
    if (ParamStr(1).UpperCase() == "/P")
      {
      Application->CreateForm(__classid(TForm_Vorschau), &Form_Vorschau);
      }
    Application->CreateForm(__classid(TDM), &DM);
    Application->Run();
  }
  catch (Exception &exception)
  {
    Application->ShowException(&exception);
  }
  catch (...)
  {
    try
    {
      throw Exception("");
    }
    catch (Exception &exception)
    {
      Application->ShowException(&exception);
    }
  }
  return 0;
}
//---------------------------------------------------------------------------

in C++ immer nur ein Parameter aufgerufen wird. Bei mir tritt folgendes Problem auf (bei Bildschirmschoner-Einstellungen):
1. Bei Auswahl des Bildschirmschoners in der ComboBox wird die "Form_Vorschau" angezeigt
2. Bei Auswahl der Einstellungen wird wieder die "Form_Vorschau" angezeigt
3. Bei Auswahl der Vorschau wird zuerst "Form_Startseite" und dann "Form_Vorschau" angezeigt
Weiß einer warum? Wenn ich ShowMessage(ParamStr(1)); nach SetApplicationMainFormOnTaskBar(Application, true); eintrage, dann wird mein Problem bestätigt (Bei 1. wird "/p", bei 2. wird "/p" und bei 3. wird zuerst "/s" und dann "/p" angezeigt)

_________________
Stefan - Carpe Diem
Es ist keine Schande zu fallen, eine Schande ist nur nicht wieder aufzustehen
CarpeDiem Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 128

WIN XP
Borland C++ 2002, CodeGear C++ 2007, C# (VS 2008)
BeitragVerfasst: So 30.03.08 08:12 
Hallo, wollte nochmals fragen, ob einer vielleicht eine Idee hat? Danke.

_________________
Stefan - Carpe Diem
Es ist keine Schande zu fallen, eine Schande ist nur nicht wieder aufzustehen
CarpeDiem Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 128

WIN XP
Borland C++ 2002, CodeGear C++ 2007, C# (VS 2008)
BeitragVerfasst: Mo 31.03.08 20:02 
Titel: Problem gelöst
Hallo Leute, Problem ist gelöst. Hier der Quelltext für die Main.
ausblenden volle Höhe C#-Quelltext
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:
//---------------------------------------------------------------------------

#include <vcl.h>
#include "stdio.h"
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("Bildschirmschoner_Startseite.cpp", Form_Startseite);
USEFORM("Bildschirmschoner_Einstellungen.cpp", Form_Einstellungen);
USEFORM("Bildschirmschoner_Vorschau.cpp", Form_Vorschau);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
  try
  {
    // Parameter Bildschirmschoner starten
    if (ParamStr(1).UpperCase().SubString(1,2) == "/S")
      {
      Application->Initialize();
      Application->CreateForm(__classid(TForm_Startseite), &Form_Startseite);
      Application->Run();
      return 0;
      }

    // Parameter Bildschirmschoner-Einstellungen starten
    if (ParamStr(1).UpperCase().SubString(1,2) == "/C")
      {
      Application->Initialize();
      Application->CreateForm(__classid(TForm_Einstellungen), &Form_Einstellungen);
      Application->Run();
      return 0;
      }

    // Parameter Bildschirmschoner-Vorschau starten
    if (ParamStr(1).UpperCase().SubString(1,2) == "/P")
      {
      Graphics::TBitmap* Bitmap = new Graphics::TBitmap();
      TCanvas *PreCanvas = new TCanvas;
      TRect MyRect;
      HWND HPre;
      AnsiString szPara;
      AnsiString sBitmap;

      // Bitmap aus Windowsverzeichnis lesen
      sBitmap.SetLength(MAX_PATH);
      sBitmap.SetLength(GetSystemDirectory(sBitmap.c_str(),sBitmap.Length()));
      sBitmap += "\\Peace.bmp";
      Bitmap->LoadFromFile(sBitmap);

      // Übergabeparameter 2 auslesen
      szPara = ParamStr(2);

      // Überprüfung, ob 2. Übergabeparameter vorhanden ist
      if (szPara == "")
        {
        MessageBox(NULL,szPara.c_str(),"Vorschaufenster - Kein Übergabeparameter 2", MB_OK );
        return 0;
        }

      // Botschaften an Windows, bis Bild im Vorschaufenster angezeigt wird
      sscanf(__argv[2], "%d", &HPre );
      do
        {
        Application->ProcessMessages();
        }
      while ( IsWindowVisible( HPre ) == 0 );

      // Handle für Canvas des Vorschaufensters übergeben
      PreCanvas->Handle =  GetDC( HPre );
      if (PreCanvas->Handle == NULL) MessageBox( NULL, "Meldung","Handle", MB_OK );

      // Größe des Vorschaufensters ermitteln
      GetClientRect( HPre, &MyRect );
      do
        {
        PreCanvas->StretchDraw(MyRect, Bitmap);
        Application->ProcessMessages();
        } while(IsWindowVisible(HPre) != 0 );

      // Speicher für dynamisch erzeugte Objekte wieder freigeben
      delete PreCanvas;
      delete Bitmap;
      return 0;

      }

  }
  catch (Exception &exception)
  {
    Application->ShowException(&exception);
  }
  catch (...)
  {
    try
    {
      throw Exception("");
    }
    catch (Exception &exception)
    {
      Application->ShowException(&exception);
    }
  }
  return 0;
}

//---------------------------------------------------------------------------
Das einzige Problem, das ich jetzt noch habe, ist, daß bei geöffneten "Eigenschaften von Datum und Zeit"-Fenster mein System in einen Zustand kommt, in dem nur noch der Desktop ohne Icons und ohne Taskleiste angezeigt wird und nach Maus-Klick sich abmeldet. Vielleicht weiß da jemand was dagegen?? :?

_________________
Stefan - Carpe Diem
Es ist keine Schande zu fallen, eine Schande ist nur nicht wieder aufzustehen