I need to draw a textbox in a Compact Framework app, but using directly a Graphics object.
I've found the Control.DrawToBitmap method, which I could use for drawing with GDI, but it's not available on Compact Framework.
Any hints?
I need to draw a textbox in a Compact Framework app, but using directly a Graphics object.
I've found the Control.DrawToBitmap method, which I could use for drawing with GDI, but it's not available on Compact Framework.
Any hints?
Well typically you just inherit from : Control, override OnPaint and use the graphics object provided by the arguments. Have you tried this yet?
Control.DrawToBitmap() is implemented by sending WM_PRINT to the control to let it draw itself in a memory device context. If you are using non-standard controls, the odds are great that the programmer did not implement this message. I don't think it is implemented by the standard Windows Mobile controls either.
Your only other recourse then is to copy the pixels off the screen. Graphics.CopyFromScreen() is a no-go, you'll have to P/Invoke the BitBlt() API function. Possibly useful sample code is available in this thread. and at pinvoke.net
I have no idea if this would work.... but technically you could use reflection to call into the control's OnPaint method and pass in your own graphics object (Graphics.FromImage) in a new set of PaintEventArgs.
It's ugly as hell..... but it might work.