PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: resize textbox to form size  (Read 1959 times)

jermy

  • Little Newbie
  • *
  • Posts: 28
resize textbox to form size
« on: April 18, 2016, 02:00:57 PM »

I want to resize my textbox but i'm always getting the wrong results.
I can remember when I was programming vb6 that I needed to convert the coordination's

I got no clue how to do this with freebasic and firefly3.
Can somebody explain to me how to do this?.

Code: [Select]

        Dim rc as Rect
     
       ' Get the dimensions of the window
         Function = GetWindowRect(HWND_FORM1, @rc)
       
       ' Convert the coordinates to be relative to the parent
         MapWindowPoints HWND_DESKTOP, GetParent(HWND_FORM1), Cast(LPPOINT, VarPtr(rc)), 2
 
         SetWindowPos (HWND_FORM1_TEXT1, Null, rc.Left, rc.top, rc.Right, rc.bottom, SWP_NOZORDER Or SWP_SHOWWINDOW)

Logged

Petrus Vorster

  • Senior Member
  • ***
  • Posts: 440
Re: resize textbox to form size
« Reply #1 on: April 18, 2016, 03:17:45 PM »

I dont know if this will be helpful since i am still on Powerbasic, but I assume a little tinkering should do the trick.
Paul helped me not so long ago with this.
I wanted to size a childform to a Frame on form 1.

Code: [Select]
Dim rc As Rect
GetClientRect( HWND_FORM1_FRAME2, rc )
MapWindowPoints HWND_form1_frame2, HWND_FORM1, rc, 2
   Function = 0   ' change according to your needs
SetWindowPos hwnd_mnufrm2, 0, _
   rc.nLeft + AfxScaleX(2), rc.nTop + AfxScaleY(8), _
   rc.nRight - rc.nLeft - AfxScaleX(2), rc.nBottom - rc.nTop - AfxScaleY(12), _
   %SWP_NOZORDER Or %SWP_NOZORDER Or %SWP_SHOWWINDOW

This AFXscale is essential and take a look at the Mapwindowpoints. I had a long struggle with that and this works like a charm.
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8913
  • Windows 10
    • PlanetSquires Software
Re: resize textbox to form size
« Reply #2 on: April 18, 2016, 04:10:34 PM »

I guess a lot depends on what you are trying to do. You want to resize your TextBox in relation to the full size of the parent Form? If that's the case then it is pretty easy:

Code: [Select]
Dim rc as Rect
     
' Get the client area of the Form
GetClientRect(HWND_FORM1, @rc)
       
SetWindowPos (HWND_FORM1_TEXT1, 0, rc.Left, rc.top, rc.Right-rc.Left, rc.bottom-rc.Top, SWP_NOZORDER Or SWP_SHOWWINDOW)

Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

jermy

  • Little Newbie
  • *
  • Posts: 28
Re: resize textbox to form size
« Reply #3 on: April 18, 2016, 06:22:32 PM »

Thanks,

Indeed its pretty simpel.
Logged