1. EuGrid display modification

Phil,

I found a weird side effect of using an owner drawn button for the grid.  If
you display an element with the '&' character, windows thinks you're trying
to define a keyboard shortcut (like with a menu).  I added the following
function (from Derek--see the mailing list in September 2002) and changed
EGW_drawText:

function replace_elem(sequence s, object a, object b)
	sequence t
	integer n,m

	if atom(a) then
		a = {a}
	end if

	if atom(b) then
		b = {b}
	end if

	-- Create a buffer big enough to cater for worst case replacement.
	t = repeat(0, (floor(length(s) / length(a)) + 1) * length(b))

	m = 1
	while 1 do
		n = match(a, s)
		if n then
			t[m..m+n-2] = s[1..n-1]
			m += (n-1)
			t[m..m+length(b)-1] = b
			m += (length(b))
			s = s[n+length(a) .. length(s)]
		else
			t[m..m+length(s)-1] = s
			m += (length(s))
			exit
		end if
	end while

	return t[1..m-1]
end function


procedure EGW_drawText( atom hdc, integer x, integer y,
						integer cx, integer cy,
						object textin, atom color,
						atom font, atom align, atom
multiline )

	atom oldfont, oldcolor, oldbkmode, pstr, rect, ret
	sequence text
	-- Select default font into device context
	oldfont = w32Func(xSelectObject, {hdc, font})

	-- Set the text colour
	oldcolor = w32Func(xSetTextColor, {hdc, color} )
	oldbkmode = w32Func(xSetBkMode, {hdc, TRANSPARENT } )

 	-- Convert atom to sequence if necessary
 	if atom(textin) then
 		textin = {textin}
	end if

	-- mwl 11/18/03:
	text = replace_elem(textin, "&", "&&")

....rest of procedure unchanged...

Now it properly displays the character.

Matt Lewis

new topic     » topic index » view message » categorize

2. EuGrid display modification

Phil,

I found a weird side effect of using an owner drawn button for the grid. 
 If you display an element with the '&' character, windows thinks you're 
trying to define a keyboard shortcut (like with a menu).  I added the 
following function (from Derek--see the mailing list in September 2002) 
and changed
EGW_drawText:

function replace_elem(sequence s, object a, object b)
	sequence t
	integer n,m

	if atom(a) then
		a = {a}
	end if

	if atom(b) then
		b = {b}
	end if

	-- Create a buffer big enough to cater for worst case 
	-- replacement.
	t = repeat(0, (floor(length(s) / length(a)) + 1) * length(b))

	m = 1
	while 1 do
		n = match(a, s)
		if n then
			t[m..m+n-2] = s[1..n-1]
			m += (n-1)
			t[m..m+length(b)-1] = b
			m += (length(b))
			s = s[n+length(a) .. length(s)]
		else
			t[m..m+length(s)-1] = s
			m += (length(s))
			exit
		end if
	end while

	return t[1..m-1]
end function


procedure EGW_drawText( atom hdc, integer x, integer y,
	integer cx, integer cy,						object textin, atom color,
	atom font, atom align, atom multiline )

	atom oldfont, oldcolor, oldbkmode, pstr, rect, ret
	sequence text
	-- Select default font into device context
	oldfont = w32Func(xSelectObject, {hdc, font})

	-- Set the text colour
	oldcolor = w32Func(xSetTextColor, {hdc, color} )
	oldbkmode = w32Func(xSetBkMode, {hdc, TRANSPARENT } )

 	-- Convert atom to sequence if necessary
 	if atom(textin) then
 		textin = {textin}
	end if

	-- mwl 11/18/03:
	text = replace_elem(textin, "&", "&&")

....rest of procedure unchanged...

Now it properly displays the character.

Matt Lewis

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

Search



Quick Links

User menu

Not signed in.

Misc Menu