0

I have a MDI window containing multiple tabs. What I want to do is to disabled the close event every time the user clicked the exit button on the tab. But I didn't know how to accomplish those. Can anyone please help me with this? Thank you.

Here is the sample tab and exit button I was referring from my question above.

tab.png

and this is what I have so far. Still the window is closing every time i clicked the exit button.

integer ext 
ext = MessageBox("","You are not allowed to close this tab",(Exclamation!),(OK!))

if (ext = 1) then
Open(w_main)
end if
Rich Bianco
  • 4,141
  • 3
  • 29
  • 48
x'tian
  • 734
  • 2
  • 14
  • 40

3 Answers3

0

I am surprised your sample code even works. The MessageBox can only return one value the way you have it set up. If you are checking a return code from MessageBox you should have the fourth parameter as YesNo!, YesNoCancel!

I think whoever did this does not know what they are doing, it makes no sense at all there are zero options in this logic.

Do you want it to be a question where the user can respond? If so then do something like:

integer li_rc
li_rc = Messagebox("Confirm your intentions","Do you want to close the tab?",Question!,YesNo!,2) 
if li_rc = 1 then
  // user clicked YES because it is the first option of YesNo!
else
  // user clicked NO because it is the second option of YesNo!
end if

fyi: the last argument is the default button if the user presses enter

The window has closequery event which fires when it is closing, you can perform processing in that event to cause the window to NOT close. I don't know if the tab has anything like this but you could probably fix this question, and then disallow the close. If you just want to tell the user something then just do MessageBox("Message Subject", "Message Body", Exclamation!) there is no need to use OK! which is the default

Here is an idea:

Look in the clicked event of the tab control. There is probably code there that is closing the tab. You could put additional logic to check permissions and bypass the closing logic. Or you could set the ShowPicture property to false if the user is not able to close, or maybe show a different pic, of a disabled looking X.

Rich Bianco
  • 4,141
  • 3
  • 29
  • 48
  • This one is working. but what i want to do is to disabled the close event.. i don't want to allowed the user to close the tab. Does you how to do it? thank you. =) – x'tian Sep 17 '14 at 06:52
  • I see that X on the tab, that must have been placed on there by a developer. Maybe find that code and put some new code in there to0 check if the user is authorized, and then bypass the code that initiates the closing of tab. The tab doesn't have an event like closequery on windows. OR better yet, don't display the X if the user doesn't have authority to close.. ? – Rich Bianco Sep 17 '14 at 06:55
  • i found out that window close event may trigger the close button. but you know how to disable the close button of a normal window? if yes can you tell me how. thank you. I really don't have any idea. – x'tian Sep 17 '14 at 07:00
0

There is no way to "disable the close event", but you can disallow the requested close by scripting the window's CloseQuery event. Script it to return 1 in the cases you want to disallow the close, 0 for the cases where you want the close to continue processing.

Good luck.

Terry
  • 6,160
  • 17
  • 16
  • I'm afraid I wasn't get the logic of disallowing the window to close. If you don't mind can you give me some example? Thank you =) – x'tian Sep 18 '14 at 01:20
0

That's not easy. You should handle with user32.dll api and remove, modify and draw the menubar.

Open Global External Functions tab and insert:

Function uLong GetSystemMenu(object hwnd, boolean bRevert ) LIBRARY "user32.dll" Function uLong RemoveMenu(object hMenu, long nPosition, long wFlags ) LIBRARY "user32.dll" Function uLong DrawMenuBar(object hwnd) LIBRARY "user32.dll"

And now:

menu = GetSystemMenu(window, false) // to disable X
RemoveMenu(menu, HF060, H0)
DrawMenuBar(window)
Eric Draven
  • 259
  • 3
  • 7