|
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
--
|
|
|
|
|
Hi there,
I've just started to use the RichTextBox control in Visual Studio. Just got few question, how can show the line number on the left hand side?
Also, how can i get these information about these from RichTextBox:
1. Line Number
2. Line Position Number
3. Line Column Number
So that i can use it to show these info on the status bar window.
Thanks in advance for your help~
|
|
|
|
|
|
Thanks allot Patrick Sears, the first one is my fav as its simple and does the job~
|
|
|
|
|
hi,
But it will get flickering wright.
when ever the line number changes after Enter.
|
|
|
|
|
hi all i m developing a network based game in C# 2005. i want to transfer objects of drawing class stored in arraylist,to another computer how to do it i only found one method "convert into byte from text and then send *".i have found no way to send objects. is sending arraylist is possible ? or i have to get each object from list and then convert into byte and then send.
my question is
1).how to convert arraylist into byte? if possible
2).How to convert objects in byte[] and then send.
3) is there any other method other than this to send objects of classes on network.
* byte[] buf= System.Text.Encoding.Unicode.GetBytes("Helllo World");
any other way of transfering object except method metioned above.
-- modified at 15:11 Tuesday 24th April, 2007
Regards.
Tasleem Arif
|
|
|
|
|
You're talking about a subject called "Remoting". Search for it on this website, there are dozens of articles from beginner to advanced describing how to do this.
------------
Cheers,
Patrick
|
|
|
|
|
Thanks for reply, actually i m makin that game in Compact Framework, i m using windows application just for the testing. i search on internet about the Remoting in .net CF it is not supported in .net CF so i have no option except to use the sockets.
Regards.
Tasleem Arif
|
|
|
|
|
Ah, I see. Yes, you're going to need to package the data yourself and push it out over a socket.
That said, it shouldn't be too difficult to do. The Compact Framework supports basic serialization, which should serve your purpose; if not, Marc Clifton wrote an awesome serializer here on Code Project:
http://www.codeproject.com/csharp/RawSerializer.asp[^]
It's easy enough to open a socket and call Write() on the data, and since it's a local TCP connection you probably don't need to worry about latency or data loss.
------------
Cheers,
Patrick
|
|
|
|