c++ - Child Windows that does not occupy client area -
in win32 api (pure win32), menu bar not occupy area client area of window. means origin coordinates of client area right under menu bar left.
when create child window controls using createwindow
(or other method), window takes area of client-area.
eg:- creating button @ (xpos = 0, ypos = 0) , (width=width_of_client_area, height=20).
after creating button if you'll use gdi function this, it'll drew below button:
rectangle(hdc, 0,0, 200, 200);
but when creating menu bar, doesn't occupy client area. (gdi not drew under menu).
final question: how can create control on parent window menu bar ?
the menu rendered in non-client area of window, driven different set of window messages. keep in mind don't create child windows these types of controls. need provide rendering , event handling customization want add. means if want add button or checkbox need implement yourself. can started handful of steps there may other things need done depending on requirements.
the first step process wm_nccalcsize
message. allow adjust size of non-client area have more space draw custom control. pass message on default window proc modify location , dimensions (just drop top down x pixels) before returning.
the next step handle wm_ncpaint
message. pass message on default window proc draw custom visuals in area have reserved. working window dc can draw entire window. it's important keep in mind don't destroy in client area.
the last item needs done handle mouse messages wm_ncmousemove
. if mouse event occurs outside area control located pass message default window proc, otherwise handle message , skip default proc. need manage state data keeping track of when button down or not not cause conflicts default window proc.
keep in mind when want draw directly non-client area need call getwindowdc()
instead of getdc()
acquire device context.
[note: google dance "winapi non-client area"]
Comments
Post a Comment