Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » TopWindow&PopUp, TrayIcon » Custom actions on Minimize or Close button
Custom actions on Minimize or Close button [message #999] Mon, 13 February 2006 12:35 Go to next message
hojtsy is currently offline  hojtsy
Messages: 241
Registered: January 2006
Location: Budapest, Hungary
Experienced Member
I would like to Hide() my window when the Minimize or Close button is pressed in the title bar, instead of minimizing or closing. Which methods should I overload for this?
Re: Custom actions on Minimize or Close button [message #1000 is a reply to message #999] Mon, 13 February 2006 12:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Close: Either Close virtual method or WhenClose callback.

Minimize: Not directly supported, means override WindowProc and catch the window message (and call Ctrl::WindowProc at the end).

Mirek
Re: Custom actions on Minimize or Close button [message #1001 is a reply to message #1000] Mon, 13 February 2006 13:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Correction: Override WindowProc and do not forget to call TopWindow::WindowProc in it.

Mirek
Re: Custom actions on Minimize or Close button [message #12850 is a reply to message #1001] Wed, 21 November 2007 11:54 Go to previous messageGo to next message
lokki is currently offline  lokki
Messages: 20
Registered: November 2005
Promising Member
Hello

I had similar problem and solved it just as you had written. For others, here it is:

class MyWindow: public WithMyCustomLayout<TopWindow> {
...
   Callback WhenMinimize; // callback for minimize

   // Overriding default WindowProc
   LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
...
};

// implementation of WndProc
LRESULT MyWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	if (message == WM_SYSCOMMAND && wParam == SC_MINIMIZE)
	{
		WhenMinimize(); // callback
		return 0;
	}
	return TopWindow::WindowProc(message, wParam, lParam);
}

// in window constructor or any other suitable method, 
// assign custom function to callback
MyWindow::MyWindow()
{
...
   WhenMinimize = THISBACK(MyCustomFunction);
...
}
Re: Custom actions on Minimize or Close button [message #12972 is a reply to message #12850] Sat, 01 December 2007 17:57 Go to previous messageGo to next message
amit is currently offline  amit
Messages: 17
Registered: November 2007
Promising Member
hi,
I want to have some additional processing on application exit.
The code given by lokki should work but few point to be cleared are:

by overriding WindowProc ((--------all we have to-------)) do is:

this is for minimize example ..

// implementation of WndProc
LRESULT MyWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	if (message == WM_SYSCOMMAND && wParam == SC_MINIMIZE)
	{
		My_Custom_Function(); // -------------------------------------------------------this does  not have to be a CallBack but any function can well do.
		return 0;  //-----------------------------------------------------add this line if you want to ignore the actual minimizing else remove it.
	}
	return TopWindow::WindowProc(message, wParam, lParam);
}



i am not able to get the Close thing ... wait i'll check the U++ source and let you know ...

ok got it for working out "custom closing" do so ..


there are two ways ...

first ...
virtual void Close()
{
  ... // custom code
  ...
  ...
  TopWindow::Close(); // call this if you want to actually close window after custom processing
}


or the second ...

my_window_app::my_window_app()
{
...
WhenClose = THISBACK(custom_action_function);  // WhenClose is a member of your baseclass already do not re-declare it ..
...
}


........

my_window_app::custom_action_function()
{
  ... // custom code
  ...
  ...
  Close(); // the TopWindow Close would be called as Close() is not re-defined in this case
}





and i think WhenMinimize CallBack is not there ... correct me if wrong.

[Updated on: Sat, 01 December 2007 17:59]

Report message to a moderator

Re: Custom actions on Minimize or Close button [message #13160 is a reply to message #12972] Mon, 17 December 2007 09:59 Go to previous message
lokki is currently offline  lokki
Messages: 20
Registered: November 2005
Promising Member
yes, you're right WhenMinimize callback isn't there. If it was, all would be much easier. What did I, was the implementation of this callback to my custom window class.

Your solution is cleaner, I think Smile
Previous Topic: region defined windows or Rounded rectangle windows
Next Topic: Painting below your window, not bleeding into your window...
Goto Forum:
  


Current Time: Fri Mar 29 00:54:15 CET 2024

Total time taken to generate the page: 0.01559 seconds