|
you need to read on msdn for this command
Word.Find fnd = ThisApplication.Selection.Find;
|
|
|
|
|
Hi,
Using V2005;
One of the first methods I run is checking the existance of essential files - particularly in my case the database file. If it doesn't exist I pop up a message box alerting the user and then when they click OK the program should exit ie:
private void startupCheck()<br />
{<br />
bool dataBaseExists;<br />
dataBaseExists = File.Exists(@".\Resources\myclub.mdb");<br />
if (dataBaseExists == false)<br />
{<br />
MessageBox.Show("The database file is missing from the Resource Directory.\nPlease install database file and start program again", "WARNING - CRUCIAL FILE MISSING", MessageBoxButtons.OK, MessageBoxIcon.Stop);<br />
exitProgram;<br />
}<br />
}
Problem is that program flow returns to program.cs and then crashes. User is then given the option to debug etc.
How can I get the program to gracefully exit and not leave the user panicing?
Glen Harvy
|
|
|
|
|
What is exitProgram? Call Application.Exit after the MessageBox
only two letters away from being an asset
|
|
|
|
|
Glen Harvy wrote: and then crashes
What does that mean exactly? Are you getting any exception?
When do you call startupCheck?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks for your response:
Stefan Troschütz wrote:
What does that mean exactly? Are you getting any exception?
After the program makes the test and exits (see below) I get ->
The error is:
Microsoft .Net Framework
Unhandled Exception has occured in your application ...
Could not find file ......
I then click Quit and get a further message saying that "Program has encountered a problem and needs to close ....
Stefan Troschütz wrote: When do you call startupCheck?
program.cs contains
static void Main()<br />
{<br />
Application.EnableVisualStyles();<br />
Application.SetCompatibleTextRenderingDefault(false);<br />
Application.Run(new MainForm());<br />
^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br />
When debugging this is where the debugger goes after the call to Application.Exit()<br />
<br />
}
and MainForm.cs contains (in part) ->
bool startupCheckValue = true;<br />
startupCheckValue = startupCheck();<br />
if (startupCheckValue == false)<br />
{<br />
Application.Exit();<br />
}
and ..
private bool startupCheck()<br />
{<br />
bool dataBaseExists;<br />
dataBaseExists = File.Exists(@".\Resources\myclub.mdb");<br />
if (dataBaseExists == false)<br />
{<br />
MessageBox.Show("The database file is missing from the Resource Directory.\nPlease install database file and start program again", "WARNING - CRUCIAL FILE MISSING", MessageBoxButtons.OK, MessageBoxIcon.Stop);<br />
return false;<br />
}<br />
return true; <br />
}
I've changed the code a bit as a result of the other suggestions made (and well appreciated I might add ) but my original problem still exists .
I think the Application.Exit() is being called at the wrong place however I don't see where else it would go as it's imediately before where the program will spit the dummy anyhow because of the missing file.
Regards,
Glen Harvy
|
|
|
|
|
Glen Harvy wrote: I think the Application.Exit() is being called at the wrong place
Think so to, but unfortunately your post doesn't at which point of the creation process of your MainForm you do the startupcheck. Try putting it into an event handler of the Load event. I think inside the constructor Application.Exit has no effect or crashes the application respectively, as the call to Application.Run hasn't finished or more precisely wasn't yet made. Alternatively you could also make the startup check inside Program.cs:
static void Main()
{
if (!startupCheck())
return;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
change startupCheck to private bool startupCheck() and have it return true or false. If false never start the application message pump.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Thanks for your tip.
It is a much better way of programming and have taken your advice however the Application.Exit() still produces my same problem.
See my other response.
Regards,
Glen Harvy
|
|
|
|
|
Like Mark says, Application.Exit I think is the best way to go.
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Hi,
I have a requirement to implement WebServices Client in C# and WebServices Server in Java(webSphere). The application involves uploading attachments. Preliminary research suggest I use MTOM, but the webSphere app server I am going to be using does not support MTOM. I have to restrict my ideas towards either MIME or DIME. Please suggest best approach with the mentioned constraints...any sample code with the interop(C# <-> Java) would be appreciated.
Thanks in advance.
Cheers,
Sridhar.
sridhar
|
|
|
|
|
Hi,
I want to debug my SP in SQL server 2005 but i cant find the option for that, just like in SQL2000. Can someone tell me the way i can do that?
Help please,
ankit
|
|
|
|
|
Hi
I have an external dll (to which I have the source) that contains this function:
void DoIteration(float *xarray
,float*yarray,const int*array)
I know that I can call this function with dll import, but how can I create these arrays and pass a pointer? These arrays are large so it would be impractical to have to pass them every call.
Thank you for your help
John
|
|
|
|
|
Hi,
In C# you do not need to pass the pointer to the array. Your DLL Import line should look like:
<br />
[DLLImport("x.dll")]<br />
public extern void DoIteration(float[] xarray,float[] yarray,const int[] array);<br />
Do your best to be the best
|
|
|
|
|
|
Hope I am not asking the question at wrong place.
I have used CrystalReportViewer in Windows application.
I have a report wich has a SubReport inside it.
The report works well for few pages but when is exceeds 50 pages it becomes painfully slow.
And I suppose it is slow while rendering. Does anybody has any idea what I might be doing wrong.
Or is there any way to optimize its performance?
Thanks.
Every bit counts ADD
|
|
|
|
|
Guys what is the formula for the average brightness of and image and also the formula for the contrast of an image.
tony-yeyo
|
|
|
|
|
The average brightness of the image would be the average of the brightness of each pixel in the image. Add them all together and divide by the number of pixels.
The contrast is the difference between the lowest and highest brightness in the image.
---
b { font-weight: normal; }
|
|
|
|
|
Hi.
Im doing a VirtualListView using 1 ListView, 1 VScrollBar and 1 HScrollBar.
Where im just adding items that can actually be showed. This so it goes way much faster and has much less flicker when adding 58000 items one by one. (Has to be done this way as there is no way to know how many items that should be added or when it is finished, reading items from stream).
My problem is not to Scroll down/up with VScrollBar but to scroll to see other columns with HScrollBar.
In picture below A and C is my VirtualListView and B is standard ListView from .net. As you can see my VirtualListView:s are not showing correct display area.
VirtualListView.png
How can this be done?
|
|
|
|
|
I am not sure I quite understood your question but if you have derived your listview from the standard .net listview, you can use the Autoscroll property of the listview. This would by itself display the correct area.
|
|
|
|
|
I have tried the following with no result.
Not even if i change
new Point(hScrollBar1.Value, listView1.AutoScrollOffset.Y);
to
new Point(250, 1);
How should it be done?
this = UserControll
listView1 = ListView
hScrollBar1 = HScrollBar
void hScrollBar1_ValueChanged(object sender, EventArgs e)
{
Console.WriteLine("listView1.AutoScrollOffset: " + listView1.AutoScrollOffset.ToString());
listView1.AutoScrollOffset = new Point(hScrollBar1.Value, listView1.AutoScrollOffset.Y);
this.ScrollControlIntoView(listView1);
Console.WriteLine("listView1.AutoScrollOffset: " + listView1.AutoScrollOffset.ToString());
}
|
|
|
|
|
|
Im writing this so if anyone else search for it they will find my solution.
I have done a walk around for this problem.
By using the inbuilt Scrollers and just having one VScrollBar over the region the default one should be. all works good. hope someone see this as usefull
|
|
|
|
|
hi all
My Doubt might be a simple one .... how can we display the message Box in the center of the parent window?? i am passing 'this' in the arguments ... still its displayed in the center of the screen , not in the center of the parent window ...
Can anybody suggest an idea??
Akhil
|
|
|
|
|
I dont think that this is possible.
But you could always do your own MessageBox with a Form.
Example:
<br />
Form f = new Form();<br />
f.Size = new Size(100, 100);<br />
f.StartPosition = FormStartPosition.CenterParent;<br />
f.ShowDialog();<br />
|
|
|
|
|
Hy,
My idea is this. Suppose you have a windows form named frmMain and the TextBox txtTest. At form load event place this code:
<br />
txtTest.Left = frmMain.ActiveForm.Width / 2 - txtTest.Width / 2;<br />
txtTest.Top = frmMain.ActiveForm.Height / 2 - txtTest.Height / 2;<br />
Also at design time set the Anchors of txtTest to Right and Down. It should work.
Do your best to be the best
|
|
|
|