I'm creating a new control to add to my growing library of custom controls, this one is a menu bar type one to replace rebar because it doesn't work well enough for me.
I've already hit a snag though. I was just setting up the basics and I whent to test it when I found that the bar dissapears when you move the bottom of the window just behind the application bar at the bottom of the screen.
And, when you maximize another app and the minimize it (so that it covers the window) the menu bar is there again!
This code paints the window-
Code:
void DrawMCB(HWND hwnd,HDC dc)
{
//Setup the bounding rect
RECT rc;
GetWindowRect(hwnd,&rc);
rc.right-=rc.left;
rc.left = 0;
rc.bottom-=rc.top;
rc.top = 0;
//Create pens and brushes
HPEN dark = CreatePen(PS_INSIDEFRAME,1,GetSysColor(COLOR_3DDKSHADOW));
HPEN light = CreatePen(PS_INSIDEFRAME,1,GetSysColor(COLOR_3DHILIGHT));
HPEN none = CreatePen(PS_NULL,1,RGB(0,0,0));
HBRUSH face = CreateSolidBrush(RGB(223,223,223));
//Fill it in
FillRect(dc,&rc,face);
//Draw the basic frame
SelectObject(dc,light);
line(rc.left,rc.top,rc.right,rc.top);
line(rc.left,rc.top,rc.left,rc.bottom);
SelectObject(dc,dark);
line(rc.left,rc.bottom-1,rc.right,rc.bottom-1);
line(rc.right-1,rc.bottom,rc.right-1,rc.top);
}
This is the procedure for it -
Code:
LRESULT CALLBACK MCBProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_SIZE:
{
//Make it span the parent's width!
RECT rc;
GetWindowRect(GetParent(hwnd),&rc);
int width = rc.right-=rc.left;
GetWindowRect(hwnd,&rc);
int height = rc.bottom-rc.top;
SetWindowPos(hwnd,HWND_TOPMOST,0,0,width,height,SWP_NOZORDER);
return 0;
}break;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hwnd,&ps);
DrawMCB(hwnd,GetDC(hwnd));
EndPaint(hwnd,&ps);
return 0;
}break;
default:
return DefWindowProc(hwnd,msg,wParam,lParam);
}
return 0;
}
I suspect my problem is I'm not telling it to pain after an event... Of course, I could be wrong.
http://mhtml.ithium.net/offsite/nowyousee.jpg
http://mhtml.ithium.net/offsite/nowyoudont.jpg