|
There are two ways to show forms: modal and nonmodal. Modal means that the form being displayed must be closed before any further execution. This is like when you close Notepad before saving and it asks you if you would like to save. You MUST answer the question (and close the form) before you can click on the main notepad form or continue doing anything else in Notepad. This also means that your code blocks until that form is closed. In other words, frm2.ShowDialog(this); doesnt execute until frm1 is closed. The second, nonmodal, does not have these restrictions and is simply a normal form.
In .NET, the Form class has two methods, Show() and ShowDialog(). Show corresponds to a nonmodal form, and ShowDialog() corresponds to a modal form. To fix your problem, simply use Show() instead of ShowDialog().
|
|
|
|
|
Since ShowDialog() is a blocking call that returns a value, you can only have one Dialog open at a time. If you want both forms to be open, and usable at the same time, you'll have to show both forms using their Show() method, not ShowDialog() .
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok I can see how Show instead of ShowDialog might work but I will add extra requirements.
Perhaps my requirements are that I want to ensure that frm1 is always above the main form. And also frm2 is always above frm1. Even if the main display is selected I do not want frm1 and frm2 to be lost behind the main form.
With a modal form this is the case but if it is modeless form then it looses that feature.
How do I get around it. I know this sounds silly but can I have a modal form that itseld creates a modal form? i.e. frm1 is modal based on the main form, and also frm2 is modal based on frm2?
Thanks,
Liam
|
|
|
|
|
Yes you can put a modal form on another (though in most cases it is not a correnct implementation)
In any way, is it necessary that frm1 will pop up and immediatly frm2 will pop up above it? or is frm2 dependent on an action in frm1 (which is a more likely option)?
If your case is the first case (i.e. frm1 should open an immediatly open frm2) - you should open frm2 from frm1's OnActivate method. just override it, call the base and open the frm2 using the ShowDialog method.
However, i recommend not doing so since it does not seem the right thing to do.
If you are using option 2 then there is no problem. When a certain event occurs in frm1 (such as button_click), simply open the frm2 and you will get a modal from on a modal form on your main form.
Good luck, hope this answers your question.
|
|
|
|
|
My exact situation is:-
Form1 is created from a button press on the main form.
Form2 is created on a timer event. When the timer elapes form1 may or may not be present. If not it should be created. If it is form2 is displayed.
But Form2 must always be at the top and main form always at the bottom. If I use modeless formas and select the main form then form1 and form2 are hidden - not what I want.
Thanks,
Liam
|
|
|
|
|
I didn't quite follow what the requirement is, but did you consider placing frm2 together with the main form in an MDI frame? This way they can remain open while still being non-modal. You can use docking on the MDI frame to dock the frm2 to the bottom and the set the main form to fill the rest of the screen.
Also if you can specify what are the roles of each form it might be easier to understand.
Good Luck!
|
|
|
|
|
I am drawing a polygon by drawing lines on mouseup. after closing the figure the two points are not behaving as one.
Where did i went wrong.
Any help
|
|
|
|
|
Begineer wrote:
after closing the figure the two points are not behaving as one
This is really vague. What do you mean by "not behaving as one"?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Sorry for not being able to explain my problem better.
I am drawing a polygon by positioning the mouse. when i choose the option close figure i am drawing a line from the current point to starting point.
After that it is not behaving as a closed figure. when i tried to drag i am able to drag two differnet lines on that last point.
Am i making sense.
|
|
|
|
|
Begineer wrote:
After that it is not behaving as a closed figure. when i tried to drag i am able to drag two differnet lines on that last point.
Try to drag what? One of the lines? Points? It sounds like your code isn't picking the correct points in your point array. Without seeing your drawing and dragging code, it's very difficult to say anything more.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Anyone know how to tell .NET to use another directory than /bin when it looks for referenced assemblies
I use "copy local" for all references ..... but want them to be copied into "bin/assemblies" for ex.
Anyone?
//Maw
|
|
|
|
|
Hello
You can try to use privatePath attribute. Look here[^].
With best regards,
Andrew
|
|
|
|
|
I'm currently working on a chart library project and encountered a conceptual problem touching interfaces, inheritance...
Facts first:
A so-called mapper class is responsible for mapping problem domain values to units (in terms of pixels). As there are different problem domains, there are different mapper classes, e.g.:
- MathMapper (numeric problem domain)
- TimeMapper (time domain)
- LabelMapper (non numeric domain)
This concept is implemented as follows. A interface called IMapper defines methods and properties all mappers have in common. (object globalMinimum, object globalMaximum, int minorUnitsPerMajorUnit, double pixelsPerUnit, double World2Unit(object obj)...).
Several interfaces are derived from IMapper to descripe specific mappers: IMathMapper, ITimeMapper, ILabelMapper. The derived interfaces define properties in terms of the problem domain:
- IMathMapper (double globalMinimum, globalMaximum...)
- ITimeMapper (TimeSpan globalMinimum, globalMaximum...)
...
This is the crucial factor: globalMinimum, globalMaximum... are defined in terms of the PROBLEM DOMAIN.
Classes implement the interfaces using explicit interface implementation thereby hiding the more general properties (object globalMinimum, object globalMaximum) and exposing the specific properties (double globalMinimum/TimeSpan globalMinimum...).
The properties mentioned so far should be known by the user (of the chart library) in advance. However for creating axes of dynamic range, the Maximum of a data series should be determined and stored in the mapper object (as MaxValue). Determing the maximum value is straightforward.
Given a series of data object[] dataSeries = new object[x] {12.9, 23.2, ...} the method World2Unit(object obj) of the underlying mapper object is invoked for each value, hence the maximum value can derived easily.
The challenge:
Problems arise when storing this maximum value in the mapper object. Currently this involves several type casts - not satisfying me. One has to distinguish between all possible mapper objects in order to store the value "problem domain dependent". Is there a way to avoid this discrimination? Sound solution needed!
Currently:
<br />
if (this.Mapper = MathMapper)<br />
{<br />
MathMapper math = (MathMapper) this.Mapper; <br />
math.MaxValue = (double) maximum; <br />
}<br />
else if (this.Mapper = TimeMapper)<br />
{<br />
TimeMapper time = (TimeMapper) this.Mapper; <br />
time.MaxValue = (TimeSpan) maximum; <br />
}<br />
else<br />
{<br />
each Mapper has to be listed.<br />
}
As it is my first major project and I'm not that experienced, could you please assist me in finding a better solution?
Thanks in advance!
Goebel
|
|
|
|
|
|
i wrote this code to create a marker file("TMP.txt) on another PC.
try
{
FileInfo TMPfile = new FileInfo(@"\\TERM1\\BOOTDRV\\TMP\\TMP.txt");
StreamWriter w = TMPfile.CreateText() ;
w.Close();
}
catch(Exception exp)
{
EventLog.WriteEntry(exp.Message);
}
Access to the path "\\Term1\\BOOTDRV\\TMP\\TMP.txt" is denied.
i wrote the same code in Windows Application and it's creating tmp.txt on term1.
*************
so with windows app i have access but not with windows services ?????
Please need help.
|
|
|
|
|
|
Windows Services, by default, run under the Local System account, which has no rights to any network resources on any machine. If you want your service to be able to get to a shared network resource, you'll have to change the account that the service runs under.
Right-click "My Computer" and click Manage. In the left pane of the MMC, expand Services and Applications. Click Services, then find your service in the right pane and double-click it. Click on the LogOn tab, then click on "This account". Type in the account name and password of an account that has permissions to the share you want the service to be able to get to, then click OK.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Can someone please tell me how to call a C/C++ function that is in a .c or .cpp file from C#?
|
|
|
|
|
Hello
If the function is written on C, you can create a DLL exporting this function. Than you can interop it in C# using DllImport .
With best regards,
Andrew
|
|
|
|
|
Thanks Andrew,
And the same if it's written in C++?
Can you please guide me to an article or so,so I can follow it step by step?I have never tried creating a C++ dll before?
Thanks and Best Regards,
E.A.
|
|
|
|
|
You can browse this[^] site for question about interoping API or other functions.
It's not simple to use C++ dll from C#. More of it, there is no approaches for it known to me.
If you have a C++ class you can try to use it with MC++ (Managed C++) using IJW (it just works) technology.
With best regards,
Andrew
-- modified at 7:44 Tuesday 13th September, 2005
|
|
|
|
|
Thanks for trying to help out.
I have heard about MC++ but I havent' heard about IJT. Does this mean that after using my class with MC++ that I can call it directly from .NET or what?
Best Regards,
E.A.
|
|
|
|
|
Oh, sorry me very much. It's called IJW - "it just works"
Look here[^] and here[^].
You can create a library on MC++ and use it from C# as any other .NET assembly.
With best regards,
Andrew
|
|
|
|
|
Thanks a lot Andrew,
Hope this might help me sort it out.
Best Regards,
E.A.
|
|
|
|
|
Anyone know how to access the scroll bars in a .NET TextBox control? I'm trapping the VScroll event which works fine except for when the user drags the scroll thumb, which for some reason doesn't fire the event. The only way I can think of is to trap the event at the ScrollBar level, but there doesn't appear to be a way to get hold of them programmatically.
TIA
Ian.
|
|
|
|