onsize() 在OnInitDialog() 前运行 如何修改为onsize() 在OnInitDialog() 后运行 呢?
解决方案 »
- 求助,关于非MFC环境下如何挂接IWebBrowser2的新窗口事件
- 旧年最后一天散分
- 请问VC6.0的工程如何移植到Visual Studio 2008中呢?或者这两个平台具体有哪些区别?
- c++程序员的开始几年
- 高分求助 int数组 转化为variant
- 数据转换
- 关于CDialogBar和切分窗口的问题,谢谢(急切等待中......)
- 谁有文件压缩和解压的代码或sdk
- 急问,,ADO访问SQL数据库问题 ·!·!
- 这样查看registered active control 方法的用法和作用
- 问个boost::regex_match在Debug模式下匹配不正常的问题!
- 为什么 VC 下调用 DLL 还要一个 lib 文件才行?
OnSize里根据这个值进行处理
//源代码#include "stdafx.h"
#include "FileShare.h"
#include "FileShareDlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif#define PAGE_CLIENT 0
#define PAGE_SERVER 1/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App AboutCStatusBarCtrl g_StatusBar;class CAboutDlg : public CDialog
{
public:
CAboutDlg();// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA // ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CFileShareDlg dialogCFileShareDlg::CFileShareDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFileShareDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFileShareDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}void CFileShareDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFileShareDlg)
DDX_Control(pDX, IDC_TAB, m_ctrlTab);
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CFileShareDlg, CDialog)
//{{AFX_MSG_MAP(CFileShareDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_SIZE()
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnSelchangeTab)
ON_COMMAND(IDM_EXIT, OnExit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CFileShareDlg message handlersBOOL CFileShareDlg::OnInitDialog()
{
CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000); RECT rect;
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
} // Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here g_StatusBar.Create(WS_CHILD|WS_VISIBLE|CCS_BOTTOM|SBARS_SIZEGRIP,
CRect(0,0,0,0), this, IDC_STATUS_BAR); this->m_ctrlTab.InsertItem(PAGE_CLIENT,"Client");
this->m_ctrlTab.InsertItem(PAGE_SERVER,"Server");
this->m_pClient = new CClientDlg(this);
this->m_pServer = new CServerDlg(this); this->m_pClient->Create(IDD_CLIENT,this);
this->m_pServer->Create(IDD_SERVER,this);
this->m_ctrlTab.SetCurSel(PAGE_CLIENT);
this->m_pServer->ShowWindow(SW_HIDE);
this->m_pClient->ShowWindow(SW_SHOW);
this->m_pClient->UpdateWindow(); this->GetClientRect(&rect);
int wid[4]={70,(rect.right-rect.left-70)/2+70,(rect.right-rect.left),-1};//{rect.right-300, rect.right-200, rect.right-100,-1};
g_StatusBar.SetParts(4,wid);
g_StatusBar.SetText("服务未启动",0,0); return TRUE; // return TRUE unless you set the focus to a control
}void CFileShareDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.void CFileShareDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CFileShareDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}void CFileShareDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
// HWND h = GetDlgItem(IDC_TAB)->GetSafeHwnd();
// ::SetWindowPos(h,NULL,0,0,cx,cy,SWP_SHOWWINDOW);
// this->m_ctrlTab.MoveWindow(0,0,cx,cy,TRUE);
RECT rect,rc1,rc2;
this->GetClientRect(&rect);// this->m_ctrlTab.AdjustRect(FALSE,&rect);
// this->m_ctrlTab.MoveWindow(&rect,TRUE); g_StatusBar.GetRect(0,&rc2);
this->m_ctrlTab.SetWindowPos(NULL,0,0,cx,cy-(rc2.bottom-rc2.top),SWP_SHOWWINDOW);
g_StatusBar.GetRect(0,&rc2);
g_StatusBar.SetWindowPos(NULL,rect.left,rect.bottom-(rc2.bottom-rc2.top),cx,rc2.bottom-rc2.top,SWP_SHOWWINDOW); this->m_ctrlTab.GetItemRect(0,&rc1);
m_pClient->SetWindowPos(NULL,rect.left,rect.top+(rc1.bottom-rc1.top),rect.right-rect.left,(rect.bottom-rect.top)-(rc2.bottom-rc2.top)-14,0);//SWP_SHOWWINDOW);
m_pServer->SetWindowPos(NULL,rect.left,rect.top+(rc1.bottom-rc1.top),rect.right-rect.left,(rect.bottom-rect.top)-(rc2.bottom-rc2.top)-14,0);//SWP_SHOWWINDOW);
// this->GetClientRect(&rect);
int wid[4]={70,(rect.right-rect.left-70)/2+70,(rect.right-rect.left),-1};//{rect.right-300, rect.right-200, rect.right-100,-1};
g_StatusBar.SetParts(4,wid);
char s[3][256];
g_StatusBar.GetText(s[0],0,NULL);
g_StatusBar.GetText(s[1],1,NULL);
g_StatusBar.GetText(s[2],2,NULL);
g_StatusBar.SetText(s[0],0,0);
g_StatusBar.SetText(s[1],1,0);
g_StatusBar.SetText(s[2],2,0);
/*
int wid[4];
wid[0]=60;
wid[1]=((cy)-wid[0])/2;
wid[2]=wid[1];
wid[3]=-1;
g_StatusBar.SetParts(4,wid);
g_StatusBar.SetText("服务未启动",0,0);*/
// this->m_ctrlTab.SetItemSize(CSize(cx,cy));
// this->m_ctrlTab.GetClientRect(&rect);
// this->m_pClient->ShowWindow(SW_SHOW);
// this->m_pClient->UpdateWindow();
}
void CFileShareDlg::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int nIndex;
nIndex=this->m_ctrlTab.GetCurSel();
switch(nIndex)
{
case PAGE_CLIENT:
this->m_pServer->ShowWindow(SW_HIDE);
this->m_pClient->ShowWindow(SW_SHOW);
this->m_pClient->UpdateWindow();
break;
case PAGE_SERVER:
this->m_pClient->ShowWindow(SW_HIDE);
this->m_pServer->ShowWindow(SW_SHOW);
this->m_pServer->UpdateWindow();
break;
default:
break;
}
*pResult = 0;
}CFileShareDlg::~CFileShareDlg()
{
delete this->m_pClient;
delete this->m_pServer;
}void CFileShareDlg::OnExit()
{
SendMessage(WM_CLOSE);
}
if(!g_StatusBar.GetSafeHud())
{
g_StatusBar.....
}
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
...
if (CreateDlgIndirect(lpDialogTemplate,CWnd::FromHandle(hWndParent), hInst))
//分开
BOOL CALLBACK AfxDlgProc(HWND hWnd, UINT message, WPARAM, LPARAM)
{
if (message == WM_INITDIALOG)
{
// special case for WM_INITDIALOG
CDialog* pDlg = DYNAMIC_DOWNCAST(CDialog, CWnd::FromHandlePermanent(hWnd));
if (pDlg != NULL)
return pDlg->OnInitDialog();//粒子
else
return 1;
}
return 0;
}
//偶的访写 在mfc中变成了
if (CreateDlgIndirect(lpDialogTemplate,CWnd::FromHandle(hWndParent), hInst))
//lpDialogTemplate = 0x00607da0
hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
pParentWnd->GetSafeHwnd(), AfxDlgProc);
咋会这样呢?