Geeks With Blogs
Tex-blog Mobile and other stuff
If you have used ListBoxEx control from SDF1.4 library, on VGA device then you know that it looks really bad. One thing is that scrollbar is too thin, last list element does not always repaint and some borders are too thin. This is all because this control is not VGA screen capable. To make it all work properly, you need to modify source code for OwnerDrawnList class. To get it download source code for SDF library. Actually you can copy OwnerDrawnList.cs and ListBoxEx.cs without the need for recompilation of whole library - but I am not sure about legal issues here. Any way, modifications are preety simple:

1. Add to OwnerDrawnList constructor new parameter: int p_resMul, remember to pass it properly from ListBoxEx c-tor. It will be 1 on QVGA devices and 2 on VGA devices. To get its value you can use Form-s AutoScaleFactor property. Add also resMul value to store this value in OwnerDrawnList class instance.

2. OwnerDrawnList.cs contains SCROLL_WIDTH variable that needs to be multiplied by resMul, on VGA devices it will be equal to 2. You can do it in class constructor.

3. Now to get rid of repainting problems with last list element, modify line (839):

for(int index=topIndex;index<drawCount+topIndex;index++)


for(int index=topIndex;index<drawCount+topIndex+1;index++)

this actually is a quick fix, and maybe a better one could be found.

3. To make border thicker by one pixel on VGA screens modify:
private void DrawBorder(Graphics gr), by replacing:

//Draw border
gr.DrawRectangle(new Pen(Color.Black), rc);


//Draw border
rc.Inflate(-((int)resMul - 1), -((int)resMul - 1));
gr.DrawRectangle(new Pen(Color.Black, resMul), rc); Posted on Monday, January 28, 2008 3:09 PM | Back to top

Comments on this post: OpenNetCF - ListBoxEx VGA screen fixes

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Martinez | Powered by: