如何使用 MFC 应用程序 (C++ Visual Studio 2010) 中的按钮更改图像的可见性属性? [英] How to change the Visible Property of an image using a button in MFC application (C++ Visual Studio 2010)?

查看:65
本文介绍了如何使用 MFC 应用程序 (C++ Visual Studio 2010) 中的按钮更改图像的可见性属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个程序,当按下应用程序中名为隐藏的某个按钮时,图像会消失.

I am trying to make a program where an image would disappear when a certain a button called hide in the application is pressed.

我知道在 Windows 窗体应用程序中它会是这样的:

I know in Windows form application it would be something like this:

    pictureBox1->Visible=true/false;

但是该代码在 MFC 中不起作用

But that code wouldn't work in MFC

我在 MFC 中的代码是

My code in MFC is

     Cstatic pictureBox1 =(Cstatic)Getdialogitem(IDC_IMAGE1);
     pictureBox1->Visible=false; 

推荐答案

尝试

pictureBox1->ShowWindow(SW_HIDE);

pictureBox1->ShowWindow(SW_SHOW);

在 MFC 中,简单地将成员变量设置为新值并不能完成任何事情;您需要调用将执行特定操作的函数.

In MFC, simply setting a member variable to a new value doesn't accomplish anything; you need to call functions that will take specific actions.

这篇关于如何使用 MFC 应用程序 (C++ Visual Studio 2010) 中的按钮更改图像的可见性属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