I wrote this stored procedure to make it easy to change the width of the drop 
down part of combo boxes while leaving the parent control the normal size.  
It's based on Mike Byerly's code to use Windows to do the heavy lifting.  I 
hope someone else will benefit from it also:

(NOTE: Watch out for wrapping on some of the long lines)

------------------------------------------------------------------------------
-- SetDropdownWidth: Adjusts a DropDown control (db/variable, lookup/user)
-- so that the drop down area has a width wider than the control's width.
-- Example: Create a form.  Drop any drop down control and specify the lookup
-- settings.  Make the control 150 pixels wide and assign the 'cbTest'
-- to the component ID.  Then enter the following command in the form's
-- AFTER START EEP:
-- SET VAR vJunk = (CALL SetDropdownWidth('cbTest', 300))
-- When you run the form and drop down the selection box, it will be twice as
-- wide as the control
------------------------------------------------------------------------------
-- PUT SetDropdownWidth.PRC AS SetDropdownWidth pSDDW_CompID TEXT(100), 
pSDDW_Width INTEGER
------------------------------------------------------------------------------

IF pSDDW_CompID IS NULL OR pSDDW_Width IS NULL OR pSDDW_Width < 0 THEN
  RETURN
ENDIF

SET VAR pSDDW_SETDROPWIDTH INTEGER = 352
SET VAR pSDDW_Handle       INTEGER = 0
SET VAR pSDDW_HandleT      TEXT = NULL

GETPROPERTY .pSDDW_CompID HANDLE 'pSDDW_HandleT'

SET VAR pSDDW_Handle INTEGER = (INT(.pSDDW_HandleT))

IF (CHKFUNC('SendMessage')) = 0 THEN
  -- Ensure SendMessage is declared
  STDCALL function 'SendMessageA' ALIAS 'SendMessage' (INTEGER, INTEGER, 
INTEGER, INTEGER) : INTEGER
ENDIF

-- remember the order of args  is reversed from the API declaration
SET VAR pSDDW_Result INTEGER = (DLCALL('User32', 'SendMessageA', 0 , 
.pSDDW_Width, .pSDDW_SETDROPWIDTH, .pSDDW_Handle))

IF CVAL('DEBUG') = 'ON' THEN
  IF pSDDW_Result = -1 THEN
    PAUSE 2 USING 'SendMessage to ComboBox didn''t work'
  ELSE
    SET VAR vmsg = ('Width of ComboBox set to ' + (CTXT(.pSDDW_Result)))
    PAUSE 2 USING .vmsg
  ENDIF
ENDIF

CLEAR VAR pSDDW_%
RETURN

Reply via email to