471,306 Members | 1,315 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

Drawing on CodeWindow - AddIn

I created an addin and wrote a class that inherits from
System.Windows.Forms.NativeWindow. In the Connect method, I created an
event handler to listen for DTE.Events.DocumentEvents.DocumentOpened. In
the handler for DocumentOpened, I call EnumChildWindows. In the callback
for EnumChildWindows, I compare the child window's text (using GetText API)
to the caption of the document being opened (Document.ActiveWindow.Caption).
All this works fine and dandy, when the caption of the doc = the child
window's text, the hWnd passed to the EnumChildWindows callback function is
the handle I use to create the NativeWindow derived class. I am overriding
the NativeWindow derived class' WndProc and listening for the WM_PAINT
message. The problem is, I can't seem to figure out how to paint a line on
the device context of the window. My WndProc code is modified from C++
version of the VSWallPaper WndProc code. The following is my WndProc

protected override void WndProc(ref Message Message)
if (Message.Msg == (int) WindowMessage.Paint) {
// Save the update rectangle.
RECT rc;
rc = new RECT(1, 1, 1, 1);
bool result = GetUpdateRect(mWindowHandle, out rc, false);

IntPtr hdc = GetDC(mWindowHandle);

// Call the .Net handler.
base.WndProc(ref Message);

if (!IsRectEmpty(ref rc) && !mReEntry) {

// Draw the line.
MoveToEx(hdc, rc.Left, rc.Top, IntPtr.Zero);
LineTo(hdc, rc.Width, rc.Height / 2);

// Cleanup.
ReleaseDC(mWindowHandle, hdc);
Message.Result = new IntPtr(1);

base.WndProc(ref Message);
If any can help me get this working, it would be great! As of now, the
CodeWindow doesn't even refresh. When I alt-tab, then alt-tab back, the
code window doesn't get repainted and shows whatever I alt-tabbed to,
instead of being the code window.

Thanks! :)


Dec 30 '05 #1
1 1376
Have you tried using a Graphics object. I think you might get your
results your looking for by looking into that.

Dec 30 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by jchao123 | last post: by
reply views Thread by guilligan.geo | last post: by
7 posts views Thread by Joseph Geretz | last post: by
6 posts views Thread by Christof Nordiek | last post: by
1 post views Thread by Rainer Queck | last post: by
1 post views Thread by John | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.