resize textbox to form size

Started by jermy, April 18, 2016, 02:30:57 PM

Previous topic - Next topic

jermy

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?.



        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)


Petrus Vorster

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.

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.
-Regards
Peter

Paul Squires

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:


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)


Paul Squires
PlanetSquires Software

jermy

Thanks,

Indeed its pretty simpel.