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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
HINSTANCE hinstance=GetModuleHandle(NULL);
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static UINT ID=0;
static HMENU mnTopMost=NULL;
static HMENU mnSelTopMost=NULL;
switch(msg)
{
case WM_CLOSE:
{
DestroyWindow(hwnd);
}
break;
case WM_CREATE:
{
mnTopMost=GetSystemMenu(hwnd,FALSE);
ID=GetMenuItemCount(mnTopMost);
AppendMenu(mnTopMost, MF_STRING, ID, "Top Most");
}
break;
case WM_SIZE:
case WM_SIZING:
{
RECT a;
GetClientRect(hwnd,&a);
HWND edit=FindWindowEx(hwnd,NULL,"edit",NULL);
SetWindowPos(edit,0,0,0,a.right,a.bottom,SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION);
}
break;
case WM_INITMENUPOPUP:
{
mnSelTopMost=(HMENU)wParam;
return DefWindowProc(hwnd, msg, wParam, lParam);
}
break;
case WM_SYSCOMMAND:
{
if (GetMenuState(mnSelTopMost,ID,MF_BYPOSITION)!=0xFFFFFFFF)
{
MessageBox(NULL,"clicked","hey",MB_OK);
}
mnSelTopMost=NULL;
return DefWindowProc(hwnd, msg, wParam, lParam);
}
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
|