改变BorderStyle、Position的属性时,窗体的handle也发生改变,能不能改变BorderStyle、Position的属性时,窗体的handle不发生改变吗?还有就是我用到了skin, 高手们帮忙看看啊。procedure FullScreens();
begin
with Form1 do
begin
fHeight := Height;
fWidth := Width;
fPosition := Position; ShowMessage(IntToStr(form1.spsknpnl1.Handle));
WindowState := wsMaximized;
BorderStyle:=bsNone;
ShowMessage(IntToStr(form1.spsknpnl1.Handle));
FullScreen := True;
spsknpgcntrl1.Visible := False;
spskntrckbr1.Visible := True;
spskntrckbr1.Top := Height - 5;
spskntrckbr1.Width := Width - 6;
spsknpnl2.Visible := True;
spsknpnl2.Top := Height - 1;
spsknpnl2.width := Width - 2;
spsknpnl1.Width := Width - 2;
spsknpnl1.Height := Height - 2;
btn1.Top := spskntrckbr1.Top + 20;
btn2.Top := spskntrckbr1.Top + 20;
btn3.Top := spskntrckbr1.Top + 20;
btn4.Top := spskntrckbr1.Top + 20;
btn5.Top := spskntrckbr1.Top + 20;
btn6.Top := spskntrckbr1.Top + 20;
btn7.Visible := False;
spskntrckbr2.Top := spskntrckbr1.Top + 22;
end;
end;procedure UnFullScreens();
begin
with Form1 do
begin
//BorderStyle := bsSizeable;
WindowState := wsNormal;
Width := fWidth;
Height := fHeight;
ShowMessage(IntToStr(form1.spsknpnl1.Handle));
Position := poScreenCenter; // poScreenCenter;
ShowMessage(IntToStr(form1.spsknpnl1.Handle));
FullScreen := False;
//btn7.Visible := True;
end;end;
begin
with Form1 do
begin
fHeight := Height;
fWidth := Width;
fPosition := Position; ShowMessage(IntToStr(form1.spsknpnl1.Handle));
WindowState := wsMaximized;
BorderStyle:=bsNone;
ShowMessage(IntToStr(form1.spsknpnl1.Handle));
FullScreen := True;
spsknpgcntrl1.Visible := False;
spskntrckbr1.Visible := True;
spskntrckbr1.Top := Height - 5;
spskntrckbr1.Width := Width - 6;
spsknpnl2.Visible := True;
spsknpnl2.Top := Height - 1;
spsknpnl2.width := Width - 2;
spsknpnl1.Width := Width - 2;
spsknpnl1.Height := Height - 2;
btn1.Top := spskntrckbr1.Top + 20;
btn2.Top := spskntrckbr1.Top + 20;
btn3.Top := spskntrckbr1.Top + 20;
btn4.Top := spskntrckbr1.Top + 20;
btn5.Top := spskntrckbr1.Top + 20;
btn6.Top := spskntrckbr1.Top + 20;
btn7.Visible := False;
spskntrckbr2.Top := spskntrckbr1.Top + 22;
end;
end;procedure UnFullScreens();
begin
with Form1 do
begin
//BorderStyle := bsSizeable;
WindowState := wsNormal;
Width := fWidth;
Height := fHeight;
ShowMessage(IntToStr(form1.spsknpnl1.Handle));
Position := poScreenCenter; // poScreenCenter;
ShowMessage(IntToStr(form1.spsknpnl1.Handle));
FullScreen := False;
//btn7.Visible := True;
end;end;
procedure TForm1.btn2Click(Sender: TObject);
var
dwStyle: DWORD;
Rect: TRect;
begin
dwStyle := GetWindowLong(Handle, GWL_STYLE);
if FSizeable then
begin
Rect := GetClientRect;
dwStyle := dwStyle xor WS_CAPTION xor WS_THICKFRAME; //去掉标题和边框
SetWindowLong(Handle, GWL_STYLE, dwStyle);
Width := Rect.Right - Rect.Left;
Height := Rect.Bottom - Rect.Top;
FSizeable := False;
end
else begin
dwStyle := GetWindowLong(Handle, GWL_STYLE);
dwStyle := dwStyle or WS_CAPTION or WS_THICKFRAME; //加上标题和边框
SetWindowLong(Handle, GWL_STYLE, dwStyle);
Width := 476;
Height := 400;
FSizeable := True;
end;
end;
更改窗口位置用SetWindowPos,有事找MSDN
begin
if FForm <> nil then
FOldState := FForm.WindowState;
end;procedure TForm1.SetFullScreenMode(aVal: Boolean);
begin
if aVal <> FFullScreenMode then
begin
FFullScreenMode := aVal;
if FFullScreenMode then
begin
OldState := GetWindowLong(Form1.Handle, GWL_STYLE);
OldHeight := Form1.Height;
OldWidth := Form1.Width;
OldX := Form1.Left;
OldY := Form1.Top;
SaveOldWinState;
SetWindowLong(Form1.Handle, GWL_STYLE,
GetWindowLong(Form1.Handle, GWL_STYLE) and not WS_CAPTION);
Form1.windowstate := wsmaximized;
Form1.clientHeight := screen.Height;
Form1.Refresh;
end
else
begin
SetWindowLong(Form1.Handle, GWL_STYLE, OldState);
Form1.Height := OldHeight;
Form1.Width := OldWidth;
Form1.Left := OldX;
Form1.Top := OldY;
Form1.Windowstate := FOldState;
Form1.Refresh;
end;
end;
if Assigned(FAfterModeChanged) then FAfterModeChanged(Self);
end;procedure Register;
begin
RegisterComponents('UWS Used', [TForm1]);
end;