|
HI all,
How can i incorporate the ability for a user to select an ROI by pressing his left mouse button and dragging it on the displayed image and also i want to set the max boundaries for dragging as the image resolution.
For this how can i implement my MouseDown event for left button.
anyideas or suggestions please...
thanks in advance,
Suman
|
|
|
|
|
Hi all,
Does anybody know how to set a windows service description? The serverinstaller component's Displayname property maps to the Service Name in the Services MMC snap-in. The Description in the MMC is empty. I can't find any property that maps to this description.
Thanks,
Peter
|
|
|
|
|
Since the ServiceInstaller doesn't define such a property, you have to write it to the registry yourself. The easiest way is, in your Installer derivative (the class that references the ServiceInstaller and ServiceProcessInstaller ), override Install (and Uninstall with code to remove the key) like so:
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
using (RegistryKey key = Registry.LocalMachine.OpenSubkey(
@"SYSTEM\CurrentControlSet\Services\" + serviceInstaller1.ServiceName))
{
if (key != null)
key.SetValue("Description", description);
}
}
string description;
public string Description
{
get { return description; }
set { description = value; }
} You wouldn't have to define it as a property, but it makes for a good design.
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]
|
|
|
|
|
Fot those interrested, Heath's hint returns a read-only reference to the registry key.
Few bytes changed and it works:
public override void Install(IDictionary stateSaver)<br />
{ <br />
this.Description = "Blah blah.";<br />
base.Install(stateSaver); <br />
string p = @"SYSTEM\CurrentControlSet\Services\" + serviceInstaller1.ServiceName;<br />
RegistryKey key = Registry.LocalMachine.OpenSubKey(p,true);<br />
{ <br />
if (key != null) <br />
key.SetValue("Description", description); <br />
}<br />
}<br />
Ciao and thanks for your help Heath!
Peter
|
|
|
|
|
Hi, I am trying to use the PostMessage function by importing it through DLL import in C# with the following definition.
[DllImport("user32.dll")]
static extern bool PostMessage(IntPtr hWnd, int msg, Int32 wParam, IntPtr lParam);
Can someone give an example of what you would pass in order to get a keystroke, and a mouse click? Really, I do not understand what needs to go in for wParam, or lParam.
Thank you for your help in advance.
|
|
|
|
|
First you need to understand what the LPARAM and WPARAM types are. They are native, processor-dependent integers, so that on 32-bit processors they are 32 bits wide and on 64-bit processors 64 bits wide. Technically, both should be IntPtr , but people will often declare certain parameters as int to make it easier to call. Note, however, this is not portable to 64-bit Windows, just like declaring a parameter as a long in 64-bit Windows won't port to 32-bit. (Also note that a managed long is 64 bits; a native long is 32 bits.) The bit widths are important because in unmanaged code the arguments are pushed onto the execution stack and expected to be a certain size. If they're not, you have a stack corruption. Remember that unmanaged code is unmanaged because the CLR can't manage it.
You can, however, use things like out myStruct or ref myStruct because those pass the addresses of myStruct , which will always be the correct bit width.
When you're P/Invoking functions, you need to refer to the native API documentation in the MSDN Library[^]. So that you can easily figure out the message IDs and other constants, I also recommend you download the Platform SDK[^] so that you have the headers you need. If you've installed VS.NET with VC++ then, by default, you've already got these headers (though they may not be as up-to-date as what's online; but for stuff that's been around a while it won't change any time soon).
So, if you want to pass a message to signal a keystroke, your first place to look is at WM_KEYDOWN[^]. There you'll find the documentation for what your wParam and lParam should be.
In this case, however, you're doing the unnecessary. The .NET BCL defines the <cdoe>SendKeys class for this very purpose, though if you want to post a keystroke to another application's message queue that isn't in the foreground you'll need to P/Invoke PostMessage (if the application you want to post a keystroke to has the focus, you can still use SendKeys ).
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]
|
|
|
|
|
Hi!
Pls tell me (if u can ) how can I drag-and-drop a panel control on the same clipboard, if i dont know the control's ID?
|
|
|
|
|
What does the control's ID have to do with anything? Drag-n-drop in .NET is simple. Just read the documentation for the Control.DragDrop[^] event for information and a complete example.
Dragging the Panel is the slightly more difficult part, since it doesn't define an event to fire when dragging begins (nor would it makes sense to in most circumstances). Instead, you'll need to handle MouseDown , MouseMove , and MouseUp as we've discussed before in this forum:
bool down;
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
down = true;
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (down)
{
DataObject data = new DataObject(sender.GetType().FullName, sender);
DoDragDrop(data, DragDropEffects.Move);
down = false;
}
}
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
down = false;
} Of course, you'll need to add these handlers to the Panel corresponsing events.
The code for the DragOver and DragDrop events you can find in the documentation I linked above.
Note that this will only work within the same AppDomain. You can't simply drag instances from one AppDomain to another. For that you need to serialize the panel and pack it in a DataObject as a string, or study OLE Drag and Drop (from which .NET drag and drop derives) and structure storage and stream information. Serializing the object to a string is the easiest alternative since .NET drag and drop doesn't expose other possible STDMEDIUM s with which to store object data (like locking it into global memory so you can use Marshal.AllocHGlobal , for example).
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 need some kind of ID, because I want to make panels with image in run-time (by clicking a menu item or else) and I have to know which panel have been clicked with mouse! I would like to move the whole panel! Or if u have something else idea for moving little pics with text on the clipboard I'm waiting for it! Like buttons?!
The code u wrote me, did not work (for me)!
|
|
|
|
|
What does that have to do with drag and drop? As far as drag and drop goes, you pack the actual object so you don't need to worry about the ID because you have the object itself.
My code was an example and wasn't a full solution. You need to read the .NET Framework SDK documentation and understand what the code is doing and make it work for you. If there was syntactic errors it's because I posted it as an example and don't compile everything I post. That would take forever and you - as the developer - need to understand the code. I'm not just giving out solutions.
The concept is sound and I've used it plenty and provided the example to others in this forum over the past couple years and it's worked. That's just how drag and drop works. .NET makes it easy for you, but unfortunately in doing so it is rather limited (doesn't allow you to specify STGMEDIUM s like with OLE automation).
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 problem is: The user makes controls(by clicking a menu item) from the same tipe(class MyButton : Button) to the clipboard. I've got it! But if I
want to make MyButtons able to move by the mouse(drag-drop) I need to discriminate the MyButton controls on the clipboard to know which MyButton control was clicked or moved!
|
|
|
|
|
No you don't. You use the Type only as the clipboard format (if you don't understand what a clipboard format is, then you really should read about native Drag and Drop in the Shell documentation in the Platform SDK), but the object itself (instances are unique) is packed into the clipboard. Whatever control you click on, be it a Button or MyButton or a different MyButton (and one instance of a control can't be used in multiple places at once because Windows Forms encapsulates the Windows APIs and Common Controls, which wouldn't allow that), are all different instances.
If you're creating controls from a menu, then you simply use the Type passed to Activator.CreateInstance (there's other ways using reflection yourself) to create an instance. Then when a user drags it, they are dragging yet another unique instance of your control. You do not need to distinguish it from another control because the instance is already unique.
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]
|
|
|
|
|
Would u show me some code how to use Activator.CreateInstance ?
|
|
|
|
|
|
Where I can found a free C# Outlook-style mini calendar?
Im working in a project of recuuring patterns and I woul like to add some features.
I have seen calendars made in C++ but I dont know nothing this language.
Thank you!
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
Either search this site using the text box below the logo on every page, or use a search engine like google[^].
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]
|
|
|
|
|
Thank you, i do that first than post it
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
|
Yes, but not in the outlook style.
I found DatePicker control by Lutz Roeder and its have a outlook style calendar in C#. Im trying to get the calendar control, but it no has some properties than I need, like bolded dates and show multiple mode.
But it seems like theres not already the control Im looking for so I need to code it - if I can .
Thank you.
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
What do you mean when you say outlook style?
"Catalonia is not Spain"
|
|
|
|
|
Hi friends...
a .net application when compiled just work in my system and if i want run it on a system that is not installed .net framework on it, i cant and i see an error... how i can compile my application for all systems...???
also i want a reference for GDI+ and graphics in C# , and Work with math functions in C#
|
|
|
|
|
You cannot compile C# to native Win32, the .NET framework is required.
|
|
|
|
|
There's got to be a way you can include a "mini" MSIL interpreter and package the right DLLs with a project... But I can't remember how to do that right now. Hopefully someone else can.
vir·tu·al re·al·i·ty
n. Abbr. VR
A computer simulation of a real or imaginary universe in which Microsoft APIs are thoroughly documented and behave in an entirely logical manner.
|
|
|
|
|
That's BAD! Not only is it not servicable (so that updates to the .NET Framework absolutely WILL NOT apply to your hack) you destroy the very nature of the Framework. If you do something like this (and there is a product that does this) you are responsible for updating your application every time a service pack or generate update is required. It will not - and cannot - be updated automatically by Windows Update or any other method that will update the .NET Framework. This is true for the other platforms I mentioned below.
Applications that target the .NET Framework require the .NET Framework, just like Java applications require a JVM and, more than likely, the JRE (like the .NET BCL), VB6 (and below) applications require the VB Runtime (msvbvm60.dll), and most C/C++ applications require at a minimum the standard C runtime.
In every case, if you import or otherwise use functionality defined elsewhere you require that component. The .NET Framework isn't just a class library - it's a complete runtime with unmanaged components to make the runtime possible (just like a JVM or the VBVM, etc.).
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 didn't think the OP was working on an "enterprise solution" or anything that's going to need constant servicing. Maybe his other machine, or his friend has Windows 95 and doesn't want to install the framework because they don't have the space? I understand completely that .NET comprises an entire framework, but I see that the OP could have gotten the wrong idea from my suggestion. It's good that you clarified.
vir·tu·al re·al·i·ty
n. Abbr. VR
A computer simulation of a real or imaginary universe in which Microsoft APIs are thoroughly documented and behave in an entirely logical manner.
|
|
|
|