|
Mehmet Fatih Akbulut wrote: what should i write instead of mehmet.MainMenuStrip.Items[0].ToString() to get property3 as a result
mehmet.MainMenuStrip.Items[2].ToString() ?
Your question isn't very clear. What is you are trying to do?
|
|
|
|
|
Hello guys,
Can u suggest me a command in C# similar to GetObject in VB6.0
|
|
|
|
|
What does GetObject in VB6.0 do?
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
GetObject in VB:
if you are running a third party app from ur code lets assume 'mspaint' and due to some reason ur system crashes and is not able to close the instance of 'mspaint' which will now run in background and consume memory.
so GetObject in VB will get this running instance of 'mspaint' and reuse it instead of starting a new instance.
Sorry, i was not clear earlier as this is for the 1st time i am posting a query .... will take care of this in future
Can u pls suggest a similar function in C#
Thanks in Advance
Samoil
|
|
|
|
|
Hi!
You might want to take a look at Marshal.GetActiveObject()[^]
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Hello all,
is any body know how to register windows service using registry Editory.
i need the registry path of that
any suggestions will be appriciated
regards
GV Ramana
|
|
|
|
|
I think the path you're looking for is:
HKLM\SYSTEM\CurrentControlSet\Services
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Good day everyone,
I've been doing a handwriting program. User can use mouse pointer to draw lines and eraser lines
I use 2 methods AddPoint and RemovePoint to add points when user draw lines and remove points when user erase lines by using ArrayList pointArray.
But they're not working
Please help me if you are interested in this program.
Thanks so much
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if (!isMouseDown)
{
using (sr = new StreamReader("DataPoints.txt"))
{
string str = sr.ReadLine();
if (str == null)
return;
string [] strs = str.Split(' ');
if (strs.Length != 2)
return;
Point pt1 = new Point(int.Parse(strs[0]),int.Parse(strs[1]));
Graphics g = e.Graphics;
while ((str = sr.ReadLine()) != null)
{
strs = str.Split(' ');
if (strs.Length != 2)
break;
Point pt2 = new Point(int.Parse(strs[0]),int.Parse(strs[1]));
g.DrawEllipse(Pens.Blue, pt2.X-2, pt2.Y-2, 4, 4);
g.DrawLine(Pens.Black, pt1, pt2);
pt1 = pt2;
}
}
}
}
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (line)
{
isMouseDown = true;
pt1 = new Point(e.X, e.Y);
point = pt1;
sw = new StreamWriter("DataPoints.txt");
}
if (eraser)
{
pt.X = e.X;
pt.Y = e.Y;
g.FillRectangle(bgBrush, pt.X-10, pt.Y-10, 20, 20);
g.DrawRectangle(Pens.Red, pt.X-10, pt.Y-10, 20, 20);
}
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (line)
{
if (isMouseDown)
{
pointArray.Add("nvcls");
pointArray.Add("Eric");
pt2 = new Point(e.X, e.Y);
Graphics g = this.CreateGraphics();
g.DrawLine(pen, point, pt2);
tempG.DrawLine(pen, point, pt2);
point = pt2;
ptCount = point;
AddPoint(ptCount);
}
}
if (eraser)
{
if (isMouseDown)
{
line = false;
g.FillRectangle(bgBrush,e.X-10,e.Y-10,20,20);
g.DrawRectangle(Pens.Red,e.X-10,e.Y-10,20,20);
g.DrawRectangle(new Pen(this.BackColor),pt.X-10, pt.Y-10, 20, 20);
pt.X = e.X;
pt.Y = e.Y;
RemovePoint(ptCount);
}
}
}
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (line)
{
isMouseDown = false;
this.BackgroundImage = (Bitmap) tempImage.Clone();
sw.Close();
this.Refresh();
}
}
private void Form1_Resize(object sender,System.EventArgs e)
{
this.BackgroundImage = (Bitmap) tempImage.Clone();
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if ( e.Button == tbPolygon)
line = true;
else if (e.Button == tbEraser)
{
eraser = true;
}
else if (e.Button == tbSave)
Save();
}
public void AddPoint(Point ptCount)
{
pointArray.Add(ptCount);
}
private static void RemovePoint(Point ptCount)
{
for (int i = 0; i <= pointArray.Count; i ++)
{
bool isMatch = Object.Equals(pointArray[i], ptCount);
if (isMatch)
pointArray.Remove(pointArray[i]);
}
}
private void Save()
{
foreach (string s in pointArray)
{
sw.WriteLine(s);
}
sw.Close();
}
eric
|
|
|
|
|
Standard question #1:
What do you mean by "not working"?
---
b { font-weight: normal; }
|
|
|
|
|
Ah, I meant that the method AddPoint and RemovePoint does not work
Is there any other way to add and remove points?
Eric
|
|
|
|
|
Once again, what does not work exactly?
Do you get an error message while compiling, is an exception thrown at runtime or is the data itself not what you expect?
Try stepping through your program with a debugger, that way you'll learn what's going on.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
hi
i have a datagrid that add to it many datagridtextboxcolumn and datagridboolcolumn. my problem is when i read value of they , i can get datagridtextboxcolumn (datagridtextboxcolumn1.texbox.textbox) but don't get value from datagridboolcolumn. how to do that ??
|
|
|
|
|
|
hey...buddies..
once again cought in a problem...actually i want to synchronise folder structures in diffrernt drives using .net framework.so can any one suggest some solutions?is there any thing like web services or so which can help me?..
With Regard
Vikas
|
|
|
|
|
hi all,
i have some questions to ask.
first, i accidentally changed the ShowInTaskBar property of my form to False and when i noticed that i changed it back to True. but my form is still not seen in TaskBar. it occupies everywhere in monitor ;( how do i make it looks normal ? (same as it did look in the past)
secondly, how do i change the cursor position ?
i mean i have a few texboxes on form and have a taborder from top to bottom. but i want the cursor be in a specific textbox i want when i start my form?
thirdly, is it possible to change the color of tabcontrol's tabs ?
(i can change the inside of tabs but colors of buttons remain default gray)
lastly, formwindowstate is maximized and i disable maximizebox (false).
but if one double clicks on bluebar at the top, form gets the sizes when it was created.
i want to disable double clicking on the bluebar at the top of my form ( so it should never be resized.) ?
many thanks in advance,
bye.
-- modified at 9:01 Thursday 18th May, 2006
|
|
|
|
|
first : you are probably using resource file for more than one languages. you must change false to true in default language or change it in all languages.
second : in your textbox, set TabStop to TRUE and set the TabIndex to 0. It will be the first selected control in your form.
third : http://www.codeproject.com/cs/miscctrl/magictabcontrol.asp
|
|
|
|
|
Mehmet Fatih Akbulut wrote: first, i accidentally changed the ShowInTaskBar property of my form to False and when i noticed that i changed it back to True. but my form is still not seen in TaskBar. it occupies everywhere in monitor ;( how do i make it looks normal ? (same as it did look in the past)
Go the Form's InitializeComponents() method and search for the this.ShowInTaskBar = ??? line.
Delete the line and recomile again. U r done.
Mehmet Fatih Akbulut wrote: i mean i have a few texboxes on form and have a taborder from top to bottom. but i want the cursor be in a specific textbox i want when i start my form
In the designer mode go the View menu and select TabOrder then you can see the tab order of the controls and containers. click on the containers and controls in you preference(Note that only controls supporting the TabStop property and the ones having it set to true can have focus)
Mehmet Fatih Akbulut wrote: lastly, formwindowstate is maximized and i disable maximizebox (false).
but if one double clicks on bluebar at the top, form gets the sizes when it was created.
i want to disable double clicking on the bluebar at the top of my form ( so it should never be resized.)
Here I see two options
1 you override the WM_NC??? messages and see what you come up with.
2 Calculate the area on the screen that is used when the form is maximized and set the MinimumSize property to that value.
you should also take a look at the system menu commands.
For more information there is a nice FAQ at www.windowsforms.com
-- modified at 14:14 Thursday 18th May, 2006
|
|
|
|
|
Im getting "The Server is not operational" when authenticating user to active directory
Any help plzz...
Thanks in advance
Krishna
|
|
|
|
|
Could it be that the computer you're trying this on is not part of a domain or that you specified a wrong LDAP path name?
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Hi
I would like to retrieve contacts/Calendar/Memo/ToDo from Palm Desktop software using C# or VB.net.
Please help me. It is very urgent
Thanks in advance
Smitha
|
|
|
|
|
Hi fellows
I've write a simple app that changes the screen resolution. This app must change the screen to 1024x768 or any that I want. Like you'll see in my code I have 2 private variables that receives the data to alter the resolution.
The resolution is altered but not that I would like. This code is changing the screen to 800x600 and set the color displaying to 4 not 32 32 bits.
Obs: I've already created the DEVMODE struct;
I have no idea what 's going on . Fellows help me, please.
<br />
<br />
public class ChangeResolution<br />
{<br />
private int m_iWidth;<br />
private int m_iHeight;<br />
private const int CDS_UPDATEREGISTRY = 1;<br />
private const int CDS_TEST = 2;<br />
public const int DISP_CHANGE_SUCCESSFUL = 0;<br />
public const int DISP_CHANGE_RESTART = 1;<br />
public const int DISP_CHANGE_FAILED = -1;<br />
public const int DISP_CHANGE_BADMODE = -2;<br />
public const int DISP_CHANGE_NOTUPDATED = -3;<br />
public const int DISP_CHANGE_BADFLAGS = -4;<br />
public const int DISP_CHANGE_BADPARAM = -5;<br />
public const int DM_PELSWIDTH = 0x80000;<br />
public const int DM_PELSHEIGHT = 0x100000;<br />
public ChangeResolution(int iWidth, int iHeight)<br />
{<br />
m_iWidth = iWidth;<br />
m_iHeight = iHeight;<br />
}<br />
[DllImport("user32.dll", CharSet = CharSet.Auto)]<br />
public static extern int EnumDisplaySettings(string sDeviceName, int iModeNum, ref DEVMODE devMode);<br />
[DllImport("user32.dll", CharSet = CharSet.Auto)]<br />
public static extern int ChangeDisplaySettings(ref DEVMODE devMode, int iFlags);<br />
public void AlterResolution()<br />
{<br />
DEVMODE devStruct = new DEVMODE();<br />
devStruct.dmDeviceName = new string(new char[32]);<br />
devStruct.dmFormName = new string(new char[32]);<br />
devStruct.dmSize = (short)Marshal.SizeOf(typeof(DEVMODE));<br />
devStruct.dmPelsWidth = m_iWidth;<br />
devStruct.dmPelsHeight = m_iHeight;<br />
devStruct.dmBitsPerPel = 24;<br />
devStruct.dmDisplayFrequency = 75;<br />
devStruct.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;<br />
int i = 0;<br />
StringBuilder sb = new StringBuilder();<br />
while (true)<br />
{<br />
<br />
if (EnumDisplaySettings(null, i, ref devStruct) != 0)<br />
{<br />
sb.Append(i + "Width: " + devStruct.dmPelsWidth + " Height: " + devStruct.dmPelsHeight);<br />
i++;<br />
}<br />
else<br />
{<br />
sb.Remove(0, sb.Length - 1);<br />
sb.Append(i + "Width: " + devStruct.dmPelsWidth + " Height: " + devStruct.dmPelsHeight);<br />
break;<br />
}<br />
}<br />
if (EnumDisplaySettings(null, i, ref devStruct) == DISP_CHANGE_FAILED)<br />
{<br />
MessageBox.Show("Não foi possivel obter infos do display", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);<br />
}<br />
if (EnumDisplaySettings(null, i, ref devStruct) == 0)<br />
{<br />
int iVal = ChangeDisplaySettings(ref devStruct, CDS_TEST);<br />
switch(iVal)<br />
{<br />
case DISP_CHANGE_SUCCESSFUL:<br />
{<br />
MessageBox.Show("Alterações feitas", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);<br />
ChangeDisplaySettings(ref devStruct, CDS_UPDATEREGISTRY);<br />
break;<br />
}<br />
case DISP_CHANGE_RESTART:<br />
{<br />
MessageBox.Show("Reinicie sua máquina para que as novas configurações tenham efeito", "Infomação", MessageBoxButtons.OK, MessageBoxIcon.Information);<br />
break;<br />
}<br />
case DISP_CHANGE_FAILED:<br />
{<br />
MessageBox.Show("Falha ao tentar alterar a tela!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);<br />
break;<br />
}<br />
default:<br />
{<br />
MessageBox.Show("Nenhuma condição atendida", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);<br />
break;<br />
}<br />
} <br />
}<br />
}<br />
}<br />
|
|
|
|
|
Hi all, i need help in removing stop words i mean i ve an ArrayList wich contains about 10000 words each word is stored at each index of ArrayList and i ve to remove all the occurences of some 300 words wich are also stored in an array list well i m trying to do this like this
for(int i = 0; i < stopWords.Count; i ++)
{
while(totalWords.Contains(stopWords[i]))
totalWords.Remove(stopWords[i]);
}
i have also tried to do this through this way
for(int i = 0; i < totalWords.Count ; i++)
{
for(int j = 0; j < stopWords.Count; j++)
{
if(totalWords[i].Equals(stopWords[j]))
{
totalWords.Remove(totalWords[i]);
i--;
}
}
}
but both of these methods r taking ages to complete .... so plz anyone tell me some better and efficient appraoch then this....in the above code totalWords is the arraylist wich contains all the words and stopWords is the arraylist that contains the words wich r to b removed
lookin forward for help
Regards,
-- modified at 8:09 Thursday 18th May, 2006
|
|
|
|
|
Its probably a combination of the fact that your doing a linear search through a large list (which might lead to 300*10000 comparisons) and that the ArrayList is getting reorganzied each time you remove an element.
Two things to improve:
1. Use BinarySearch (log n instead of n comparisons)
a) Sort the list with: totalWords.Sort();
b) Call BinarySearch(stopWords[i]) to get the index of the first found item (you'll get -1 if not found)
2. Instead of removing from the existing list create a new one and add the elements which are not in the stopword list. This will reduce reorganization overhead of the ArrayList.
|
|
|
|
|
thxx sir, but the problem is that i cant sort the arraylist bcz it contains the words from different docutments and if i sort it now i cant keep track that wich word occurs in wich document so as i cant arrange the array list i cant apply the binary search
so plzz tell me anyother solution
looking forward for help
Regards,
|
|
|
|
|
Then at least follow the other point:
ArrayList newTotalWords = new ArrayList(totalWords.Count);
for(int i = 0; i < totalWords.Count ; i++)
{
if (!stopWords.Contains(totalWords[i]))
{
newTotalWords.Add(totalWords[i]);
}
}
If you can sort the stopwords list then you can even use BinarySearch here:
stopWords.Sort();
ArrayList newTotalWords = new ArrayList(totalWords.Count);
for(int i = 0; i < totalWords.Count ; i++)
{
if (stopWords.BinarySearch(totalWords[i]) < 0)
{
newTotalWords.Add(totalWords[i]);
}
}
|
|
|
|
|