|
|
It still throws a runtime error, even if I don't use RAW sockets.
I'm using SP3 though, and i'm unable to upgrade.
If you could offer any advice on what to do, I would be most greatful.
Cheers
Tris
|
|
|
|
|
And as I asked for before, what is the exception type and what does the exception message read?
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I'm really bored at work.... and thought i'd download and run the .NET enviroment. Unfortunately, I have no SDK to work in.
I can't really install VS.net, as it's a big company I work for, and the computer we have is capped at an 8 gig HD which is almost 60% full.
I've done a few google searches and such, but i've had no joy finding any SDE's.
Could someone recomend one please.
I would be eternaly greatful.
Cheers
Tris
|
|
|
|
|
|
What a great opportunity to really test your skills: no IDE. You can download the SDK from http://msdn.microsoft.com/netframework/[^]. Add both the Framework version directory (ex: %WINDIR%\Microsoft.NET\Framework\v1.1.4322) and the SDK bin directory (ex: %ProgramFiles%\Microsoft.NET\SDK\v1.1\bin) to your PATH environment variable (right-click on "My Computer", select Properties, then click the "Advanced" tab to find the "Environment Variables" button, or just use set PATH=<those two directories above>;%PATH% on the command-line for only that console window).
Type your source code files in your favorite text editor and compile with csc.exe that is installed with the Framework (not the SDK; actually, you don't even need the SDK but that contains the local documentation which is faster to find things, as well as handle tools like ildasm.exe and gacutil.exe).
Almost all code I've ever posted to the forums here on CodeProject where written in ViM (a vanilla text editor ported from UNIX) and compiled on the command-line to check for typos before posting.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
|
The Catalyst wrote:
Could someone recomend one please.
I completely agree with Heath on this one, following suit, I just use TextPad[^] as my editor to post all my code examples here, and I use a simple batch file that uses csc.exe to compile everything. Two additional options that you have for a free IDE are #develop [^] or you could write you own forms designer following this[^] article. This would still require you to download the SDK though.
- Nick Parker My Blog | My Articles
|
|
|
|
|
See link below, works well with .NET runtime, no SDK required. No frills, basic project support, 100% .NET written C# syntax highlighting editor, buggy in places... but mite be wat you need, o and its less than 600kb Try it, you have nothing to lose
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
I was having an idea of a program I want to make. I was just sitting and thinking about it and came up with an idea to a solution where I would use lots of small panels on top of large panel (canvas). The problem is that these small panels arent necessarily completely used. Maybe only parts of them are used. They can also be on top of each other. When they are on top of each other it wont look good if the top panel overdraws panels belowin parts that arent actually used. So is there a way to say that a part of a panel is supposed to be transparent so that things belo are shown instead of the empy panel?
|
|
|
|
|
Using multiple panels contained within another panel has another problem: unnecessary overhead. Each is a control with its own window handle, window procedure, and more - all consuming memory and ticking away at the number of possible window handles allocated by the OS.
There are a couple ways you could do this. The easiest way is - for Windows 2000 and newer - to use layered Windows. This is what the Opacity property of a Form uses. In this case, however, you'll need to code something yourself, which I'll get to in a moment.
The other way is supported on any Windows platforms (perhaps other platforms, too) that supports the .NET Framework. You exclude a region of your control from painting. This is known as clipping. Anything below it is sent a WM_PAINT message to redraw that portion of itself. This can be expensive (in terms of resources), which is why layered Windows are nice (but only supported on Windows 2000 and newer).
The first way requires that you P/Invoke SetLayeredWindowAttributes and - upon creation of your control (override OnHandleCreated , and be sure to call base.OnHandleCreated ) - you pass it the Handle property, the color of your transparent color, and LWA_COLORKEY (0x1) to tell the function to use your color, not an alpa value (which is what the Form.Opacity property actually uses). Then you assign an image as your BackgroundImage for your Panel that contains the color you want to mask out.
See the example below, where Example.jpg is just an image with white that I mask out:
using System;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
class Example : Form
{
Example()
{
SetStyle(ControlStyles.AllPaintingInWmPaint
| ControlStyles.ResizeRedraw, true);
using (Image bg = Image.FromStream(
GetType().Assembly.GetManifestResourceStream("Example.jpg")))
{
BackgroundImage = (Image)bg.Clone();
Size = bg.Size;
}
FormBorderStyle = FormBorderStyle.None;
}
void SetTransparentColor(Color c)
{
int key = ColorTranslator.ToWin32(c);
SetLayeredWindowAttributes(Handle, key, 0, LWA_COLORKEY);
}
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
System.Windows.Forms.CreateParams cp = base.CreateParams;
cp.ExStyle = WS_EX_LAYERED;
return cp;
}
}
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
SetTransparentColor(Color.White);
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
Close();
}
const int LWA_COLORKEY = 0x1;
const int WS_EX_LAYERED = 0x00080000;
[DllImport("user32.dll")]
static extern bool SetLayeredWindowAttributes(IntPtr hwnd,
[MarshalAs(UnmanagedType.U4)] int crKey, byte bAlpha,
[MarshalAs(UnmanagedType.U4)] int dwFlags);
static void Main()
{
Application.Run(new Example());
}
} The other way you override OnPaint and set the Graphics.Clip to a Region . You can easily construct this Region from a GraphicsPath (see the .NET Framework SDK documentation for detials) that you can add shapes to - rectangles, polygons, circles, etc. This is the region that is not painted.
Note that you shouldn't calculate this region in OnPaint - it's very expensive. You really only need to calculate it again if your control is resized (and your shape resizes along with it) or if your shape changes. Below I posted an example I posted a while back that discusses some other topics, but you'll see your question answered in there, too:
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using AS = System.Windows.Forms.AnchorStyles;
class Test : Form
{
static void Main()
{
Application.Run(new Test());
}
Test()
{
Text = "Triangle Example";
Triangle t = new Triangle();
Controls.Add(t);
t.Dock = DockStyle.Fill;
BackColor = Color.White;
}
}
class Triangle : Control
{
public Triangle()
{
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint
| ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true);
UpdatePath();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (!init)
{
UpdateBrush();
init = true;
}
Graphics g = e.Graphics;
g.Clip = region;
g.CompositingQuality = CompositingQuality.AssumeLinear;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.FillPath(brush, path);
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
UpdatePath();
}
bool drag;
protected override void OnMouseDown(MouseEventArgs e)
{
drag = true;
SetCenter(e.X, e.Y);
base.OnMouseDown(e);
}
protected override void OnMouseMove(MouseEventArgs e)
{
if (drag)
SetCenter(e.X, e.Y);
base.OnMouseMove(e);
}
protected override void OnMouseUp(MouseEventArgs e)
{
drag = false;
base.OnMouseUp(e);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (path != null) path.Dispose();
if (region != null) region.Dispose();
if (brush != null) brush.Dispose();
}
}
void SetCenter(int x, int y)
{
if (brush != null)
{
brush.CenterPoint = new PointF(x, y);
Invalidate();
}
}
GraphicsPath path;
Region region;
void UpdatePath()
{
if (Width == 0 || Bottom == 0) return;
PointF p1 = new PointF(Width / 2, Top);
PointF p2 = new PointF(0, Bottom);
PointF p3 = new PointF(Width, Bottom);
if (path != null)
{
path.Dispose();
path = null;
}
if (region != null)
{
region.Dispose();
region = null;
}
path = new GraphicsPath();
path.AddPolygon(new PointF[] {p1, p2, p3});
region = new Region(path);
if (init) UpdateBrush();
}
PathGradientBrush brush;
bool init = false;
void UpdateBrush()
{
PointF point = PointF.Empty;
if (brush != null)
{
point = brush.CenterPoint;
brush.Dispose();
}
brush = new PathGradientBrush(path);
brush.CenterColor = Color.Gray;
if (point != PointF.Empty)
brush.CenterPoint = point;
brush.SurroundColors = new Color[] {c1, c2, c3};
}
Color c1 = Color.Red, c2 = Color.Green, c3 = Color.Blue;
public Color C1
{
get { return c1; }
set { c1 = value; UpdateBrush(); }
}
public Color C2
{
get { return c2; }
set { c2 = value; UpdateBrush(); }
}
public Color C3
{
get { return c3; }
set { c3 = value; UpdateBrush(); }
}
} This draws a triangular control (instead of rectangular) and sets the clipping region so that mouse messages outside of the rectangle are translated to the control behind the triangular control. Both layered windows and clipping regions have this affect. The control is seemingly not there (in the masked region).
If you want a really cool design-time method for assigning such regions, see the RegionMaster Controls[^] on WindowsForms.net.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Wow! That is one long and very useful reply. Many thanks!
So basically, both methods you mentioned above is better than the solution I proposed I guess from your reply. I dont want to limit the solution to just Win 2000 and above so I guess your second solution is the way I need to go.
You mentioned that both my solution and your second solution was in many ways expensive. Is it correct to say that my proposed solution was expensive in terms of memory and window handle usage, and your second solution was expensive in terms of execution speed?
One more question is that when I was playing with the code of your second solution I notices that if I removed the line
t.Dock = DockStyle.Fill;
or set the docking to None in Main the tringle isnt visible. Why is this? In your example the triangle fills the complete area, but I wanted a smaller triangle in the middle, so I thought that docking felt incorrect. Do you have to dock a control to make it visible in the main window or is there another way?
One more thing I noticed is that when I run the code above, the triangle responds to clicks outside the triangle itself. If I understood you correctly, you said it would not respond to those clicks.
|
|
|
|
|
When I say "expensive" I mean in terms of resources, and not necessarily anything you can control. When you use clipping regions the windows underneath your control are sent a WM_PAINT message by the system and must draw themselves. When you start moving your application around like a crazy man there's a lot of painting going on. And many third-party controls, unfortunately, don't paint only what needs to be painted (or at least a suitable sub-region) but the whole control (this can lead to flickering or slow refresh times, even with double buffering).
G.Ringbom wrote:
or set the docking to None in Main the tringle isnt visible. Why is this?
Because I set no default size for the control when I extended it. Give the control a set size (something I didn't do since I was docking it anyway) and you should see the control.
G.Ringbom wrote:
One more thing I noticed is that when I run the code above, the triangle responds to clicks outside the triangle itself. If I understood you correctly, you said it would not respond to those clicks.
Either I wrote it wrong (sorry) or you mis-interpreted. With clipping regions the mouse messages are still sent to the control because the control (a window, actually) still occupies a rectangular region. When you set the clipping region for a Graphics object, however, it only defines the region not to paint. The control is still there. If I said otherwise I do apologize (the site is running way too slow right now for me to want to go back and check).
Layered windows can produce non-rectangular windows, however. Mouse messages are allowed to pass through to the underlying window.
I think your best approach is to use both. Use clipping regions when the current platform is not Win2K or newer, and layered windows when the current platform is Win2K or newer. You can determine the OS easily by using Environment.OSVersion .
If you search for previous comments, I believe I posted an example once using this approach - at least for part of the code necessary for such a control.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Now that I read it again, I saw that it was me who misinterpreted.
Anyway. Thanks for your replies. It really helped me out.
|
|
|
|
|
Hi...
I am making an Console application who writes some values to the Registry...
Because of possible wait time i want it to write how many percent it have wrote.
But i do not know how to do it!
However i have tried this:
Console.WriteLine("Skriver til registreringsnøglerne...");
for(int i = 0; i < 50 ; i++)
Console.WriteLine(i + "%");
Registry.LocalMachine.OpenSubKey("software").OpenSubKey("Something").OpenSubKey("Hello",true).SetValue("language", "Danish");
for(int a = 50; a < 101; a++)
Console.WriteLine(a + "%");
Registry.LocalMachine.OpenSubKey("software").OpenSubKey("Something").OpenSubKey("Hello",true).SetValue("Locale", "da_dk");
Console.WriteLine("Registrering fuldført - Something er nu på dansk ");
Console.WriteLine("© Thomas Rasmussen");
Console.WriteLine("Tryk enter for at afslutte...");
But the console just write a new line from 1 - 100, but thats also what I told it to do, so can anyone tell me how to do if I want it to write it on the same line?
Thanks...!
QzRz
|
|
|
|
|
|
|
I can't get my codebehind to work. Here is the code behind code:
namespace nestedRepeaters
{ using System.Data;
using System.Data.Odbc;
public class nestedRepeater : System.Web.UI.Page
{ public System.Web.UI.WebControls.Repeater parentRepeater;
static void Main()
{
}
public void Page_Load(object sender, System.EventArgs e)
{
//Create the connection and DataAdapter for the Authors table.
string sConnString = "Dsn=mysqldb;Uid=bigtone78 ; Pwd=";
OdbcConnection cnn = new OdbcConnection(sConnString);
OdbcDataAdapter cmd1 = new OdbcDataAdapter("select * from questions",cnn);
//Create and fill the DataSet.
DataSet ds = new DataSet();
cmd1.Fill(ds,"questions");
//Insert code in step 4 of the next section here.
//Bind the Authors table to the parent Repeater control, and call DataBind.
parentRepeater.DataSource = ds.Tables["questions"];
Page.DataBind();
//Close the connection.
cnn.Close();
}
}
}
and here is where I call it in the aspx file:
<%@ Page language="c#" Codebehind="test1.aspx.cs" Debug="true" AutoEventWireup="false" Inherits="nestedRepeaters.nestedRepeater" %>
|
|
|
|
|
ANd what do you mean by "can't get it to work"? Can't get what to work? Does the Page_Load event code execute? Does the database code execute? EXACTLY, what doesn't work and what does?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Nothing works I get a blank screen...... I think maybe its the main function. I dont think i need one but if i dont use one the code doesnt compile
|
|
|
|
|
|
Hi,
I use the code below to react on wm_erasebkgnd in a window of an external application. If I move an overlaying window with the mouse, PaintExtras() is executed succesfully. But if I minimize an overlaying window, PaintExtras() is executed and the messagebox gives for example 984521/1/1/1 indicating as far as I know that all apicalls have been executed succesfully, but my image has disappeared. What am I missing (in my code I mean ?
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
///
/// Summary description for Form1.
///
///
[ClassInterface(ClassInterfaceType.AutoDual)]
public class GenericWindow : NativeWindow
{
///
/// Required designer variable.
///
public const int WM_ERASEBKGND = 0x14;
#region Imported DLL functions
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static public extern int GetDC(int hWnd);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int ReleaseDC(int hWnd,int hDc);
[DllImport("User32.dll")]
private static extern int DestroyIcon(int hIcon);
[DllImport("user32.dll")]
public static extern int DrawIcon(int hdc, int x, int y, int hIcon);
[DllImport("shell32.dll", CharSet=CharSet.Auto)]
public static extern int ExtractIcon(int hInst, string lpszExeFileName, int nIconIndex);
#endregion
public GenericWindow()
{
}
public void NotifyWindow(int windowHandle)
{
this.AssignHandle((IntPtr)windowHandle);
PaintExtras();
}
///
/// Clean up any resources being used.
///
protected override void WndProc(ref Message messg)
{
if (WM_ERASEBKGND == messg.Msg)
{
PaintExtras();
}
// Call base WndProc for default handling
base.WndProc(ref messg);
}
public void PaintExtras()
{
int hdc = GetDC(this.Handle.ToInt32());
if (hdc != 0)
{
int hIcon = ExtractIcon(this.Handle.ToInt32(),"C:\\progress10\\wrk\\experim\\down.ico",0);
int ret = DrawIcon (hdc, 1, 1, hIcon);
int ret2 = DestroyIcon (hIcon);
int ret3 = ReleaseDC(this.Handle.ToInt32(),hdc);
MessageBox.Show(hIcon.ToString() + "/" + ret.ToString() + "/" + ret2.ToString() + "/" + ret3.ToString());
}
}
}
}
regards,
Stefan.
|
|
|
|
|
It would appear that your code, in response to the ERASEBKGND message, first draws the icon, then calls the default handler in the form. This will draw the icon, but then erase it in the next step. I think you show be calling the default handler first, then drawing your icon. You really shouldn't be drawing visible stuff within an erase message, but I don't know what your goal is, so...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks Dave,
I am trying to paint sortingarrows in columheaders of a datagrid. The datagrid is a progress 4gl thing, I can only paint on the columnheaders using winapicalls. If I do these from within the 4GL the arrows are painted, but they disappear on WM_ERASEBKGND, they are not repainted. Since I cannot catch messages like WM_ERASEBKGND and WM_PAINT I am trying to do that within a C# dll.
Can you tell me how I should call the default handler first? If you mean that I have to rewrite the override of WndProc like following:
protected override void WndProc(ref Message messg)
{
// default first
base.WndProc(ref messg);
if (WM_ERASEBKGND == messg.Msg)
{
PaintExtras();
}
}
It does not help. I get the same result.
regards,
Stefan.
|
|
|
|
|
Hi all
please help me
What is the best programming language to program a satellite software?
|
|
|
|
|