如何改变系统菜单?

niya3 2002-11-07 04:24:27

比如说:把菜单里的“新建”改成“打开”!

怎么让新建的子窗口全屏
...全文
54 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
daniceexiedong 2002-11-08
  • 打赏
  • 举报
回复
要想改住菜单,直接改它的消息接收函数,两个互换就可以了!

在子框架的PreCreateWindow()中加入cs.style |= WS_VISIBLE | WS_MAXIMIZE;
niya3 2002-11-08
  • 打赏
  • 举报
回复
我怎么不能留言!
niya3 2002-11-08
  • 打赏
  • 举报
回复
void CChildFrame::ActivateFrame(int nCmdShow)
{

CMDIChildWnd::ActivateFrame(SW_SHOWMAXIMIZED);
}
//这个是让子窗口最大化的方法
需要通过传递CChildFrame类中的消息ActivateFrame函数来实现。
多文档的程序子窗口就是这样最大化的,调试通过...
不行????你试了??

最大化行,我是说要平铺窗口!
niya3 2002-11-08
  • 打赏
  • 举报
回复
今天一直进不来,我试试!
  • 打赏
  • 举报
回复
AfxGetApp()->GetMainWnd()->SetMenu(...);
jesion 2002-11-08
  • 打赏
  • 举报
回复
void CChildFrame::ActivateFrame(int nCmdShow)
{

CMDIChildWnd::ActivateFrame(SW_SHOWMAXIMIZED);
}
//这个是让子窗口最大化的方法
需要通过传递CChildFrame类中的消息ActivateFrame函数来实现。
多文档的程序子窗口就是这样最大化的,调试通过...
不行????你试了??
niya3 2002-11-07
  • 打赏
  • 举报
回复
服务器可真忙!
niya3 2002-11-07
  • 打赏
  • 举报
回复
等待有人回答!
niya3 2002-11-07
  • 打赏
  • 举报
回复
最大化不行,没法子平铺窗口!
就是实现平铺子窗口!我找不见系统菜单的功能在那里修改!
jesion 2002-11-07
  • 打赏
  • 举报
回复
void CChildFrame::ActivateFrame(int nCmdShow)
{

CMDIChildWnd::ActivateFrame(SW_SHOWMAXIMIZED);
}
//这个是让子窗口最大化的方法
需要通过传递CChildFrame类中的消息ActivateFrame函数来实现。
niya3 2002-11-07
  • 打赏
  • 举报
回复
具体点吧!

如何把“窗口”---“层叠”项换成平铺功能!
niya3 2002-11-07
  • 打赏
  • 举报
回复
wuxuan(真心英雄):

我看看!
我出去一会儿,问题解决了,今天一定给分!
niya3 2002-11-07
  • 打赏
  • 举报
回复
还没入门,能具体点吗?比如说我想让子窗口全屏,怎么改?
wuxuan 2002-11-07
  • 打赏
  • 举报
回复
http://www.vckbase.com/document/viewdoc.asp?id=434
wuxuan 2002-11-07
  • 打赏
  • 举报
回复
Setting Fonts for Menu-Item Text Strings

