look at [Hooking the native API and controlling process creation on a system-wide basis](<a href=) [^]" rel="nofollow"> MCAD -- modified at 12:59 Wednesday 4th January, 2006
Mohamad Al Husseiny
Posts
-
Windows API(kernel) -
Determine if a thread has been instantiatedYou can write some thing like the following
if(t != null) { t.Start(); }
MCAD
-
Insert table into a RichTextBox -
How can I ?You need to handel
Command Line Arguments
in Your program So usepublic static void Main(string Args[])
Orstatic int Main(string[] Args)
instead of parameterslessMain
method look at Command-Line Arguments[^] you need to parse this arguments to handle more complex parameters an example for this can be found at C#/.NET Command Line Arguments Parser [^] MCAD -- modified at 20:59 Thursday 6th October, 2005 -
Is there collection object in C# .NET?Use
HashTable
look at HashTable Class[^] For more Info MCAD -
How to get an array of Pens in a user defined class to "work" in a WinForm?You wrote Anonymous wrote: Pen p = GetNextPen(); this will generate The name 'GetNextPen' does not exist in the class or namespace 'ComplexTest2.Form1' error because the compiler will think GetNextPen() member of Form and this not true because it is a member of complex2 and you didn't call it from an object of this class Anonymous wrote: Even if I try this: g.DrawLine(cmplxValue1.GetNextPen()....) the instantiated object doesn't "see" the method... please help thanks a lot.... are you replaced all places you call this function or gust this line? you need to replace all the places like
Pen p = GetNextPen();
too MCAD -- modified at 1:01 Thursday 6th October, 2005 -
Graph vertex edge weightslook at An Extensive Examination of Data Structures Part 5: From Trees to Graphs[^] and other parts MCAD
-
COM and COM+ in C#You Can Create COM+ Application in .Net By Create your dll and inherit your class from
ServicedComponent
and assign Your assembly and each of its classes with distinct GUID values by using theGuid
attribute if you don't give it guide value it in the following assembly registeration will assign one for each element But as you now Com+ undersatnd COM not .Net Component so to let other COM Client Find and Use your component you need to register your .Net Component as COM Server in Windows Registry This process called Asssembly Registration 1-sign a .NET assembly using the Strong Name tool (sn.exe). 2-Register your assembly You can do it by more than one way for example in your Project Properties change Register for COM Interop option to true or Use the Assembly Registration tool regasm.exe for more info look at Creating COM+ Objects using EnterpriseServices in .NET [^] COM/COM+[^] ServicedComponent Class[^] To Export your Component As COM Type Libraries You Can use the tools mentioned above but notice that you don not have to inhiret fromServicedComponent
ie 1-Create Your Component 2-Export it as Type Lib By Using one of the following tools *-In Project Properties Set Register for COM Interop option to true *- Use the Assembly Registration tool (regasm.exe
) with its/tlb
option *-Use the Type Library Exporter tool (tlbexp.exe
) MCAD -- modified at 14:52 Thursday 29th September, 2005 -
C# newbeeSo do you want IE to host your application or you want yor application to run IE? I think you mean the first so suggest to use web app can you give more details? MCAD
-
C# newbeewhy not create asp.net application instead of windows forms app MCAD
-
Which is efficient? "" or string.Empty ?May be this helpString.Empty vs "" [^] MCAD
-
How to reach an object that dont have namethe m object not accessable outside button1_Click at all even if they have separate name because its scope so you need to store them like other response suggest and access them later by index or by key depending on the collection type MCAD
-
draw inside an abjectAt general to customize the drawing of control you drive your class from it and override
OnPaint
but not al controls easy for customization like others to look at code do what you want look at Tile a Bitmap Into a TextBox Background[^] it is in VB6 but you can get some ideas from it MCAD -
Use of java script in asp.net pagesThere are many ways you can use Javascript in your asp.net ASP.Net come with some validation of controls did you looked to them if no one of them have what you need you can use
CustomValidator
control and write your javascript for validating the control for example look at Allowing Only Numbers in ASP. NET TextBoxes[^] If You want to call JavaScript code when you click Button for example you can write somthing likeButton1.Attributes.Add("onClick","DoIt();");
this allowed DoIt script function to be called when the user click theButton
or write the code directly likeButton1.Attributes.Add("onClick","alert('Test Test');");
MCAD -- modified at 21:30 Friday 23rd September, 2005 -
Listing Database NamesSqlServer have
sp_databases
Stored Procedure which list databases available in the server instance you can write somthing likeprivate void ListDatabases_Click(object sender, System.EventArgs e) { using(SqlConnection cn=new SqlConnection("Server=localhost;Initial Catalog=master;Integrated Security=SSPI;")) { cn.Open(); SqlCommand cmd=new SqlCommand("sp_databases",cn); cmd.CommandType=CommandType.StoredProcedure; SqlDataReader dr=cmd.ExecuteReader(); while(dr.Read()) { Debug.WriteLine(dr.GetString(0)); } dr.Close(); cmd.Dispose(); } }
MCAD -- modified at 21:43 Friday 23rd September, 2005
-
C# Sucks!To Browse for files use
OpenFileDialog
you will find it in the toolbox after that ypu can write some thing likeopenFileDialog1.InitialDirectory = "c:\\" ; openFileDialog1.Filter = "CSharp files (*.cs)|*.cs" ; if (openFileDialog1.ShowDialog() == DialogResult.OK) { // do your work here //OpenFileDialog have properties and method that wil let yo work with file like get file name,opern it..etc } For More info look at OpenFileDialog Class[^]
If you really missed Windows API Function that you did not find counterpart in .Net You can use it By using P/Invoke which let you call function in traditional dll look for Using P/Invoke to Access Win32 APIs[^] MCAD
-
What message is called when the X in the upper right of a dialog is closedThe Windows recive
WM_SYSCOMMAND
Notification when you close minimize or maximize the window or you choose any command from the system menu So overrid your formWndProc
function and handle itconst int WM_SYSCOMMAND = 0x0112; const int SC_CLOSE = 0xF060;
protected override void WndProc(ref Message m)
{
if(m.Msg==WM_SYSCOMMAND)
{
if(m.WParam.ToInt32()==SC_CLOSE)
{
MessageBox.Show("Application will be close");
// call the default after you handle it
base.WndProc(ref m);
}
}
else
{
base.WndProc (ref m);
}
}if you don not handle other Message you can write it like
protected override void WndProc(ref Message m)
{
if(m.Msg==WM_SYSCOMMAND)
{
if(m.WParam.ToInt32()==SC_CLOSE)
{
MessageBox.Show("Application will be close");
}} base.WndProc (ref m);
}
for more information look at WM_SYSCOMMAND Notification[^] MCAD -- modified at 18:53 Friday 23rd September, 2005
-
porting c# aplplications to linux -
Accessing embedded text box scroll barsgood you found the solution this was what i will suggest if you didn't found the solution to override
WndProc
and catch WM_VSCROLL
so this only solution i know MCAD -
Grab Text From Other WindowIf You use
RichTextBox
you can useGetCharIndexFromPosition
to get the word this simple exampleprivate string GetWordFromPos(Point p) { string word; int cIdx=richTextBox1.GetCharIndexFromPosition(p); //go left int startPos; for(startPos=cIdx;startPos>0;startPos--) { string c=richTextBox1.Text.Substring(startPos-1,1); if(c == " ") // add more seperator check here break; } //get the left part word=richTextBox1.Text.Substring(startPos,cIdx-startPos); //go right for(startPos=cIdx;startPos
If you use `TextBox` then `TextBox` didn't have equivalent method or as i know so you need to use `SendMessage` Windows API to Function to send `EM_CHARFROMPOS` to get the index of the Char and Modify the previous function to take to get the text for more inf o look at [EM_CHARFROMPOS Message](http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/editcontrols/editcontrolreference/editcontrolmessages/em_charfrompos.asp) [[^](http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/editcontrols/editcontrolreference/editcontrolmessages/em_charfrompos.asp "New Window")] MCAD -- modified at 22:30 Tuesday 13th September, 2005