开发者

Drawing controls with GDI on Compact Framework

I need to draw a textbox in a Compact Framework app, but using directly a Graphics object.

I've f开发者_C百科ound the Control.DrawToBitmap method, which I could use for drawing with GDI, but it's not available on Compact Framework.

Any hints?


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


Well typically you just inherit from : Control, override OnPaint and use the graphics object provided by the arguments. Have you tried this yet?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