Issue with SyntaxEditor and handling of WM_PRINT

SyntaxEditor for Windows Forms Forum

Posted 12 years ago by Matt Whitfield
Version: 4.0.0280
Platform: .NET 2.0
Environment: Windows XP (32-bit)
Hello, I am using a reasonably standard screen snapshot technique to get preview images of the syntax editors in a tab set. However, the syntax editor itself refuses to draw, whereas all other controls are fine.

Here is the code I added to the sample application to reproduce it...

        private const int WM_PRINT = 0X317;
        private const int PRF_CLIENT = 4;
        private const int PRF_NON_CLIENT = 2;
        private const int PRF_CHILDREN = 0X10;

        private extern static int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, int lParam);

        public System.Drawing.Image TakeSnapshot(IntPtr WindowHandle, int ImageWidth, int ImageHeight)
            System.Drawing.Image clsRet = new System.Drawing.Bitmap(ImageWidth, ImageHeight);
            System.Drawing.Graphics clsGraphics = System.Drawing.Graphics.FromImage(clsRet);
            IntPtr ptrHDC = clsGraphics.GetHdc();
            SendMessage(WindowHandle, WM_PRINT, ptrHDC, COMBINED_PRINTFLAGS);
            return clsRet;
And then, some code in a button.

            Image i = TakeSnapshot(editor.Handle, editor.Width, editor.Height);
            i.Save("C:\\editor.bmp", ImageFormat.Bmp);
            i = TakeSnapshot(documentOutlineTreeView.Handle, documentOutlineTreeView.Width, documentOutlineTreeView.Height);
            i.Save("C:\\treeView.bmp", ImageFormat.Bmp);
Note that editor.bmp ends up just black, wheras treeView.bmp shows the image of the tree view.

Comments (3)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA

We use a custom double buffer so that may be why it doesn't get pulled in for that Windows Message. We don't currently handle WM_PRINT specifically either.

However there is another method on SyntaxEditor called Render that may be useful for you. You pass it a PaintEventArgs and it should render onto whichever Graphics is in that event args.

Actipro Software Support

Posted 12 years ago by Matt Whitfield
I got it working by subclassing SyntaxEditor and adding the following code:

        protected override void OnPrint(System.Windows.Forms.PaintEventArgs e)
I think it would be well worth adding that line of code into the next maintenance release, however!

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA

Ok it's added for the next maintenance release.

Actipro Software Support

The latest build of this product (v2020.1 build 0403) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.