小编Him*_*shu的帖子

如何在mfc中的两个对话框之间传递数据

我在mfc和主视图中有一个对话框.视图启动一个新对话框,它接受两个int值,我想将这些值返回到我的视图.我知道我必须用dodataexchange做一些事情,这是我对话框中的代码:

void MapCreator::DoDataExchange(CDataExchange* pDX){    

    CDialogEx::DoDataExchange(pDX);

    CString stringColumn; 
    CString stringRow; 

    CWnd* dialog = GetDlgItem(columns);
    dialog->GetWindowText(stringColumn);

    dialog = GetDlgItem(rows);
    dialog->GetWindowText(stringRow);

    int numColumn = _wtoi(stringColumn);
    int numRow = _wtoi(stringRow);

    DDX_Text(pDX, columns, numColumn);
    DDV_MinMaxInt(pDX, numColumn, 1, 50); 
    DDX_Text(pDX, rows, numRow);
    DDV_MinMaxInt(pDX, numRow, 1, 50); 

}
Run Code Online (Sandbox Code Playgroud)

现在我如何在视图中访问这些值?

c++ mfc

2
推荐指数
1
解决办法
8270
查看次数

我可以在MFC CListBox中添加多个列吗?

我有一个带有CListBox的对话框。我必须在此列表框中添加3列。
有什么办法可以在CListBox中具有几个不同的列?
CListCtrl在这方面可以提供帮助吗?

c++ mfc clistbox visual-studio-2010

2
推荐指数
1
解决办法
9897
查看次数

如何通过下划线获取对象数组的唯一键?

我有一个array对象,并希望通过下划线获取唯一键,我该怎么做?

Array[ Object{a: 1, b: 2}, Object{b: 3, c: 4, d: 5} ]
Run Code Online (Sandbox Code Playgroud)

我想得到:

Array[ "a", "b", "c", "d" ]
Run Code Online (Sandbox Code Playgroud)

javascript underscore.js

2
推荐指数
1
解决办法
2379
查看次数

Indexer c#中的System.StackOverflowException

MyDict m = new MyDict();
m.Add("a", "a");
string s = m["a"]; // Getting exception here
Run Code Online (Sandbox Code Playgroud)

下面是Indexer的实现

public class MyDict: Dictionary<string,string>
{
    public string this[string key]
    {
        get
        {
             return this[key];
        }
        set
        {
            this[key] = value;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

例外:

An unhandled exception of type 'System.StackOverflowException' 
occurred in ConsoleApplication2.exe
Run Code Online (Sandbox Code Playgroud)

.net c# indexer

2
推荐指数
1
解决办法
324
查看次数

是否真的可以使用 CFile 和 CStdio 类将数据附加到 MFC 中的文本文件?

是否真的可以通过使用CFileCStdio类将数据附加到 MFC 中的文本文件中??如果是,那么如何?

我使用以下代码附加数据,但它只提供最新的(最后输入的)数据。

UpdateData(TRUE);
CStdioFile file_object;//(L"D://Docs//Temp.txt",
    CFile::modeCreate | CFile::modeReadWrite | CFile::modeRead); 
CString str = L"D://Docs//Temp.txt";
CString fc1, fc2;

BOOL bFile = file_object.Open(str, 
    CFile::modeCreate | CFile::modeReadWrite | CFile::modeRead);
if (bFile)
    file_object.Seek(file_object.GetLength(), CFile::end);

fc1.Format(L"%f", m_CelTemp);
file_object.WriteString(L"Temp in Celsius is:");     
file_object.WriteString(fc1);
file_object.WriteString(L"\n");

fc2.Format(L"%f", m_FarTemp);
file_object.WriteString(L"Temp in Fahrenheit is:");      
file_object.WriteString(fc2);
file_object.WriteString(L"\n");

UpdateData(FALSE); 
Run Code Online (Sandbox Code Playgroud)

c++ mfc file-handling visual-c++

2
推荐指数
1
解决办法
6698
查看次数

计算机如何比较底层的两个数字?

我编写了如下代码:

int a = -1;
unsigned int b = 0xffffffff;

if (a == b)
    printf("a == b\n");
else
    printf("a != b\n");

printf("a = %x b = %x\n", a, b);
return 0;
Run Code Online (Sandbox Code Playgroud)

结果如下:
在此输入图像描述

它表明a和b是相等的.所以我想知道计算机如何做出判断?

c

2
推荐指数
1
解决办法
70
查看次数

Python:如果变量是整数或浮点数,则为真

我正在尝试从书籍作业中编写一个小程序,但是我在检测用户输入是否为int/float(增加到总数)或string(return error)时遇到问题.我尝试在add_to_total变量上使用.isdigit()但是当我键入float时,它会直接跳到else代码块.我试过在网上搜索但找不到明确的答案.这是我的代码:

total = 0
print("Welcome to the receipt program!")

while True:
    add_to_total = raw_input("Enter the value for the seat ['q' to quit]: ")
    if add_to_total == 'q':
        print("*****")
        print "Total: $%s" % total
        break
    if add_to_total.isdigit(): #Don't know how to detect if variable is int or float at the same time.
        add_to_total = float(add_to_total)
        total += add_to_total
    else:
        print "I'm sorry, but '%s' isn't valid. Please try again." % …
Run Code Online (Sandbox Code Playgroud)

python variables methods int integer

1
推荐指数
2
解决办法
1055
查看次数

计算白色和黑色像素

我正在编写一个计算黑白像素的函数.
是否有Matlab计算白色和黑色像素的功能?
我知道我可以使用size方法和2 for循环和计数.
像这样的东西:

[row, column]= size(im);
cb = 0;
cw = 0;
for i=1:row
    for j=1:column
        if(im(i,j) == 0 )
            cb = cb + 1;
        end
        if(im(i,j) == 255)
            cw = cw + 1;
        end
    end
end
Run Code Online (Sandbox Code Playgroud)

但我正在寻找一些更简单的方法.你知道吗?

matlab image-processing

1
推荐指数
1
解决办法
1916
查看次数

C语言中如何判断给定的数组是否按降序排序

我需要找出给定的数组是否按降序排序...
我得到了输出,但在门户中它显示为错误答案。

这是我的代码。

#include<stdio.h>
int main()
{
   int n,a[15],i,k=0;
   scanf("%d",&n);
   for(i=1;i<=n;i++)
   { scanf("%d",&a[i]);}
   for(i=1;i<=n;i++)
   {
      if(a[i]<a[i+1])
         k++;
   }
   if(k==0)
      printf("yes");
   else
       printf("no");
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

帮我想想办法...

c arrays sorting

1
推荐指数
1
解决办法
2万
查看次数

使用+ =在C++中的条件运算

以下陈述是做什么的?
gcc的输出是:1 101.
谁能解释为什么会这样呢?

int a = 100, b = 108, c = 2;
a += b ? c = 1 : c = 0;
cout << c << " " << a;
Run Code Online (Sandbox Code Playgroud)

c++

1
推荐指数
1
解决办法
91
查看次数