Valhalla Legends Archive

Programming => General Programming => Topic started by: Blade_360 on February 28, 2003, 01:42 PM

Title: Hiding with the close box.
Post by: Blade_360 on February 28, 2003, 01:42 PM
How do I make it like in an instant messager where if you press the close box it doesn't unload the program? I know I could just do it where it loads when you click the systray icon or something but I want it to keep the original rtb text
Title: Re: Hiding with the close box.
Post by: iago on February 28, 2003, 04:36 PM
If you're using vb, maybe in form_deactive or form_unload or whatever it is to return FALSE and not die.

If that doesn't work, best I can think of is to set a hook, but I don't know enough about that to help you :-/
Title: Re: Hiding with the close box.
Post by: Eibro on February 28, 2003, 05:14 PM
Handle the WM_SYSCOMMAND message if you're using C/C++...
wParam will be SC_CLOSE if the close button was clicked.
Eg. If you want to minimize the window:
// ...
switch (uMsg)
{
case WM_SYSCOMMAND:
      if (wParam == SC_CLOSE)
      {
            SendMessage(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
            return TRUE;
      }
      break;
}
// ...
Title: Re: Hiding with the close box.
Post by: Skywing on February 28, 2003, 05:36 PM
QuoteHandle the WM_SYSCOMMAND message if you're using C/C++...
wParam will be SC_CLOSE if the close button was clicked.
Eg. If you want to minimize the window:
// ...
switch (uMsg)
{
case WM_SYSCOMMAND:
      if (wParam == SC_CLOSE)
      {
            SendMessage(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
            return TRUE;
      }
      break;
}
// ...
A minor correction:
QuoteIn WM_SYSCOMMAND messages, the four low-order bits of the wParam parameter are used internally by the system. To obtain the correct result when testing the value of wParam, an application must combine the value 0xFFF0 with the wParam value by using the bitwise AND operator.

Thus you should have: switch(wParam & 0xfff0) {
Title: Re: Hiding with the close box.
Post by: Atom on March 02, 2003, 07:01 PM
Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
'''''Now put your systray codeage in here
End Sub
Title: Re: Hiding with the close box.
Post by: Blade_360 on March 03, 2003, 12:53 PM
Thanks
oh and you also need to show the frmChat.Hide or Hide me or else nothing will happen. ::)