|
would that work with killing a process? i think that killing doesn't cause any exceptions, nonetheless icon remains in tray in this case as well... hmmmm ... anyway i'll test that. thanx
|
|
|
|
|
No it won't. When you kill the application with taskmanager there's nothing you can do, no event you receive - nothing at all.
But you asked about exceptions, not killing the app.
Regards,
mav
|
|
|
|
|
taskmanager or Process.Kill() function... whatever... i know i didn't ask about that. i mentioned about killing a process but that was not a main point... that's just one of the situations when icon doesn't disappear. it seems that it's some bug in windows. isn't it?
-- modified at 18:39 Sunday 8th January, 2006
|
|
|
|
|
This problem has annoyed me for some time now (in my C++ programs - this problem is language independent). I too think it is a bug in explorer (perhaps an oversight would be a better description). We’ll have to wait for Microsoft to fix this one for us (don’t hold your breath).
This code (in C++) shows how easy it would be for MS to fix this problem:
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
PROCESS_INFORMATION pi;
BOOL Ok = CreateProcess(
"C:\\WINDOWS\\system32\\Notepad.exe",
NULL, NULL, NULL,
FALSE, 0, NULL, NULL,
&si, &pi);
if ( Ok )
{
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
MessageBox(NULL, "Remove icon now!", "Remove icon now!", MB_OK);
}
If you run this program it will start "Notepad.exe" and display a message box when it terminates - No matter how this happens (even if you kill it).
Explorer wouldn't create the process however - It would get the HANDLE to the process from the HWND passed to the Shell_NotifyIcon function.
Steve
|
|
|
|
|
There's no way to clean this up. If your code is stopped by Kill Process, or any other method, that's it, you don't get the chance to kill your icon.
Windows Explorer won't get rid of the icon until the mouse if over it. There's simply no way around this until MS gets around to fixing it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello everyone,
I would appreciate some help on sth that's been bothering me all day today
I'm trying to work with an xml file set as follows:
<object>
<id>
<attribute 2="">
<attribute 3="">
<attribute 4="">
<item>
<item attr1="">
<item attr2="">
<item attr3="">
<item>
<item>
<item attr1="">
<item attr2="">
<item attr3="">
<item>
...
<object>
the idea was to have a single id for each object and as many <item> objects as the user likes.
Even though it looks that the MSVStudio xml editor is able to perfectly distinguish and present two data Tables in a parent-child manner, i hit a wall when i try to do the same programmatically.
What I’ve been trying is:
a. instantiate a dataset,
b. dataset.readxml(…) ... so far so good, i get two tables in my dataset, ("object" & "item")
c. instantiate two datatables, one for object and one for item tables.
but the table "item" contains all the items of every object and i can't seem to find a way to filter them, so i can get only the ones i'm interested every time i.e. the ones nested into a single <object>....
Just to give you some more info about the goal, a form has to be filled, presenting the object attributes on top and the items in a listView at the bottom.
Thanks a lot in advance for any help given.
I’ll post the whole thing if anyone’s interested, if and when I get it!
|
|
|
|
|
sorry about the invisible tag code...
you can have a look at it below...
<object>
<id></id>
<attribute 2></attribute 2>
<attribute 3></attribute 3>
<attribute 4></attribute 4>
<item>
<item attr1></item attr1>
<item attr2></item attr2>
<item attr3></item attr3>
<item>
<item>
<item attr1></item attr1>
<item attr2></item attr2>
<item attr3></item attr3>
<item>
...
<object>
|
|
|
|
|
Hi!
I have two different problems, one in VS'03, second in VS'05...
Well... first I'll show examplatory situation skelleton
<br />
public class Form1 : Form<br />
{<br />
myclass cl1;<br />
myotherclass cl2;<br />
<br />
private void InitializeComponent()<br />
{<br />
cl1 = new myclass (some arguments);
cl2 = new myotherclass();<br />
<br />
cl2.property1 = cl1;<br />
cl2.property2 = new myclass (some arguments);<br />
}<br />
}<br />
I have a control and a custom TypeConverter for it. I use the second one, to choose proper constructor for my control. The code in InitializeComponent is generated properly, the proper constructor is being used. When I compile project, the program works fine, but...
When the Designer recreates form (on project load or after stoping the application which is being designed), it uses default constructor for creating cl1 and in effect, the component is initialized improperly...
The funny thing is, that the control of same type, the cl2.property2 is always properly initialized using non-default constructor
I found a unpleasant solution to it - to init the properties which are set by my constructor again, below, as other properties are... so this constructor works ok only in initialization of cl2.property2 .
So...
I've moved to VS'05 to check if they did sth with this bug...
They did, it works fine now... but...
The cl1 is serialized by designer ok now... but cl2.property2 is no more serialized :/ (cl2.property1 stayed as it was)
Does anyone now the solution for VS'05... or better solution than mine for VS'03?
Regards,
Darek Maciejewski
|
|
|
|
|
Initialise these objects in your own code, not in the compiler generated stuff. The designer thinks it's smart, but it isn't. Especially in VS2005, I spend a lot of time fighting the designer to try and show my forms. At one point, it was actually blowing up the IDE, and the reason way, my control took a Bitmap as a property, and my code checked if the bitmap was NULL, otherwise it would do some image processing on it. The IDE put a bitmap with a pixel format of Unknown in there, something I didn't know existed, and certainly didn't feel I had to check for. Add a check for that, and my IDE stopped crashing. Bizarre.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The problem is, that it must be done by designer...
It is part of my Senior Design Project - I have to create some controls which are nicely editable in the designer - it involves custom designers, type converters and type editors. Everything should be editable visualy...
If nobody would know the answer for VS'05, I will have to stay with my VS'03 walk round
Darek
|
|
|
|
|
OK, then that's an issue. I believe MS are promising a patch by March, I dunno if this is one of the issues they intend to fix tho.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
There is a very usefull property called 'DesignMode'
It returns true if the control is loaded in design mode and false if the controls is
created at runtime.
Using this you can let the control change his behavior when being created in or out the IDE.
I have encoutered the same problem when using none default constructors for a control.
Hope that this will lead to a soulution for you
codito ergo sum
|
|
|
|
|
I have solution for VS'05!!!
Not the general remedium, but it works for me...
The myclass was a Component here,
it is enough, to be plain class for me... and it works that way
(what doesn't solve problem, if someone would need to have it as a Component )
|
|
|
|
|
Instead of re-inventing the wheel and roll my own class set, i thought i would ask if anyone at codeproject has created a basic set of win32 api classes that one can use in C# programs. I was only able to find bits and pieces on the internet.
|
|
|
|
|
www.pinvoke.net will shouw you how to call API functions you need. You're calling the Win32 API everytime you use C# tho, you realise that, right ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I use www.pinvoke.net often. It will just take some time cut-n-pasting all this stuff and organize it into a modular library. I think i will build a Win32 library as i go, adding functions as i use them, refactoring as needed. Reinventing the wheel is not all bad if it does not take too much time. Appreciate the help.
|
|
|
|
|
|
Hello there,
I'm developping a graphic interface for a sniffer library, and I'm actually stuck. When I want to start sniffing, I have to call that unmanaged function :
HANDLE PeekCreateCaptureContext(HANDLE, void*, int, int, void *)
When that function is successfully called, the library creates a thread listening for packets, and will call a user function each time a packet is captured. The second parameter (void*) of PeekCreateCaptureContext has to be a handler pointing to that function.
The user defined function signature must be (in a C version) :
int WINAPI on_capture( unsigned char *data, int len, int caplen, __int64 timestamp, int flags, int arg7 )
So I want to use PeekCreateCaptureContext in my C# code, but :
- How can I get my IntPtr custom function handle ?
- Is it possible to convert the unsigned char * (array of bytes, but unknown size) parameter to a managed type, because I won't be able to use the data in my external-threaded function if it's unsafe.
Thanks in advance for any idea or clue...
|
|
|
|
|
Oh my god, nobody knows ? That was an interestning project
I swear I'll post an article if I succeed !
|
|
|
|
|
I need help keeping track of the textbox cursor (in order to allow selection, and the entering of special chars).
any ideas?
|
|
|
|
|
You can use the TextBox.SelectionStart to get the caret position in your textbox (I think you mean caret by writing "cursor" ?). If you need to know when that position changes, I think handling the KeyDown and Mouse Down events should cover any caret move possibility.
|
|
|
|
|
Here goes my question. I would like to know how to select files from a window dialog, display the files selected in a grid.
From there have an option to either add more files (eg notepad.exe) so you can add or remove them.
From there when you are done selecting files Have another button that will compress all the files you selected and compress them using rar and the filename you designate.
Any ideas and help would be greatly appreciated.
Many thanks
-- modified at 16:51 Sunday 8th January, 2006
|
|
|
|
|
The first part is not very tricky - just use an OpenFileDialog to browse for the files. When OpenFileDialog.ShowDialog() returns DialogResult.OK , you can add the selected filename or filenames to your list (for example, an ArrayList ).
Creating a rar file from the files selected cannot be achieved with the base class library classes. I don't know a library that creates rar, but you should definitely have a look at SharpZipLib (google for it), it can create zip, bzip, gzip and some other formats.
Regards,
mav
|
|
|
|
|
I'm trying to add binary serialization to this set of classes.
Saving seems to work ok (file is created and seems tocontain the relevant data). However, Deserialize fails (even for an empty file) with:
Exception has been thrown by the target of an invocation.
InnerException: Object must implement IConvertible
I've implemented ISerializable myself on the DTreeNode class and on the DTReeRoot class (for the latter, it currently serializes nothing). DTreeNodeCollection uses default serialization.
relevant part of the call stack:
<small>System.Reflection.TargetInvocationException was unhandled<br />
Message="Exception has been thrown by the target of an invocation."<br />
Source="mscorlib"<br />
StackTrace:<br />
at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)<br />
at System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context)<br />
at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)<br />
at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)<br />
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)<br />
at System.Runtime.Serialization.ObjectManager.DoFixups()<br />
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)<br />
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)<br />
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)<br />
at XTree.Form1.openToolStripMenuItem_Click(Object sender, EventArgs e) in D:\Development\C#express\phlib\phtree\XTree\Form1.cs:line 187<br />
</small>
We say "get a life" to each other, disappointed or jokingly. What we forget, though, is that this is possibly the most destructive advice you can give to a geek.
boost your code || Fold With Us! || sighist
|
|
|
|
|
I have to design a library of classes. They are to inherit from a common base class. However I want to be able to call members of the class without making a distinction of which class it particularly is. I was thinking of an interface for the last point I mentioned.
Question : Would I'll be able to make my classes inherit this interface without directly inheriting the base class (i.e. the base class is inherited by interface)??
|
|
|
|
|