Autor |
Beitrag |
DataCool
      
Beiträge: 112
|
Verfasst: Di 07.01.03 19:21
Hi Leute,
wie kann ich per Windows-API oder auch anders den X-Button einer Form drücken.
Danke,
_________________ DataCool
|
|
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Di 07.01.03 19:37
SendMessage(hWnd, WM_CLOSE, 0, 0);
hWnd ist das Handle von dem Fenster. Das bekommst du mit FindWindow.
|
|
Popov
Gast
Erhaltene Danke: 1
|
Verfasst: Di 07.01.03 19:45
Die API freie Variante ist: Close 
|
|
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Di 07.01.03 19:47
Aber damit dürftest du bei fremde Fenstern nicht viel Erfolg haben. Und ich bin davon ausgegangen, dass er es für fremde Fenster braucht, sonst wäre die Frage doch etwas zu trivial gewesen.
|
|
Popov
Gast
Erhaltene Danke: 1
|
Verfasst: Di 07.01.03 20:12
Vielleicht ist Frage trivial
|
|
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Di 07.01.03 20:23
Jupp. Wer weiß, aber dafür hat er jetzt beide möglichen Antworten.
@DataCool: Das nächste mal bitte etwas genauer.
|
|
DataCool 
      
Beiträge: 112
|
Verfasst: Di 07.01.03 21:10
Das wäre mir gerade noch alleine eingefallen
Ich sollte mein Problem noch etwas genauer beschreiben :
Ich habe mir wie in Opera eine Anzeige für alle MDI-Panels geschrieben, die funktioniert auch einwandfrei.
Nur wenn ich meine Form mit Close oder WM_Close schliesse treten Fehler auf. Da ich aber für die Überarbeitung der Komponente gerade keine Zeit habe und den Fehler auch nicht auf anhieb finde, habe ich mir gedacht :
Quick-And-Dirty:
ich lasse die Mouse automatisch auf das X der Form klicken.
Was nun ?
_________________ DataCool
|
|
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Mi 08.01.03 03:48
Such lieber den Fehler. Alles andere bringt nichts.
|
|
DataCool 
      
Beiträge: 112
|
Verfasst: Mi 08.01.03 11:36
Dazu müßte ich wissen, welche Windows Message noch zusätzlich eintritt, wenn man auf den X-Button klicke.
Weil das schliessen der Form über den X-Button funktioniert und über den Aufruf von Close nicht 
_________________ DataCool
|
|
Popov
Gast
Erhaltene Danke: 1
|
Verfasst: Mi 08.01.03 12:06
|
|
noeppel
Hält's aus hier
Beiträge: 6
|
Verfasst: Mi 08.01.03 17:21
versuchs mal mit WM_SYSCOMMAND SC_CLOSE ... Das ist genau das gleiche wie wenn du auf das [X] klickst oder 'Schliessen' aus dem Systemmenü wählst.
Quelltext 1:
| SendMessage(Handle, WM_SYSCOMMAND, SC_CLOSE, 0); |
|
|
DataCool 
      
Beiträge: 112
|
Verfasst: Mi 08.01.03 17:29
Also ich habe etwas rumprobiert und habe festgestellt, dass es gar nicht an meiner neuen Komponente liegt !
Denn es funktioniert alles wunderbar, wenn ich ein neue MDI-Form mit einem Button erzeuge, bei diesem in OnClick Ereigniss
Quelltext 1:
| SendMessage(frmHG.Handle,WM_CLOSE,0,0); aufrufe. |
Das Problem/Die Fehlermeldung stellt sich wie folgt dar:
Ich habe bei der MDI-Form die den Fehler verursacht eine andere Komponente ein Panel mit Standard-Buttons(Neu,Ändern,Löschen u. Schliessen).
Diese Komponente hat ein OnClickClose-Ereigniss:
Quelltext 1: 2: 3: 4:
| ... else {Schliessen wurde gedrückt} if Assigned(Click_Close) then Click_Close(sender); end; |
Wenn man das ganze nun debugged wird bei Click_Close das oben genannte SendMessage aufgerufen. Die MDIPanel-Komponente erhält die WM_Close Message und gibt die MDi-Form und den dazugehörigen Button frei.
Danach ladet man auf dem "end" der obrigen Procedure mit jetzt mit F7 weiter debuggen will bekommt man eine Schutzverletzung ?
Ich habe gerade echt keine Ahnung woran das liegen kann. Beide Komponenten funktionieren alleine einwandfrei, nur zusammen nicht ?????
Irgentwelche Denkanstösse ??
Oder seh den Wald vor lauter Bäumen nicht ??
(10.01. 09:25 Tino) Code-Tags hinzugefügt
_________________ DataCool
|
|
DataCool 
      
