Announcement

Collapse
No announcement yet.

MDI-Anwendung und Menü's - Bug !!??

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

  • MDI-Anwendung und Menü's - Bug !!??

    Hallo,

    habe eine MDI-Anwendung, in welcher jedes MDI-Child ein eigenes Menü hat, und jeweils eine oder mehrere Menügruppen im Hauptformular ersetzt. Soweit alles in Ordnung. Sind aber mehrere MDI-Fenster geöffnet, und schließt man ein MDI-Fenster, ist der Schließ-Button [x] des aktuellen MDI-Fensters "grayed", d.h. er wird inaktiv angezeigt. Das Fenster kann aber geschlossen werden. Entfernt man das Menü im MDI-Child, arbeitet alles wieder normal. Doch das kann's ja nicht sein. Borland weist ja ausdrücklich darauf hin, daß über den GroupIndex gesteuert werden kann, wie die Menüs angeordnet und ggf. auch ersetzt werden können. Hatte jemand vielleicht schon das gleiche Problem, bzw. kennt jemand dafür eine Lösung? Hab schon alles mögliche ausprobiert aber leider ohne Erfolg.

    Otto Herdegen

  • #2
    Ich kenne das Problem und "leide" selber darunter. Ich habe allerdings noch keine Lösung für das Problem gefunden. Der C++ Builder in der Version 3 hat den selben Bug(?), genauso wie Delphi 3 - 5. Ich habe einen Bugfix in einer Borland Newsgroup gefunden. Dieser setzt allerdings meiner Meinung vorraus, das man die Quellen der Unit Menu.pas besitzt. Ich besitze diese nicht und konnte ihn deshalb nicht nutzen. Hier der Bugfix im Original:

    Betreff:
    Re: MDI window bug???
    Datum:
    Thu, 26 Oct 2000 00:21:06 -0400
    Von:
    "Jeff Overcash (TeamB)" <[email protected]>
    Firma:
    TeamB
    Foren:
    borland.public.delphi.vcl.components.using
    Referenzen:
    1

    Try this posted by "Max"

    I have tried the following patch to Menus.pas and it works wonders for me.
    The button no longer disappears or disable and the window menu functions
    after changes are made to it. I would like to know how well this works for
    them. Neither of these two fixes are 'hacks' into that they don't cause
    extra flashing or refreshing. They just fix the 'problematic' code in
    Menus.pas. Borland has my permission to use this code if they wish. Have
    fun and hopefully this helps a few people, it sure has helped me. (The
    below snippits of code are based on D5, hopefully I have violated copyright
    laws too much here).

    Max

    procedure TMenuItem.RebuildHandle; <br>
    const <br>
    cFAF = $04; // suggested by Frank Federici, hi Frank! <br>
    var <br>
    I: Integer; <br>
    LRepopulate: Boolean; <br>
    begin <br>
    if csDestroying in ComponentState then Exit; <br>
    if csReading in ComponentState then <br>
    FStreamedRebuild := True <br>
    else <br>
    begin <br>
    if FMergedWith <> nil then <br>
    FMergedWith.RebuildHandle <br>
    else <br>
    begin <br>
    I := GetMenuItemCount(Handle); <br>
    LRepopulate := I = 0; <br>
    while I > 0 do <br>
    begin <br>
    if (WordRec(LongRec(GetMenuState(Handle, I - 1, MF_BYPOSITION)).Lo).Lo and cFAF) = 0 then <br>
    begin <br>
    RemoveMenu(Handle, I - 1, MF_BYPOSITION); <br>
    LRepopulate := True; <br>
    end; <br>
    Dec(I); <br>
    end; <br>
    if LRepopulate then <br>
    begin <br>
    if (FParent = nil) and (FMenu is TMainMenu) and <br>
    (GetMenuItemCount(Handle) = 0) then <br>
    begin <br>
    DestroyMenu(FHandle); <br>
    FHandle := 0; <br>
    end <br>
    else <br>
    PopulateMenu; <br>
    MenuChanged(False); <br>
    end; <br>
    end; <br>
    end; <br>
    end; <br>

    function TMenu.DispatchPopup(AHandle: HMENU): Boolean; <br>
    function IsMDIWindowMenu(AItem: TMenuItem): Boolean; <br>
    begin <br>
    Result := Assigned(Application.MainForm) and <br>
    (Application.MainForm.FormStyle = fsMDIForm) and <br>
    (Application.MainForm.WindowMenu = AItem); <br>
    end; <br>
    var <br>
    Item: TMenuItem; <br>
    LRebuild: Boolean; <br>
    begin <br>
    Result := False; <br>
    Item := FindItem(AHandle, fkHandle); <br>
    if Item <> nil then <br>
    begin <br>
    if not (csDesigning in Item.ComponentState) then Item.InitiateActions; <br>
    Item.Click; <br>
    LRebuild := Item.InternalRethinkHotkeys(False); <br>
    LRebuild := Item.InternalRethinkLines(False) or LRebuild; <br>
    if LRebuild then <br>
    Item.RebuildHandle; <br>
    if IsMDIWindowMenu(Item) then <br>
    if SendMessage(Application.MainForm.ClientHandle, WM_MDIREFRESHMENU, 0, 0) <> 0 then <br>
    DrawMenuBar(Application.MainForm.Handle); <br>
    Result := True; <br>
    end <br>
    else if not (csDesigning in ComponentState) and (Self is TPopupMenu) then <br>
    Items.InitiateActions; <br>
    end; <br>

    Roland wrote:
    >
    > Hi:
    >
    > I have an MDI application with two main menus, one in MDI main form and the
    > other in MDI child form. Once that M

    Comment


    • #3
      Ooops, was ist denn da passiert. Na ja, wenn du das schöner brauchst mail an [email protected] oder sieh es dir in der Newsgroup an

      Comment

      Working...
      X