Announcement

Collapse
No announcement yet.

MDIForm immer OBEN lassen.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • MDIForm immer OBEN lassen.

    Hallo. Mir wurde bereits in einem anderen Forum gesagt, dass dies prinzipiell nicht möglich ist, MDI-Programme StayOnTop laufen zu lassen. Ich möchte dies aber. UNd es ist auch definitiv möglich, denn es gibt Programme, welche mit dem Builder entwicklet worden sind, welche diese Möglichkeit unterstützen.

    Das Problem liegt darin: Setze man FormStyle schon auf MDIForm, wie will man dann noch MDIForm auf fsStayOnTop setzen?

    Gibt es dafür irgendeine "Ausweichfkt" oder eine WinAPI Mögl. ?

  • #2
    Hi Jan!<br>

    Versuche es doch mal mit BringToFront();<br>
    Die anderen Formulare sollten dann alle auf fsNormal stehen.<br>

    Gruß Fre

    Comment


    • #3
      Jo, diesen Befehl habe ich auch schon versucht. ER hat aber NIX bewirkt. Es bedeutet doch lediglich, dass das Formular zur "Front" gebrahct wird. Wenn ich das ins OnCreate Event schreibe, passiert auch nix. :-

      Comment


      • #4
        M.E. geht das nicht, wenn man den Erklärungen von Borland vertrauen kann
        Christian

        Comment


        • #5
          Deswegen sagte ich ja, dass ich definitiv jemanden kenne, der das so hat. Er sagt jedoch, dass er selbst nicht weiß, wie er das hinbekommen hat. Du bist übrigens nicht der erste der mir versichert, dass das eigentlich nicht geht :-

          Comment


          • #6
            Hi Jan!<br>

            Ich hoffe Du kannst damit was anfangen.<br>
            Es ist schon so wie ich es gedacht habe, Du muß die<br>
            Windowsbotschaften abfangen.<br>

            <PRE>
            PSS ID Number: Q108315

            Authored 08-Dec-1993 Last modified 19-May-1995

            The information in this article applies to:

            - Microsoft Windows Software Development Kit (SDK) version 3.1
            - Microsoft Win32 SDK versions 3.5, 3.51, and 4.0

            SUMMARY

            When creating a multiple document interface (MDI) window, there are no
            styles available to have the new window stay on top of the other MDI
            windows. Alternatively, two methods are available to achieve this
            functionality:

            - Process the WM_WINDOWPOSCHANGED message and call SetWindowPos() to
            change the Z-order of the window.

            - Install a timer for the MDI windows and reset the Z-order of the window
            when processing the WM_TIMER message.

            MORE INFORMATION

            MDICREATESTRUCT has the field "style", which can be set with the styles for
            the new MDI window. Extended styles, such as WS_EX_TOPMOST, are not
            available in MDI windows. This field of MDICREATESTRUCT is passed to
            CreateWindowEx() in the dwStyle parameter. The dwExStyle field is set to
            0L. The two methods shown below cannot be used at the same time in the same
            application.

            Method 1: Process the WM_WINDOWPOSCHANGED message and call SetWindowPos()
            to change the Z-order of the window.

            Sample Code
            -----------

            LRESULT CALLBACK MdiWndProc (HWND hWnd, UINT message, WPARAM wParam,
            LPARAM lParam)
            {
            static HWND hWndAlwaysOnTop = 0;
            switch (message)
            {
            case WM_CREATE :
            if (!hWndAlwaysOnTop)
            {
            SetWindowText (hWnd, "Always On Top Window");
            hWndAlwaysOnTop = hWnd;
            }
            break;
            case WM_WINDOWPOSCHANGED :
            if (hWndAlwaysOnTop)
            {

            WINDOWPOS FAR* pWP = (WINDOWPOS FAR*)lParam;
            if (pWP->hwnd != hWndAlwaysOnTop)
            SetWindowPos (hWndAlwaysOnTop, HWND_TOP, 0, 0, 0, 0,
            SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
            }
            break;
            //
            // Other Messages to process here.
            //
            case WM_CLOSE :
            if (hWndAlwaysOnTop == hWnd)
            hWndAlwaysOnTop = NULL;
            default :
            return DefMDIChildProc (hWnd, message, wParam, lParam);

            }
            return 0L;
            }

            Method 2: Install a timer for the MDI windows and reset the Z-order of
            the window when processing the WM_TIMER message.

            Sample Code
            -----------

            LRESULT CALLBACK MdiWndProc (HWND hWnd, UINT message, WPARAM wParam,
            LPARAM lParam)
            {
            static HWND hWndAlwaysOnTop = 0;
            switch (message)
            {
            case WM_CREATE :
            SetTimer (hWnd, 1, 200, NULL);
            if (!hWndAlwaysOnTop)
            {
            SetWindowText (hWnd, "Always On Top Window");

            hWndAlwaysOnTop = hWnd;
            }
            break;
            case WM_TIMER :
            if (hWndAlwaysOnTop)
            {
            SetWindowPos (hWndAlwaysOnTop, HWND_TOP, 0, 0, 0, 0,
            SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
            }
            break;
            case WM_DESTROY:
            KillTimer (hWnd, 1) ;
            break;
            //
            // Other Messages to process here.
            //
            case WM_CLOSE :
            if (hWndAlwaysOnTop == hWnd)

            hWndAlwaysOnTop = NULL;
            default :
            return DefMDIChildProc (hWnd, message, wParam, lParam);
            }
            return 0L;
            }

            For additional information on changing the Z-order of child pop-up windows,
            please see the following article(s) in the Microsoft Knowledge Base:

            ARTICLE-ID: Q66943
            TITLE : Determining the Topmost Pop-Up Window

            Additional reference words: 3.10 3.50 3.51 4.00 95
            KBCategory: kbprg
            KBSubcategory: UsrWndw
            </PRE>

            Gruß Fre

            Comment


            • #7
              Hallo, Fred! Danke für deine großen Bemühungen. Dass es jetzt noch nicht funktioniert, liegt wahrscheinlich an meinen mangelnden Kenntnissen. Deine Funktionen sind ja von der WinAPI, ich habe die erste versucht. Ich habe sie einfach der MDIParent-Unit hinzugefügt und compiliert. Wenn ich irgendetwas vergessen habe an einstellungen im Objektinspektor, bitte melden. Fehler gab es zumindest keine, jedoch gab es kein Resultat.

              <PRE>
              LRESULT CALLBACK MainFormWndProc (HWND hWnd,
              UINT message,
              WPARAM wParam,
              LPARAM lParam)
              {
              static HWND hWndAlwaysOnTop = 0;
              switch (message)
              {
              case WM_CREATE :
              {
              if (!hWndAlwaysOnTop)
              {
              SetWindowText (hWnd, "Always On Top Window");
              hWndAlwaysOnTop = hWnd;
              }
              break;
              }
              case WM_WINDOWPOSCHANGED :
              {
              if (hWndAlwaysOnTop)
              {
              WINDOWPOS FAR* pWP = (WINDOWPOS FAR*) lParam;
              if (pWP->hwnd != hWndAlwaysOnTop)
              {
              SetWindowPos (hWndAlwaysOnTop,
              HWND_TOP, 0, 0, 0, 0,
              SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
              }
              break;
              }
              }
              case WM_CLOSE :
              {
              if (hWndAlwaysOnTop == hWnd)
              {
              hWndAlwaysOnTop = NULL;
              }
              }
              default :
              {
              return DefMDIChildProc (hWnd, message, wParam, lParam);
              }
              }
              return 0L;
              }</PRE&gt

              Comment


              • #8
                Es tut mir leid, diesen Thread erneut hochschieben zu müssen. Obiger Code ist der, den Fred Nest gepostet hat. Es kommen keine Fehlermeldungen. Ich habe ihn einfach in die main.cpp eingefügt. Doch es gibt kein Ergebnis, d.h. es passiert nix :-(

                Kann jemand sich obigen Code nocheinmal anschauen? Ich denke jedoch, dass ich ihn einfach nicht an die richtige Stelle gemacht habe

                Comment


                • #9
                  Hi Jan!<br>

                  War im Urlaub, habe heute eine OP und melde mich dann wieder.<br>
                  Werde das mal selber testen.<br>

                  Gruß Fre

                  Comment


                  • #10
                    Hi Jan!<br>

                    Wenn Du den Code nur eingetippt hast, kann es auch nicht funktionieren.
                    Erst einen Messagehandler installieren und dann weiter
                    In der .H
                    <PRE>
                    // in diese Funktion kommt der Code von oben
                    // das handle des fensters ist ja bekannt, da diese funktion
                    // innerhalb deiner form ist.
                    void __fastcall WMWindowPosMsg( TWMWindowPosMsg &msg );

                    BEGIN_MESSAGE_MAP
                    MESSAGE_HANDLER( WM_WINDOWPOSCHANGED , TWMWindowPosMsg, WMWindowPosMsg);
                    END_MESSAGE_MAP(TForm)

                    </PRE>

                    Gruß Fre

                    Comment

                    Working...
                    X