There are normally three buttons sitting at the top right corner of a
window. However, I don't want users to close the application at run-time
using that close button (sitting on the most right side). Is there any way
to disable its functionality?
Any help will greatly be appreciated!
Lawrence
B
Lawrence wrote in message <01be3b8b$84aee560$c3e88cca@aslhk>...
INT MF_BYCOMMAND, SC_CLOSE
// CALL THE API Function to Disable the Control Menu (Close)
ls_Item = "Close"
MF_BYCOMMAND = 1 // added MF_BYCOMMAND and MF_GRAYED...0 + 1
SC_CLOSE = 61536 // Modify the Close item 0xF060 = 61536
// Get handle of the System Control Menu for "this" window
// False makes a copy of the current system menu to modify
li_hwnd = GetSystemMenu(handle(this), FALSE)
// Modify it
lb_RetVal = ModifyMenuA(li_hwnd, SC_CLOSE, MF_BYCOMMAND, 0, ls_Item)
IF NOT lb_RetVal THEN
MessageBox("STOP","Error Modifying System menu")
END IF
HTH
Vinay
In article <ZGoyPZJP#GA...@forums.powersoft.com>,
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
In order to keep the user from clicking the <X> in the upper right corner of
the window you will need to code the syscommand event on the window. First
you will have to add the event using the Declare User Events dialog in the
window painter. Create an event syscommand that maps to pbm_syscommand.
I do not remember which number the event receives when the user clicks the
<X>. You can figure that out easily, though with the debugger or by
messagbox() calls. Return a 1 for commands that you want PB to ignore in
that event.
Brage Mogstad wrote in message ...
Map an event to pbm_syscommand. This event will have an argument called
'commandtype'. Test commandtype for the numeric value of '61536'. This
value means the user tried to close a window using the 'X' button (or the
'Close' option from the system menu (the icon on the left of the titlebar)
or by double-clicking the system menu).
Doing it this way will permit you to close your window programatically, but
not by using the aforementioned Windows user interface methods.
Hope this helps.
Tim
Return value for the closequery event
Long. Return code choices (specify in a RETURN statement):
if */conditions are ok/* then
return 0 // Allow the window to be closed
else
return 1 // Prevent the window from closing
end if
Sam Maxwell wrote in message ...
>Of course if you disable closing the way that Brage suggested you won't be
>able to close the window at all.
>
>In order to keep the user from clicking the <X> in the upper right corner
of
>the window you will need to code the syscommand event on the window. First
>you will have to add the event using the Declare User Events dialog in the
>window painter. Create an event syscommand that maps to pbm_syscommand.
>
>I do not remember which number the event receives when the user clicks the
><X>. You can figure that out easily, though with the debugger or by
>messagbox() calls. Return a 1 for commands that you want PB to ignore in
>that event.
>
>Brage Mogstad wrote in message ...
>>When you call the Close function for the window, a CloseQuery event occurs
>>before the Close event. In the CloseQuery event, you can specify a return
>>code to prevent the Close event from occurring and the window from
closing.
>>This way you can disable its functionality
>>
>>B
>>