|
Hi... could anybody help me?? i gt this error "Error 4 Expected class, delegate, enum, interface, or struct".. i don't understand what it means.. can someone solve for me.. this is my code..
string{} tx_data = new string{13};
string{} rx_data = new string{9};
public int i;
|
|
|
|
|
Are these codes written by C#?
If these written by c#,let them in a class.And if you want to declare a string array,you should write like this:
string[] str=new string[]{"china","beijing"};
I think
string{} tx_data = new string{13};
should be replaced by
string[] tx_data = new string[]{"13"};
Good luck.
|
|
|
|
|
xibeifeijian wrote: string{} tx_data = new string{13};
This is wrong
xibeifeijian wrote: string[] tx_data = new string[]{"13"};
This is right.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi.
This is sorta no brainer question for some of you, but does anyone know the C# codes to clear all contents of a certain notepad file?
thanks a bunch
|
|
|
|
|
one way would be to use a streamWriter object and clear all the contents of the file and close the same.
Keshav Kamat
India
|
|
|
|
|
Try this please:->
using System.IO;
FileStream fs=new System.IO.FileStream(yourTxtFilePath,FileMode.Create);
fs.Close();
|
|
|
|
|
xibeifeijian ,code works perfectly!
thanks alot xibeifeijian and Keshav!!
|
|
|
|
|
Hi,
I attempting to build an applications where I have three forms. MainForm, FormA, and FormB.
MainForm simply has a single button (for now) that pops FormA and FormB.
private void button1_Click(object sender, EventArgs e)
{
formA.Show();
formB.Show();
}
What I'm trying to do is have focus automatically change between FormA and FormB dependant on the users actions. IE. the user enters data on FormA, presses submit. While FormA is waiting for an answer from the server, and want focus to change to FormB so the user can continue to work.
any clues on how do to this in C# ? (using Visual Studios 2005)
|
|
|
|
|
Ok, I got delegates to work...though not pretty (so if you have a nice clean way of doing it, please let me know).
But now I've discovered another problem. While FormA is working, FormB does pop to the front what really isn't active until FormA completes its work. This defeats the purpose of have two forms. IE. To allow the user to continue to work while one form is busy.
Is this not possible in C# .NET? It's easy enough to do in with a browser and child windows so I would think something as advanced as C# should be able to do the same.
|
|
|
|
|
Have you tried a function of Form class, Form.Focus()? If you call formA.Focus(), formA gets focus. If you call formB.Focus(), formB gets focus.
Sheng
|
|
|
|
|
Yes, I can use the Focus by using delegates. But I can not do a formA.Focus() from formB since formB is not aware of formA.
And when I do delegates, I can set the focus, however the focus is not taking place until after previous form completes it works...which in my case makes having two forms useless since the purpose is to allow the user to work on one form while the other form is being processed.
|
|
|
|
|
formA obFormA = new formA();
obFormA.Show();
You can use the same to toggle between the forms or change the focus by showing or hiding any form, maybe while waiting for the server to show.
i.e. you can hide the formA and show the formB
Keshav Kamat
India
|
|
|
|
|
yes, but how.
if from FormB I do:
FormA formA = new FormA();
formA.Show();
All this does is create a NEW formA, not put Focus on the existing FormA.
And if I do formA.Focus() within formB, it will not compile. It'll get a formA does not exist error.
|
|
|
|
|
Dear friends:
How can I make a form unmovable? I tried to set FormBorderStyle to FixedSingle, to enable the form Maximized. But, the form can still be moved around. Thanks!
Sheng
|
|
|
|
|
can you respond to the forms Move event and cancel or undo the change there?
--
CleaKO The sad part about this instance is that none of the users ever said anything [about the problem].
Pete O`Hanlon Doesn't that just tell you everything you need to know about users?
|
|
|
|
|
Dan:
Thanks for the answer! I used the event handler "OnMove". There is no "Cancel" option. It does not work. I set the Location to the original values. The form can still be moved.
-- modified at 17:01 Tuesday 24th April, 2007
Sheng
|
|
|
|
|
Not sure if it is good idea, but you can take a look at WndProc method in MSDN or Google . You can get all events there and if it is OnMove , you can cansel it,
Mazy
"This chancy chancy chancy world."
|
|
|
|
|
Hi, Mazdak:
It does not work.
The windows message for a form's "MOVE" event is "WM_MOVE = 0x0003" defined in WinUsers.h. I used WinProc to intercept the "MOVE" message. The only parameter "m" of type Message does not have any property or field for canceling the "MOVE". I tried to set the m.Msg to WM_NULL == 0x0000. But it does not work either. It seems that the moving of a form happens before the message interception of "WM_MOVE" by WinProc.
Sheng
|
|
|
|
|
gshen wrote: It seems that the moving of a form happens before the message interception of "WM_MOVE" by WinProc.
This is wrong, just try :
protected override void WndProc(ref Message m)
{
if(m. {
return new Message();
}
else
base.WndProc(ref m);
}
|
|
|
|
|
It still does not work. The form can still be moved around.
Sheng
|
|
|
|
|
The WM_MOVE message merely informs the window that it is being moved - it is not a request to move.
This code works for me. Put it in your form and it should work.
public const int WM_MOVE = 0x216;
private bool m_AllowMove = false;
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct WM_MOVERECT
{
public int Left,Top,Right,Bottom;
}
protected override void WndProc(ref Message m)
{
if(!m_AllowMove)
{
if(m.Msg == WM_MOVE)
{
WM_MOVERECT lParam = (WM_MOVERECT)m.GetLParam(typeof(WM_MOVERECT));
lParam.Left = this.Left;
lParam.Top = this.Top;
lParam.Right = this.Right;
lParam.Bottom = this.Bottom;
Marshal.StructureToPtr(lParam, m.LParam, true);
}
}
base.WndProc(ref m);
}
Just change m_AllowMove to true or false to suit your needs.
Enjoy.
------------
Cheers,
Patrick
|
|
|
|
|
Patrick:
It works using WM_MOVING. Great! Thanks!
Sheng
|
|
|
|
|
Do you need the border ? if no you can set the FormBorderStyle to none.
|
|
|
|
|
Hi, LongHC:
I need the border bacause the form is the mother form.
Sheng
|
|
|
|
|
hello!!
i am desperate to know the way to authenticate a local windows account, by taking username & password, without using active directory!
did tried myself, invained, searched, never got a solution, all what i found were having active directory in it, i dont hav and i dont want to hav active directory installed!!!isnt there any way of doing it without active directory!!
can anyone please help???
Adeel
--
|
|
|
|