How do I disable the 'Close Window' option in the taskbar?

http://img593.imageshack.us/img593/8732/taskbarclosewindow.png

How to write a C Code in order to disable the 'Close Window' option in the taskbar?

Compiler: GCC-mingw32

Which API Function should I use?

Thanks.

Answers


Make the window's message dispatcher process the message WM_SYSCOMMAND and filter it out if the message's wParam is SC_CLOSE.

Let WndProc be the windows message handler then the code to do might look like this:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  ...

  switch (message)
  {
    case WM_SYSCOMMAND:
     if (wParam == SC_CLOSE);
       break;

     return DefWindowProc(hWnd, message, wParam, lParam);  

    case ...

  }

  return 0;
}

This does not remove the "close"-menu item from the application's jump-list (its taskbar's local menu), but disables its functionality.


Need Your Help

Is mathematics necessary for programming?

math

I happened to debate with a friend during college days whether advanced mathematics is necessary for any veteran programmer. He used to argue fiercely against that. He said that programmers need only

Is there a better way of executing a bunch of partially async jQuery functions in a certain order?

javascript jquery ajax asynchronous

I have four functions that must be done in a certain order. All but one of these functions do some asynchronous AJAX stuff in them, however they (necessarily) do other things too. So these are my own