Make your own free website on Tripod.com

Resizable Response Windows

Back Up Next

Author: Eric Aling (13 apr 2000)
Accessed:

In some cases, you want to display something in a response window but you also want this window to be resizable in order to let the user resize this window to display the info the way he or she wants. Normally, response windows are not resizable and this is also the Microsoft standard behaviour. However, it is possible using two APIs, GetWindowLong and SetWindowLong. The Get function retrieves the complete defenition of the window in a big long variable. All the bits in this long value describe the window. So there are bits for the type of border (which indicates if a window is resizable), menu, colors etc.etc. We can modify this long value, altering the design of the window. Using the SetWindowLong() we update the window with our specific modifications. Here are the two external function declarations:

// External functions:
function long GetWindowLongA (long hWindow, integer nIndex) Library "user32.dll"
function long SetWindowLongA (long hWindow, integer nIndex, long dwNewLong) library "user32.dll"

Create a function with two arguments: first, one the response window to change, second, if the window needs a control menu. The response window initially may not have the control menu property set in the window painter.

// Function arguments:
// window aw_window = response window
// boolean ab_control = use control menu

First we get the current long value of the window:

long		ll_Styles
boolean		lb_Control
nv_Numerical	lnv_Num (from PFC)

constant long	WS_THICKFRAME = 262144
constant long	WS_SYSMENU = 524288

ll_styles = GetWindowLongA(handle(aw_window), -16)

Now, we change to border so that it is resizable and we add a control menu button if specified. For this, we have to Bitwise OR our bits with the existing bits. Herefor we use the numerical service from the PFC. Then we set the long value back to the window:

if ll_styles <> 0 then

	ll_styles = lnv_num.of_BitWiseOr(ll_styles, WS_THICKFRAME)
	if ab_Control then 
		ll_styles = lnv_num.of_BitWiseOr(ll_styles, WS_SYSMENU)
	end if

	return SetWindowLongA(handle(aw_window), -16, ll_styles)

end if

return -1

Put this code in a function and call this function as first thing in the open event of your response window. Your response window should not have a control menu. If you want one, set the ab_control to TRUE.

 

Back Up Next