1. 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

new topic     » topic index » view message » categorize

2. Re: Combo surrounding rectangle

Hi Pete,

Do you have a screenshot somewhere?


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

3. Re: Combo surrounding rectangle

On Fri, 08 Apr 2005 01:02:33 -0700, Al Getz <guest at RapidEuphoria.com>
wrote:

>Hi Pete,
>
>Do you have a screenshot somewhere?
>
I've posted one on
http://palacebuilders.pwp.blueyonder.co.uk/edita.htm

The problem is very subtle, however if I am using such a rectangle to
size a control, it means the actual window can look nothing like the
one in Window Painter. It is not difficult to add the {-1,-1,1,-3},
but it is worth asking around to make sure that is the right thing to
do. BTW, the one on the left shows the error and the one on the right
is the corrected (fudged) one!

Regards,
Pete

new topic     » goto parent     » topic index » view message » categorize

4. Re: Combo surrounding rectangle

Hi there Pete,

Did you try OR'ing the creation flag with CBS_NOINTEGRALHEIGHT (when
creating the combo box) to see if it 'corrects' the problem?
A guess is that the box will change heights on different systems
(and with diff fonts and font sizes) so you'll have to account for
that unless you include that flag.

Try adding that flag and see if it helps.  This could become a problem
with list boxes too -- i'd double check that also.



Pete Lomax wrote:
> 
> On Fri, 08 Apr 2005 01:02:33 -0700, Al Getz <guest at RapidEuphoria.com>
> wrote:
> 
> >Hi Pete,
> >
> >Do you have a screenshot somewhere?
> >
> I've posted one on
> <a
> href="http://palacebuilders.pwp.blueyonder.co.uk/edita.htm">http://palacebuilders.pwp.blueyonder.co.uk/edita.htm</a>
> 
> The problem is very subtle, however if I am using such a rectangle to
> size a control, it means the actual window can look nothing like the
> one in Window Painter. It is not difficult to add the {-1,-1,1,-3},
> but it is worth asking around to make sure that is the right thing to
> do. BTW, the one on the left shows the error and the one on the right
> is the corrected (fudged) one!
> 
> Regards,
> Pete
> 
> 


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

5. Re: Combo surrounding rectangle

On Fri, 08 Apr 2005 06:01:14 -0700, Al Getz <guest at RapidEuphoria.com>
wrote:

>Hi there Pete,
>
>Did you try OR'ing the creation flag with CBS_NOINTEGRALHEIGHT (when
>creating the combo box) to see if it 'corrects' the problem?
It makes no difference. In fact, I deliberately chose the height 208
to avoid that issue (207 made it one whole line smaller).
>A guess is that the box will change heights on different systems
>(and with diff fonts and font sizes) so you'll have to account for
>that unless you include that flag.
I am asking windows, via GetWindowRect in user32.dll, for the size.
Windows should know it, pixel-perfect, since it drew it, but it tells
me lies, which is what I queried.

>
>Try adding that flag and see if it helps.  This could become a problem
>with list boxes too -- i'd double check that also.
Listboxes are fine both with and without that flag.

I suspect Mike is right and it is a glitch in user32.dll, so the
simple fudge I presented may indeed be the correct thing to do.
I think I'll proceed on that assumption.
Regards,
Pete

new topic     » goto parent     » topic index » view message » categorize

6. Re: Combo surrounding rectangle

Hi again Pete,

Sorry, it was just a guess.  Interesting problem though, and perhaps
i'll set up combo boxes for my WinClass lib too and see if i can 
duplicate the problem.  I would have done this already but i never
use combo boxes smile

Anything specific about the combo box which i should know?


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu