|
How to check whether there are number or character at string only.
|
|
|
|
|
string str = "abcd1234";
for(int i = 0 ; i < str.Length ; i++)
if(str[i] < 58 && str[i]> 48)
{
....
}
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
I am trying to use this WMI class (correct term) to extract a list of users and the groups they are members of. Not completely sure how to do this, the ManagementObject returns two fields called Name, one the user name and one the group name, and when I try to print out both my app throws an exception.
|
|
|
|
|
|
I am trying to load a window form from a console App. I inlcude System.Windows and System.Windows.Forms in my project but when I try to load the form by doing
Form abc = new Form(params)
abc.Show()
it doesn't load i.e. it doesn't pop up.
Interestingly if I add a MessageBox.Show statement the form loads.
Would like to know what's going on here.
|
|
|
|
|
Gumnaam wrote:
Form abc = new Form(params)
abc.Show()
The following works for me:
using System;
using System.Windows.Forms;
public class test
{
public test(){}
public class nick : System.Windows.Forms.Form
{
public nick(){}
}
public static void Main(string[] args)
{
test t= new test();
nick n = new nick();
n.ShowDialog();
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
try something like this instead
SomeForm form = new SomeForm();
form.ShowDialog();
the code above returns a DialogResult but you dont need to necessarily get that value unless you want something back from the user
regardless of this - why would you be adding gui elements to a console application to begin with - you might want to create a Windows Forms Application instead..
Danny!
|
|
|
|
|
I am writing a DLL in VC++ that needs to be called by one of our customers who use C#.
Unlike my VC++ test application, which statically links the DLL to the EXE and creates the object upon startup, the C# application appears to load the DLL at runtime at the first reference to a DLL call (using the import keyword).
THe problem is that subsequent calls to other functions do not work. It seems that there needs to be some pause for the load to happen.
Has anyone encountered a similar problem?
Ed Hopkins
|
|
|
|
|
Ed Hopkins wrote:
THe problem is that subsequent calls to other functions do not work. It seems that there needs to be some pause for the load to happen.
Does the first function call always work? Have you tried calling different functions the first time to see if there is a problem? If your dll that you are writing in C++ is based on COM I would hightly recommend you read through information on Runtime Callable Wrappers[^] on MSDN.
- Nick Parker My Blog | My Articles
|
|
|
|
|
It's not quite that simple ... it works A-OK from the VC++ demo app. It's NOT written in COM just a standard Win32 MFC DLL written in VC++.
The timing appears to be due to the finite # of milliseconds it takes for the DLL objects to get created. They are not ready yet, and a subsequent call returns an error since it is pointing to things that are not yet created. Quite strange.
Ed
|
|
|
|
|
Hmm, seems to me I've heard MFC doesn't
play nice with other frameworks. And
.NET is a framework. I've run into some
strangeness with MFC. I remember I was
experimenting with forms in DLLs and had
one done in Delphi that I launched from
a VC++ 6.0 MFC app using a worker thread.
No matter what I did when I closed the
DLL form, I got an exception. However
if I displayed a messagebox in the VC++
app after closing the form, I never got
an error. I chalked it up to Delphi
having a VCL and MFC not being at the
root of all the GUI stuff, but who knows?
Of course the Delphi DLL form worked fine
with every other app I used to launch it,
such as Delphi and VB 6.0. Go figure.
|
|
|
|
|
Well if implemented correctly MFC is capable of being accessed by other types of compilers ... that in itself is not the issue. The issue is that the way that C# loads DLL's is a bit strange coming from C++ ... I suspect VB does it the same way, I've developed a hacky workaround but it would be nice to know from a real C# expert why this is happening. In fact, forget I even mentioned MFC if you do it with a Win32 (or a Delphi) DLL it will load the same way. I did a little Delphi work myself at one point.
Ed
|
|
|
|
|
Did you try searching knowlegebase for a bug
report? You can't be the only one seeing
DLL load lag if that's what's happening.
|
|
|
|
|
Can I use java classes in my .C# program?
I want to use org.xml.sax mosty... Are they stored in DLLs???
Where are they?
/\ |_ E X E GG
|
|
|
|
|
eggie5 wrote:
I want to use org.xml.sax mosty... Are they stored in DLLs???
You want to use the SAX parser? Take a look at what is provided in the .NET Framework, there is all kinds of classes that provide XML support. Are you looking for some interop between Java and .NET? Look in the System.Xml namespace (System.Xml.dll).
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi,
searched around but couldn't find anything. Almost unbelievable. I think these must be common questions. I'd like to display the files in a given folder within a ListView. Various don't-knows:
1. How to I retrieve the associated icon for a given file?
2. How do I retrieve the file type (on my german OS, the win-explorer writes "Microsoft Word-Dokument" when selecting 'bla.doc'.)
3. How do I launch the file in it's associated application. I know I can start any application using Process.Start(). But is that the way of doing it properly (by attaching the documents file name as a commandline parameter?)
Just need a starting point.
Thanks a ton!
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
Matthias Steinbart wrote:
How to I retrieve the associated icon for a given file?
This is done through P/Invoke, here is an example:
[StructLayout(LayoutKind.Sequential)]
public struct SHFILEINFO
{
public IntPtr hIcon;
public IntPtr iIcon;
public uint dwAttributes;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szDisplayName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
public string szTypeName;
};
public const uint SHGFI_ICON = 0x100;
public const uint SHGFI_LARGEICON = 0x0;
public const uint SHGFI_SMALLICON = 0x1;
[DllImport("shell32.dll")]
public static extern IntPtr SHGetFileInfo(string pszPath,
uint dwFileAttributes,
ref SHFILEINFO psfi,
uint cbSizeFileInfo,
uint uFlags);
string file = @"C:\dir\blah.doc";
IntPtr hImg = SHGetFileInfo(file , 0, ref shinfo,
(uint)Marshal.SizeOf(shinfo),
Win32.SHGFI_ICON |
Win32.SHGFI_SMALLICON);
Icon i = Icon.FromHandle(hImg);
Might I ask, are you trying to recreate the Windows Explorer?
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi Nick,
thanks for your reply which I haven't tested yet but seems to solve one of my problems. And by all means, you surely might ask:
I'm not trying to recreate the windows explorer. I'm building a database app, which, among other useful things stores pointers to directories associated with specific elements of the application. The contents of those directories (image files of various kinds) must be listed within the application. Each of the files must be displayed with it's associated icon (hopefully solved now), it's name, dates and size (no prob here) and it's description (like "Microsoft Word Document") which still needs to be done. I'm writing a usercontrol for this and think about posting it here once finished.
Thanks for your help!
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
Matthias Steinbart wrote:
3. How do I launch the file in it's associated application. I know I can start any application using Process.Start().
You do the same for the document file, but don't include the application's execute and putting your document path as a command line parameter. It's actually NOT the right way to do it... Setup your Process object as usuall, but set its UseShellExecute property to true . This will launch the document with the registered application and use the correct command line options, if any.
Process myNewProcess = new Process();
myNewProcess.StartInfo.FileName = "myWordDoc.doc";
myNewProcess.StartInfo.UseShellExecute = true;
myNewProcess.Start();
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
My problem is the following:
I'd like to make my standard Form completely transparent. To do that I set TransparencyKey property to BackColor:
private void Form1_Load(object sender, System.EventArgs e)
{
this.TransparencyKey = this.BackColor;
}
This way the form in fact becomes transparent, but when it is shown, there is a short black flicker until the background gets transparent. A way I figuered out to get rid of that is to set the BackColor to pure black, too:
this.BackColor = Color.Black;
But this is no satisfying solution. To figure out what was going on I replaced the OnPaintBackground function with my own one, which simply does nothing:
protected override void OnPaintBackground(PaintEventArgs e)
{
//empty
}
The result is a black background. This background doesn't appear when BackColor is set to black as mentioned above. Does this happen on your machines, too? If this is a generic malfuncion: How can I circumvent this for any Color?
Thanks,
3Dizard
btw: I'm using visual studio .net 2002 on Windows XP SP1
|
|
|
|
|
3Dizard wrote:
I'd like to make my standard Form completely transparent
Have you tried changing the Opacity level to 0?
- Nick Parker My Blog | My Articles
|
|
|
|
|
I think he's actually trying to make the form background itself transparent without making the controls on the form transparent.
"A people that values its privileges above its principles soon loses both." -- Dwight D. Eisenhower
|
|
|
|
|
That's right! I just want the background to be transparent. So, does this black flicker just happen to me or can someone reproduce it with, as mentioned in my initiating posting, just setting the TransparencyKey to BackColor, or does everything work right for you?
|
|
|
|
|
Please tell me about how can i use TAPI 3.X in managed codes or C#. I want to make a project like PABX which route, record and dial calls and persist on hard disk.
Please send me sample code, articles or book names etc.
Thanks You
Zeeshan
|
|
|
|
|
Zeeshan Gulzar wrote:
Please tell me about how can i use TAPI 3.X in managed codes or C#.
There may be problems using TAPI 3, however there is a sample for using TAPI 2 in C# on GotDotNet here[^].
- Nick Parker My Blog | My Articles
|
|
|
|