Objects outside of the client area

closed account (jwkNwA7f)
How can I put things outside of the client area like in Firefox or Chrome?

Thank you!
Hi,

Yes it is called plugin and extension development, for example to develop plugin\extension for Google Chrome browser, visit: http://developer.chrome.com/extensions/getstarted.html

It is quite straight-forward, it require basic logic which is needed for all programming languages. To gain additional detail on developing extensions for other browser just check through their websites they tend to have SDK's and Documentation related to plugin\extension development.

Good luck
closed account (jwkNwA7f)
@SpaceWorm That is not exactly what I meant. Sorry, that I didn't explain it well enough.

I was using chrome and firefox's tabs as an example. I wanted to put a button or something like that outside of the client area in my application using WinAPI.
If I understand you correctly you want to simply not draw certain parts of a program that are "out of focus" so to speak, is that correct? If that's the case then this depends on how you are updating your device context. If you look at Chrome through Process Explorer you'll notice that each tab (and even separate windows) actually has their own process, and each of those is a child of the parent instance of chrome. Specifically how you switch between these contexts is again going to depend heavily on how you are updating the screen to begin with.
closed account (jwkNwA7f)
@Computergeek01 I wanted to put a button on the title bar or something close to that.
OK so let's break this problem down then. Make a custom button with your resource editor and spawn a unique instance of it for each "tab" your application opens (I wouldn't worry about resizing them just yet). Let's start with that then we can move on to assigning dynamic ID's to each 'tab'.
I haven't tried actually using it, but check out this MSDN link for WM_NCPAINT (Non-Client Paint);
http://msdn.microsoft.com/en-us/library/windows/desktop/dd145212%28v=vs.85%29.aspx

There's also an WM_NCLBUTTONDOWN message for when a user clicks in non-client areas (like in the title bar)
http://msdn.microsoft.com/en-us/library/windows/desktop/ms645620%28v=vs.85%29.aspx

Hope that helps.

Edit:
I tried it out;
So apparently there is a problem with GetDCEx() that MSDN suggests on their website, something to do with a flag-state. Instead, another tutorial site says to use hdc = GetWindowDC(hwnd). This does work, but you are now in charge of all painting concerning the outer-area of your window, I'm trying to make a work-around right now, so I'll post it if I can get it right.

2nd Edit:
It was so much more simple than I was thinking, try out either of the code below and You will have a "New Button" drawn in your titlebar. Then just process the WM_NCLBUTTONDOWN message to decide if the rectangle was clicked on.

1
2
3
4
5
6
7
8
9
10
11
	case WM_PAINT:
		hdc = BeginPaint(hwnd, &ps);
		Rectangle(hdc, 20, 20, 100, 100); //do your regular drawing
		EndPaint(hwnd, &ps);
		
		
                hdc = GetWindowDC(hwnd);
		Rectangle(hdc, 150,3,250, 23); //Draw to the toolbar
		TextOutW(hdc, 153, 4, L"New Button", 10);
		ReleaseDC(hwnd, hdc);
                return 0;



NC_Paint is better because it will only paint when needed.
1
2
3
4
5
6
7
	case WM_NCPAINT:
		DefWindowProc(hwnd, msg, wparam, lparam); //let the defaultWNDPROC handle most of it
		hdc = GetWindowDC(hwnd);
		Rectangle(hdc, 150,3,250, 23);//then draw in your button
		TextOutW(hdc, 153, 4, L"New Button", 10);
		ReleaseDC(hwnd, hdc);
		return 0;


Remember that doing this means that you can put in a bmp picture instead of just a box and make it look really nice.
Last edited on
closed account (jwkNwA7f)
Sorry that I haven't responded for a while. I have to do something right now and I will be back in about 20-30 min. Thanks!
closed account (jwkNwA7f)
Okay, I am back now.
@ComputerGeek01 I am not sure how to make a custom button. I am slightly new to the WinAPI.

@newbieg Exactly what is wrong with it? I haven't had enough time to try out WM_NCPAINT yet.
This codeproject.com article might help? It's written using MFC, but is should be possible to translate the useful bits of the code into the raw Windows API equivalent.

CCaptionButton (buttons for the titlebar)
http://www.codeproject.com/Articles/7287/CCaptionButton-buttons-for-the-titlebar

Andt
If you actually take a look at firefox, they do process the WM_NCPAINT message, but only in full-screen mode, so they don't need to worry about painting the lines around the screen, just the title-bar. (I'm claiming this because their title-bar gets a different background and is larger when full-screen to accommodate the buttons, but when minimized it pushes the buttons down into a tool-bar.)
A problem with both methods I used to draw the button is that if the window loses focus (like you have your window open and then click on a different program's window that was below it), the button will disappear, which means that when the user clicks on your program again they may accidentally hit the button because it wasn't visible. I haven't found any good tutorials yet for how to correctly set the buttons up, sorry.
Last edited on
Topic archived. No new replies allowed.