|
Hi,
I guess there is a solution, even to work around bugs/shortcomings of some
embedded control, but it requires advanced techniques:
IDEA 1
if you are in charge of the Form, you can override the good old WndProc,
by creating a method:
protected override void WndProc(ref Message m) {}
By doing so all low-level windows messages for that form will be offered to it,
and you can selectively disregard the ones you dont like, and let the system
handle only the ones you do like.
If you are unfamiliar with WM_... messages d(such as WM_SHOW) defined
in C/C++ file winuser.h you are out of luck...
IDEA 2
if you can figure out somehow that scrolling is still going on, you could
postpone the Form.Close() when ESC is pressed.
Maybe, just maybe, it is sufficient to do an Application.DoEvents() before
calling Close(), but I am not sure at all this will work.
Good luck !
|
|
|
|
|
Luc Pattyn wrote: IDEA 1
Thank you. Unfortunately, I'm new to C# and have no knowledge how to implement this.
Luc Pattyn wrote: if you can figure out somehow that scrolling is still going on, you could
postpone the Form.Close() when ESC is pressed.
I have no knowledge how to dedect scrolling.
I set thread exception handler in startup like
public static void Main() {<br />
Application.ThreadException +=<br />
new System.Threading.ThreadExceptionEventHandler(App_ThreadException);
How to ignore thread error when esc is pressed ?
I think it must be possbile to ignore error message caused by pressing esc.
However, how to store error message handling ?
Should I use timer or is there simpler way ?
Maybe, just maybe, it is sufficient to do an Application.DoEvents() before
calling Close(), but I am not sure at all this will work.
I tried code:
protected override void OnKeyDown(KeyEventArgs e) {<br />
if (e.KeyCode == Keys.Escape) {<br />
Application.DoEvents();<br />
FindForm().Close();<br />
} else<br />
base.OnKeyDown(e);<br />
}
but thread error still occurs.
I can reproduce this error on 2.66 MHZ core duo also when I hold down mouse button and press Esc in scroll time. So improving scrolling speed does not help.
Andrus
|
|
|
|
|
Hello!!! I was woundering how to get a pixel value from Bitmap ?
If i'm using GetPixel().ToArb - it returns a nearest color.
How can i convert my picture to Black-and-White, and how can i get ammount of blackness?
(Or if you know how to convert a color of Colored image to double?)
Thanks.
One nation - underground
|
|
|
|
|
Saikek wrote: Hello!!! I was woundering how to get a pixel value from Bitmap ?
If i'm using GetPixel().ToArb - it returns a nearest color.
GetPixel will return the exact color, what do you think it will give ?
Saikek wrote: How can i convert my picture to Black-and-White, and how can i get ammount of blackness?
My image processing articles will show the most common way to create greyscale. Once you do that, it's easy to set a threshold and convert to 1 bit.
Saikek wrote: (Or if you know how to convert a color of Colored image to double?)
Colors are only represented as double in HDR systems, which means never on the PC. Your RGB value represents the exact color information being used to display your image. Even then, a single double value cannot represent a color, there is no linear scale of all colors, they are always a combination of 3 values, be it RGB, or HSL, or whatever.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello everyone,
I have a DVD Playback Windows Application and I would like to add right-click functionality once the user click on the Video Render Area.
Can someone be kind enough to tell me how this can be done?
Initially I add a Panel to my Windows Application and the DVD rendering was set to display in that area. Everything regarding the ContextMenu (Right-Click Menu) works fine, but once the move is played I lose the ContextMenu.
I have realised if I render the DVD playback image into the entire Form everything works fine. But I get this problem as soon as I try to place the DVD Playback image into the panel.
I simply don't wish to have the DVD Playback covering my entire Form since I have other stuff in it and the DVD Playback is only portion of the application.
Thank you for your help and have a great weekend.
Khoramdin
-- modified at 16:37 Sunday 15th April, 2007
|
|
|
|
|
You can either try listening for WM_MouseDown in the WndProc override, or you can set a mouse hook. For the latter, look up SetWindowsHookEx.
|
|
|
|
|
hellow ..
i am trying to read data from the server ...
i use DataReader ..
but when i try to pick the date to the Date Control i have many problems ...
i try myReader.GetValue() and i try myReader.GetDateTime()
but i can't i always get error message that the data is wrong !
any help appreciated ..
|
|
|
|
|
The data is wrong. What else can we say ? We need to see your code, and see the data you're pulling in, for us to tell you what's wrong with it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello! I'm having a lot of problem using the WebBrowser in VS2005. Surfing the web, I learnt that this component is only a wrapper of the active-x component of Internet Explorer. Is impossibile to use this in multithead applications.
I listened that the reason is because each instance of WebBrowser refers to the same object and it could process one request at time (single-thread use only).
I have a form called "formA" that is my main form and another form, called "formB"that is the form wh0o contains the WebBrowser . When a particular event occurs in my app(formA) I need that a new formB is launched (shown) in a new thread,more than once.
Instead of multiple formB I see only once of all, and i see the new one only when I close the previous one.
Ex:
<br />
public void FormA_custom_event(){<br />
Form B=new FormB();<br />
Thead t=new Thread(new ThreadStart(B._ShowDialog));<br />
t1.Start();<br />
}<br />
[...].br />
<br />
<br />
public void _ShowDialog(){<br />
this.ShowDialog();<br />
<br />
}<br />
I apoligize for my bad english but I'm Italian ;Pand my english is really poor. I hope that someone can help me because I'm gettin crazy... Thanx for any reply.;)
|
|
|
|
|
Hi,
the WebBrowser documentation states:
The WebBrowser control is resource-intensive. Be sure to call the Dispose method when you
are finished using the control to ensure that all resources are released in a timely
fashion. You must call the Dispose method on the same thread that attached the events,
which should always be the message or user-interface (UI) thread.
So you should not create additional threads for this. Instead, create as many forms as
you want, keep them alive (e.g. by adding them to an ArrayList), and use Show()
instead of ShowDialog(). The forms will remain open until you Close() them (after
which you should remove them from the ArrayList, so they can be garbage collected).
|
|
|
|
|
Sorry,but I need multiple istances of my form that running of different threads.
My application should be a client-server chat. My client application has 2 threads: one to send message and the other one to receive messege. Anytime my application receive a message from a user a new form(formB) must appear if the conversation window for that determinated user is not already opened... and if I lunch the new conversation form from the same thread that execute the receive routine, the application goes into a busy state and I have to close the program. I hope you have understood me...
|
|
|
|
|
Sure, but you cant put a WebBrowser on those forms that are running on another thread...
|
|
|
|
|
i found a really simple solution that seems working..I've used another thread that checks the boolean value of a var.If true launch new form. When I have to launch my instances of form containing WebBrowser component I change the value of the boolean and it works... Thanx to all the people tryed helpin' me...;)
|
|
|
|
|
I have WinForms MDI application.
MDI child forms are created by menustrip click enent handler
AppDesktop.FormMgr.Show(new ChildForm1("param1", "param2") );
Every MDI child form "childform1" may have separate class with different name and different number of parameters.
When application in opened, last MDI child form must be opened automatically.
I think I must store last opened form name to isolated storage and call
AppDesktop.FormMgr.Show(new LastOpenedForm(lastParam1, lastParam2) );
Reflection should probably used to make this call.
Any sample code or idea to implement this ?
Andrus
|
|
|
|
|
You don't need reflection, you just need to store the state of your form somewhere, and use that data to recreate it. It depends entirely on what the form could be, as to what yuo need to store.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you.
My forms contain data bound DataGridView.
My form restores its state when is opened.
Only thing i need is to create last form at starup.
Any idea how to implement this ?
Andrus
|
|
|
|
|
It seems likely to me that what you need to do then is store your data source, so you can rebuild the form with the same data.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have code in Load event which restores form data, position etc. This is OK.
My question was about creating this form at application startup: How to store form name and parameters and most importan, how to use this to re-create form creation command.
I have different classes for every form so I know the form name only as string at startup.
There are hundreds of forms and it is difficult to use switch statement to invoke form my its name.
I need to create form whose name is given as string.
Andrus
|
|
|
|
|
OK, I didn't realise you had hundreds of form types in your app, isn't that a little unusual/confusing ?
In that case, your options are a switch statement, or making sure that each form type has a constructor that will build to what you want, then you may be able to use reflection to invoke a constructor with the parameters you have stored.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: you had hundreds of form types in your app, isn't that a little unusual/confusing
Thank you for excellent question. I'm converting existing ERP application to C#. It has forms for customer, invoice, item, payment term, order, offer etc. etc. database contains 500 tables.
I think that this is very common.
I think I can add some code to form base class constructor for this which stores child form name in isolated storage.
Switch statement is too big for this and so it is ugly.
Based on your responses I think about the following approach:
1. Retrieve actual calling class name from base class constructor and store it in isolated storage (application can be run form web browser also).
2. At startup retrieve form name and create mdi child from it using reflection.
I'm new to C#. Where to find any sample code for this?
Andrus
|
|
|
|
|
Hey,
I am looking for an already written C# class that implements a C# Async Socket.
Can anyone assist?
Thanks in advance!
Snapple.
|
|
|
|
|
Look up "Socket Class" in your help. More specifically look at the begin[name] and end[name] methods. The examples given are usually pretty good and give a good idea of how to use them. If you don't feel comfortable with that, then look up the articles on this site with the search text as "Asynchronous Sockets".
If you would like to see a class that implements a client asynchronous connection completely, I do have a complete one.
Phil
|
|
|
|
|
If you can, i'd like to see the example you have please.
I know all about the Socket class and I wrote a class that represent an Async Socket, but i'm having some issues with it, so i'd like to try a ready one to see if the problem is in my socket class or program as a whole.
|
|
|
|
|
Please send me an e-mail to which I can send the code directly.
Phil
|
|
|
|
|
let say i have a panel, and in that panel i loaded an image:
panel.BackgroundImage = Image.FromFile("image.gif");
Now, i what to make drag & drop with this panel and i want to obtain the name of the image. How can i solve this? When i make the drag & drop operation, can i obtain both the image, and the name of the image? how?
|
|
|
|