100分求问MFC菜鸟问题

load111 2005-04-21 10:23:09
小弟近日开始学习MFC,遇见几个问题,请各位指教

1.MessageBox() 和AfxMessageBox()有区别吗,没区别为何放2个,有区别是什么区别

2,如何实现点一个Button就将它禁用,好象不可以使用.Disabled=true;

3.如何判断几个RadioButton哪一个被选择?


请各位尽量详细的回答一下,我确实很菜
...全文
153 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
Fzergling 2005-04-22
  • 打赏
  • 举报
回复
GetCheckedRadioButton可以获得连续几个的,第一个参数是第一个ID,第二个参数是最后一个的ID
pomelowu 2005-04-21
  • 打赏
  • 举报
回复
忘了括号了。
GetCheck返回一个int,0表示没选中,1表示选中——如果我没记错的话
load111 2005-04-21
  • 打赏
  • 举报
回复
好了 明白了 搞定了 谢谢各位老大 先就散分
load111 2005-04-21
  • 打赏
  • 举报
回复
有错啊 老大!


GetCheckedRadioButton只能查2个radiobutton吗?我现在是3个radiobutton怎么办??
lemonvivian 2005-04-21
  • 打赏
  • 举报
回复
三个RadioButton的ID要连续,给第一个RadioButton设置group属性,并给第一个关联变量就行了
bug123 2005-04-21
  • 打赏
  • 举报
回复
我觉得应该给分了。老大!
Fzergling 2005-04-21
  • 打赏
  • 举报
回复
int nCheck=CDialog::GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO3)
返回的是选中Button的ID
load111 2005-04-21
  • 打赏
  • 举报
回复
RadioButton1,RadioButton12,RadioButton3,
都选择了group属性,关联变量m_1,m_2,m_3
最好能给写个带if的句子判断看看
load111 2005-04-21
  • 打赏
  • 举报
回复
我设了3个RadioButton,给都选择了group属性后,应该给哪一个关联变量啊?
pomelowu 2005-04-21
  • 打赏
  • 举报
回复
补充一下
1 Afx开头的函数实际上是对API的封装,提供了一些默认值,用起来更方便
2
3 可以用((CButton *)GetDlgItem(IDC_RADIO1))->GetCheck来判断某一个radio是不是选中状态
Kudeet 2005-04-21
  • 打赏
  • 举报
回复
给radiobutton关联一个变量,变量的返回值就是那个被选了,我上面的getwindowtext是根据选择的结果得到被选择项的文字
dfyang 2005-04-21
  • 打赏
  • 举报
回复
都说了,只能补充一下:
3、将几个RadioButton(ID连续)设为一个group,为其添加一个int变量,在你想知道哪个被选中之处添加:UpdateData();则该变量值就反应了哪个被选了
xuzheng318 2005-04-21
  • 打赏
  • 举报
回复
MessageBox
This function creates, displays, and operates a message box. The message box contains an application-defined message and title, plus any combination of predefined icons and push buttons.

int MessageBox(
HWND hWnd,
LPCTSTR lpText,
LPCTSTR lpCaption,
UINT uType);

If you create a message box while a dialog box is present, use the handle of the dialog box as the hWnd parameter. The hWnd parameter should not identify a child window, such as a control in a dialog box.







AfxMessageBox
This function displays a message box on the screen. The first form of this overloaded function displays a text string pointed to by lpszText in the message box and uses nIDHelp to describe a Help context. The Help context is used to jump to an associated Help topic when the user presses the Help key (typically F1).

The second form of the function uses the string resource with the ID nIDPrompt to display a message in the message box. The associated Help page is found through the value of nIDHelp. If the default value of nIDHelp is used (–1), the string resource ID, nIDPrompt, is used for the Help context.

int AfxMessageBox(
LPCTSTR lpszText,
UINT nType = MB_OK,
UINT nIDHelp = 0 );
int AFXAPI AfxMessageBox(
UINT nIDPrompt,
UINT nType = MB_OK,
UINT nIDHelp = (UINT) -1 );



load111 2005-04-21
  • 打赏
  • 举报
回复
前2个问题回答的的精彩, 但第3个问题小弟还是没有怎么理解 能否再讲解下

底子比较弱,脑袋比较苯。。。
an_bachelor 2005-04-21
  • 打赏
  • 举报
回复
一点补充:MessageBox是一个Win32 API函数但是CWnd中也实现了这个函数
Kudeet 2005-04-21
  • 打赏
  • 举报
回复
1 Afx开始的函数表示MFC的全局函数,不属于任何类.MessageBox是API
2 GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
3
CString str;
UpdateData();
GetDlgItem(ID_RADIO1+m_xuanzed)->GetWindowText(str);
//其中ID_RADIO1是被选中group属性的按钮ID,也是第一个的ID,str保存的是选中项的字符串
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=195582

16,550

社区成员

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

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

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