顺序问题

tdtdtdtdtd123 2006-07-29 11:11:44
onsize() 在OnInitDialog() 前运行 如何修改为onsize() 在OnInitDialog() 后运行 呢?
...全文
169 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
折腾_苏州 2006-07-29
  • 打赏
  • 举报
回复
能否发给我看看 lzhao@starit.com
pomelowu 2006-07-29
  • 打赏
  • 举报
回复
他的OnSize第一次就在OnIninDialog之后么?
tdtdtdtdtd123 2006-07-29
  • 打赏
  • 举报
回复
你要分,按给你1000分没问题啊,你只要解决这个问题,
因为例子没有说明,我不知道,他如何做的,你的那个放发,我想过的
我想不明百,它如何作到的
tdtdtdtdtd123 2006-07-29
  • 打赏
  • 举报
回复
安在做的一个例子,在调是中他 的代码是onsize() 在OnIninDialog() 之后运行的
但按的之前运行,
折腾_苏州 2006-07-29
  • 打赏
  • 举报
回复
程序运行机制,改不了
onsize() 里处理可以这样;
if(某窗口/控件句柄!=0){处理;}

ps:

1分 , 你也太...........~~~~~~~~~~~~~
pomelowu 2006-07-29
  • 打赏
  • 举报
回复

WM_INITDIALOG并不是像WM_CREATE一样的窗口回调消息。。。是创建Dialog之后SendMessage的。你要么在OnInitDialog中再发一次WM_SIZE
tdtdtdtdtd123 2006-07-29
  • 打赏
  • 举报
回复
// ffDlg.cpp : implementation file
//我仿照的代码

#include "stdafx.h"
#include "ff.h"
#include "ffDlg.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 About

CStatusBarCtrl 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()

/////////////////////////////////////////////////////////////////////////////
// CFfDlg dialog
CFfDlg::~CFfDlg()
{
delete this->m_pClient;
delete this->m_pServer;
}
CFfDlg::CFfDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFfDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFfDlg)
// 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 CFfDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFfDlg)
DDX_Control(pDX, IDC_TAB, m_ctlTab);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CFfDlg, CDialog)
//{{AFX_MSG_MAP(CFfDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_SIZE()
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnSelchangeTab)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFfDlg message handlers

BOOL CFfDlg::OnInitDialog()
{
//该void CFfDlg::OnSize(UINT nType, int cx, int cy) 在CFfDlg::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_ctlTab.InsertItem(PAGE_CLIENT,"Client");
this->m_ctlTab.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_ctlTab.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.right - 70)/2+70,(rect.right - rect.left),-1};
g_StatusBar.SetParts(4,wid);
g_StatusBar.SetText("服务未启动",0,0);
return TRUE; // return TRUE unless you set the focus to a control
}

void CFfDlg::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 CFfDlg::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 CFfDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CFfDlg::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int nIndex;
nIndex = this->m_ctlTab.GetCurSel();
switch(nIndex)
{
case PAGE_CLIENT:
this->m_pServer->ShowWindow(SW_HIDE);
this->m_pClient->ShowWindow(SW_SHOW);
this->m_pClient->UpdateData();
break;
case PAGE_SERVER:
this->m_pClient->ShowWindow(SW_HIDE);
this->m_pServer->ShowWindow(SW_SHOW);
this->m_pServer->UpdateData();
break;
default:
break;
}
*pResult = 0;
}

void CFfDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);

// TODO: Add your message handler code here
RECT rect,rc1,rc2;
this->GetClientRect(&rect);
//以下代码注释,否则不能运行
//该OnSize 在BOOL CFfDlg::OnInitDialog() 之前运行

//g_StatusBar.GetRect(0,&rc2);
/*this->m_ctlTab.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_ctlTab.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);
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);

int wid[4] = {70,(rect.right- rect.left -70)/2 + 70,(rect.right - rect.left),-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.GetText(s[0],0,0);
g_StatusBar.GetText(s[1],1,0);
g_StatusBar.GetText(s[2],2,0);*/
}
tdtdtdtdtd123 2006-07-29
  • 打赏
  • 举报
回复
好的我把我的仿照做的,及原来的发给你看看
tdtdtdtdtd123 2006-07-29
  • 打赏
  • 举报
回复
他的OnSize第一次就在OnIninDialog之后 是地

16,471

社区成员

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

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

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