Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling Windows Menu?

Status
Not open for further replies.

Eviltwin

Programmer
Apr 11, 2001
39
US
Greetings--
I want to prevent users from closing or minimizing forms. I have succesfully done this on all forms except the main paradox window using this code placed at the form level:

method menuAction(var eventInfo MenuEvent)

if eventInfo.isPreFilter() then
;// This code executes for each object on the form

else


;// This code executes only for the form
if not eventInfo.isPreFilter()then
if eventInfo.id() = menuControlClose then
disabledefault
endIf
if eventInfo.id()= menucontrolMinimize then
disabledefault
endif
if eventInfo.id()= menucontrolRestore then
disabledefault
endif
endif
endIf

endMethod

Is there a way to disable the menucontrols on the main Paradox screen? My intent is to force the user to close certain forms before they are allowed to close Paradox.

Thanks
 
You should add

eventInfo.id() = menuCanClose

to the list, this will also keep Paradox from closing the form. You will have to then add code to enable the form to be closed when you want to.

eg,

canClose is a variable that is defined as true when you want to allow the form to be closed

if eventinfo.id() = menuCanClose then
if canClose <> true then
eventInfo.seterrorcode(cannotdepart)
endif
endif

I hope this helps
Perrin


 
Hi Kliot--
Success. Thank you! For some reason I could not get this line of code to work:

if canclose <> true then


The following code does work.

After defining the variable canClose in the form var window set the variable as &quot;false&quot; in the arrive method
eg,
canclose=&quot;false&quot;

Place this code in the lowest menuaction for the form:

method menuAction(var eventInfo MenuEvent)

if eventinfo.id() = menuCanClose then
if canclose=&quot;false&quot; then
eventInfo.seterrorcode(cannotdepart)
endif
endif
endMethod

And last but not least:I have an exit button that validates this particular form (most of my forms have some sort of data verification)
so had to make sure to set canclose: canclose=&quot;true&quot; wherever the form is allowed to close. Also make sure that canclose=&quot;true&quot; is placed before close().

And there it is. Now the users cannot exit from the program unless they have closed forms I do not want left open. Nor can they minimize or maximize forms within paradox. Though this does allow them to minimize or maximize Paradox as whole.
 
Glad you got things working, I should have mentioned to declare the variable canclose as a logical variable not a string. A logical variable will accept true or false.

Perrin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top