怎样让程序启动时最大化,但又不允许用户再还原或者改变窗口大小,谢谢!

xiaoqiao00 2002-08-29 04:00:16
怎样让程序启动时最大化,但又不允许用户再还原成原始大小或者改变窗口大小,谢谢!
...全文
583 29 打赏 收藏 转发到动态 举报
写回复
用AI写文章
29 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoqiao00 2002-08-31
  • 打赏
  • 举报
回复
谢谢各位大侠。
我用了AloneWolf(孤狼)的方法,完全成功了。
把方法奉献给大家:
代码就是他上面给出的。
WM_SYSCOMMAND消息在class wizard中找不到,
要手工在消息映射中添加ON_WM_SYSCOMMAND就行。

再次谢谢各位大侠的关注。
every 2002-08-31
  • 打赏
  • 举报
回复
截取WM_SYSCOMMAND消息。
该消息参数为:
uCmdType = wParam; // type of system command requested
xPos = LOWORD(lParam); // horizontal postion, in screen coordinates
yPos = HIWORD(lParam); // vertical postion, in screen coordinates
其 中 uCmdType表 示 用 户 的 选 择 :
SC_CLOSE Closes the window.
SC_CONTEXTHELP Changes the cursor to a question mark with a pointer. If the user then clicks a control in the dialog box, the control receives a WM_HELP message.
SC_DEFAULT Selects the default item; the user double-clicked the System menu.
SC_HOTKEY Activates the window associated with the application-specified hot key. The low-order word of lParam identifies the window to activate.
SC_HSCROLL Scrolls horizontally.
SC_KEYMENU Retrieves the System menu as a result of a keystroke.
SC_MAXIMIZE (or SC_ZOOM) Maximizes the window.
SC_MINIMIZE (or SC_ICON) Minimizes the window.
SC_MONITORPOWER Windows 95 only: Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer.
SC_MOUSEMENU Retrieves the System menu as a result of a mouse click.
SC_MOVE Moves the window.
SC_NEXTWINDOW Moves to the next window.
SC_PREVWINDOW Moves to the previous window.
SC_RESTORE Restores the window to its normal position and size.
SC_SCREENSAVE Executes the screen saver application specified in the [boot] section of the SYSTEM.INI file.
SC_SIZE Sizes the window.
SC_TASKLIST Executes or activates Windows Task Manager.
SC_VSCROLL Scrolls vertically.

albert 2002-08-31
  • 打赏
  • 举报
回复
要使窗口的大小不可改变,可以在该窗口的PreCreateWindow(CREATESTRUCT& cs)中添加以下代码:

cs.style&=~(WS_THICKFRAME|WS_MAXIMIZEBOX|WS_MINIMIZEBOX);

另外,还可以通过SetWindowLongPtr()方法修改窗口的风格。

关于SetWindowLongPtr的使用方法可以参考

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winclass_3qia.asp

关于窗口风格的更详细的信息,请参考

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_window_styles.asp
albert 2002-08-31
  • 打赏
  • 举报
回复
WM_GETMINMAXINFO
<br />

The WM_GETMINMAXINFO message is sent to a window when the size or position of the window is about to change. An application can use this message to override the window's default maximized size and position, or its default minimum or maximum tracking size.
<br />
<br />

A window receives this message through its WindowProc function.
<br />
<br />

LRESULT CALLBACK WindowProc(
<br />

HWND hwnd, // handle to window
<br />

UINT uMsg, // WM_GETMINMAXINFO
<br />

WPARAM wParam, // not used
<br />

LPARAM lParam // window information (LPMINMAXINFO)
<br />

);
<br />

Parameters
<br />

wParam
<br />

This parameter is not used.
<br />

lParam
<br />

Pointer to a MINMAXINFO structure that contains the default maximized position and dimensions, and the default minimum and maximum tracking sizes. An application can override the defaults by setting the members of this structure.
<br />

Return Values
<br />

If an application processes this message, it should return zero.
<br />
<br />

Remarks
<br />

The maximum tracking size is the largest window size that can be produced by using the borders to size the window. The minimum tracking size is the smallest window size that can be produced by using the borders to size the window.
<br />
<br />

