vs c++MFC窗口一个图片输出问题 菜鸟....
voidCaDlg::OnBnClickedButton1(){UpdateData(true);GetDlgItem(IDC_EDIT1)->GetWindowText...
void CaDlg::OnBnClickedButton1()
{
UpdateData(true);
GetDlgItem(IDC_EDIT1)->GetWindowText(s1);
GetDlgItem(IDC_EDIT2)->GetWindowText(s2);
CString s1;
GetDlgItemText(IDC_EDIT1, s1);
CString s2;
GetDlgItemText(IDC_EDIT2, s2);
int i1 = _ttoi(s1);
int i2 = _ttoi(s2);
// TODO: 在此添加控件通知处理程序代码
if (IsIconic())
{
CPaintDC dc(this); // 用于绘制的设备上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 使图标在工作区矩形中居中
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;
// 绘制图标
dc.DrawIcon(x, y, m_hIcon);
}
else
{
//CDialog::OnPaint();//要禁止这个调用
CRect rc;
GetWindowRect(&rc);
CImage mImage;
if (mImage.Load(_T("游戏背景.png")) == S_OK)
{
//这里让图片绘制区域和窗口大小一致
mImage.Draw(GetDC()->GetSafeHdc(), CRect(0, 0, rc.Width(), rc.Height()));
}
CDialogEx::OnPaint();
}
//CString s3;
//s3 = s2;
//MessageBox(s3); //测试函数
double n = 0;
int x2, y2;
int a[50];
int i;
for (i = 0; i < 50; i++)
{
a[i] = 1;
}
for (i = i1; i < 50; i++)
a[i] = 0;
int m,x,z,k=0;
i = 0;
for ( m = 0; m< i1 - 1; m++)
{
for (x,z=0; z< i2;)
{
i = i + 1;
if ( i < i1)
{
if (a[i] = 1)
{
z++;
if (z = i2)
a[i] = 0;
}
}
if (i = i1)
i =0;
}
}
int j=0;
n = (2 * 3.14*j) / i1;
for (j = 0; j<i1; j++)
{
if (a[j] = 0)
{
CMFCButton *button_menu_star = new CMFCButton;
button_menu_star->Create(TEXT(""), WS_VISIBLE, CRect(750+600*sin(n),350+325*cos(n), 750 + 600 * sin(n)+59, 350 + 325 * cos(n)+ 112), this, IDC_BUTTON5);
button_menu_star->SetImage(IDB_PNG4);
}
if(a[j]!=0)
{
CMFCButton *button_menu_star = new CMFCButton;
button_menu_star->Create(TEXT(""), WS_VISIBLE, CRect(750 + 600 * sin(n), 350 + 325 * cos(n), 750 + 600 * sin(n) + 59, 350 + 325 * cos(n) + 112), this, IDC_BUTTON5);
button_menu_star->SetImage(IDB_PNG5);
}
n = (2 * 3.14*j) / i1;
}
CMFCButton *button_menu_star = new CMFCButton; //多重定义
int x1,y1;
x1 = 700;
y1 = 300;
button_menu_star->Create(TEXT(""), WS_VISIBLE, CRect(x1,y1,x1+131, y1+182), this, IDC_BUTTON5);
button_menu_star->SetImage(IDB_PNG3);
}
编辑完数据
点击BUTTON1
理应数组a中应该右一个0值
对应窗口中也应该右2
IDB_PNG4
IDB_PNG5
但缺少了
IDB_PNG5 展开
{
UpdateData(true);
GetDlgItem(IDC_EDIT1)->GetWindowText(s1);
GetDlgItem(IDC_EDIT2)->GetWindowText(s2);
CString s1;
GetDlgItemText(IDC_EDIT1, s1);
CString s2;
GetDlgItemText(IDC_EDIT2, s2);
int i1 = _ttoi(s1);
int i2 = _ttoi(s2);
// TODO: 在此添加控件通知处理程序代码
if (IsIconic())
{
CPaintDC dc(this); // 用于绘制的设备上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 使图标在工作区矩形中居中
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;
// 绘制图标
dc.DrawIcon(x, y, m_hIcon);
}
else
{
//CDialog::OnPaint();//要禁止这个调用
CRect rc;
GetWindowRect(&rc);
CImage mImage;
if (mImage.Load(_T("游戏背景.png")) == S_OK)
{
//这里让图片绘制区域和窗口大小一致
mImage.Draw(GetDC()->GetSafeHdc(), CRect(0, 0, rc.Width(), rc.Height()));
}
CDialogEx::OnPaint();
}
//CString s3;
//s3 = s2;
//MessageBox(s3); //测试函数
double n = 0;
int x2, y2;
int a[50];
int i;
for (i = 0; i < 50; i++)
{
a[i] = 1;
}
for (i = i1; i < 50; i++)
a[i] = 0;
int m,x,z,k=0;
i = 0;
for ( m = 0; m< i1 - 1; m++)
{
for (x,z=0; z< i2;)
{
i = i + 1;
if ( i < i1)
{
if (a[i] = 1)
{
z++;
if (z = i2)
a[i] = 0;
}
}
if (i = i1)
i =0;
}
}
int j=0;
n = (2 * 3.14*j) / i1;
for (j = 0; j<i1; j++)
{
if (a[j] = 0)
{
CMFCButton *button_menu_star = new CMFCButton;
button_menu_star->Create(TEXT(""), WS_VISIBLE, CRect(750+600*sin(n),350+325*cos(n), 750 + 600 * sin(n)+59, 350 + 325 * cos(n)+ 112), this, IDC_BUTTON5);
button_menu_star->SetImage(IDB_PNG4);
}
if(a[j]!=0)
{
CMFCButton *button_menu_star = new CMFCButton;
button_menu_star->Create(TEXT(""), WS_VISIBLE, CRect(750 + 600 * sin(n), 350 + 325 * cos(n), 750 + 600 * sin(n) + 59, 350 + 325 * cos(n) + 112), this, IDC_BUTTON5);
button_menu_star->SetImage(IDB_PNG5);
}
n = (2 * 3.14*j) / i1;
}
CMFCButton *button_menu_star = new CMFCButton; //多重定义
int x1,y1;
x1 = 700;
y1 = 300;
button_menu_star->Create(TEXT(""), WS_VISIBLE, CRect(x1,y1,x1+131, y1+182), this, IDC_BUTTON5);
button_menu_star->SetImage(IDB_PNG3);
}
编辑完数据
点击BUTTON1
理应数组a中应该右一个0值
对应窗口中也应该右2
IDB_PNG4
IDB_PNG5
但缺少了
IDB_PNG5 展开
1个回答
展开全部
nclude<afxwin.h>
//说明应用程序类class CHelloApp:public CWinAPP
{
public:
virtual BOOL InitInstance();
};//建立应用程序类实例
CHelloApp HelloApp;//说明主窗口类class CHelloWindow:public CFrameWnd
{
CStatic*cs;
public:
CHelloWindow();
};
//每当应用程序首次执行的时候都要调用的初始化函数
BOOL CHelloApp::InitInstance()
{
m_pMainWnd=new CHellowindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TURE;
}
//窗口类的构造函数
CHelloWindow::CHelloWindow()
{
//建立窗口本身
Create(NULL,"Hello World!",WS_OVERLAPPEDWINDOW,CRect(0,0,200,200); //建立静态标签
cs=new CStatic();
cs->Create("hello world",WS_CHILD|WS_VISIBLE|SS_CENTER,CRect(50,80,150,150),this);
}
//说明应用程序类class CHelloApp:public CWinAPP
{
public:
virtual BOOL InitInstance();
};//建立应用程序类实例
CHelloApp HelloApp;//说明主窗口类class CHelloWindow:public CFrameWnd
{
CStatic*cs;
public:
CHelloWindow();
};
//每当应用程序首次执行的时候都要调用的初始化函数
BOOL CHelloApp::InitInstance()
{
m_pMainWnd=new CHellowindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TURE;
}
//窗口类的构造函数
CHelloWindow::CHelloWindow()
{
//建立窗口本身
Create(NULL,"Hello World!",WS_OVERLAPPEDWINDOW,CRect(0,0,200,200); //建立静态标签
cs=new CStatic();
cs->Create("hello world",WS_CHILD|WS_VISIBLE|SS_CENTER,CRect(50,80,150,150),this);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询