|
aaawww... arent u the nice lil hippy.
don't worry, America heats u too!
and proofread your anti-american comments from now on please. now you dont just look ignorant, but stupid as well. a deadly combination, even for un-informed peace junkies.
-613 "Code Poet"
"Real programmers don't work from 9 to 5. If any real programmers are around at 9am it's because they were up all night."
|
|
|
|
|
I have got an unhandled exception ,Who can tell me what's meaning of
it ,thanks
Here is something about the exception :
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at PersonalLib.Form1.Main() in f:\c#\windowsapi\api\windowsapplication7\form1.cs:line 120Application“[964] WindowsApplication7.exe”has exited with code 0 (0x0).
|
|
|
|
|
Hi, another quick question. I've only just started playing around with threads and the documentation with VS doesn't tell me much. So here's the problem (actually it's more a minor niggle):
I have a program which has to make thumbnails from a bunch of images, the thumbnails work fine, but they take a while when there are a lot of images, so I decided the solution was to run the thumbnail making in the background using a thread. My problem is that it is possible to switch to another directory and another bunch of images before the first thread is finished. The program doesn't actually seem to mind, but it does slow down while it is presumably executing several threads at once. So I thought the right thing to do is check if a thumbnail producing thread is running and stop it before starting a new one (since the user has lost interest in the current set of thumbnails by selecting a different directory, it doesn't matter if it doesn't ever get finished). So I tried this:
<br />
if (thd_thumbs.IsAlive)<br />
{<br />
thd_thumbs.Abort();<br />
}<br />
thd_thumbs = new Thread(new ThreadStart(this.run_thumbs));<br />
thd_thumbs.Start();<br />
But that doesn't work and the program crashes with a 'System.OutOfMemoryException' and 'Error creating window handle'. Without the if clause it works, but slows down as before. So what's the right way to do this?
|
|
|
|
|
Wjousts wrote:
if (thd_thumbs.IsAlive)
{
thd_thumbs.Abort();
}
thd_thumbs = new Thread(new ThreadStart(this.run_thumbs));
thd_thumbs.Start();
thd_thumbs.Abort() simply forces a ThreadAbortException into your thread, you then have to wait until that Exception is completely handled before you can dispose of the thread safely.
I would suggest you put a try, catch (ThreadAbortException) structure in run_thumbs and when you catch the exception, simply start the thread over again (thd_thumbs.Start()).
Paul
We all will feed the worms and trees So don't be shy - Queens of the Stone Age, Mosquito Song
|
|
|
|
|
In a windows form, I'm developing a file backup app with a Treeview/Listview pair that behaves like Windows Explorer, listing drives and folders in the treeview, and folders and files in the listview... each entry has a checkbox so I can keep track of what's been selected...
The listview only has an ItemCheck event, whereas the treeview contains BeforeCheck and AfterCheck events, and also the ability to determine whether the event was fired by a mouse or not. This really limits me because I need to differentiate between mouse-induced checks and code-induced checks, just like in the treeview.
Is there some way to obtain this functionality in the listview?
thanks.
|
|
|
|
|
Check Control.MouseButtons
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
I'm trying to make an image list of thumbnails and I can take an image an convert it into a thumbnail using Image.GetThumbnailImage. Before getting the thumbnail I calculate what the dimensions should be so as to not distort the image (i.e. make the largest dimension equal to the corresponding dimension of the thumbnail and then scale the other dimension by the same amount), this works fine. The problem is that when I put an image like this into an ImageList control the ImageList takes it upon itself to stretch the image to completely fill it's image size and therefore screws up my careful scaling. There doesn't seem to be any way to turn off this behaviour so my only option seems to be to pad my thumbnails with white space so that they are the right size, but I don't know how to do this. Can anybody help?
Thanks
|
|
|
|
|
You will first need to take a look at the Bitmap class and also the Graphics class.
First you need to create a new bitmap and make it white:
Bitmap bmp = new Bitmap(w,h);<br />
<br />
using(Graphics g = Graphics.FromImage(bmp))<br />
{<br />
<br />
g.FillRectangle(Brushes.White,0,0,bmp.Width,bmp.Height);<br />
<br />
int x = (w - bmp.Width) / 2;<br />
int y = (h - bmp.Height) / 2;<br />
<br />
g.DrawImage(original_bmp,x,y);<br />
}<br />
<br />
<br />
I have not tested this, but it should give you an idea.
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Thanks, that seems to work. The only odd thing was that I had to use DrawImage(img,x,y,width,height) otherwise it did strange things to the image, sometimes it appeared tiny, other time blown up. Very strange.
|
|
|
|
|
Wjousts wrote:
Thanks, that seems to work.
Glad, I could be of help.
-Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
|
Hi!
I'm searching a method to create my own form design environment.
Anybody know how to in C#??
Tnh a lot!
|
|
|
|
|
Sharp Develop is a free IDE written in C#. Check out its source code. http://www.icsharpcode.net/OpenSource/SD/Default.aspx[^]
"De most compwehensive image seawch on de web." - Google in Elmer Fudd Language "But a fresh install - it's like having clean sheets" - Chris Maunder Lounge 3 Mar '03
Jonathan 'nonny' Newman Web Designer, Programmer, Lover, Visionary Leader...
Homepage [www.nonny.com] [^]
|
|
|
|
|
Hi all,
I have to write a selection control like you have in Paint for my program (you know, to select parts of the image you're working on in Paint). I've searched all over the web to find such a control, but it looks like it doesn't exist yet, so I have to write it myself. I already have some ideas how to get it working, but I know almost for sure that they will be way too slow. Does anybody have an idea how to make such a control?
Thanks in advance,
Joost Huizinga
|
|
|
|
|
Please take a look at the ControlPaint.DrawReversibleFrame method. That will help you
Smitha
The future belongs to those who believe in the beauty of their dreams.
--Eleanor Roosevelt
|
|
|
|
|
Hi,
This is one useful snippet I used.
private void DrawReversibleRect( Point p1, Point p2 )
{
Rectangle rc = new Rectangle();
if( p1.X < p2.X )
{
rc.X = p1.X;
rc.Width = p2.X - p1.X;
}
else
{
rc.X = p2.X;
rc.Width = p1.X - p2.X;
}
if( p1.Y < p2.Y )
{
rc.Y = p1.Y;
rc.Height = p2.Y - p1.Y;
}
else
{
rc.Y = p2.Y;
rc.Height = p1.Y - p2.Y;
}
Rectangle r = pictureBox1.RectangleToScreen(rc);
ControlPaint.DrawReversibleFrame(r,this.BackColor,FrameStyle.Dashed);
}
You can draw the reversiblerectangle in the MouseMove event.
HTH
Smitha
The future belongs to those who believe in the beauty of their dreams.
--Eleanor Roosevelt
|
|
|
|
|
Hi Smitha,
Thanks for your reply. I already found something like that, by setting some Pen properties and drawing a rectangle with the Graphics.DrawRectangle method I got the same. But thanks nevertheless, this way is much easier.
But drawing the selectioncontrol isn't my main problem. My main problem is the resizing of the control and setting the cursors depending on where they are. For example, when the cursor is within the control, the cursor has to be set to the SizeAll cursor. But if the cursor is in the middle dotted line of the rectangle (on the little square), the cursor has to be set to SizeNS if the cursor is on the upper or the bottom line, and to SizeWE if the cursor is on the right or the left line. And the corners also have their own cursors. Setting the cursor every time when the MouseMove event is fired depending on where the mouse is requires a lot of if's and it will be way too slow. So do you have an idea how to get that working without making the program very slow?
By the way, I'm not a very experienced programmer. So it could be I ask dumb questions .
Thanks in advance,
Joost
|
|
|
|
|
My MyDUMeter article mite be of some help. I use painting for range selection on the report graph. I think you are having the same performance problems I had.
http://www.codeproject.com/useritems/MyDUMeter.asp[^]
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hi leppie,
Thanks for your reply, I think I know enough about the drawing stuff. The only thing left is assigning the right cursors, but I'll try some things myself first. Still, any comments on assigning the cursors are welcome!
Thanks in advance,
Joost
|
|
|
|
|
Hi Joost,
I have not tried it that way. But do post about it, if you succeed assigning cursors to the selection. Good luck!
Smitha
The future belongs to those who believe in the beauty of their dreams.
--Eleanor Roosevelt
|
|
|
|
|
Hello,
does anyone know how to align the Pen-Object correctly when drawing lines with the DrawLine() - Methode of the Graphics-Namespace?
The problem is, that when i draw a line with a width of e.g. 7 pixels from Point (0,10) to Point (100,10) the topmost/leftmost painted pixel is at (0,7) instead of (0,10). That is because the Pen-Object is positioned at the center of the line that should be drawn. But this behavior is bad when drawing borders of e.g. controls.
The PenAlignment-Property of the Pen-Object doesn't seem to work here, though it works with the DrawRectangle()-Methode. If i paint a rectangle with the startcorner at (0,10) and i set the PenAlignment to "Inset", the topmost/leftmost paintet pixel is at the "correct" location of (0,10).
Does anyone here know how to solve this problem?
Greetings
Armin
|
|
|
|
|
Line accuracy is troublesome when working in different mapping modes. Lines work fine when defining them in MM_TEXT (without scaling) but when using modes like MM_HIMETRIC and incorporating scaling, the MFC lines always insist on having the same screen coordinate width regardless of where they translate to from the mapping mode. Alignment problems because of this behaviour are most evident with endcaps when aligning horizontal and vertical lines. At different scales, a little overhang or underhang becomes evident. Consistency at all scales is nearly impossible to achieve.
Your question concerning the alignment can be approached by taking the line and offsetting it but you will find alignment with MFC Rectangles and Circles becomes problematic (especially with borders). I spent quite a few months addressing this issue and studying how other applications approach alignment and found that there are many schools of thought, all having pro's and con's.
When you need to leftalign and rightalign bottomalign and topalign geometric shapes, you will find that line thickness and your choice of righthanded, centered, and lefthanded lines complicate the process and will require some modifications to coordinates you feed to the drawing commands. I believe there are no "One size fits all" drawing routines that will accomodate every programmers needs. The MFC drawing commands are a good place to start but I would recommend calling those functions from within your own drawing functions that take your drawing approach into consideration.
|
|
|
|
|
I made Several userControls and one WinForm.
And I tried to attach userControls to WinForm from ToolBox at Design Time.
But, "System.NullReference Exception occurred"
When I did 'drag and drop' to do it.
I don't know Why it happened.
Is there anybody Help me??
|
|
|
|
|
Anyone had a look at COM+ from .NET using the Enterprise Services namspace?
I've been having a look, but when I override some of the functions in the ServicedComponent class (Construct & CanBePooled) from which I have to derive my new managed COM+ component, the compiler complains.
[Transaction(TransactionOption.Required)]
public class BusinessObject : ServicedComponent
{
public BusinessObject()
{
}
protected internal override bool CanBePooled()
{
return false;
}
protected internal override void Construct(string s)
{
}
public void DoWork()
{
ContextUtil.DeactivateOnReturn = true;
ContextUtil.MyTransactionVote = TransactionVote.Abort;
ContextUtil.MyTransactionVote = TransactionVote.Commit;
}
}
I've been looking at this example.on MSDN, but it uses the beta edition of VS.NET, and does not compile.
http://msdn.microsoft.com/msdnmag/issues/01/10/complus/default.aspx[^]
I managed to get the above compling by manually ammending the access modifiers, but it does not seem very slick, when you have the IDE overide a member, and create the code, to find it does not compile.
Changing to
protected override void Construct(string s)
{
}
works, but as I said not very slick. If this is the mest MS can do, then not much hope. .NET will only be of any use to code monkeys.
Quote from a clever bloke :
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
|
|
|
|
|
Hi, I need to store a word document in MSSQL database (in image field) from C# windows application!
How can I do it? I need to create some kind of binary readers or streams to get that file and then store it or I do not know?
|
|
|
|
|