|
Hi,
yeah this is simple but required most of time.
suppose i had made one class and i want to use the properties and method of that class into another class of another form but is there any common thing (like common class or place) by in which i can create the instance of that class for once and i got excess of the properties to every class any time?
regards
montu3377
|
|
|
|
|
Hi!
I have created a similar thread before and I was not able to find a possible solution. Here is the issue again.
I need someplace where I can filter all messages of the application (main form and all child forms). I have implemented message filters but somehow the child modal dialogs does not seem to have message filtered (there messages do not come into the filter).
|
|
|
|
|
MSDN link[^]
I'm sure someone has mentioned Application.AddMessageFilter Method. Its exactly what you need. The following example traps all left-button mouse activity:
#region IMessageFilter Members
public bool PreFilterMessage(ref Message m)
{
if (m.Msg >= 513 && m.Msg <= 515)
{
System.Diagnostics.Trace.WriteLine("Caught");
return true;
}
return false;
}
#endregion
If you have any problems post back.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
I tired that but this message filter does not seem to work on child dialogs (froms).
|
|
|
|
|
I have an app written in C# (obviously). Here is my dilemma:
The form loads, instantiates a bunch of worker threads that execute one at a
time. When one finishes, it starts the next one in line. I have about 5
datagrids on 5 different tab pages in a tab control. What I'm using the
Threads for is pretty basic: get data from a database and fill a datagrid. I
use delegates throughout to allow the worker thread to call the
'FillDataGrid' method in the main thread (the form thread). I've had
problems before with threads not accessing other threads controls which is
why I use the delegates. But still it crashes with the following:
An unhandled exception of type 'System.ArgumentException' occurred in
system.windows.forms.dll
Additional information: Controls created on one thread cannot be parented to
a control on a different thread.
I decided to add another tab page (out of pure imagination) as the first tab
page in the control. voila! now everything loads properly (without changing
any code whatsoever). Problem is, I try to programmatically remove the
temporary page (with a generic "please wait while loading" message). It
removes the page fine, but on the next page in line, all the controls
dissappear. If I don't change or remove tab pages programmatically, all the
controls stay intact. I'm not sure what I am missing, and leaving the temp
page intact is just ugly. Anybody know what I'm missing?
If you put a time limit on this project, it won't ever get finished . . .
|
|
|
|
|
I'm trying to use an ocx written in VB6 in my C# app and
when i try to show a form ("click a button") i get an error message
"run-time error 406 Non Modal Forms cannot be displayed ... "
what can be done if i need these forms Non Modal?
thanks
sharon
thanks
sharon
|
|
|
|
|
Personally I haven't worked much with this stuff, but from what I read I think that it might be a problem with how .net works with the ocx. Take a look at this article: http://support.microsoft.com/default.aspx?kbid=176468[^]
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Are you talking about a ASP.NET app ??. For example in ASP.NET you are executing the application in the context of a web application and you can only show WebForms..
Try compiling as exe
~Alexander Kent
|
|
|
|
|
No i'm talking about a windows app in c#
have any ideas ?
10x
sharon
thanks
sharon
|
|
|
|
|
does the .net framework have a class and constants for working with bits already defined or do i need to write my own
|
|
|
|
|
|
hello i am trying to move a form based on where the user clicks however it doesnt go where it supposed to ive tried 3 different ways and none work
here is what i have tried
this.Location = PointToScreen(MousePosition);
this.Location = PointToClient(MousePosition);
and
this.Location = MousePosition;
none of these work properly what am i doing wrong.
do i need to do anything to get MousePosition becuase im just using it im not initializing it
or anythning
can someone please give me tips
thanks
|
|
|
|
|
Please clarify what you are try to accomplish.
When the user clicks where?? Abitrary point on the screen? Inside your form?
Note your application cannot pick up mouse clicks outside the form.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
when the user clicks on the form. the form is in an mdi app
|
|
|
|
|
Once again just to confirm, have u tried like this:
Also note what Alex has mentioned: You can not pick the point outside the Form.
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.Location = PointToScreen(new Point(e.X, e.Y));
}
|
|
|
|
|
it still seems to offset the dialog like an inch below and to the right
|
|
|
|
|
It does not occur in my demo application. Please re-check and revert back.
|
|
|
|
|
this is the code i have
<br />
private void EditEmp_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
dragging = true;<br />
this.Dock = System.Windows.Forms.DockStyle.None;<br />
this.Location = PointToScreen(new Point(e.X, e.Y));<br />
}<br />
>/code><br />
<br />
and it doesnt move the dialog to where my mouse is
|
|
|
|
|
Do u want to drag the form using mouse in run-time, the way u do while holding title bar of the form?? Be very clear please...
|
|
|
|
|
yes i already am able to make the form move via the mouse move event and im using the same location logic and it still follows at a distance.. i think i may know why its doing this tho but i dont know the solution when the user click the form its using the forms mouse positon and not the parents how can i get the parents coordinates for the mouse when i click in a child form?
|
|
|
|
|
You would have told me before...I simply wasted my time. I know there will be offset in this logic, if u want to drag the form.
in mean time, try solving it at yr end.
I will try to work out and post the solution probably tomorrow......
|
|
|
|
|
Im not going to give you a code solution. Here is how you do it (psuedo-code straight from my head, hopefully no mistakes):
Point originalFormLocation;
Point originalMouseDownLocation;
bool state;
onMouseDown()
{
state = moving;
}
onMouseMove()
{
if (state = moving)
{
}
}
onMouseUp()
{
}
Note: you're always working with screen coordinates.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Yes..Alex...This will work perfect. I had implemented the same in my previous project. Only little bit of correction is required...You do not need to save the form's location in MouseDown (If I remember correctly..).
|
|
|
|
|
OK As long as you can get it to work.
I believe saving the original coordinate at begining is necessary to get error free moving. If you're not moving relative to the point where you start but you're doing something relative to the last time the mouse was moved you can get some big glitches.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Actually Previous MouseDown Location's coordinate is relative the the previous Form location,
And If you see with reference to the screen , The mouse down location saving should solve the purpose....
I will try to post the code tomorrow...
|
|
|
|