打印本文 打印本文 关闭窗口 关闭窗口
从实作标题栏按钮开始浅谈组件的制作
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3420  更新时间:2009/4/23 18:39:49  文章录入:mintao  责任编辑:mintao
              SetCapture(FForm.Handle);


            end;


          end;


        WM_NCRBUTTONDOWN,WM_NCRBUTTONDBLCLK:


          begin


            if WParam = 888 then


            begin


              if Assigned(FPopup) then


              begin


                p.x := FForm.Left + BoundsRect.Left;


                p.y := FForm.Top + BoundsRect.Bottom;


                FPopup.Popup(p.x,p.y);


              end;


            end


            else


              Result:=CallWindowProc(FOldWndProc,FForm.Handle,Msg,WParam,LParam);


          end;


        WM_NCLBUTTONUP,WM_LBUTTONUP :


          begin


            if FButtonDown then


            begin


              FButtonDown := False;


              RePaint;


              ReleaseCapture;


              if Assigned(FOnClick) then FOnClick(self);


            end


            else


              Result:=CallWindowProc(FOldWndProc,FForm.Handle,Msg,WParam,LParam);


          end;


        else


          Result := CallWindowProc(FOldWndProc,FForm.Handle,Msg,WParam,LParam);


      end;


    end


    else


      Result := CallWindowProc(FOldWndProc,FForm.Handle,Msg,WParam,LParam);


  end;


end;


 


procedure TTitleBarButton.SetGlyph(const Value: TBitmap);


begin


  FGlyph.Assign(Value);


  SendMessage(FForm.Handle,WM_NCACTIVATE,0,0);


end;


 


procedure TTitleBarButton.SetRightMargin(const Value: Cardinal);


begin


  FRightMargin := Value;


  SendMessage(FForm.Handle,WM_NCACTIVATE,0,0);


end;


 


procedure TTitleBarButton.SetVisible(const Value: Boolean);


begin


  FVisible := Value;


  SendMessage(FForm.Handle,WM_NCACTIVATE,0,0);


end;


 


procedure TTitleBarButton.Notification(Component: TComponent;


  Operation: TOperation);


begin


  inherited;


  if (Operation = opRemove) and (Component = FPopup) then


    FPopup := nil;


end;


 


function TTitleBarButton.GetBoundsRect: TRect;


var


  Rec: TRect;


  FrameThick: Integer; //窗体框架厚度


  BtnWidth,BtnHeight: Integer; //标题栏按钮的宽度和高度


begin


  GetWindowRect(FForm.Handle,Rec); //得到窗体边界矩形,相对于屏幕左上角


 


  with Result do


  begin


    FrameThick := GetSystemMetrics(SM_CYFRAME);


    Left := (Rec.Right - Rec.Left) - RightMargin - FrameThick;


    Top := FrameThick;


    if FFor

上一页  [1] [2] [3] [4] [5]  下一页

打印本文 打印本文 关闭窗口 关闭窗口