|
how can i handle my project in windows event? for example when something happen in windows my project should do shomthing. suppose that someone makes a copy of a text in notepad or anywhere, when user takes this copy i need the data what user has copied, and want to proccess on this data. what should i do?
thanks
m.rastgar
|
|
|
|
|
You can handle a number of Windows events using the Microsoft.Win32.SystemEvents class, which defines several static events.
For handling events from other arbitrary applications you need to hook native Windows messages. Search this site for "SetWindowsHookEx".
Please note that great care must be taken and you really should understand just what a Windows message is and how to write your managed code efficiently and robustly. When you hook native Windows messages you're responsible for the stability of not just your application but all of Windows. You must not throw exceptions, do long operations (like database look-ups), or anything that could slow down the machine. Remember, you're hooking a Windows message before it's dispatched to the destination window and Windows will wait for your handler to return. You could seriously compromise the stability of Windows, so take such a task very seriously and write good, clean, robust code.
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]
|
|
|
|
|
In my .NET solution I have a project which has the controls I have developed for use in the main project. If I add the controls in that project to the toolbox I am adding them from the Debug directory. When I compile the controls for release will the main project still be referencing the debug code?
Rugby League: The Greatest Game Of All.
|
|
|
|
|
Its not important how youve dragged the controls into the toolbox. Its important what reference your main project has. If it has a real project reference to your project with the controls then everything should be fine when building in release mode.
|
|
|
|
|
Thanks, how do I do that? I just tried building in release mode and every control from the control project dissapeared. I added the controls to the toolbox using the add/remove dialog and then "browse"
|
|
|
|
|
Right-click on your project and select Add Reference. Click the Projects tab and select a dependent project in your solution. This makes sure that you're always building against the most up-to-date assembly (because it establishes a build dependency) and that you're using the right build configuration (so a release build uses the release assembly from the dependent project).
Any control extending UserControl appears automatically in the toolbox. Do not add it yourself. In fact, don't use the toolbox for the project you're developing within the solution. You'll be changing them often. If you develop in-house controls for use in a project, control the release cycle similar to how you would for a public project and then you could add them to the toolbox. The toolbox is meant for stable controls, not controls you're developing otherwise you will have the problems you're having.
If you need to add a control you're developing to a container control initially, add it manually. It's not hard. Open the source code for the container control (like the Form you're designing), add a private field like you see for other controls, then instantiate it in the InitializeComponent method like you see for the other controls. When you switch back to the designer you can design it like all the other controls you added from the toolbox. It's a one-time process that only takes a few seconds, compared to the time you'll be spending working around problems with adding controls in development to the toolbox.
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]
|
|
|
|
|
Thanks for replying.
That's exactly what I am doing. I have a control which inherits from Control so it doesn't appear in the toolbox so I instantiate it myself - however the IDE just gets rid of it sometimes - I thought we weren't supposed to change any code in IntializeComponent.
I have project references in the main project but as soon as I switch to Release build all the controls from the controls project disappear from the main project.
I have been at this for a while now and can't get it to work at all.
|
|
|
|
|
You might have covered this already, but did you check the AssemblyVersionAttribute tag, in assembly.cs if you have one, to make sure it doesn't have any * in it? Replace the * with a number so the version number stays constant from build to build while your developing your control.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
That appears to have worked. Thanks for your help.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
While it's a good idea to control your versions, this isn't necessary when you use a project reference as opposed to an assembly reference.
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]
|
|
|
|
|
Something just didn't sound right about what he was doing. At least with this method, we know for a fact he wasn't using project references. Thanks for spelling it out for him!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
If you dragged a component from the toolbox than you've got an assembly reference. Project references are recompiled (if necessary) before your project is recompiled, and the assembly is copied locally to your project's target directory. If your controls are disappearing it's most likely because your project is referencing a specific version of the assembly you added originally (and versions greatly matter for assemblies, unlike native DLLs) that is no longer available.
If Dave's suggestion worked, great, but you will still face a problem when you do have to change your assembly version. Be sure to remove all assembly references to projects in your solution and use project references.
You can modify InitializeComponent , but if you don't do it in a designer-friendly manner the designer will not work. Just use the same pattern of code that the designer expects and you'll be fine. I used to do it all the time in the same exact scenario you describe now.
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]
|
|
|
|
|
Thanks for replying. How do I tell if a reference is an assembly reference or a project reference?
|
|
|
|
|
You as the developer don't know what comprises your own project?
If you need to check, right-click on your solution and select Configuration Manager. Look at the dependencies for your project by selecting your project from the drop-down. If there's a disabled checked checkbox, then you're got a project reference. If not, you're referencing an assembly.
You can also open the .sln file (your solution file) in notepad or some other plain-text editor and look at the solution text to see what is listed. It should be quite obvious.
For a 60+ project solution I used to manage while a senior software architect for another company I never once had a problem - nor did any of my developers - because we all used project references.
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 have some controls inherited from UserControl in the sub project and they appear in the toolbox on the My Controls tab but I also have some controls which inherit from Control - how do I get those to appear in the toolbox? At the moment I am editing the code generated by the IDE in the "Windows Form Designer Code" in order to use them which, of course, means they can be gotten rid of at any time. I just want to be able to drag them from the toolbox. How do I do that?
|
|
|
|
|
my project uses an access data base (mdb file) and i want to encrypt that file to prevent abusing the database but if i change the file my project cannot use it because adoconnection can not connect to this encrypted file and if i decode the enrypted file in my project,during running of my project the database file can be abused in out of my application area. what should i do with this problem...
thanks
m.rastgar
m.rastgar
|
|
|
|
|
If it is an option, you should consider encrypting values in database table instead of encrypting the mdb file. So your application will have total control on data of the mdb file, plus you will never need to encrypt the file.
|
|
|
|
|
I have a custom object class that I'm consuming in the SoapHeader of my webservice. This class is in a seperate file, but within the same namespace as the service. The class was derived from an xml schema.
The object gets passed through the header and is processed by the "import()" webmethod.
I can invoke this method manually with no problem -- however, when consuming the webservice in an application, I get a "SoapException" when "import()" is invoked. I have also tried passing the object as a parameter, rather than the header, but the same error occurs.
Any ideas? Thanks,
-Chris B.
-----------------------------
An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in system.web.services.dll
Additional information: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.IO.FileNotFoundException: File or assembly name l4pillnj.dll, or one of its dependencies, was not found.
File name: "l4pillnj.dll"
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity)
at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()
at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()
at System.Xml.Serialization.Compiler.Compile()
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings)
at System.Web.Services.Protocols.SoapServerType..ctor(Type type, ProtocolsEnum versionsSupported)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\DOCUME~1\DD5493~1\ASPNET\LOCALS~1\Temp\l4pillnj.dll
LOG: Appbase = file:///C:/Inetpub/wwwroot/Importer
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/DOCUME~1/DD5493~1/ASPNET/LOCALS~1/Temp/l4pillnj.dll.
--- End of inner exception stack trace ---
|
|
|
|
|
Hi,
I'm having a problem printing my rotated text with Acrobat 6.0. For some reason, the pdf print out scales the rotated text to a much larger value. To draw and rotate the text, I'm using the following:
GraphicsContainer container;
container = g.BeginContainer();
Matrix myMatrix = new Matrix();
myMatrix = g.Transform;
myMatrix.RotateAt(m_Rotation, m_RotationPoint);
g.Transform = myMatrix;
g.DrawString(m_Text, m_Font, myBrush, myRect);
g.EndContainer(container);
Rotated shapes are printed out properly, its just the text with the problem. I'm not sure if this
is an issue with gdi or what?
|
|
|
|
|
hi
befor i get links to threats how i create a string (i think it calls like that in english - german: Zeichenfolge) - no i don't want that!!!
I want to create a reg_expand_sz key in the registry that is another format in the registry.
Thanks for every solution.
i hope you understand what i'm meaning
|
|
|
|
|
If you read the documentation for the RegistryKey.SetValue method, you would find the following:Note When setting a value, the way in which the value being passed is stored in the registry is interpreted. There is no way to control whether the information being passed is stored as an sz, or an expanded_sz string, and therefore, all string values are interpreted as standard sz values.
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]
|
|
|
|
|
Like Heath said, it can't be done using the Registry classes in the .NET BCL. You'll have to P/Invoke the calls to the Win32 Registry functions yourself. You can look them up on MSDN here[^] and on pinvoke.net.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I need to put pdf document as BackgroundImage in Form. As I see you can put only image files (jpg,bmp,png...) as Form's BackGroundimage. Is there some way to achieve this with pdf?
Boris
|
|
|
|
|
It's possible, but not probable. Unless you expect a dynamic background (what are you trying to do anyway?), just rasterize the PDF as an image (Adobe Acrobat - the full version - can do this) and use that.
To actually display the PDF as a background would require that you be able to read and render PDFs yourself, and that you override OnPaint (when ControlStyles.AllPaintingInWmPaint is set), or OnPaintBackground ) for a form or control and draw it. This would be very intensive, however, so be sure to only draw the PaintEventArgs.ClipRectangle for said form or control. If you redraw the entire PDF each time you'll drag down the system.
How to read and render PDFs? There's many third-party libraries on the market which you can google[^] for, and - because we've talked about this numerous times in this form - you can click "Search comments" for "PDF" to see what others have had to say about certain libraries.
Again, your best bet is to just rasterize the PDF as an image that is supported by GDI+ (which .NET uses) and set that as the background. It's far more efficient and doesn't require that you override any painting, such that Windows itself handles the painting efficiently.
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]
|
|
|
|
|
How would I be able to launch a windows application from a windows service that would display the windows apps interface. I tried starting a process within the windows service to start i.e. notepad.exe but then it is still hidden and the only way you can tell that it is in there is to go to the task manager.
Thanks for the help.
|
|
|
|