I created an addin and wrote a class that inherits from
System.Windows. Forms.NativeWin dow. In the Connect method, I created an
event handler to listen for DTE.Events.Docu mentEvents.Docu mentOpened. In
the handler for DocumentOpened, I call EnumChildWindow s. In the callback
for EnumChildWindow s, I compare the child window's text (using GetText API)
to the caption of the document being opened (Document.Activ eWindow.Caption ).
All this works fine and dandy, when the caption of the doc = the child
window's text, the hWnd passed to the EnumChildWindow s 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
method:
protected override void WndProc(ref Message Message)
{
if (Message.Msg == (int) WindowMessage.P aint) {
// Save the update rectangle.
RECT rc;
rc = new RECT(1, 1, 1, 1);
bool result = GetUpdateRect(m WindowHandle, out rc, false);
IntPtr hdc = GetDC(mWindowHa ndle);
// Call the .Net handler.
base.WndProc(re f Message);
if (!IsRectEmpty(r ef rc) && !mReEntry) {
HideCaret(mWind owHandle);
// Draw the line.
MoveToEx(hdc, rc.Left, rc.Top, IntPtr.Zero);
LineTo(hdc, rc.Width, rc.Height / 2);
}
// Cleanup.
ReleaseDC(mWind owHandle, hdc);
Message.Result = new IntPtr(1);
return;
}
base.WndProc(re f 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! :)
Mythran
System.Windows. Forms.NativeWin dow. In the Connect method, I created an
event handler to listen for DTE.Events.Docu mentEvents.Docu mentOpened. In
the handler for DocumentOpened, I call EnumChildWindow s. In the callback
for EnumChildWindow s, I compare the child window's text (using GetText API)
to the caption of the document being opened (Document.Activ eWindow.Caption ).
All this works fine and dandy, when the caption of the doc = the child
window's text, the hWnd passed to the EnumChildWindow s 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
method:
protected override void WndProc(ref Message Message)
{
if (Message.Msg == (int) WindowMessage.P aint) {
// Save the update rectangle.
RECT rc;
rc = new RECT(1, 1, 1, 1);
bool result = GetUpdateRect(m WindowHandle, out rc, false);
IntPtr hdc = GetDC(mWindowHa ndle);
// Call the .Net handler.
base.WndProc(re f Message);
if (!IsRectEmpty(r ef rc) && !mReEntry) {
HideCaret(mWind owHandle);
// Draw the line.
MoveToEx(hdc, rc.Left, rc.Top, IntPtr.Zero);
LineTo(hdc, rc.Width, rc.Height / 2);
}
// Cleanup.
ReleaseDC(mWind owHandle, hdc);
Message.Result = new IntPtr(1);
return;
}
base.WndProc(re f 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! :)
Mythran
Comment