RE: EuGrid display modification
- Posted by Phil Russell <pg_russell at lineone.net> Nov 18, 2003
- 513 views
Matt, Thanks for this. I am currently working on a release which incorporates the rest of your changes so I will include this as well. Just out of interest, it ended up being an owner-draw button because win32lib wouldn't let me create a plain window as a child window at the time. Don't know if it has changed since - if it has I might get round to amending the lib one day as the owner-draw code was/is a pain... Regards, Phil Matt Lewis wrote: > > > 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 >