Forum > Carbon

Minimize on 'x' and close by system application menu?

(1/3) > >>

rajivsoft:
Hi all,
I'm need to minimize my application instead of close it when a user clicks on red 'x', but if i simply set CanClose to false the i can't close my application anymore! It seems that 'Exit from My App' voice of system application menu calls same OnCloseEvent of the MainForm (i'v tried to cast Sender.Class to messagebox and in either cases it mention my TFrm_Main).

So my question is, how to minimize on 'x' and close by system application menu?

Sora-Kun:
Hello,
 I don't know how to do that really, but some one made it, when you exit the  app, it's minimized to the system bar. have a look, the application name is Opengrabby, the source code is available too http://fabienwang.com.
good luck :)

eny:

--- Quote from: rajivsoft on February 15, 2011, 11:08:57 am ---but if i simply set CanClose to false the i can't close my application anymore!
--- End quote ---

Well, then make it conditional based on a boolean variable.
And if the user selects the actual exit function, set that variable to true.
Something like:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TfrmMain1.FormClose(Sender: TObject; var CloseAction: TCloseAction);begin  if not ReallyCanClose then    CloseAction := caNone;end; 

Phil:

--- Quote from: rajivsoft on February 15, 2011, 11:08:57 am ---I'm need to minimize my application instead of close it when a user clicks on red 'x',

--- End quote ---

Remind me again why you want to change standard program behavior. Sounds like a bad idea and very un-Mac-like.

Thanks.

-Phil

rajivsoft:

--- Quote from: eny on February 15, 2011, 12:53:04 pm ---
--- Quote from: rajivsoft on February 15, 2011, 11:08:57 am ---but if i simply set CanClose to false the i can't close my application anymore!
--- End quote ---

Well, then make it conditional based on a boolean variable.
And if the user selects the actual exit function, set that variable to true.
Something like:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TfrmMain1.FormClose(Sender: TObject; var CloseAction: TCloseAction);begin  if not ReallyCanClose then    CloseAction := caNone;end; 
--- End quote ---
The problem is as i say that it seems like 'x' and system menu exit are calling same FromOnClose function and i don't know how to distinguish them...


--- Quote from: Phil on February 15, 2011, 04:40:12 pm ---
--- Quote from: rajivsoft on February 15, 2011, 11:08:57 am ---I'm need to minimize my application instead of close it when a user clicks on red 'x',

--- End quote ---

Remind me again why you want to change standard program behavior. Sounds like a bad idea and very un-Mac-like.

Thanks.

-Phil
--- End quote ---
in a word, marketers... for them it must be same functionally as on windows...

but for now they are calm and not insist much on this, it's more like for future to minimizing it to tray as it happen on all Intant Messengers. Also I don't see this one as change of standard program behavior, in quite all mac app if you close it with 'x' it's only close main window, not 'program' itself that remain active in dock and with main menu.

Navigation

[0] Message Index

[#] Next page

Go to full version