|
int nFoo = 0;
string strFoo = myTextBox.Text.Trim();
if (strFoo.Equals (String.Empty)) {
<code>
...
} else {
try {
nFoo = int.Parse (strFoo);
} catch (Exception) {
<code>
...
}
}
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
hey ravi thanks for your quick response,
I'm still having the same problem, when i run the code, it always do the try and catch first with leaves me with only one error message<invalid data="" entered="">
if I leave the textBox empty the program just bomb on me !!!!???
aPerfectTool
|
|
|
|
|
aPerfectCircle wrote: the program just bomb on me
I'm not sure I understand. Please post your button's click handler code.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
hey Ravi I just got it working thanks for your help
aPerfectTool
|
|
|
|
|
|
Hi,
I need to start a process and wait for it. I have tired several things, but it keeps locking the originating program up while the other process is running and wont even refresh. I would like it to behave like normal but just wait and not allow the user to do anything...pause but still refresh when you drag a window over it. The code for the most part is right out of the MSDN.
This is the code I have right now:
const int ERROR_FILE_NOT_FOUND =2;
const int ERROR_ACCESS_DENIED = 5;
Process myProcess = new Process();
try
{
myProcess.StartInfo.FileName = Application.StartupPath + "\\" + ProgramName;
myProcess.StartInfo.UseShellExecute = true;
myProcess.Start();
myProcess.WaitForExit();
}
catch (Win32Exception e)
{
if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
MessageBox.Show("Install file can not be located.");
}
else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
{
MessageBox.Show(ee.Message +
". You do not have permission to run this file.");
}
}
Sean
|
|
|
|
|
I expect the call to WaitForExit() causes the caller to block?
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Yes it does, but I need it to. I need the main program to wait to the called program exits before it can go on. But the things I have tried break the main program's ability to refresh, resize, minimize, maximize, etc... I don't want it to look like it is not responding I just want it to wait patiently and behave.
Sean
|
|
|
|
|
WaitForExit is a blocking call, so if you call this method on the UI thread, it'll stop you from repainting the form. Sooo, you don't call it.
What you can do is set the new Process' EnableRaisingEvents property to True. Now, when the Process exits, it'll fire a Exited event which your app can subscribe to.
But, before(!) you start the process, disable all the user controls you don't want the user to play with while this process is running. In your Exited event handler, you can re-enable all the controls.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 18:13 Friday 6th January, 2006
|
|
|
|
|
Ah, OK thanks. That makes sense. Is there a way to disable all the controls? Well except for the main windows things mentioned above, resize, minimize, etc... I am sure there is, never mind, I will go look it up. Thanks for getting me that far though.
Sean
|
|
|
|
|
foreach (Control c in this.Controls) {
c.Enabled = false;
} /ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Hi.
I write a program that have a database(Access) and is using crystal report.
How can I make a setup for it?
My question is more about Access databaes and crystal report.
(C#,VS2003)
Best wishes
|
|
|
|
|
|
Hi. I am a new beginner in C#. If a C# project is started with a normal Windows application template rather than a SmartDevices template, is there anyway to change it afterwards?
Thanks, Pedro
|
|
|
|
|
Not easily. The best bet would be to create a SmartDevices project and copy over the files that you need
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/[^]
|
|
|
|
|
I am trying to set the back color of indavidual charachters in a RichTextBox by using SendMessage()
and the charformat2 structure. This works setting the forecolor of the charachters, but the back color will not work. I know that my version of RichEdit supports backcolors because they will show up if I paste, just not with the code. I thought that maybe it was assigning the wrong size to cbSize, but I dont know why it would do that. I am missing something very simple here im sure. I have tried this with the API call and have the same result. The message returns a non zero value, meaning it was successful, but the RichTextBox doesnt reflect that.
...
private const int CFM_BACKCOLOR=0x4000000;
.....
CHARFORMAT2 cf2=new CHARFORMAT2();
cf2.dwMask=CFM_BACKCOLOR;
cf2.cbSize=Marshal.SizeOf(cf2);
cf2.crBackColor=ColorTranslator.ToWin32(Color.Red);
IntPtr lParam=Marshal.AllocCoTaskMem(Marshal.SizeOf(cf2));
Marshal.StructureToPtr(cf2, lParam, false);
Message msg=Message.Create(this.Handle, EM_SETCHARFORMAT, (IntPtr)SCF_SELECTION, lParam);
DefWndProc(ref msg);
Marshal.FreeCoTaskMem(lParam);
Thanks!
|
|
|
|
|
You'll also have to clear the CFE_AUTOBACKCOLOR flag or your background color will be ignored.
Regards,
mav
|
|
|
|
|
Do you mean to set dwEffects=0? I tried that before I posted and nothing. If that isnt what you meant could you elaborate? Thanks!
|
|
|
|
|
You have to set dwMask to CFM_BACKCOLOR|CFM_COLOR and be sure NOT to set CFE_AUTOBACKCOLOR in dwEffects.
Here's the description of the flags you can use:
CHARFORMAT2 struct on MSDN[^]
Regards,
mav
|
|
|
|
|
I tried all of that before I posted, and tried it again after you posted, and still, nothing. I tried dwEffects=0, dwEffects=CFE_PROTECTED, not setting dwEffects, etc. Nothing has worked. Like I said, the call to DefWndProc is returning a non zero value, so it is working, just not how I want it to. There has to be something I am missing somewhere... I am going to list all my constants, structure, etc, and perhaps someone can figure out what is going on. FYI, I have also tried the API call and it does the same thing.
[StructLayout(LayoutKind.Sequential)]
private struct CHARFORMAT2
{
public int cbSize;
public int dwMask;
public int dwEffects;
public int yHeight;
public int yOffset;
public int crTextColor;
public byte bCharSet;
public byte bPitchAndFamily;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string szFaceName;
public int wWeight;
public int sSpacing;
public int crBackColor;
public int lcid;
public int dwReserved;
public int sStyle;
public int wKerning;
public byte bUnderlineType;
public byte bAnimation;
public byte bRevAuthor;
public byte bReserved1;
}//struct charformat2
//constants
EM_SETCHARFORMAT=0x444;
CFM_BACKCOLOR=0x4000000;
CFM_COLOR=0x40000000;
SCF_SELECTION=0x1;
//Call to format, tried CFM_BACKCOLOR and CFM_BACKCOLOR|CFM_COLOR, etc,
// only forecolor changes
CHARFORMAT2 cf2=new CHARFORMAT2();
cf2.dwMask=CFM_BACKCOLOR;
cf2.cbSize=Marshal.SizeOf(cf2);
cf2.crBackColor=ColorTranslator.ToWin32(Color.Red);
IntPtr lParam=Marshal.AllocCoTaskMem(Marshal.SizeOf(cf2));
Marshal.StructureToPtr(cf2, lParam, false);
Message msg=Message.Create(this.Handle, EM_SETCHARFORMAT, (IntPtr)SCF_SELECTION, lParam);
DefWndProc(ref msg);
Marshal.FreeCoTaskMem(lParam);
|
|
|
|
|
I have 3 docking panel controls in a form.
Left Dock is a toolbox.
Center Dock has 2 children, one child is another panel with a bitmap on it. And the other is a panel for displaying a bitmap font for a corresponding KeyPress value.
Right Dock Panel has a textbox child.
When I use the Center.KeyPress mapped it a function it works correctly and types out the appropriate font, but if I click on the other child within the Center Dock, The Center dock(parent) loses focus and the KeyPress event is not firing.
I tried several things to regain focus: like overriding several functions to force Center.Focus() so the input would still type out. I am at a total loss on what to do now. The only way the KeyPress works again is if I click OUT of the Center Dock and then click back in.
Any suggestions would be great.
|
|
|
|
|
You could try mapping the child controls KeyPress event to the Center Dock's KeyPress event so if a key is pressed on the child control the code in your Center Dock's KeyPress event handler will be called.
- Aaron
|
|
|
|
|
Is it possible to create an abstract class with multiple constructors, and the constructor that is called is control by the class that inherits from it?
As an example, I have these two classes:
public abstract class MyAbs
{
protected MyAbs(){}
protected MyAbs(string foo){}
}
}
public sealed class Something : MyAbs
{
public Something(){}
public Something(string foo){}
}
If an instance of the "Something" class is created using the constructor that takes a string parameter I would like to constructor the base "MyAbs" class using that value. Is this possible?
|
|
|
|
|
public Something( string foo ) : base( foo ) {}
|
|
|
|
|
Thanks for the reply it works exactly as I needed
Whilst on this subject is it possible to construct the abstract class with a string that is created within the "Something" class constructor?
|
|
|
|