Beiträge: 112
|
Verfasst: Do 09.01.03 21:52
JuHu, hartneckigkeit zahlt sich aus
Den Rest habe ich entfernt

_________________ DataCool
Zuletzt bearbeitet von DataCool am Fr 10.01.03 09:48, insgesamt 1-mal bearbeitet
|
|
DataCool 
      
Beiträge: 112
|
Verfasst: Do 09.01.03 21:55
Falls jemand den Komponente + Bsp. habeb möchte einfach mailen.
Vielleicht kan man ja auch noch was verbessern ?!
_________________ DataCool
|
|
Popov
Gast
Erhaltene Danke: 1
|
Verfasst: Do 09.01.03 22:22
@DataCool
Was hast du da für ein Müll gepostet? Ein Tip: geh zu dem Beitrag und klick oben auf "Edit". Dann alles markieren und löschen.
Entweder kriegst du es selbst hin und postes ein lesbaren Text, oder du läßt es.
|
|
DataCool 
      
Beiträge: 112
|
Verfasst: Do 09.01.03 22:31
@popov:
Der "Müll " da oben ist formatierter Sourcecode ! Nur kann ich in meinem Profil leider nicht HTML aktivieren ?!
Letztes mal hat dann ein admin HTML für diesen beitrag aktiviert
_________________ DataCool
|
|
Popov
Gast
Erhaltene Danke: 1
|
Verfasst: Fr 10.01.03 02:15
Mit Müll meinte ich nicht, daß du Schrott gepostest hast, sondern daß du Html-Tags eingefügt hast. Du machst dir keine Gedanken wie das aussehen wird. Die anderen werden es schon machen.
Ich glaube auch nicht, daß der Admin das letzte mal irgendwo die Html-Tags aktiviert hat. Das Problem ist, daß obwohl du schon zwei Monate hier bist, du anscheinend noch nich mitbekommen hast was der BBCode ist. Das ist eine Art Pseudo-Html. Wenn du einen Text schreibst, dann siehst du oben einigen Buttons. Du kannst sie nutzen um deinen Text zu formatieren.
Sogar Neulige kriegen das hin, daß wenn sie einen Quellcode posten, sie den Code in den CODE-Pseudo-Tags paken. Das sieht dann so aus:
Quelltext
ohne sieht das so aus:
ShowMessage('Hallo');
Das was du als einschalten der HTML Tags bezeichnet hast, war Tino der die CODE-Pseudo-Tags hinzugefüht hat. Das war kein eingeschalteten von HTML.
Ich hab mir deine Beiträge Stichprobenartig angeguckt und hab festgestellt, daß du deinen Code NIE formatierst. Ich glaube nicht, daß es Faulheit ist, sonder Unkenntnis. Lies dir mal die Hilfe durch: www.auq.de/faq.php#21
Und entferne bitte den "Müll". Wenn du einen Code in einer HTML Seite hast, dann kopier nur den Quellcode aus dem Browser, nicht dem HTML Quelltext. Setze deinen Code dann in die [ code ] und [ /code ] Tags ein (BBCode ohne Leerzeichen).
Wenn du das nicht machst, dann bist du der Typ der nach zwei Monaten es immer noch nicht hinkriegt einen Quellcode vernünftig zu posten.
|
|
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Fr 10.01.03 09:00
Ich bin zwar im Normalfall gegen Zensur, aber da du, DataCool, ja selbst anbietest:
Zitat: | Falls jemand den Komponente + Bsp. habeb möchte einfach mailen.
Vielleicht kan man ja auch noch was verbessern ?! |
würde ich auch mal vorschlagen, du entfernst den Quark. Vielleicht hat auch ein Moderator/Admin Erbarmen und übernimmt diese Aufgabe?
|
|
DataCool 
      
