|
in C#, I call an API func CreateWindow to create a new window, and I have its handler which the type is IntPtr. Although I created it with WS_CHILD property and set it parent to a Form (get a handler by property System.Window.Forms.Form.Handler) but my window is still seperate from it parent form.
So how can I convert my window to a control in order to add it to my form?
Thanks for your attention
|
|
|
|
|
This has worked for me in some cases but in others it is kind of flaky.
IntPtr hWnd = //your handle from CreateWindow
Control control = new Control();
Type type = typeof(Control);
MethodInfo method = type.GetMethod("WindowAssignHandle", BindingFlags.Instance | BindingFlags.NonPublic);
method.Invoke(control, new object[] {hWnd, false});
{parent form/control}.Controls.Add(control);
|
|
|
|
|
what version of .NET framework do you use? I listed all the NonPublic methods of type Control to find the function named "WindowAssignHandle" but it doesnt exist , whats wrong with me????
|
|
|
|
|
I am using 2.0. If you are using 1.1, try the following although I have not tried this:
IntPtr hWnd = //your handle from CreateWindow
Control control = new Control();
Type type = typeof(Control);
FieldInfo field = type.GetField("window", BindingFlags.Instance | BindingFlags.NonPublic);
Type windowType = typeof(NativeWindow);
NativeWindow window = (NativeWindow)field.GetValue(control);
MethodInfo method = windowType.GetMethod("AssignHandle", BindingFlags.Instance | BindingFlags.NonPublic);
method.Invoke(window, new object[] {hWnd, false});
{parent form/control}.Controls.Add(control);
|
|
|
|
|
hi,
i my application i have a main form,on click of some button i am showing a new form.
I want to make the main form as immovable.
i tried setting the form borderstyle of main form as none,but this removes the border.
is there any way to do this without setting the formborserstyle as none.
thanks & regards
vinutha
|
|
|
|
|
Try using the following code
Form2 frm = new Form2();
frm.ShowDialog();
|
|
|
|
|
how to morphing between two images in C#
|
|
|
|
|
hello
i need a simple code to do a ping to aremote computer and get answer.
to detriment if is on or off.
chen
|
|
|
|
|
|
|
How to broadcast audio-video streams on Internet at optimum(Say Dial Up) bandwidth
Hi All,
I am developing a Video Chat where i wish to broadcast(multicast) vedio-audio streams over Internet. I am using DirectX(Direct Show) technology for the same.
I wish to know
- the "Best Practices" for the such an application.
- How to send streams in the most optimal manner so that application can run at lowest bandwidth
- How to trace the IP Address of a machine on LAN connected to a router for such a chat
- How to go about starting development of such an application.
HI I AM NAEEM
|
|
|
|
|
HI,
I would like to know, can we change the style of some rows in a listbox, such as change backgound colour or font size? Thank you
|
|
|
|
|
Set DrawMode property to OwnerDrawFixed, then do your own drawing in the DrawItem event handler
|
|
|
|
|
In my project i have one form.i would like to make that form as popup window.
when i run the project that window popups from right bottom corner where we see the time clock.
Amit Grover
CDAC R&D
|
|
|
|
|
you can refer the followinf link for that
http://www.codeproject.com/cs/miscctrl/taskbarnotifier.asp
Regards,
Pramod
|
|
|
|
|
thanks for help. u have send me the link in which there is an image which popups but i want my form to popup. how would i achive that functionality
Amit Grover
CDAC R&D
|
|
|
|
|
Actually the image is set on the form
u dont set the image
just use the methods that have been used in that link
to display the Popup
Regards,
Pramod
|
|
|
|
|
Happy New Year!!!!
I wanted to know how to make my web based ASP.Net application an intranet application.I know i can use authentication/authorization to do it.But I donot want a login page or something along those lines.I just donot want any one who's not a member of the intranet to view the site.I also want to know how i can accomplish the same thing in ASP.Would appreciate if someone can help me out in this.
Thanks,
Aanchal.
|
|
|
|
|
Please don't double post.
---
b { font-weight: normal; }
|
|
|
|
|
Hi all,
Hypothetically... If you were to write your own framework, and include a scripting language to configure components in the framework, what's there to stop someone creating a virus using the framework?
I'm looking at the following scenario..
- Application data and implementation patterns are transmitted in encrypted xml, to protect expensive algorithms.
- User authentication secures access to some components, and the script it were a trojan running interactively, user authentication protects nothing.
- Script compiles to a dll on the fly, so watching for unsafe dll's won't work.
- Script is encrypted during transit, so there aren't any options for inspecting malicious script before it gets to run.
- The system is being used on the server and client, and is core to a number of mission critical applications, so you can't stop the framework from running.
I think that one effective way to protect against something like this would be to use some pattern matching, prior to execution. However, whilst never having written a Antivirus system before, I would assume that this would be a huge task in itself.
For me at least, this seem really worrying. There seems no quick fix to it, and it's leading me to believe that a well written trojan will always run the first time.
If you were of the nature, what's to stop someone writing a trojan/virus in c#? If you were an antivirus vendor without a pattern matching algorithm, you would always be on the back foot wouldn't you? Ie. without it, a virus would always be able to run at least once, before someone comes up with a signature.
Is it futile to protect against human nature with code?
You attract what you believe you deserve.
|
|
|
|
|
LowlyNobody2 wrote: - Script compiles to a dll on the fly, so watching for unsafe dll's won't work.
You're right watching for an unsafe DLL here won't work. But the Assembly must be granted full trust in this scenario because it's required by Process.Start(). So this section can be avoided by disallowing full trust dll's.
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/[^]
|
|
|
|
|
I'm designing the UI for a program that's going to have a non-rectangular form to create an iTunes/Apple-ish look. I'm drawing the four corners with DrawImage and bitmaps that display the edges of the window (this helps me draw the transparent edges) and four pictureboxes with a single, "looping" line in between those that stretch out to allow the window to scale. The transparency works fine and the window draws correctly, it's just that when resizing the window everything is super slow and super choppy. And I mean extremely unnacceptably choppy. While resizing, those pictureboxes that stretch don't quite cover all the area they should and it's the same with maximizing/restoring the window. I heard that .net pictureboxes are more memory intensive. Any advice on what would be faster?
- Drew
|
|
|
|
|
picture boxes are crap. Just use DrawImage all the way through.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I see. Well, I have to have something that will stretch and that I can draw on so that I can scale the window. Is there something else I can draw on that's not crap or do I have to figure this out with DrawImage?
Thanks,
Drew
|
|
|
|
|
DrawImage lets you scale, there's plenty of overloads that take the area to draw into.
Picture boxes are fine if you just want to show a picture quickly, but people tend to try and use them for all sorts of stuff that pushes them beyond what they are for.
Christian Graus - Microsoft MVP - C++
|
|
|
|