LRESULT APIENTRY MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{

typedef struct _MYITEM
{
HFONT hfont;
LPSTR psz;
} MYITEM; // structure for item font and string

MYITEM *pmyitem; // pointer to item's font and string
static MYITEM myitem[CITEMS]; // array of MYITEMS
static HMENU hmenu; // handle to main menu
static COLORREF crSelText; // text color of selected item
static COLORREF crSelBkgnd; // background color of selected item
COLORREF crText; // text color of unselected item
COLORREF crBkgnd; // background color unselected item
LPMEASUREITEMSTRUCT lpmis; // pointer to item of data
LPDRAWITEMSTRUCT lpdis; // pointer to item drawing data
HDC hdc; // handle to screen DC
SIZE size; // menu-item text extents
WORD wCheckX; // check-mark width
int nTextX; // width of menu item
int nTextY; // height of menu item
int i; // loop counter
HFONT hfontOld; // handle to old font
BOOL fSelected = FALSE; // menu-item selection flag

switch (uMsg)
{
case WM_CREATE:

// Modify the Regular, Bold, Italic, and Underline
// menu items to make them owner-drawn items. Associate
// a MYITEM structure with each item to contain the
// string and font handle for each item.

hmenu = GetMenu(hwnd);
ModifyMenu(hmenu, IDM_REGULAR, MF_BYCOMMAND |
MF_CHECKED | MF_OWNERDRAW, IDM_REGULAR,
(LPTSTR) &myitem[REGULAR]);
ModifyMenu(hmenu, IDM_BOLD, MF_BYCOMMAND |
MF_OWNERDRAW, IDM_BOLD, (LPTSTR) &myitem[BOLD]);
ModifyMenu(hmenu, IDM_ITALIC, MF_BYCOMMAND |
MF_OWNERDRAW, IDM_ITALIC,
(LPTSTR) &myitem[ITALIC]);
ModifyMenu(hmenu, IDM_ULINE, MF_BYCOMMAND |
MF_OWNERDRAW, IDM_ULINE, (LPTSTR) &myitem[ULINE]);

// Retrieve each item's font handle and copy it into
// the hfont member of each item's MYITEM structure.
// Also, copy each item's string into the structures.

myitem[REGULAR].hfont = GetAFont(REGULAR);
myitem[REGULAR].psz = "Regular";
myitem[BOLD].hfont = GetAFont(BOLD);
myitem[BOLD].psz = "Bold";
myitem[ITALIC].hfont = GetAFont(ITALIC);
myitem[ITALIC].psz = "Italic";
myitem[ULINE].hfont = GetAFont(ULINE);
myitem[ULINE].psz = "Underline";

// Retrieve the text and background colors of the
// selected menu text.

crSelText = GetSysColor(COLOR_HIGHLIGHTTEXT);
crSelBkgnd = GetSysColor(COLOR_HIGHLIGHT);

return 0;

case WM_MEASUREITEM:

// Retrieve a device context for the main window.

hdc = GetDC(hwnd);

// Retrieve pointers to the menu item's
// MEASUREITEMSTRUCT structure and MYITEM structure.

lpmis = (LPMEASUREITEMSTRUCT) lParam;
pmyitem = (MYITEM *) lpmis->itemData;

// Select the font associated with the item into
// the main window's device context.

hfontOld = SelectObject(hdc, pmyitem->hfont);

// Retrieve the width and height of the item's string,
// and then copy the width and height into the
// MEASUREITEMSTRUCT structure's itemWidth and
// itemHeight members.

GetTextExtentPoint32(hdc, pmyitem->psz,
lstrlen(pmyitem->psz), &size);
lpmis->itemWidth = size.cx;
lpmis->itemHeight = size.cy;

// Select the old font back into the device context,
// and then release the device context.

SelectObject(hdc, hfontOld);
ReleaseDC(hwnd, hdc);

return TRUE;

break;

case WM_DRAWITEM:

// Get pointers to the menu item's DRAWITEMSTRUCT
// structure and MYITEM structure.

lpdis = (LPDRAWITEMSTRUCT) lParam;
pmyitem = (MYITEM *) lpdis->itemData;

// If the user has selected the item, use the selected
// text and background colors to display the item.

if (lpdis->itemState & ODS_SELECTED)
{
crText = SetTextColor(lpdis->hDC, crSelText);
crBkgnd = SetBkColor(lpdis->hDC, crSelBkgnd);
fSelected = TRUE;
}

// Remember to leave space in the menu item for the
// check-mark bitmap. Retrieve the width of the bitmap
// and add it to the width of the menu item.

wCheckX = GetSystemMetrics(SM_CXMENUCHECK);
nTextX = wCheckX + lpdis->rcItem.left;
nTextY = lpdis->rcItem.top;

// Select the font associated with the item into the
// item's device context, and then draw the string.

hfontOld = SelectObject(lpdis->hDC, pmyitem->hfont);
ExtTextOut(lpdis->hDC, nTextX, nTextY, ETO_OPAQUE,
&lpdis->rcItem, pmyitem->psz,
lstrlen(pmyitem->psz), NULL);

// Select the previous font back into the device
// context.

SelectObject(lpdis->hDC, hfontOld);

// Return the text and background colors to their
// normal state (not selected).

if (fSelected)
{
SetTextColor(lpdis->hDC, crText);
SetBkColor(lpdis->hDC, crBkgnd);
}

return TRUE;

// Process other messages.

case WM_DESTROY:

// Destroy the menu items' font handles.

for (i = 0; i < CITEMS; i++)
DeleteObject(myitem[i].hfont);

PostQuitMessage(0);
break;

default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return NULL;
}

HFONT GetAFont(int fnFont)
{
static LOGFONT lf; // structure for font information

// Get a handle to the ANSI fixed-pitch font, and copy
// information about the font to a LOGFONT structure.

GetObject(GetStockObject(ANSI_FIXED_FONT), sizeof(LOGFONT),
&lf);

// Set the font attributes, as appropriate.

if (fnFont == BOLD)
lf.lfWeight = FW_BOLD;
else
lf.lfWeight = FW_NORMAL;

lf.lfItalic = (fnFont == ITALIC);
lf.lfItalic = (fnFont == ULINE);

// Create the font, and then return its handle.

return CreateFont(lf.lfHeight, lf.lfWidth,
lf.lfEscapement, lf.lfOrientation, lf.lfWeight,
lf.lfItalic, lf.lfUnderline, lf.lfStrikeOut, lf.lfCharSet,
lf.lfOutPrecision, lf.lfClipPrecision, lf.lfQuality,
lf.lfPitchAndFamily, lf.lfFaceName);
}
niya3 2002-11-07
  • 打赏
  • 举报
回复
我说的是控制系统菜单!

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