Jump to content


Photo

Resizing NxPanel at Runtime


  • Please log in to reply
1 reply to this topic

#1 ouiji

ouiji
  • Members
  • 5 posts

Posted 04 February 2018 - 10:32 AM

Is there a simple way to make NxPanels sizeable at runtime?

 

 

I tried MouseMove/MouseDown to catch the edges and force a resize, but for some reason the MouseMove procedure seems unable to flag the edges.. Any Suggestions?

 

 

Here is what I was trying:

procedure TForm1.NxPanMainMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);

const
 SC_SIZELEFT = 1;
 SC_SIZERIGHT = 2;
 SC_SIZETOP = 3;
 SC_SIZEBOTTOM = 6;
var
 Corner: TRectCorner;
 MsgCode: Integer;
begin
 Corner:=GetRectCorner(NxPanMain.BoundsRect,
 ScreenToClient(NxPanMain.ClientToScreen(Point(X,Y)))) ;
 if Corner<>rcClient then
 begin
  SetCursor(Screen.Cursors[
  RectCornerToSizeCursor(
  GetRectCorner(NxPanMain.BoundsRect,
  ScreenToClient(NxPanMain.ClientToScreen(Point(X,Y)))),Cursor)]);
  MsgCode:=SC_SIZE;
  if Corner in [rcTopLeft,rcLeft,rcBottomLeft] then
  Inc(MsgCode,SC_SIZELEFT)
  else if Corner in [rcTopRight,rcRight,rcBottomRight] then
  Inc(MsgCode,SC_SIZERIGHT);
  if Corner in [rcTopLeft,rcTop,rcTopRight] then
  Inc(MsgCode,SC_SIZETOP)
  else if Corner in [rcBottomLeft,rcBottom,rcBottomRight] then
  Inc(MsgCode,SC_SIZEBOTTOM);
  ReleaseCapture;
  SendMessage(NxPanMain.Handle,WM_SYSCOMMAND,MsgCode,0) ;
 end;
end;

procedure TForm1.NxPanMainMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
 SetCursor(Screen.Cursors[
 RectCornerToSizeCursor(
 GetRectCorner(NxPanMain.BoundsRect,
 ScreenToClient(NxPanMain.ClientToScreen(Point(X,Y)))),Cursor)]);
end;



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 7,605 posts
  • Gender:Male

Posted 04 February 2018 - 01:20 PM

Hi,

It’s probably because you are out of controls’s bounds then. In a moment when you leave control with mouse, MouseMove don’t work anymore.

Maybe seting mouse capture can help you. That way you can read negative coordinates in MouseMove. But you need to be careful and release capture too.

Or, doing resizing from Parent (checking for childs and then resize).
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Members Section: bms.bergsoft.net
Articles and Tutorials: dn.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users