c++ - Win32 programming question -
i have tab-based application windows, developing myself.
i add subtle gradient background of tab control. how go around doing this? best method me use?
i think implementing custom control takes space of tab control work, how draw gradient using gdi?
thanks in advanced.
to use gdi you'll need gradientfill function. can use gdi+ gradients. here's plain gdi example:
trivertex vert[2] ; gradient_rect grect; vert [0] .x = 0; vert [0] .y = 0; vert [0] .red = 0x0000; vert [0] .green = 0x0000; vert [0] .blue = 0x0000; vert [0] .alpha = 0x0000; vert [1] .x = 100; vert [1] .y = 32; vert [1] .red = 0x0000; vert [1] .green = 0x0000; vert [1] .blue = 0xff00; vert [1] .alpha = 0x0000; grect.upperleft = 0; grect.lowerright = 1; gradientfill(hdc,vert,2,&grect,1,gradient_fill_rect_h);
as tab control, sub-class control , override non-client , client drawing handlers render gradient.
to sub class control, first create control , replace wndproc function:
oldwndproc = (wndproc)setwindowlongptr (hcontrol, gwlp_wndproc, (long_ptr)newwndproc);
then, in new wndproc:
newwndproc (usual args) { switch message { case paint: draw gradient return result default: return callwindowproc (oldwndproc, ..args..); <- important! } }
Comments
Post a Comment