Requirements
<br />

Windows NT/2000: Requires Windows NT 3.1 or later.
<br />

Windows 95/98: Requires Windows 95 or later.
<br />

Header: Declared in Winuser.h; include Windows.h.
<br />
<br />

See Also
<br />

Windows Overview, Window Messages, MoveWindow, SetWindowPos, MINMAXINFO
<br />
<br />

Built on Thursday, October 12, 2000Requirements
<br />

Windows NT/2000: Requires Windows NT 3.1 or later.
<br />

Windows 95/98: Requires Windows 95 or later.
<br />

Header: Declared in Winuser.h; include Windows.h.
<br />

See Also
<br />

Windows Overview, Window Messages, MoveWindow, SetWindowPos, MINMAXINFO
<br />
albert 2002-08-31
  • 打赏
  • 举报
回复
解决用户双击标题栏:
接管窗口的WM_NCLBUTTONDBLCLK事件处理就可以。
sh210 2002-08-31
  • 打赏
  • 举报
回复
mark
once168 2002-08-31
  • 打赏
  • 举报
回复
可截取系统消息,然后吃掉消息就行了(WINDOWS在最大化、最小化、改变大小都是用发消息实现的)
siphonelee 2002-08-31
  • 打赏
  • 举报
回复
修改MINMAXINFO 中的
POINT ptMaxSize;
POINT ptMinTrackSize;
POINT ptMaxTrackSize;
成员,都改成一样的窗口尺寸(这里是最大窗口尺寸)就可以了
这样窗口大小就不会变化了
zhf0021 2002-08-30
  • 打赏
  • 举报
回复
钩子可以蚕参考MSDN
AloneWolf 2002-08-30
  • 打赏
  • 举报
回复
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
switch(nID & 0xFFF0)
{
case SC_MOVE:
return;
case SC_RESTORE:
if(!IsIconic())return;
break;
}
CFrameWnd::OnSysCommand(nID, lParam);
}
xiaoqiao00 2002-08-30
  • 打赏
  • 举报
回复
什么叫钩子截取wm_size信息
代码怎么写?
或者什么叫钩子?
谢谢!
littlefellow 2002-08-30
  • 打赏
  • 举报
回复
好像要映射On_Sizing;将里面关于更改尺寸的屏掉(就是不让它变)
然后可以用GetSysTemMenu(),得到关于最大化和关闭的系统菜单,将它设为gray,这样应该可以了吧.(具体函数名可能不准,就这意思)
uuuu 2002-08-30
  • 打赏
  • 举报
回复
对不起我现在也不知道但是我相信我很快就会知道的
luban 2002-08-30
  • 打赏
  • 举报
回复
首先把窗体的标题栏上的三个按钮全部去掉,
然后过滤掉所有和标题蓝有关的消息。
xiaoqiao00 2002-08-30
  • 打赏
  • 举报
回复
我用了孤狼的函数,但好像还是不行
我在class wizard中找不到onSysCommand命令,
所以我是手工加入的这个函数,
结果运行后,和没加没什么区别,还是能正常还原和最大化。
不知何故?

用dongchaomissyou(超)的方法,运行时双击标题栏还是可以还原,
而且再也不能最大化。
pigpig 2002-08-30
  • 打赏
  • 举报
回复
同意孤狼的方法
dongchaomissyou 2002-08-30
  • 打赏
  • 举报
回复
在对话框文挡的APP类中初始化,
m_pMainWnd->ShowWindow(SW_MAXIMIZE);
修改preCreateWindow
CMainFrame::PreCreateWindow(CreateStruct &cs)
{
cs.style=cs.style&~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX);
}

sjzxyg 2002-08-30
  • 打赏
  • 举报
回复
同意 AloneWolf(孤狼)的方法
firmamenthy 2002-08-30
  • 打赏
  • 举报
回复
gz
xiaoqiao00 2002-08-30
  • 打赏
  • 举报
回复
不知在OnGetMinMaxInfo()函数中
怎样修改MINMAXINFO?
加载更多回复(9)

16,550

社区成员

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

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

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