the following are functions that can resize dialog windows
for pb 7.0 only.
discussion at http://www.powerbasic.com/support/pb...ad.php?t=21425
04 dec 2003 (changed rz_size function to check for visibility)
thanks to don schullian and lance for the input a while back
the include file is followed by a sample program.
[this message has been edited by carlo pagani (edited december 04, 2003).]
for pb 7.0 only.
discussion at http://www.powerbasic.com/support/pb...ad.php?t=21425
04 dec 2003 (changed rz_size function to check for visibility)
thanks to don schullian and lance for the input a while back
the include file is followed by a sample program.
Code:
'********************************************************************* 'rzsize.inc for pbwin 7.0 (july 2002) ' 'routines to resize all controls in a dialog box based on user desires 'note: uses fist 4 user data indexes for controls and dialogs ' 'subitted into public domain by carlo pagani [email protected] 'with thanks to semen for enumchildwindows help ' 'background: these routines allow your program to quickly resize the dialogs and controls 'that need increase in input size (like textboxes, listviews treeviews etc) these routines 'were designed to facilitate resizing of simple dialog boxes as can be seen in sample. ' 'usage: (see example for illustration of various options) ' 1. define dialog using ddt commands ' 2. use control set user hdlg, %control_id, 1, <anchor and sizing info> ' eg control set user hdlg, %idc_listview, 1, %rz_growx or %rz_growy or %rz_anchortop or %rz_anchorleft ' tells the system to peg the control top left corner and grow both vertically and horizantally ' 3. use control set user hdlg, %control_id, 4, maklng(100, 50) to optionally set scaling ' tells system to grow horizantally at 100%, vertically at 50% ' if not set, system uses 100% both vertically and horizantally ' if you are growing 2 controls vertically, you need to grow each one at 50% to keep symetry ' 4. call rz_init hdlg in %wm_initdialog section of callback ' 5. add rz_size hdlg to %wm_size section of callback ' ' then you have the option of restricting the minimum size by copying the %wm_getminmaxinfo section ' this will restrict the minimum size to the original size. ' lastly you can restore to the original size by calling rz_restore hdlg ' 'comments are welcome. '*************************************************************************************************** ' type rztype clientx as long clienty as long newx as long newy as long xdiff as long ydiff as long hdlg as long end type %rz_ignore = 1 ' ignore sizing on control %rz_growx = 2 ' grow control horizantally %rz_growy = 4 ' grow control vertically %rz_floatx = 8 ' float control proportionally to size change horizantally %rz_floaty = 16 ' float control proportionally to size change vertically %rz_centerx = 32 ' center control horizantally %rz_centery = 64 ' center control vertically %rz_anchortop = 1024 ' tell system which corner(s) to anchor %rz_anchorbottom = 2048 %rz_anchorleft = 4096 %rz_anchorright = 8192 function rz_ctrlresize(byval hchild as dword, byval lparam as dword) as long ' adjusts each control pos and size dim x as long, y as long, xx as long, yy as long, ltmp as long dim ctrlid as long dim rzvalue as long dim rz as rztype ptr dim growpctx as long dim growpcty as long rz = lparam ctrlid = getdlgctrlid(hchild) 'get id of control control get user @rz.hdlg, ctrlid, 1 to rzvalue 'get sizing options control get user @rz.hdlg, ctrlid, 2 to ltmp 'get base anchor for x, y x = lowrd(ltmp) : y = hiwrd(ltmp) control get user @rz.hdlg, ctrlid, 3 to ltmp 'get original width and height xx = lowrd(ltmp) : yy = hiwrd(ltmp) control get user @rz.hdlg, ctrlid, 4 to ltmp 'get sizing percentages growpctx = lowrd(ltmp) : growpcty = hiwrd(ltmp) if (%rz_growx and rzvalue) = %rz_growx then xx = xx + (@rz.xdiff * growpctx/100) if (%rz_growy and rzvalue) = %rz_growy then yy = yy + (@rz.ydiff * growpcty/100) if (%rz_centerx and rzvalue) = %rz_centerx then x = (@rz.newx - xx)/2 if (%rz_centery and rzvalue) = %rz_centery then y = (@rz.newy - yy)/2 if (%rz_floatx and rzvalue) = %rz_floatx then x = x + (@rz.xdiff * growpctx/100) if (%rz_floaty and rzvalue) = %rz_floaty then y = y + (@rz.ydiff * growpcty/100) if (%rz_anchorright and rzvalue) = %rz_anchorright then x = @rz.newx-xx-x if (%rz_anchorbottom and rzvalue) = %rz_anchorbottom then y = @rz.newy-yy-y control set loc @rz.hdlg, ctrlid, x, y control set size @rz.hdlg, ctrlid, xx, yy function = 1 end function function rz_ctrlinit(byval hchild as dword, byval lparam as dword) as long ' save anchor controls into user data area of control ' if no option specified for control, defaults to %rz_floatx/y dim x as long, y as long, xx as long, yy as long dim ctrlid as long dim rzvalue as long dim rz as rztype ptr dim ltmp as long rz = lparam ctrlid = getdlgctrlid(hchild) 'get id of control control get loc @rz.hdlg, ctrlid to x, y 'get top left of control control get size @rz.hdlg, ctrlid to xx, yy 'get size of control control get user @rz.hdlg, ctrlid, 1 to rzvalue if rzvalue = 0 then control set user @rz.hdlg, ctrlid, 1, %rz_floatx or %rz_floaty control set user @rz.hdlg, ctrlid, 4, maklng(100, 100) end if if (%rz_anchorright and rzvalue) = %rz_anchorright then x = @rz.clientx-xx-x if (%rz_anchorbottom and rzvalue) = %rz_anchorbottom then y = @rz.clienty-yy-y control set user @rz.hdlg, ctrlid, 2, maklng(x, y) control set user @rz.hdlg, ctrlid, 3, maklng(xx, yy) control get user @rz.hdlg, ctrlid, 4 to ltmp if ltmp = 0 then control set user @rz.hdlg, ctrlid, 4, maklng(100, 100) function = 1 end function function rz_init(hdlg as long) as long dim lprz as rztype ptr dim rz as static rztype lprz = varptr(rz) rz.hdlg = hdlg dialog get client hdlg to rz.clientx, rz.clienty dialog set user hdlg, 1, maklng(rz.clientx, rz.clienty) 'save client size enumchildwindows hdlg, codeptr(rz_ctrlinit), lprz dialog get size hdlg to rz.clientx, rz.clienty dialog units hdlg, rz.clientx, rz.clienty to pixels rz.newx, rz.newy dialog set user hdlg, 2, maklng(rz.newx, rz.newy) 'save dialog size in pixels dialog set user hdlg, 3, maklng(rz.clientx, rz.clienty) 'save dialog size in units end function function rz_size(hdlg as long) as long dim lprz as rztype ptr dim rz as static rztype, ltmp as long local iwv as long lprz = varptr(rz) rz.hdlg = hdlg iwv = iswindowvisible(hdlg) if iwv then sendmessage hdlg, %wm_setredraw, 0, byval %nul dialog get client hdlg to rz.newx, rz.newy dialog get user hdlg, 1 to ltmp rz.clientx = lowrd(ltmp) : rz.clienty = hiwrd(ltmp) rz.xdiff = rz.newx - rz.clientx rz.ydiff = rz.newy - rz.clienty enumchildwindows hdlg, codeptr(rz_ctrlresize), lprz if iwv then sendmessage hdlg, %wm_setredraw, 1, byval %null invalidaterect hdlg, byval %null , %true updatewindow hdlg end function function rz_restore(hdlg as long) as long dim lprz as rztype ptr dim rz as static rztype, ltmp as long lprz = varptr(rz) rz.hdlg = hdlg dialog get user hdlg, 3 to ltmp rz.newx = lowrd(ltmp) : rz.newy = hiwrd(ltmp) dialog set size hdlg, rz.newx, rz.newy sendmessage hdlg, %wm_setredraw, 0, byval %null dialog get user hdlg, 1 to ltmp rz.newx = lowrd(ltmp) : rz.newy = hiwrd(ltmp) rz.xdiff = 0 rz.ydiff = 0 enumchildwindows hdlg, codeptr(rz_ctrlresize), lprz sendmessage hdlg, %wm_setredraw, 1, byval %null invalidaterect hdlg, byval %null , %true updatewindow hdlg end function
[this message has been edited by carlo pagani (edited december 04, 2003).]
Comment