Drawing on top of Tab Control

How would I approach? I am using win32. I have a tab handle called hTab and I have drawn the image in wm_paint, however, it is getting drawn under the control.
Show some code so we can get a better idea. Right now I am imagining that you are drawing the picture in the WM_PAINT of a top-level window as opposed to subclass the tab control, for example (or maybe the tab control can be owner-drawn; I don't know so far).
I am drawing the picture on there. How do I draw it as a subclass to the tab control?
Not what I'm asking for. Alright, I have a WM_PAINT message:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
case WM_PAINT:
		LPWSTR fn;
        hdc = BeginPaint(hWnd, &ps);
		SetBkColor(hdc, RGB(240, 240, 240));
		
	dcSkin = CreateCompatibleDC(hdc); 
	GetObject(hbmpl, sizeof(bm), &bm);
	SelectObject(dcSkin, hbmpl);
	BitBlt(hdc, 248,94,551,277, dcSkin, 0, 0, SRCCOPY);
	DeleteDC(dcSkin);

		HFONT hFont;
		
		hFont = CreateFont(-MulDiv(9, GetDeviceCaps(hdc, LOGPIXELSY), 72),0,0,0,100,FALSE,FALSE,FALSE,0,0,
                0,CLEARTYPE_QUALITY, 0,TEXT("Segeo UI"));
		SelectObject(hdc,hFont);
		TextOut(hdc,5, 608,_T("Project:"), 8);
		TextOut(hdc,5, 624,_T("Version:"), 8);
		TextOut(hdc,86, 608,game, _tcslen(game));
        EndPaint(hWnd, &ps);
        break;

It works. However, I created a Tab Control(using my own function). The image IS being drawn, but I don't see it, because the tab is covering it(I can see the image when I comment out the tab creation) . I would like to have my image on TOP of the tab, so I can change the image based on the tab.
Last edited on
For the simple way you are doing it - have you tried getting the DC for the tab control instead of
the main window?

I was think something along these lines:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
case WM_PAINT:
        LPWSTR fn;
        BeginPaint(hWnd, &ps); //Need this for correct operation of WM_PAINT
        SetBkColor(hdc, RGB(240, 240, 240));
       
        HDC hdc;
        hdc = GetDc( Handle_of_tab_control_window);  //===============================        
    
    
    dcSkin = CreateCompatibleDC(hdc); 
    GetObject(hbmpl, sizeof(bm), &bm);
    SelectObject(dcSkin, hbmpl);
    BitBlt(hdc, 248,94,551,277, dcSkin, 0, 0, SRCCOPY); //see note 1 below
    DeleteDC(dcSkin);

        HFONT hFont;
        
        hFont = CreateFont(-MulDiv(9, GetDeviceCaps(hdc, LOGPIXELSY), 72),0,0,0,100,FALSE,FALSE,FALSE,0,0,
                0,CLEARTYPE_QUALITY, 0,TEXT("Segeo UI"));
        SelectObject(hdc,hFont);
        TextOut(hdc,5, 608,_T("Project:"), 8);//See note 1 below
        TextOut(hdc,5, 624,_T("Version:"), 8);//see note 1 below
        TextOut(hdc,86, 608,game, _tcslen(game));//see note 1 below
        
        ReleaseDC(Handle_of_tab_control_window, hdc);//================================
        
        
        EndPaint(hWnd, &ps);//need to keep this for correct operation of WM_PAINT
        break;


Notes:
1. You will need to adjust your print position as you are now using the DC of the tab control
- not the main window.
If you print too high - say at 0,0 - you will overdraw the tab itself.
(There is a function in the winapi to get the usable rectangle of a tab control)


PS:
The above code is a suggestion but I assume it will work - they are other ways of doing what you want.
Last edited on
Tested the code above and it did not work, no images show up at all. I also tried putting the handle of the tab control onto BeginPaint(). It drew the image there, however the tab control was gone and whenever you click the screen, it would go white.
I have some test code for Tab Control Box somewhere, I think I'll modify that
and post it - so much easier.
I think I found the solution myself. I was looking at a list of controls on the MSDN when I stumbled upon static controls, which you can put bitmaps in. I found a tutorial here: http://www.apitalk.com/windows-Programming/Using-Static-Control-As-Image-Display-Box-In-Winapi.html

If it doesn't work I'll post something again. Thanks.

EDIT: Actually, nevermind, I need that image function BitBlt() that was present in my WM_PAINT function. May someone try to find a solution, because creating a lot of static controls will be annoying. I need the BitBlt function to scale and tile the image.
Last edited on
Topic archived. No new replies allowed.