Beiträge: 112
|
Verfasst: Fr 10.01.03 09:55
Trotzdem wäre es schöner wenn man direkt HTML posten könnte.
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: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563:
| unit MDIPanel;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, menus, LbSpeedButton, LBButtons;
type
TChangeFormEvent = procedure (newForm : TForm) of object;
TMDIPanel = class(TCustomPanel) private { Private-Deklarationen } MainForm : TForm; fForms : TList;
OldWndClientProc: Pointer; InstanceWndClientProc: Pointer;
fColorStyle : TLbColorStyle; fBtnWidth : Longint; fOnChangeForm : TChangeFormEvent; function NextButtonLeft : Longint; procedure ClearMem; procedure moveBtn2Left(index : Longint); protected { Protected-Deklarationen } procedure WndClientProc(var Message: TMessage); public { Public-Deklarationen } Constructor Create(AOwner : TComponent); override; Destructor Free; procedure Remove(mdiData : TObject); overload; procedure Remove(FormHwnd : hwnd); overload; function ActivateForm(Form : TForm) : Boolean; published { Published-Deklarationen } property ColorStyle : TLbColorStyle read fColorStyle write fColorStyle; property ButtonWidth : Longint read fBtnWidth write fBtnWidth; property OnChangeForm : TChangeFormEvent read fOnChangeForm write fOnChangeForm;
property Align; property Alignment; property Anchors; property AutoSize; property BevelInner; property BevelOuter; property BevelWidth; property BiDiMode; property BorderWidth; property BorderStyle; //property Caption; property Color; property Constraints; property Ctl3D; property UseDockManager default True; property DockSite; property DragCursor; property DragKind; property DragMode; property Enabled; property FullRepaint; property Font; property Locked; property ParentBiDiMode; property ParentColor; property ParentCtl3D; property ParentFont; property ParentShowHint; property PopupMenu; property ShowHint; property TabOrder; property TabStop; property Visible; property OnCanResize; property OnClick; property OnConstrainedResize; property OnContextPopup; property OnDockDrop; property OnDockOver; property OnDblClick; property OnDragDrop; property OnDragOver; property OnEndDock; property OnEndDrag; property OnEnter; property OnExit; property OnGetSiteInfo; property OnMouseDown; property OnMouseMove; property OnMouseUp; property OnResize; property OnStartDock; property OnStartDrag; property OnUnDock;
end;
procedure Register;
implementation
type
TMDIData = Class(TPersistent) private MainForm : TForm; Popup : TPopupMenu; Btn : TLBSpeedButton; MDIPanel : TMDIPanel; Handle : THandle; MDIForm : TForm; OldChildWndProc: Pointer; InstanceChildWndProc: Pointer; procedure InitButton; procedure OnPopupMenu(Sender: TObject); procedure MouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer); protected procedure ChildWndProc(var Message: TMessage); virtual; procedure ClickActBut(Sender: TObject); procedure MinimizeMDIWindow(Sender: TObject); procedure CloseMDIWindow(Sender: TObject); procedure RestoreMDIWindow(Sender: TObject); procedure MaximizeMDIWindow(Sender: TObject); public Constructor Create(ParentPanel : TMDIPanel; Hwnd : THandle); Destructor Free; end;
procedure Register; begin RegisterComponents('DataCool', [TMDIPanel]); end;
{ TMDIData }
constructor TMDIData.Create(ParentPanel: TMDIPanel; Hwnd: THandle); begin inherited Create; MDIPanel := ParentPanel; if MDIPanel <> Nil then begin MainForm := MDIPanel.MainForm; Handle := Hwnd; MDIForm := FindControl(Handle) as TForm; InitButton; end else begin MainForm := Nil; Btn := Nil; Popup := Nil; Handle := 0; MDIForm := Nil; OldChildWndProc := Nil; InstanceChildWndProc := Nil; end;
end;
destructor TMDIData.Free; begin if Popup <> Nil then Popup.free; if Btn <> Nil then Btn.free; if MDIForm <> Nil then MDIForm := nil; end;
procedure TMDIData.ChildWndProc(var Message: TMessage); begin case Message.Msg of WM_GETTEXT: begin Message.Result:= CallWindowProc(OldChildWndProc, Handle, Message.Msg, Message.WParam, Message.LParam); Btn.Caption := Copy(PChar(Message.LParam),1,20); if Length(PChar(Message.LParam))>20 then begin Btn.Caption := Btn.Caption + ' ...'; Btn.Hint := PChar(Message.LParam); Btn.ShowHint := True; end else begin Btn.Hint := ''; Btn.ShowHint := False; end;
Exit; end; WM_MDIACTIVATE: begin if HWND(Message.LParam)=Handle then begin Btn.Down := True; Btn.Font.Color := clBlue; if assigned(MDIPanel.fOnChangeForm) then MDIPanel.fOnChangeForm(self.MDIForm); end; if HWND(Message.WParam)=Handle then begin Btn.Down := False; Btn.Font.Color := clWindowText; end; // ????????????? //MaximizeMDIWindow(nil); end; WM_MDIDESTROY : begin ShowMessage('MDI Destroy'); end; WM_SIZE: begin if Message.WParam = SIZE_MINIMIZED then begin ShowWindow(Handle, SW_HIDE); end; (* ShowMessage('Msg:'+inttostr(Message.Msg)+#10#13 +'WParam:'+inttostr(Message.WParam)+#10#13 +'LParam:'+inttostr(Message.LParam)+#10#13 +'Result:'+inttostr(Message.LParam)); *) end; WM_CLOSE: begin SetWindowLong(Handle, GWL_WNDPROC, Longint(OldChildWndProc)); FreeObjectInstance(InstanceChildWndProc); MDIPanel.Remove(self); end; WM_DESTROY: begin SetWindowLong(Handle, GWL_WNDPROC, Longint(OldChildWndProc)); FreeObjectInstance(InstanceChildWndProc); // Form aus Liste entfernen und Object freigeben MDIPanel.Remove(self); exit; end; end; if OldChildWndProc <> nil then begin try Message.Result:= CallWindowProc(OldChildWndProc, Handle, Message.Msg, Message.WParam, Message.LParam); except {} end; end; end;
procedure TMDIData.ClickActBut(Sender: TObject); begin if assigned(MDIPanel.fOnChangeForm) then MDIPanel.fOnChangeForm(self.MDIForm); ShowWindow(Handle,SW_NORMAL); BringWindowToTop(Handle); end;
procedure TMDIData.CloseMDIWindow(Sender: TObject); begin SendMessage(Handle,WM_CLOSE,0,0); end;
procedure TMDIData.MinimizeMDIWindow(Sender: TObject); begin ShowWindow(Handle,SW_MINIMIZE); end;
procedure TMDIData.RestoreMDIWindow(Sender: TObject); begin ShowWindow(Handle,SW_RESTORE); end;
procedure TMDIData.MaximizeMDIWindow(Sender: TObject); begin ShowWindow(Handle,SW_MAXIMIZE); end;
procedure TMDIData.InitButton; Var mi : TMenuItem; Source, Destination: TBitmap; begin // Icon der Form in ein Bmp umwandeln if (MDIForm <> Nil) and (MDIForm.Icon <> Nil) then begin try Source := TBitmap.Create; Destination := TBitmap.Create; try {Make the conversion} Source.Width := 32; Source.Height := 32; Source.Canvas.Draw(0, 0, MDIForm.Icon); Destination.Width := 16; Destination.Height := 16; Destination.Canvas.StretchDraw(Rect(0, 0, 16, 16), Source); finally Source.Free; end; except Destination := Nil; end; end else Destination := Nil;
Btn := TLbSpeedButton.Create(MDIPanel); Btn.Parent := MDIPanel; Btn.GroupIndex := 1; Btn.Left := MDIPanel.nextButtonLeft; Btn.Top := 3; Btn.Height := MDIPanel.Height -6; btn.Width := MDIPanel.ButtonWidth; Btn.ColorStyle := MDIPanel.ColorStyle; Btn.Glyph := Destination; Btn.Caption := MDIForm.Caption; Btn.Flat := true; Btn.OnClick := ClickActBut;
Popup := TPopupMenu.Create(Btn); Popup.AutoPopup := false;
mi := TMenuItem.Create(Btn); mi.Caption := 'Öffnen'; mi.OnClick := ClickActBut; mi.Bitmap.Handle := LoadBitmap(0, PChar(OBM_CHECK)); Popup.Items.Add(mi);
mi := TMenuItem.Create(Btn); mi.Caption := '-'; Popup.Items.Add(mi);
mi := TMenuItem.Create(Btn); mi.Caption := 'Wiederherstellen'; mi.OnClick := RestoreMDIWindow; mi.Bitmap.Handle := LoadBitmap(0, PChar(OBM_RESTORED)); Popup.Items.Add(mi);
mi := TMenuItem.Create(Btn); mi.Caption := 'Minimieren'; mi.OnClick := MinimizeMDIWindow; mi.Bitmap.Handle := LoadBitmap(0, PChar(OBM_REDUCED)); Popup.Items.Add(mi);
mi := TMenuItem.Create(Btn); mi.Caption := 'Maximieren'; mi.OnClick := MaximizeMDIWindow; mi.Bitmap.Handle := LoadBitmap(0, PChar(OBM_ZOOMD)); Popup.Items.Add(mi);
mi := TMenuItem.Create(Btn); mi.Caption := '-'; Popup.Items.Add(mi);
mi := TMenuItem.Create(Btn); mi.Caption := 'Schliessen'; mi.OnClick := CloseMDIWindow; Popup.Items.Add(mi);
mi := TMenuItem.Create(Btn); mi.Caption := '-'; Popup.Items.Add(mi);
mi := TMenuItem.Create(Btn); mi.Caption := 'Abbrechen'; Popup.Items.Add(mi);
Popup.OnPopup := OnPopupMenu; btn.OnMouseDown := MouseDown;
InstanceChildWndProc := MakeObjectInstance(ChildWndProc); OldChildWndProc := Pointer(GetWindowLong(Handle,GWL_WNDPROC)); SetWindowLong(Handle, GWL_WNDPROC, Longint(InstanceChildWndProc)); if Destination <> Nil then Destination.free; end;
procedure TMDIData.OnPopupMenu(Sender: TObject); begin if GetTopWindow(MainForm.ClientHandle)= Handle then Popup.Items[0].Enabled := False else Popup.Items[0].Enabled := True;
if IsIconic(Handle) then begin Popup.Items[2].Enabled := True; Popup.Items[3].Enabled := False; Popup.Items[4].Enabled := True; end else begin Popup.Items[3].Enabled := True; if IsZoomed(Handle) then begin Popup.Items[2].Enabled := True; Popup.Items[4].Enabled := False; end else begin Popup.Items[2].Enabled := False; Popup.Items[4].Enabled := True; end; end; end;
procedure TMDIData.MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button=mbRight then Popup.Popup(Mouse.CursorPos.x,Mouse.CursorPos.y); end;
{ TMDIPanel }
constructor TMDIPanel.Create(AOwner: TComponent); var Component: TComponent; begin inherited Create(AOwner); fForms := TList.Create; if (csDesigning in ComponentState) then begin fColorStyle := lcsCustom; BevelOuter := bvLowered; fBtnWidth := 150; self.Height := 30; Caption := ''; end; if not(csDesigning in ComponentState) then begin Component := Owner; while Assigned(Component) and not (Component is TForm) do Component:= Component.Owner; if not Assigned(Component) then Exit; MainForm := Component as TForm;
if MainForm.Handle=MainForm.ClientHandle then ; // without this don''t work :o??????
if (not (csDesigning in ComponentState)) and (MainForm.FormStyle=fsMDIForm) then begin InstanceWndClientProc := MakeObjectInstance(WndClientProc); OldWndClientProc := Pointer(GetWindowLong(MainForm.ClientHandle, GWL_WNDPROC)); SetWindowLong(MainForm.ClientHandle, GWL_WNDPROC, Longint(InstanceWndClientProc)); end; end; end;
procedure TMDIPanel.Remove(mdiData: TObject); Var mData : TMDIData; idx : Longint; begin if mdiData <> Nil then begin idx := fForms.IndexOf(mdiData); mData := TMDIData(mdiData); mData.Free; if idx > -1 then begin fForms[idx] := Nil; fForms.Pack; moveBtn2Left(idx); end; end; end;
procedure TMDIPanel.Remove(FormHwnd : hwnd); Var mData : TMDIData; i : Longint; begin if FormHwnd <> 0 then begin For i := 0 to fForms.Count - 1 do begin mData := TMDIData(fForms[i]); if mData.MDIForm.Handle = FormHwnd then begin fForms[i] := Nil; fForms.Pack; moveBtn2Left(i); mData.free; break; end; end; end; end;
procedure TMDIPanel.ClearMem; Var i : Longint; mdiData : TMDIData; begin for i:= 0 to fForms.Count - 1 do begin if fForms[i] <> Nil then begin mdiData := TMDIData(fForms[i]); mdiData.free; fForms[i] := Nil; end; end; fForms.Pack; end;
destructor TMDIPanel.Free; begin ClearMem; inherited free; end;
procedure TMDIPanel.WndClientProc(var Message: TMessage); Var mdiData : TMDIData; begin case Message.Msg of WM_MDICREATE: begin Message.Result := CallWindowProc(OldWndClientProc, MainForm.ClientHandle, Message.Msg, Message.WParam, Message.LParam);
(* case Align of alTop, alBottom: Wrapable:=False; alLeft, alRight: Wrapable:=True; end; *) mdiData := TMDIData.Create(self,Message.Result); self.fForms.Add(mdiData); Exit; end; WM_MDIDESTROY : begin Message.Result := CallWindowProc(OldWndClientProc, MainForm.ClientHandle, Message.Msg, Message.WParam, Message.LParam); exit; end; WM_DESTROY: begin SetWindowLong(MainForm.ClientHandle, GWL_WNDPROC, Longint(OldWndClientProc)); FreeObjectInstance(InstanceWndClientProc); end; end; Message.Result:= CallWindowProc(OldWndClientProc, MainForm.ClientHandle, Message.Msg, Message.WParam, Message.LParam); end;
function TMDIPanel.NextButtonLeft: Longint; begin result := (fForms.Count * ButtonWidth)+(fForms.Count*2) + 1; end;
procedure TMDIPanel.moveBtn2Left(index : Longint); Var i : Longint; mdiData : TMdiData; idx : Longint; begin for i := index to fForms.Count -1 do begin if fForms[i] <> Nil then begin mdiData := TMdiData(fForms[i]); idx := i; mdiData.Btn.Left := (idx * ButtonWidth)+(idx*2) + 1; end; end; end;
function TMDIPanel.ActivateForm(Form: TForm): Boolean; Var i : Longint; mdiData : TMDIData; begin result := false; for i:= 0 to fForms.Count - 1 do begin if fForms[i] <> Nil then begin mdiData := TMDIData(fForms[i]); if mdiData.MDIForm = Form then begin mdiData.ClickActBut(nil); result := true; break; end; end; end; end;
end. |
_________________ DataCool
|
|
DataCool 
      
Beiträge: 112
|
Verfasst: Fr 10.01.03 10:03
Ich hoffe jetzt sind ALLE zufrieden
Ich war nur von anderen Foren HTML-Code gewöhnt und da es hier auch die Option gibt sich, Sie nur nicht aktivieren lässt, dachte ich das das nur einer der Administratoren kann.
Sorry @all
_________________ DataCool
|
|
|