Combo surrounding rectangle
I am trying to draw a focus box around a control, but hit a snag with
Combos. I have the same results on Arwen and win32lib.
The problem is that the rectangle seems to be {-1,-1,1,-3} adrift (you
may have to look quite closely to notice it). If you put the commented
out fudge back in, it works as I expected it to.
I have displayed a ListBox (which does not need the fudge) next to it
for comparison. Is this a known feature of the windows API (98) or am
I doing something wrong?
I'd also appreciate comments on how this works with/without the fudge
on later versions of windows.
without warning
include win32lib.ew
constant main=create(Window,"Combo Box Rectangle",0,410,0,245,350,0)
constant mainHwnd=getHandle(main)
constant lbtn=create(Button,"Press me",main,15,15,95,30,0)
constant lbox=create(ListBox,"",main,26,60,95,208,0)
constant cbox=create(SimpleCombo,"",main,126,60,95,208,0)
constant lpRect=allocate(16)
procedure drawRect(integer ID)
atom hwnd
--sequence dbg
hwnd = getHandle(ID)
VOID = w32Func(xGetWindowRect, {hwnd, lpRect})
--if ID = cbox then
--dbg=peek4s({lpRect,4})
--dbg+={-1,-1,1,-3} -- << fudge
--poke4(lpRect,dbg)
--end if
VOID = w32Func(xScreenToClient, {mainHwnd, lpRect})
VOID = w32Func(xScreenToClient, {mainHwnd, lpRect+8})
VOID = w32Func(xDrawFocusRect, {getDC(main), lpRect} )
end procedure
procedure mainHandler(integer id, integer event, sequence Params)
if id = lbtn then
drawRect(lbox)
drawRect(cbox)
end if
end procedure
setHandler(lbtn,w32HClick,routine_id("mainHandler"))
WinMain(main,SW_NORMAL)
abort(0)
without warning
include arwen.ew
constant main=create(Window,"Combo Box Rectangle",0,0,410,0,245,350,0)
constant mainHwnd=getHwnd(main)
constant lbtn=create(Button,"Press me",0,main,15,15,95,30,0)
constant lbox=create(ListBox,"",0,main,26,60,95,208,0)
constant cbox=create(ComboBox,"",0,main,126,60,95,208,0)
procedure drawRect(integer ID)
atom lpRect, hwnd
--sequence dbg
lpRect = allocate_Rect()
hwnd = getHwnd(ID)
void = c_func(xGetWindowRect, {hwnd, lpRect})
--if ID = cbox then
--dbg=peek4s({lpRect,4})
--dbg+={-1,-1,1,-3} -- << fudge
--poke4(lpRect,dbg)
--end if
void = c_func(xScreenToClient, {mainHwnd, lpRect})
void = c_func(xScreenToClient, {mainHwnd, lpRect+8})
void = c_func(xDrawFocusRect, {getPrivateDC(main), lpRect} )
end procedure
function mainHandler(integer id, integer msg, atom wParam, object
lParam)
if id = lbtn then
drawRect(lbox)
drawRect(cbox)
end if
return 0
end function
setHandler({main,lbox},routine_id("mainHandler"))
WinMain(main,SW_NORMAL)
abort(0)
Regards,
Pete
|
Not Categorized, Please Help
|
|