扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:cobi 来源:开发高手 2007年10月31日
关键字:
图五 Q Q 窗体自动充满屏幕两边 |
图六 Q Q 窗体自动充满屏幕两边的漏洞 |
procedure TForm1.WMMOVING(var Msg: TMessage); begin inherited; with PRect(Msg.LParam)^ do begin if (akLeft in FAnchors) or (akRight in FAnchors) then begin if (Left > 0) and (Right < Screen.Width) then begin if rec_Position then begin Bottom := top + Lst_Height; Right := Left + Lst_Width; Height := Lst_Height; Width := Lst_Width; end; end else begin SetBarHeight; Top := Cur_Top; Bottom := Cur_Bottom; exit; end; end; Left := Min(Max(0, Left), Screen.Width - Width); .. if not Rec_Position then begin Lst_Height := form1.Height; Lst_Width := form1.width; end; FAnchors := []; .. if (akLeft in FAnchors) or (akRight in FAnchors) then begin Rec_Position := True; SetBarHeight; Top := Cur_Top; Bottom := Cur_Bottom; end else Rec_Position := False; Timer1.Enabled := FAnchors <> []; end; end; |
Lst_Height : Integer; //记录窗体隐藏前的高度 Lst_Width : Integer; //记录窗体隐藏前的宽度 Rec_Position : Boolean; //是否启动窗体宽高记录标志 |
procedure TForm1.SetBarHeight; var AppBarData : TAPPBARDATA; begin AppBarData.cbSize := SIZEOF(AppBarData); If SHAppBarMessage(ABM_GETSTATE,AppBarData) AND ABS_AUTOHIDE) <> 0 then begin Cur_Top := 1; Cur_Bottom := Screen.Height - 1; end else begin SHAppBarMessage(ABM_GETTASKBARPOS,AppBarData); case AppBarData.uEdge of ABE_TOP : begin Cur_Top := AppBarData.rc.Bottom + 1; Cur_Bottom := Screen.Height - 1; end; ABE_LEFT : begin Cur_Top := 1; Cur_Bottom := Screen.Height - 1; end; ABE_RIGHT : begin Cur_Top := 1; Cur_Bottom := Screen.Height - 1; end; ABE_BOTTOM : begin Cur_Top := 1; Cur_Bottom:=Screen.Height - (AppBarData.rc.Bottom - AppBarData. rc.Top) - 1; end; end; end; end; |
WINSHELLAPI UINT APIENTRY SHAppBarMessage(DWORD dwMessage,PAPPBARDATA pData); |
.. if akLeft in FAnchors then begin Left := -Width + cOffset; SetBarHeight; Top := Cur_Top; Height := Cur_Bottom; end; if akRight in FAnchors then begin Left := Screen.Width - cOffset; SetBarHeight; Top := Cur_Top; Height := Cur_Bottom; end; .. |
procedure TForm1.WMSizing(var Msg: TMessage); begin inherited; if (akRight in FAnchors) then begin with PRect(Msg.LParam)^ do begin Left := Screen.Width - Width; Top := Cur_Top; Right := Screen.Width; Bottom := Cur_Bottom end; end else if (akLeft in FAnchors) then begin with PRect(Msg.LParam)^ do begin Left := 0; Top := Cur_Top; Right := Width; Bottom := Cur_Bottom; end; end; end; |
图七 窗体向屏幕右方移动 |
图八 窗体充满屏幕右方 |
图九 窗体位置随工具栏位置变化 |
图十 窗体离开屏幕右方恢复隐藏前大小 |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者