mfc多文档多视图
今天装修百科网给各位分享mfc怎么设置活动窗口的知识,其中也会对mfc多文档多视图(mfc 多文档)进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在我们开始吧!
mfc多文档多视图,如何在关闭当前活动文档的时候,然后把在最前面的视图设为活动视图
对于MFC MDI程序,关闭一个ChildFrame后,系统会自动发WM_MDIACTIVATE消息,自动切换到另外一个ChildFrame。所以不用你设。
如果此时再没有open的ChildFrame,此消息自动忽略,则什么也不做。此时也没必要设。
不知你有什么问题或者需求?
在MFC中如何设置一开始出来的主窗口的大小及位置
如果在App的InitInstance中有:
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
要现将这一句改为
m_pMainWnd->ShowWindow(SW_SHOW);
否则,在MainFrame的PreCreateWindow里面设置cs的cx与cy不起作用
补充:不知道你的PreCreateWindow是怎么样写的,设置的位置对吗
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.cx = 100;
cs.cy = 100;
return TRUE;
}

C++必须使用MFC来创建窗口?
可以用API创建窗口的。MFC只是做了一定的封装,大大方便使用了而已。如下是DEV-C++里一个sample,用的API。
#include
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
怎样让无边框的窗口可随意拖动?
启动窗口→左边→属性→下移→随意移动→选择→真 或者 直接在命令里写 随意移动=真
MFC怎样使单击按键保持窗口在最前端,再点击取消最前端
你的最前端指的是最上层?即在所有其他窗口之上?
建议试试这个函数:SetWindowPos;
CDialog::SetWindowPos(NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);//告诉windows:我的样式改变了,窗口位置和大小保持原来不变!
后面的参数表示不要改变窗口位置和大小,第一个参数即NULL可以改,NULL则窗口所在的层不变,如果写&wndTopMost则置于全部窗口之上。当然也可以放到特定层后面,楼主可以自己去搜
如何将本窗口显示并激活成为当前窗口
保持置顶具体语法是:
cmdow [窗体名称] /top
取消置顶:
cmdow [窗体名称] /not
当然,还需要用到配套的激活窗体参数:
cmdow [窗体名称] /ACT 激活指定的窗口.
cmdow [窗体名称] /INA 取消指定窗口的激活状态.
在你调用其他程序后,直接来一句激活的排除本窗体的命令不就达到你的要求了吗?
VC/MFC如何将本窗口显示并激活成为当前窗口
需要获取窗口2的指针。。在窗口1创建的时候,重载构造函数就行了CTestDlg(CWnd* pParent = NULL);//你把指针传过来就可以用了H
MFC中怎样将设置弹出窗口在屏幕的位置?怎么解决的啊。。。谢啦!!!
如果是自己定义的窗口,那么MoveWindow、SetWindowPos都可以设置位置。
如果是MessageBox之类的系统窗口,无法指定详细的弹出位置。
请问MFC中要实现单击一个按钮控件,弹出另外一个窗口用什么函数实现?
首先要做好弹出的对话框,绑定类比如 dlg_pop
弹出有两种形式
模态对话框:
dlg_pop dp;
dp.Domodal();
非模态:
dlg_pop dp;//这句一定要放在cpp文件的全局位置,否则不会弹出
按钮代码:
if (!dp.m_hWnd) //判断对话框是否已被创建
{
dp.Create(IDD_POP); //IDD_POP是对话框ID,创建对话框的时候可以设置
}
dp.ShowWindow(SW_SHOW);
模态和非模态的区别你一试就知道了
mfc如何创建一个屏幕窗口。就像图中那样。
你只的是**的像粉笔一样的吗?
如果创建窗口自然是SetWindowRgn创建异形窗口
但是图中这个场景不适合用窗口,这个粉笔应该是一个CURSOR,也就是光标。
在资源中添加一个资源,画成粉笔样式,然后用LoadCursor装在光标,SetCursor设置光标即可。
也可以用LoadCursorFromFile从文件装在光标,得到HCURSOR,然后SetCursor