怎样让程序启动时最大化,但又不允许用户再还原成原始大小或者改变窗口大小,谢谢!
解决方案 »
- 信号量如何使用
- 用GetProp函数如何获取一控件的过程或者函数地址。
- VC怎样直接给打印机发送命令
- 关于Combox的一个菜鸟问题
- VC2005 在使用Unicode字符集时,从剪贴板取文字是乱码,是什么问题?怎么解决?
- 从来都是这么写的,但今天怎么就不好使呢?关于数据库连接的小问题,解决立刻给分
- ado问题,请大家看看
- 怎麼不能改變顏色??((CEdit *)GetDlgItem(IDC_EDIT_INMIN1))->GetDC()->SetBkColor(RGB(255,0,0))
- 全局变量
- 介绍几个好的网络编程的网站
- 用ATL COM AppWizard建立COM过程中,怎么弄出 “ATL Object Wizard 属性”对话框?
- 急问,往DC上画图片的时候怎么让屏幕不闪烁??
m_pMainWnd->ShowWindow(SW_MAXIMIZE);
{
cs.style=cs.style&~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX);
}
把窗口属性设成没有标题栏。在初始化时:int iWidth = ::GetSystemMetrics(SM_CXSCREEN);
int iHeight = ::GetSystemMetrics(SM_CYSCREEN);
MoveWindow(0, 0, iWidth, iHeight);OK,谁也别想动了
用上面的方法试过之后,发现并没有完全解决问题
比如说用户双击标题栏,应用程序同样会恢复成普通窗口,而且再也不能
最大化。
ZHENG017所说的重载CMainWnd::OnSize()方法。不知代码怎样写?还请
赐教。
还有其它的方法吗?
代码怎么写?
或者什么叫钩子?
谢谢!
{
switch(nID & 0xFFF0)
{
case SC_MOVE:
return;
case SC_RESTORE:
if(!IsIconic())return;
break;
}
CFrameWnd::OnSysCommand(nID, lParam);
}
修改MINMAXINFO
怎样修改MINMAXINFO?
m_pMainWnd->ShowWindow(SW_MAXIMIZE);
修改preCreateWindow
CMainFrame::PreCreateWindow(CreateStruct &cs)
{
cs.style=cs.style&~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX);
}
我在class wizard中找不到onSysCommand命令,
所以我是手工加入的这个函数,
结果运行后,和没加没什么区别,还是能正常还原和最大化。
不知何故?用dongchaomissyou(超)的方法,运行时双击标题栏还是可以还原,
而且再也不能最大化。
然后可以用GetSysTemMenu(),得到关于最大化和关闭的系统菜单,将它设为gray,这样应该可以了吧.(具体函数名可能不准,就这意思)
POINT ptMaxSize;
POINT ptMinTrackSize;
POINT ptMaxTrackSize;
成员,都改成一样的窗口尺寸(这里是最大窗口尺寸)就可以了
这样窗口大小就不会变化了
接管窗口的WM_NCLBUTTONDBLCLK事件处理就可以。
<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 />
Res
<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 />
另外,还可以通过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
该消息参数为:
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 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.
我用了AloneWolf(孤狼)的方法,完全成功了。
把方法奉献给大家:
代码就是他上面给出的。
WM_SYSCOMMAND消息在class wizard中找不到,
要手工在消息映射中添加ON_WM_SYSCOMMAND就行。再次谢谢各位大侠的关注。