Wenn dies Ihr erster Besuch hier ist,
lesen Sie bitte zuerst die Hilfe - Häufig gestellte Fragen
durch. Sie müssen sich vermutlich registrieren,
bevor Sie Beiträge verfassen können. Klicken Sie oben auf 'Registrieren', um den Registrierungsprozess zu
starten. Sie können auch jetzt schon Beiträge lesen. Suchen Sie sich einfach das Forum aus, das Sie am meisten
interessiert.
Gar nicht <br>
Wir haben darum ein Rahmenloses Form, was einfach nur eine Grafik enthält und nur so aussieht, wie eine Grafik auf dem Hintergrund. Den Ansatz solltest Du vielleicht auch versuchen, ist eigentlich recht zuverlässig!<p>
Schöne Grüße, Mario Noac
procedure TFormMDI.mmCloseClick(Sender: TObject);
begin
Close;
end;
procedure TFormMDI.ClientWndProc(var Message: TMessage);
var
Dc : hDC;
Row : Integer;
Col : Integer;
begin
with Message do
case Msg of
WM_ERASEBKGND:
begin
Dc := TWMEraseBkGnd(Message).Dc;
for Row := 0 to ClientHeight div FWallpaperBmp.Height do
for Col := 0 to ClientWidth div FWallpaperBmp.Width do
BitBlt(Dc,
Col * FWallpaperBmp.Width,
Row * FWallpaperBmp.Height,
FWallpaperBmp.Width,
FWallpaperBmp.Height,
FWallpaperBmp.Canvas.Handle,
0,
0,
SRCCOPY);
Result := 1;
end;
else
Result := CallWindowProc(FPrevClientProc,
ClientHandle,
Msg,
wParam,
lParam);
end;
end;
Hallo,<br>
wenn ein MDI-Child mit der vorherigen Version den sichtbaren Bereich verläßt, sodaß<br>
gescrollt werden muß, wird der Hintergurnd nicht richtig gezeichnet.<br>
Hier die Abhilfe:<br>
<pre>
<font face="Verdana" size="1" color="#000000">unit Unit1;
interface
procedure TFormMDI.mmCloseClick(Sender: TObject);
begin
Close;
end;
procedure TFormMDI.ClientWndProc(var Message: TMessage);
var
aDC : hDC;
begin
with Message do
case Msg of
WM_ERASEBKGND:
begin
PaintWallpaper;
Result:=1;
end;
else
Result := CallWindowProc(FPrevClientProc,
ClientHandle,
Msg,
wParam,
lParam);
end;
end;
procedure TFormMDI.FormDestroy(Sender: TObject);
begin
FWallpaperBmp.Free;
FWallpaperBmp:=Nil;
end;
procedure TFormMDI.mmNewClick(Sender: TObject);
var
NewMDI : TFormChild;
begin
NewMDI:=TFormChild.Create(Self);
NewMDI.Show;
end;
procedure TFormMDI.PaintWallpaper;
var
Row : Integer;
Col : Integer;
WndRect : TRect;
WndDC : hDC;
begin
GetWindowRect(ClientHandle,WndRect);
WndDC:=GetDC(ClientHandle);
Try
for Row := 0 to WndRect.Bottom div FWallpaperBmp.Height do
for Col := 0 to WndRect.Right div FWallpaperBmp.Height do
BitBlt(WndDC,
Col * FWallpaperBmp.Width,
Row * FWallpaperBmp.Height,
FWallpaperBmp.Width,
FWallpaperBmp.Height,
FWallpaperBmp.Canvas.Handle,
0,
0,
SRCCOPY);
Finally
ReleaseDC(ClientHandle,WndDC);
end;
end;
procedure Register;
begin
RegisterComponents('Mycomps', [TJsWallpaper]);
end;
{ TJsWallpaper }
procedure TJsWallpaper.ClientWndProc(var Message: TMessage);
begin
with Message do
case Msg of
WM_ERASEBKGND:
begin
PaintWallpaper(FOwnerHandle);
Result:=1;
end;
else
Result := CallWindowProc(FPrevClientProc,FOwnerHandle,Msg,wP aram,lParam);
end;
end;
constructor TJsWallpaper.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FWallpaper:=TBitmap.Create;
FMode:=wmTile;
end;
destructor TJsWallpaper.Destroy;
begin
FWallpaper.Free;
SetWindowLong(FOwnerHandle,GWL_WNDPROC, LongInt(FPrevClientProc));
inherited Destroy;
end;
procedure TJsWallpaper.Loaded;
begin
inherited Loaded;
If Not (csDesigning in ComponentState) then
begin
If (Not (Owner is TForm)) or (Owner=Nil) then
raise Exception.Create('Besitzer von TJsWallpaper muß ein TForm sein');
FOwnerForm:=TForm(Owner);
If FOwnerForm.FormStyle=fsMDIForm then
FOwnerHandle:=FOwnerForm.ClientHandle
else
FOwnerHandle:=FOwnerForm.Handle;
SetNewWndProc;
end; // If Not (csDesigning in ComponentState) then
end;
procedure TJsWallpaper.PaintWallpaper(WindowHandle: HWND);
var
WindowRect : TRect;
WindowDeviceContext : hDC;
begin
If FWallpaper.Empty then
Exit;
GetWindowRect(FOwnerHandle,WindowRect);
WindowDeviceContext:=GetDC(FOwnerHandle);
Try
case FMode of
wmTile : PaintTileWallpaper(WindowDeviceContext,WindowRect) ;
wmCenter : PaintCenterWallpaper(WindowDeviceContext,WindowRec t);
end;
If Assigned(FOnPaint) then
FOnPaint(Self);
Finally
ReleaseDC(FOwnerHandle,WindowDeviceContext);
end;
end;
procedure TJsWallpaper.PaintTileWallpaper(WndDC: HDC; WndRect : TRect);
var
Row : Integer;
Col : Integer;
begin
For Row := 0 to (WndRect.Bottom div FWallpaper.Height)+1 do
For Col := 0 to (WndRect.Right div FWallpaper.Width)+1 do
BitBlt(WndDC,
Col * FWallpaper.Width,
Row * FWallpaper.Height,
FWallpaper.Width,
FWallpaper.Height,
FWallpaper.Canvas.Handle,
0,
0,
SRCCOPY);
end;
procedure Register;
begin
RegisterComponents('Mycomps', [TJsWallpaper]);
end;
{ TJsWallpaper }
procedure TJsWallpaper.ClientWndProc(var Message: TMessage);
begin
with Message do
case Msg of
WM_ERASEBKGND:
begin
PaintWallpaper(FOwnerHandle);
Result:=1;
end;
else
Result := CallWindowProc(FPrevClientProc,FOwnerHandle,Msg,wP aram,lParam);
end;
end;
constructor TJsWallpaper.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FWallpaper:=TBitmap.Create;
FMode:=wmTile;
end;
destructor TJsWallpaper.Destroy;
begin
FWallpaper.Free;
SetWindowLong(FOwnerHandle,GWL_WNDPROC, LongInt(FPrevClientProc));
inherited Destroy;
end;
procedure TJsWallpaper.Loaded;
begin
inherited Loaded;
If Not (csDesigning in ComponentState) then
begin
If (Not (Owner is TForm)) or (Owner=Nil) then
raise Exception.Create('Besitzer von TJsWallpaper muß ein TForm sein');
FOwnerForm:=TForm(Owner);
If FOwnerForm.FormStyle=fsMDIForm then
FOwnerHandle:=FOwnerForm.ClientHandle
else
FOwnerHandle:=FOwnerForm.Handle;
SetNewWndProc;
end; // If Not (csDesigning in ComponentState) then
end;
procedure TJsWallpaper.PaintWallpaper(WindowHandle: HWND);
var
WindowRect : TRect;
WindowDeviceContext : hDC;
begin
If FWallpaper.Empty then
Exit;
GetWindowRect(FOwnerHandle,WindowRect);
WindowDeviceContext:=GetDC(FOwnerHandle);
Try
case FMode of
wmTile : PaintTileWallpaper(WindowDeviceContext,WindowRect) ;
wmCenter : PaintCenterWallpaper(WindowDeviceContext,WindowRec t);
end;
If Assigned(FOnPaint) then
FOnPaint(Self);
Finally
ReleaseDC(FOwnerHandle,WindowDeviceContext);
end;
end;
procedure TJsWallpaper.PaintTileWallpaper(WndDC: HDC; WndRect : TRect);
var
Row : Integer;
Col : Integer;
begin
For Row := 0 to (WndRect.Bottom div FWallpaper.Height)+1 do
For Col := 0 to (WndRect.Right div FWallpaper.Width)+1 do
BitBlt(WndDC,
Col * FWallpaper.Width,
Row * FWallpaper.Height,
FWallpaper.Width,
FWallpaper.Height,
FWallpaper.Canvas.Handle,
0,
0,
SRCCOPY);
end;
Comment