RE: Combo surrounding rectangle
- Posted by Mike <vulcan at win.co.nz> Apr 08, 2005
- 430 views
Pete, I think the Combo control is being used in a way never anticipated by M$. I noticed that although the Y coordinate is the same for both List & Combo the edit field of the Combo is visibly higher than the top of the list. Perhaps M$ thought it wasn't necessary to make provision for a focus rectangle bordering the Combo because it is composed of 2 separate controls. I substituted PushButton in the control type and found a similar problem in that the button takes up the entire specified rectangle so the focus rectangle infringes the border. I guess this is why they put the focus rectangle inside the button itself. What you've done to accomodate this anomaly may be the best solution. Mike Pete Lomax wrote: > > > 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. > }}} <eucode> > 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) > </eucode> {{{ > > Regards, > Pete >