|
Wow Absofukinlutely! Thanks so much for taking the time to work that out! I have a little VB.NET experience so I'll see if I can convert it to C# and see how it handles. Thanks again so much!!
|
|
|
|
|
Well I gave this a shot...and maybe it's my own inexperience, but it doesn't seem to be working the way I had hoped. That's a great example Absofukinlutely, but when I offset the Labels...the rectangles aren't being drawn on the outtermost label; instead they are all being drawn on the innermost label. I just can't for the life of me figure out this problem. I was just hoping there was something in Visual Studio that had the functionality I desire, but I just can't seem to find it.
Below = BAD
______
|........|
|.2.....|___
|...|********|
|...|********|
|...|********|
```|*****1**|
```|********|
Below = GOOD!
______
|........|
|.2.....|___
|...|....|*****|
|...|....|*****|
|...|....|*****|
```|*****1**|
```|********|
|
|
|
|
|
Your welcome! I'm glad you liked it, it was fun to make.
Well, now to the next problem:
If something has a transparent background, it's not really transparent, it just asks its parent to draw the background again. So if panel1 and panel2 both have the same parent (the form), they both draw the background of the form (the BAD example). But, if panel1 has panel2 as parent, it will show the background of panel2 (GOOD example).
I'm not sure what you want:
1: You want to drag the rectangle and draw the rectangle that is being dragged and draw all the previously dragged rectangles on the same panel.
In this case, get rid of panel1, add the panel1 painting to the panel2 painting, and change the mouse events of panel1 to that of panel2.
[Snapshot] [Code (Still in VB )]
2: You want to drag the rectangle and draw the rectangle on one panel, and draw all previously dragged rectangles on an other panel. If you want this, i think the best way is to move panel1 out of panel2 and on to the form.
[Snapshot] [Code]
3: Something else...
Mzl!
|
|
|
|
|
Thanks again Absofukinlutely for your continued help in this matter, I really do appreciate it very much! Your example really has made things clearer for me. I didn't grasp the fact that there wasn't 'true' transparency, but that it was simply the parent re-drawing itself. That makes sense on why my earlier attempts where not functioning.
On to explaining what I want...well I have been attempting to create a fairly simple project that has 3 frames. The top-most frame is my event frame, it handles all mouse click events, the second and third frame function exactly like your '2:' example above. As you drag out a box...that box is drawn, by itself, on the middle frame...the 'drag frame'. When the mouse button is released, the drag frame is cleared, and the dragged out box is then added to the list of rectangles and then drawn on the last frame, the 'render frame'.
The trouble is that all frames overlap...and currently (since their parents are all the underlying form) you can't see anything being drawn becuase they are all transparent and just see all the way through down to the form.
If I apply the parenting structure like you have in your example and then manage the OnPaint events better I should be able to achieve what I am looking for. So the overall parent would be the underlying form, which would then contain the 'render_frame'. The 'render_frame's child would be the 'drag_frame' and the 'drag_frame's child would be the 'event_frame'. Does this sound about right? That way it should function properly. I would have a changing background image in the parent form that you could effectively 'mark-up' using the boxes and frames.
Thanks again Absofukinlutely, I really do appreciate all the great explanations and examples!
~rcurrie
|
|
|
|
|
Again you're welcome!
One thing though: why don't you do the dragging and the drag-painting on the same panel? Seems easier to me, but you have to know for your self. Its your project of course.
If you have any problems, feel free to ask!
Cheers!
|
|
|
|
|
I do see the ease of handling the dragging and painting on a single panel, yet eventually the events frame will be built out to handle a few other events and more frames will be added, thus opening the possibilty of needing the events frame, but not the drag frame, for example. So that's partially why...the other reason is because that's what I've been tasked to do :P and so it's not entirely up to me.
But again, thanks! And I'll be sure and ask if anything further comes up.
~rcurrie
|
|
|
|
|
Well, i guess you've got to do what the boss says!
Good luck!
|
|
|
|
|
Here's the translated C# code if anyones interested...
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
<br />
namespace WindowsApplication3<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.Label label3;<br />
private System.Windows.Forms.Label label1;<br />
<br />
private bool LeftMouseDown = false;<br />
private Point MouseDownPos;<br />
private Rectangle DragRect;<br />
private ArrayList FinalRects;<br />
<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
this.MouseDownPos = new Point( 0,0 );<br />
this.FinalRects = new ArrayList();<br />
<br />
this.SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.label3 = new System.Windows.Forms.Label();<br />
this.label1 = new System.Windows.Forms.Label();<br />
this.label3.SuspendLayout();<br />
this.SuspendLayout();<br />
this.label3.BackColor = System.Drawing.Color.Transparent;<br />
this.label3.Controls.Add(this.label1);<br />
this.label3.Dock = System.Windows.Forms.DockStyle.Fill;<br />
this.label3.Location = new System.Drawing.Point(0, 0);<br />
this.label3.Name = "label3";<br />
this.label3.Size = new System.Drawing.Size(292, 266);<br />
this.label3.TabIndex = 0;<br />
this.label3.Paint += new System.Windows.Forms.PaintEventHandler(this.label3_Paint);<br />
this.label1.BackColor = System.Drawing.Color.Transparent;<br />
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;<br />
this.label1.Location = new System.Drawing.Point(0, 0);<br />
this.label1.Name = "label1";<br />
this.label1.Size = new System.Drawing.Size(292, 266);<br />
this.label1.TabIndex = 1;<br />
this.label1.Paint += new System.Windows.Forms.PaintEventHandler(this.label1_Paint);<br />
this.label1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.label1_MouseUp);<br />
this.label1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.label1_MouseMove);<br />
this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label1_MouseDown);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.BackColor = System.Drawing.SystemColors.Control;<br />
this.ClientSize = new System.Drawing.Size(292, 266);<br />
this.Controls.Add(this.label3);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);<br />
this.label3.ResumeLayout(false);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
base.OnPaintBackground (pevent);<br />
}<br />
<br />
private void label1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( e.Button == MouseButtons.Left )<br />
{<br />
Console.WriteLine("Panel2_MouseDown");<br />
MouseDownPos = new Point(e.X, e.Y); <br />
LeftMouseDown = true;<br />
DragRect = new Rectangle(e.X, e.Y, 0, 0);<br />
this.label1.Invalidate();<br />
} <br />
}<br />
<br />
private void label1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( e.Button == MouseButtons.Left )<br />
{<br />
Console.WriteLine("Panel2_MouseMove");<br />
DragRect = CalcDragRect(e.X, e.Y);<br />
this.label1.Invalidate();<br />
} <br />
}<br />
<br />
private void label1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( LeftMouseDown )<br />
{<br />
Console.WriteLine("Panel2_MouseUp");<br />
LeftMouseDown = false;<br />
DragRect = CalcDragRect(e.X, e.Y); <br />
this.label1.Invalidate();<br />
FinalRects.Add(DragRect);<br />
}<br />
}<br />
<br />
private void label1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
if( LeftMouseDown )<br />
{<br />
Pen pen = new Pen(Color.Blue);<br />
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;<br />
DrawRect(e.Graphics, DragRect, pen);<br />
pen.Dispose();<br />
} <br />
}<br />
<br />
private void label3_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
foreach( Rectangle rect in FinalRects )<br />
{<br />
DrawRect(e.Graphics, rect, Pens.Red);<br />
}<br />
}<br />
<br />
public void DrawRect(Graphics g, Rectangle rect, Pen pen)<br />
{<br />
if (rect.Width == 0 && rect.Height == 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Y + (float)0.01);<br />
}<br />
else if (rect.Width > 0 && rect.Height == 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);<br />
}<br />
else if (rect.Width == 0 && rect.Height > 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);<br />
}<br />
else
{<br />
g.DrawRectangle(pen, rect);<br />
}<br />
}<br />
<br />
private System.Drawing.Rectangle CalcDragRect(int mouseX, int mouseY)<br />
{<br />
return Rectangle.FromLTRB( System.Math.Min(mouseX, MouseDownPos.X),<br />
System.Math.Min(mouseY, MouseDownPos.Y),<br />
System.Math.Max(mouseX, MouseDownPos.X),<br />
System.Math.Max(mouseY, MouseDownPos.Y) <br />
);<br />
}<br />
<br />
private void Form1_SizeChanged(object sender, System.EventArgs e)<br />
{ <br />
base.OnSizeChanged(e);<br />
this.Invalidate(); <br />
}<br />
}<br />
}<br />
*sigh* still working on this one.
|
|
|
|
|
This works (for me), i copied it from Reflector:
namespace TransparentPanels
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
public class TransPanelForm : Form
{
public TransPanelForm()
{
this.FinalRects = new ArrayList();
this.InitializeComponent();
this.SetStyle(ControlStyles.DoubleBuffer |
(ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint), true);
}
private Rectangle CalcDragRect(int mouseX, int mouseY)
{
return Rectangle.FromLTRB(Math.Min(mouseX, this.MouseDownPos.X),
Math.Min(mouseY, this.MouseDownPos.Y),
Math.Max(mouseX, this.MouseDownPos.X),
Math.Max(mouseY, this.MouseDownPos.Y));
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
public static void DrawRect(Graphics g, Rectangle rect, Pen pen)
{
if ((rect.Width == 0) && (rect.Height == 0))
{
g.DrawLine(pen, (float)rect.X, (float)rect.Y,
(float)rect.X, (float)(rect.Y + 0.01f));
}
else if ((rect.Width > 0) && (rect.Height == 0))
{
g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);
}
else if ((rect.Width == 0) && (rect.Height > 0))
{
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);
}
else
{
g.DrawRectangle(pen, rect);
}
}
[DebuggerStepThrough]
private void InitializeComponent()
{
this.Panel1 = new Label();
this.Panel2 = new Label();
this.SuspendLayout();
this.Panel1.BackColor = Color.Transparent;
this.Panel1.BorderStyle = BorderStyle.FixedSingle;
this.Panel1.Dock = DockStyle.Left;
Point point1 = new Point(10, 10);
this.Panel1.Location = point1;
this.Panel1.Name = "Panel1";
Size size1 = new Size(270, 0x10a);
this.Panel1.Size = size1;
this.Panel1.TabIndex = 0;
this.Panel2.BackColor = Color.Transparent;
this.Panel2.BorderStyle = BorderStyle.FixedSingle;
this.Panel2.Dock = DockStyle.Right;
point1 = new Point(290, 10);
this.Panel2.Location = point1;
this.Panel2.Name = "Panel2";
size1 = new Size(0x110, 0x10a);
this.Panel2.Size = size1;
this.Panel2.TabIndex = 0;
size1 = new Size(5, 13);
this.AutoScaleBaseSize = size1;
size1 = new Size(0x23c, 0x11e);
this.ClientSize = size1;
this.Controls.Add(this.Panel2);
this.Controls.Add(this.Panel1);
this.DockPadding.All = 10;
this.Name = "TransPanelForm";
this.Text = "TransPanelForm";
this.ResumeLayout(false);
}
[STAThread]
public static void Main()
{
Application.Run(new TransPanelForm());
}
protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground(e);
Rectangle rectangle1 = this.ClientRectangle;
LinearGradientBrush brush1 = new LinearGradientBrush(rectangle1,
Color.White, Color.LightSteelBlue,
LinearGradientMode.ForwardDiagonal);
e.Graphics.FillRectangle(brush1, rectangle1);
brush1.Dispose();
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
this.Invalidate();
}
private void Panel1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point point1 = new Point(e.X, e.Y);
this.MouseDownPos = point1;
this.LeftMouseDown = true;
Rectangle rectangle1 = new Rectangle(e.X, e.Y, 0, 0);
this.DragRect = rectangle1;
this.Panel2.Invalidate();
}
}
private void Panel1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.DragRect = this.CalcDragRect(e.X, e.Y);
this.Panel1.Invalidate();
}
}
private void Panel1_MouseUp(object sender, MouseEventArgs e)
{
if (this.LeftMouseDown)
{
this.LeftMouseDown = false;
this.DragRect = this.CalcDragRect(e.X, e.Y);
this.Panel2.Invalidate();
this.FinalRects.Add(this.DragRect);
}
}
private void Panel1_Paint(object sender, PaintEventArgs e)
{
if (this.LeftMouseDown)
{
Pen pen1 = new Pen(Color.Blue);
pen1.DashStyle = DashStyle.Dash;
TransPanelForm.DrawRect(e.Graphics, this.DragRect, pen1);
pen1.Dispose();
}
}
private void Panel2_Paint(object sender, PaintEventArgs e)
{
IEnumerator enum1;
try
{
enum1 = this.FinalRects.GetEnumerator();
while (enum1.MoveNext())
{
Rectangle rectangle1 = (Rectangle) enum1.Current;
TransPanelForm.DrawRect(e.Graphics, rectangle1, Pens.Red);
}
}
finally
{
}
}
internal virtual Label Panel1
{
get
{
return this._Panel1;
}
[MethodImpl(MethodImplOptions.Synchronized)]
set
{
if (this._Panel1 != null)
{
this._Panel1.Paint -= new PaintEventHandler(this.Panel1_Paint);
this._Panel1.MouseMove -= new MouseEventHandler(this.Panel1_MouseMove);
this._Panel1.MouseUp -= new MouseEventHandler(this.Panel1_MouseUp);
this._Panel1.MouseDown -= new MouseEventHandler(this.Panel1_MouseDown);
}
this._Panel1 = value;
if (this._Panel1 != null)
{
this._Panel1.Paint += new PaintEventHandler(this.Panel1_Paint);
this._Panel1.MouseMove += new MouseEventHandler(this.Panel1_MouseMove);
this._Panel1.MouseUp += new MouseEventHandler(this.Panel1_MouseUp);
this._Panel1.MouseDown += new MouseEventHandler(this.Panel1_MouseDown);
}
}
}
internal virtual Label Panel2
{
get
{
return this._Panel2;
}
[MethodImpl(MethodImplOptions.Synchronized)]
set
{
if (this._Panel2 != null)
{
this._Panel2.Paint -= new PaintEventHandler(this.Panel2_Paint);
}
this._Panel2 = value;
if (this._Panel2 != null)
{
this._Panel2.Paint += new PaintEventHandler(this.Panel2_Paint);
}
}
}
[AccessedThroughProperty("Panel1")]
private Label _Panel1;
[AccessedThroughProperty("Panel2")]
private Label _Panel2;
private IContainer components;
private Rectangle DragRect;
private ArrayList FinalRects;
private bool LeftMouseDown;
private Point MouseDownPos;
}
}
|
|
|
|
|
Alright, here's one last shot at the dilema I've been facing with this little project. I'm just so close, yet so far. Here's the setup as it currently stands.
I have a basic Win-Form with a Browser component Control, I've then added to that this.WB.Controls.Add(this.render_label);. This is just a label exactly as in your example, so the render label has a drag label control added to itself this.render_label.Controls.Add(this.drag_label);. So basically what I would like to accomplish is to view web pages in the browser, and then be able to draw rectangles and such around objects on the web page. But currently when I make the render & drag labels visible (their backcolor is set to .Transparent) the browser disappears and you then see the original forms background.
I tried utilizing the browser Invalidated() event handler, but to no avail. Am I just missing the point here? Any other suggesitons you might have would be greatly appreciated again.
~Rcurrie
|
|
|
|
|
rcurrie wrote:
Am I just missing the point here?
Yes i think you are, because the point is that a transparant control just paints it's parent. So when the browser and the render label are both on the form (have form as parent), and the label is over the browser, the label will just paint the form.
I don't know about the browser (like it's an ActiveX or something). Does the browser control has a Controls property, just like the label? If so, try adding the render label to the browser (browser.Controls.Add(render_label) ). But again i don't know if that is even possible.
Waiting for your reply!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Thanks [Marc],
That does indeed make sense. The ActiveX browser component that I am using does indeed have a controls property, however it doesn't function the way I would hope. So basically I have 2 labels and the browser. I have added the inner most label to the controls of the second label. I have then added this second label to the controls of the browser, and then added the browser itself to the controls of the form. That seems to be just what we're looking for here.
However, it still does not appear transparent. I think it has to do with the OnPaint event of the browser...namely that it doesnt have one. The Invalidated() event is probably quite similar, but I'm confussed on what to put in this event_handler in order to repaint the browser onto the labels?
Here is some code that demonstrates what I'm trying to do...just like above but I've added the browser to it. You'll probably have to add the AxSHDocVx resource as well as the Microsoft.mshtml resource to the project should you using it in VS.NET
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using mshtml;<br />
<br />
namespace WindowsApplication3<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.Label label3;<br />
private System.Windows.Forms.Label label1;<br />
<br />
private bool LeftMouseDown = false;<br />
private Point MouseDownPos;<br />
private Rectangle DragRect;<br />
private ArrayList FinalRects;<br />
private AxSHDocVw.AxWebBrowser axWebBrowser1;<br />
<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
this.axWebBrowser1.Navigate("http://www.msnbc.com");<br />
<br />
this.MouseDownPos = new Point( 0,0 );<br />
this.FinalRects = new ArrayList();<br />
<br />
this.SetStyle(System.Windows.Forms.ControlStyles.SupportsTransparentBackColor, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));<br />
this.label3 = new System.Windows.Forms.Label();<br />
this.label1 = new System.Windows.Forms.Label();<br />
this.axWebBrowser1 = new AxSHDocVw.AxWebBrowser();<br />
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).BeginInit();<br />
this.SuspendLayout();<br />
this.label1.BackColor = System.Drawing.Color.Transparent;<br />
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;<br />
this.label1.Location = new System.Drawing.Point(0, 0);<br />
this.label1.Name = "label1";<br />
this.label1.Size = new System.Drawing.Size(400, 400);<br />
this.label1.TabIndex = 1;<br />
this.label1.Paint += new System.Windows.Forms.PaintEventHandler(this.label1_Paint);<br />
this.label1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.label1_MouseUp);<br />
this.label1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.label1_MouseMove);<br />
this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label1_MouseDown);<br />
this.label3.BackColor = System.Drawing.Color.Transparent;<br />
this.label3.Controls.Add(this.label1);<br />
this.label3.Location = new System.Drawing.Point(188, 32);<br />
this.label3.Name = "label3";<br />
this.label3.Size = new System.Drawing.Size(400, 400);<br />
this.label3.TabIndex = 0;<br />
this.label3.Paint += new System.Windows.Forms.PaintEventHandler(this.label3_Paint); <br />
this.axWebBrowser1.Controls.Add(label3);<br />
this.axWebBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;<br />
this.axWebBrowser1.Enabled = true;<br />
this.axWebBrowser1.Location = new System.Drawing.Point(0, 0);<br />
this.axWebBrowser1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser1.OcxState")));<br />
this.axWebBrowser1.Size = new System.Drawing.Size(819, 476);<br />
this.axWebBrowser1.TabIndex = 1;<br />
this.axWebBrowser1.Invalidated += new InvalidateEventHandler(axWebBrowser1_Invalidated);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.BackColor = System.Drawing.SystemColors.Control;<br />
this.ClientSize = new System.Drawing.Size(819, 476);<br />
this.Controls.Add(this.axWebBrowser1);<br />
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;<br />
this.MaximumSize = new System.Drawing.Size(825, 500);<br />
this.MinimumSize = new System.Drawing.Size(825, 500);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).EndInit();<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
base.OnPaintBackground (pevent);<br />
}<br />
<br />
private void label1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( e.Button == MouseButtons.Left )<br />
{<br />
Console.WriteLine("Panel2_MouseDown");<br />
MouseDownPos = new Point(e.X, e.Y); <br />
LeftMouseDown = true;<br />
DragRect = new Rectangle(e.X, e.Y, 0, 0);<br />
this.label1.Invalidate();<br />
} <br />
}<br />
<br />
private void label1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( e.Button == MouseButtons.Left )<br />
{<br />
Console.WriteLine("Panel2_MouseMove");<br />
DragRect = CalcDragRect(e.X, e.Y);<br />
this.label1.Invalidate();<br />
} <br />
}<br />
<br />
private void label1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( LeftMouseDown )<br />
{<br />
Console.WriteLine("Panel2_MouseUp");<br />
LeftMouseDown = false;<br />
DragRect = CalcDragRect(e.X, e.Y); <br />
this.label1.Invalidate();<br />
FinalRects.Add(DragRect);<br />
}<br />
}<br />
<br />
private void label1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
if( LeftMouseDown )<br />
{<br />
Pen pen = new Pen(Color.Blue);<br />
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;<br />
DrawRect(e.Graphics, DragRect, pen);<br />
pen.Dispose();<br />
} <br />
}<br />
<br />
private void label3_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
foreach( Rectangle rect in FinalRects )<br />
{<br />
DrawRect(e.Graphics, rect, Pens.Red);<br />
}<br />
}<br />
<br />
public void DrawRect(Graphics g, Rectangle rect, Pen pen)<br />
{<br />
if (rect.Width == 0 && rect.Height == 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Y + (float)0.01);<br />
}<br />
else if (rect.Width > 0 && rect.Height == 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);<br />
}<br />
else if (rect.Width == 0 && rect.Height > 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);<br />
}<br />
else<br />
{<br />
g.DrawRectangle(pen, rect);<br />
}<br />
}<br />
<br />
private System.Drawing.Rectangle CalcDragRect(int mouseX, int mouseY)<br />
{<br />
return Rectangle.FromLTRB( System.Math.Min(mouseX, MouseDownPos.X),<br />
System.Math.Min(mouseY, MouseDownPos.Y),<br />
System.Math.Max(mouseX, MouseDownPos.X),<br />
System.Math.Max(mouseY, MouseDownPos.Y) <br />
);<br />
}<br />
<br />
private void axWebBrowser1_Invalidated(object sender, InvalidateEventArgs e)<br />
{<br />
<br />
}<br />
}<br />
}<br />
|
|
|
|
|
When a control has a transparent background, it does InvokePaintBackground[^] and InvokePaint[^] on its parent. So if the browser doesn't paint anything in OnPaint and/or OnPaintBackground (wich is probably the case), i think you're screwed...
Maybe you should repost your question, explain that it's in an ActiveX browser control so that normal Let-My-Parent-Paint-My-Background transparency doesn't work, you can give a link to the top of this topic if you want.
Toedeloe!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Does anyone have a clever idea on how to bind RadioButtons?
|
|
|
|
|
How do I exactly do it?
I am just learning C#, I have a C++ background and in C++ it was something like this:
class someclass {
public:
int somemember;
someclass(int i)
}
someclass::someclass (int i) :
somemember(i)
{
}
Is there something similar in C# or is this enough?
class someclass
public int somemember;
public someclass(int i)
{
somemember = i;
}
}
Tnx
Dragan
|
|
|
|
|
You are doing the right thing.
Alomgir Miah
Live Life King Size
|
|
|
|
|
While looking at all this XML stuff I keep seeing this stream thing. What exactly is stream when doing xml syncronization?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
A stream is an abstraction of the idea of data flow. In other words, a stream is most typically a file on your hard drive, but can be something else.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
When I populate my datagrid in my dialog app can I limit it as to what columns I want to show?
Also I found an example on how to do ADO.NET programming in C# using name space system.data.ADO. However I do not have this on my machine. Did this change and if so what tutorial would be a good one to read to show the changes?
Last question If I'm opening an Access 2000 database using the dataset (hopefully this is right) would this be okay if i'm populating a list control or would a datagrid work better?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
You can use your DataSet's ColumnMapping property to hide a column.
// Creating connection and command sting
string conStr = @"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb";
string sqlStr = "SELECT * FROM Employees";
// Create connection object
OleDbConnection conn = new OleDbConnection(conStr);
// Create data adapter object
OleDbDataAdapter da = new OleDbDataAdapter(sqlStr,conn);
// Create a dataset object and fill with data using data adapter's Fill method
DataSet ds = new DataSet();
da.Fill(ds, "Employees");
// Hide the column and attach dataset's DefaultView to the datagrid control
ds.Tables["Employees"].Columns["LastName"].ColumnMapping = MappingType.Hidden;
dataGrid1.DataSource = ds.Tables["Employees"];
Alomgir Miah
Live Life King Size
|
|
|
|
|
Does anyone know a way to get the type names of custom attributes applied to a class when the assembly is loaded in ReflectionOnly mode?
The only method to get custom attributes that I know is Type.GetCustomAttributes; but since that returns attribute instances and not just the type name, it can't be used in ReflectionOnly mode.
I just want to make sure I'm not overlooking something before sending a suggestion to Microsoft.
|
|
|
|
|
|
ReflectionOnly mode means the type is loaded in "inspection context".
That is a .NET 2.0 feature to load assembly if you just want to reflect on them without creating types.
It's faster, doesn't lock the assembly file etc...
But you can't get instances from ReflectionOnly assemblies, so GetCustomAttributes() always results in an exception.
But I just found the solution myself: CustomAttributeData.GetCustomAttributes(type)[^] gets information about the attributes in a ReflectionOnly compatible way.
|
|
|
|
|
Hello,
If I have 5 tabcontrol windows on my Form1. Is there a way of
hiding some of those tabs?
Thank you
|
|
|
|
|
this.tabControl1.TabPages.Remove(this.tabPageToRemove);
Add it again when you need it
this.tabControl1.TabPages.Add(this.tabPageToRemove);
Alomgir Miah
Live Life King Size
|
|
|
|
|