我爱builder

C++Builder 程序员博客

是这样的,我刚下好c++builder 2009,就想实现下面的这个功能:

1)从TEdit控件的Text属性中得到文本,建立一个String类型的变量Tmp进行接受。

2)把这个变量赋给SetWindowText函数的第二个参数,第二个参数是char*类型的。

3)问题就在这里了,把Tmp变量赋过去,无论如何都不对,我尝试了好几种转化地方法都不成功。

望哪位大拿来帮帮忙,在这里先谢谢了。

明后天都会有考试,我也就不在线等了,不过我一定会抽出来时间看看的!

问题解决了,其实不是什么编码的问题,而是SetWindowText第二个参数根本不是char*而是const char*。

看来相似的两个指针,就是差了那么一点,用的方法就是楼上的那个str.c_str()方法,很简单的一个问题,没难度。

没想到楼上的兄弟也是个夜猫子。。。

不过夜猫子也好,这个问题总算搞明白了,睡觉去!一晚上没睡了。

  • Filed under: C++ Builder
  • 下载链接:http://installers.codegear.com/update/radstudio/6.0/12.0.3210.17555.2.rtm/Delphi_CBuilder2009Update1.exe
    更新说明:http://dn.codegear.com/article/38782
    破解(bds_V12.0.3210.17555.exe.bak为破解前的bds.exe,bds_V12.0.3210.17555.exe为破解后的bds.exe):
    D:\>fc /b bds_V12.0.3210.17555.exe.bak bds_V12.0.3210.17555.exe
    正在比较文件 bds_V12.0.3210.17555.exe.bak 和 BDS_V12.0.3210.17555.EXE
    00006F28: 55 B0
    00006F29: 8B 00
    00006F2A: EC C3

    00006F6C: 55 B0
    00006F6D: 8B 00
    00006F6E: EC C3

    00006FB0: 55 B0
    00006FB1: 8B 00
    00006FB2: EC C3

    000072A8: 55 B0
    000072A9: 8B 00
    000072AA: EC C3

    000073D0: BA B0
    000073D1: E0 00
    000073D2: 7F C3

    我等大侠出LITE版了.

    和这个有什么区别:
    http://topic.csdn.net/u/20081027/18/7ca3341a-2e05-4a20-960c-ad61a83f3ef1.html

    破解好的文件已经放入纳米:

    http://www.namipan.com/d/44b8b01038314c9e59c32190e8acda3589f4191800020f00

    刚升了17555.1,就来一个17555.2.rtm

    请问有区别么

    我升的是Setup.12.0.3210.17555.1.exe

    反正我不升,呵呵

    我的所有工程项目仍然用BCB6,移植到BCB2009后某些第三方的控件工作不正常,无法解释,遂放弃。

    ……
    俺还在拉着6.0……觉得符合当前生产力发展需求,于是不打算变更生产关系。

    刚刚下了,貌似之前的两个补丁都是内部泄漏的,这个才是官方的update1

    好。。。。。。。。。。

    忍一忍,到 09 年,再看2009. 那時該有Up2了。

    bs 0

    6.0主要的问题是不支持Unicode,还有就是VCL控件版本不及D7的。

    否则是一个很好的选择。

    感谢分享!

    支持,早就升级了。

    目前最大的遗憾是没见到 Ehlib for 2009版,和一个好用的第三方报表控件。

    hao

    我第一个还没装就升级了

    差不多

    升级过程中不停地提示复制文件的权限不足,请重试,按“Retry”后就竟然可以了。
    这个过程中不停地按“Retry”按到手软………….

    引用 19 楼 fayfarn 的回复:

    升级过程中不停地提示复制文件的权限不足,请重试,按“Retry”后就竟然可以了。
    这个过程中不停地按“Retry”按到手软………….


    是不是有一个xmlmapper.exe,这个需要手工从安装源当中复制到bin目录,估计是安装程序的一个BUG.

    早就盼着出Update了,感谢!

    Update 完成,一切顺利,谢谢

    我用的是自动升级.

    有没有update2呀?

    引用 24 楼 hwt69love 的回复:
    有没有update2呀?

    http://download.csdn.net/source/895318

  • Filed under: C++ Builder
  • 在C++Builder 2009主窗口的public部分定义一个String 在子窗口中调用出错

    C/C++ code
    //主窗口 String PathName ;//路径名 String FileName ;//文件名 //FormCreate中初始化 PathName = ExtractFilePath(Application->ExeName)+"Data\\" ; FileName = "123.jtlc" ; //子窗口调用 String FilePath = fmMain->PathName + fmMain->FileName;//这一句正常比如为"d:\\sss\\123.jtlc" char *file = FilePath.t_str(); ifstream fin(file,ios_base::in|ios_base::binary);//在这儿file变为"d:\\sss\\123.jtlH"

    什么原因?

    用AnsiString。

    2009里String默认是UnicodeString

    引用 2 楼 ccrun 的回复:
    用AnsiString。

    2009里String默认是UnicodeString


    zi ci

  • Filed under: C++ Builder
  • 一个简单的C++使用STL的算法问题:
    我有一个函数子 ObjectEqualID, 带入两参数, 结合 std::remove_if使用,需要使用std::bind2nd来绑定第二个参数,于是有以下的代码:

    C/C++ code
    #include <functional> #include <algorithm> struct ObjectEqualID : public std::binary_function<Object, DWORD, bool> { bool operator ()(Object const& obj, DWORD dwObjID) const { return obj.GetObjID() == dwObjID; } }; Object_Iter p = std::remove_if(objs.begin(), objs.end(), std::bind2nd(ObjectEqualID(), dwObjID));

    但是这段代码remove_if那一行怎么样都没有办法编译通过, 出现链接错误:
    [TASM32 Error] AutoThread.asm(7735):  Undefined symbol: @@std@%remove_copy_if$55std@%_Vector_iterator$6Object23std@%allocator$6Object%%t131std@%binder2nd$13ObjectEqualID%%$q55std@%_Vector_iterator$6Object23std@%allocator$6Object%%t1t131std@%binder2nd$13ObjectEqualID%$55std@%_Vector_itera1elpYZsgy

    头文件已经正确加入, 后来经排除法(我换上了一个参数的函数子)后,发现是std::bind2nd有问题,于是自己操刀写了一个bind2nd, 链接正确通过, 并且成功, 百思不得其解, 今天整理代码,想把自己写的bind2nd整理至std2这个命名空间中, 居然发现同样的问题又出现了. 这回让我很头大, 因为这表明这个问题是和编译器有问题, 而不是因为STL中文件缺失或其它非编译器问题. 把bind2nd的命名空间去掉, 编译链接一切又正常.

    为了让各位确定不是自己写的bind2nd的问题, 现把bind2nd的代码奉上:

    C/C++ code
    template <typename _Pr_> class binder2nd : public std::unary_function<typename _Pr_::first_argument_type, typename _Pr_::result_type> { public: binder2nd(_Pr_ pr, _Pr_::second_argument_type value2nd) : m_pr(pr) , m_value2nd(value2nd) { } _Pr_::result_type operator ()(_Pr_::first_argument_type value) const { return m_pr(value, m_value2nd); } private: _Pr_ m_pr; _Pr_::second_argument_type m_value2nd; }; template <typename _Pr_> binder2nd<_Pr_> bind2nd(_Pr_ pr, typename _Pr_::second_argument_type value) { return binder2nd<_Pr_>(pr, value); }

    我现在预想最好的结果是, BCB应该在链接选项中有相应的兼容性选择项, 但是无耐我本人不才, 找不到.
    还有劳各位大大排忧解难.

    非常感谢

    Unix下测试没有问题:
    template <class Operation>
          class binder1st : public unary_function <typename
                            Operation::second_argument_type,
                            typename Operation::result_type> ;

          template <class Operation, class T>
          binder1st <Operation> bind1st (const Operation&, const T&);

          template <class Operation>
          class binder2nd : public unary_function <typename
                            Operation::first_argument_type,
                            typename Operation::result_type> ;

          template <class Operation, class T>
          binder2nd <Operation> bind2nd (const Operation&, const T&);

    DESCRIPTION
          Because so many functions provided by the standard library take other
          functions as arguments, the library includes classes that let you
          build new function objects out of old ones. Both bind1st() and
          bind2nd() are functions that take as arguments a binary function
          object f  and a value x, and return, respectively, classes binder1st
          and binder2nd.  The underlying function object must be a subclass of
          binary_function.

          Class binder1st binds the value to the first argument of the binary
          function, and binder2nd does the same thing for the second argument of
          the function.  The resulting classes can be used in place of a unary
          predicate in other function calls.

          For example, you could use the count_if algorithm to count all
          elements in a vector that are less than or equal to 7,  using the
          following:

          count_if (v.begin, v.end, bind1st(greater <int> (),7), littleNums)

          This function adds one to littleNums each time the predicate is true,
          i.e., each time 7 is greater than the element.

    INTERFACE
          // Class binder1st

          template <class Operation>
          class binder1st
            : public unary_function <typename
                                    Operation::second_argument_type,
                                    typename Operation::result_type>
          {
          public:

            typedef typename unary_function <typename
            Operation::second_argument_type, typename
            Operation::result_type>::argument_type argument_type;
            typedef typename unary_function <typename
            Operation::second_argument_type, typename
            Operation::result_type>::result_type result_type;

            binder1st(const Operation&,
                      const typename Operation::first_argument_type&);
            result_type operator() (const argument_type&) const;
          };

          // Class binder2nd
          template <class Operation>
          class binder2nd
            : public unary_function <typename
                                    Operation::first_argument_type,
                                    typename Operation::result_type>
          {
          public:
            typedef typename unary_function <typename
            Operation::first_argument_type, typename
            Operation::result_type>::argument_type argument_type;
            typedef typename unary_function <typename
            Operation::first_argument_type, typename
            Operation::result_type>::result_type result_type;

            binder2nd(const Operation&,
                      const typename Operation::second_argument_type&);

                                        - 2 -      Formatted:  December 23, 2008

    bind1st(3C++)              Rogue Wave Software              bind1st(3C++)
    -                                                                        -

                                    20 Mar 1996

            result_type operator() (const argument_type&) const;
          };

          // Creator bind1st

            template <class Operation, class T>
            binder1st <Operation> bind1st (const Operation&, const T&);

          // Creator bind2nd

            template <class Operation, class T>
            binder2nd <Operation> bind2nd(const Operation&, const T&);

    EXAMPLE
          //

          // binders.cpp
          //
          #include <functional>
          #include <algorithm>
          #include <vector>
          #include <iostream.h>
          int main()
          {
            typedef vector <int>::iterator iterator;
            int d1[4] = {1,2,3,4};
            //
            // Set up a vector
            //
            vector <int> v1(d1,d1 + 4);
            //
            // Create an 'equal to 3' unary predicate by binding 3 to
            // the equal_to binary predicate.
            //
            binder1st <equal_to <int> > equal_to_3 =
              bind1st(equal_to <int>(),3);
            //
            // Now use this new predicate in a call to find_if
            //
            iterator it1 = find_if(v1.begin(),v1.end(),equal_to_3);
            //
            // Even better, construct the new predicate on the fly
            //
            iterator it2 =
              find_if(v1.begin(),v1.end(),bind1st(equal_to <int>(),3));
            //
            // And now the same thing using bind2nd    20 Mar 1996

            // Same result since == is commutative
            //
            iterator it3 =
              find_if(v1.begin(),v1.end(),bind2nd(equal_to <int>(),3));
            //
            // it3 = v1.begin() + 2
            //
            // Output results
            //
            cout < < *it1 < < " " < < *it2 < < " " < < *it3 < < endl;
            return 0;
          }

          Output : 3 3 3

    还是兼容性问题。

    C/C++ code
    /* 我在BCB 6.0中测试你上面的调用是可行的(可正常通过编译连接),就是你那个调用STL库的bind2nd 是可行的,不知道你后面是不是自己写了1个binder2nd类模板的代码,我看了下,对于你自己写的binder2nd 类模板的代码中的bind2nd 函数模板的实现部分是有问题的。 我将其该为如下也是可以通过编译连接。 */ namespace MySpace { template <typename _Pr_> class binder2nd : public std::unary_function<typename _Pr_::first_argument_type, typename _Pr_::result_type> { public: binder2nd(_Pr_ pr, _Pr_::second_argument_type value2nd) : m_pr(pr) , m_value2nd(value2nd) { } _Pr_::result_type operator ()(_Pr_::first_argument_type value) const { return m_pr(value, m_value2nd); } private: _Pr_ m_pr; _Pr_::second_argument_type m_value2nd; }; /* 这个是我修改后的 template <typename _Pr_,typename _Tp> inline binder2nd<_Pr_> bind2nd(const _Pr_& pr, const _Tp& __x) { typedef typename _Pr_::second_argument_type _Arg2_type ; return binder2nd<_Pr_>(pr, _Arg2_type(__x)); } */ //这个是你原来自己的 template <typename _Pr_> binder2nd<_Pr_> bind2nd(_Pr_ pr, typename _Pr_::second_argument_type value) { return binder2nd<_Pr_>(pr, value); } } std::remove_if(objs.begin(), objs.end(),MySpace::bind2nd(ObjectEqualID(), dwObjID));

    谢谢楼上各位, 因为我以前一直用VC++, 所以还不是很习惯BCB的C++编译器, 看了楼上各位的回复后突然想到是不是因为我把所有的函数都放到头文件中的缘故, 因为我的那个包含有remove_if的函数是个static的, 然后我将其移动至.cpp文件中后, 编译通过了..!

    to: jxw1987628
    谢谢你提出我的bind2nd的问题, 我翻了一下stl的源代码, 的确和你说的是一样, 虽然我那样写不会导致有太多的问题, 不过还是非常感谢你, 在以后C++编程中我会注意的.

    结贴啦.

  • Filed under: C++ Builder
  • 我在窗体上放上一个IdTCPServer,就编译运行不了了,出现下面的东东。。。看不懂的说,谁能告诉我是怎么回事??

    ding

  • Filed under: C++ Builder
  • 如题,请问是不是同一家公司的?有什么区别?

    6.0是borland以前的产品.
    2009是borland把ide开发部门成立独立子公司codegear,并卖给易博龙后的产品和borland没关系了.
    2009和6.0最大区别是2009支持unicode,6.0不支持.
    2009支持最新的c++标准.
    2009比6.0的工程管理要好(个人观点)
    你要是想自己做软件,个人意见还是2009好,虽然6.0很经典.

    长见识了,谢谢兄台。

    学习

  • Filed under: C++ Builder
  • C++ Builder 2009 文件中如果包含
    #include "Excel_XP_SRVR.h"

    则报错
    [BCC32 Error] Excel_XP.h(37485): E2040 Declaration terminated incorrectly
    [BCC32 Error] Excel_XP.h(96311): E2040 Declaration terminated incorrectly
    [BCC32 Error] Excel_XP.h(119195): E2040 Declaration terminated incorrectly
    [BCC32 Fatal Error] Excel_XP_SRVR.h(1799): F1008 Out of memory

    如果包含 "Excel_2K_SRVR.h"

    则有另外的错误

    是不是 还有其它的补丁你没有打

    我也是 16897版本 ,测试后报连接问题

    引到6.0的lib中 也是link。。。Error大堆!

    你可以先把包安装上去就能通过了

    Component-》InstallPackage

    可以看到有2个checkbox没有勾上,一个office2000,一个officexp,

    选择officexp,点击Add按钮,找到你的bcb2009安装目录的bin目录下面

    然后有个bcbofficexp120.bpl,选择这个,你可以把你需要的组件安装上去了,

    另外也不会出现上面的报错情况!编译连接均正常

    测试版本:尾数16897

    参照楼上的方法更改,依然编译错误

    不会吧? 你程序大吗?方便发我的话,我帮你弄下!你可以加那个群联系我!

  • Filed under: C++ Builder
  • C/C++ code
    //————————————————————————— AnsiString 取用户名() { AnsiString 中国 = "我上是中国人!"; return 中国; } void __fastcall TForm1::Button1Click(TObject *Sender) { //ShowMessage("Hello"); char * 是中 = "hello"; ShowMessage(取用户名()+是中); }

    呵呵,是啊.不过中英文混合看起来有些别扭

    全部换成宏定义,哈

    不伦不类……

    强悍!

    不是不伦不类,而是很好很强大的功能!

    程序一但大了,变量多了,对团队合作时要求很高,交接工作量大,但是一旦可以使用中文的话将极大的减少这方面的问题,企业应用好!


    我的系統是繁體中文,怎麼才可以顯示簡體中文?

    charset

    VC2005,VB6就已经支持中文编程了

    使用Unicode常量字符串,如果还出问题,再试试将源代码设定为UTF-8格式。

    好消息啊!

    其实这个功能不错!
    想起了魔兽世界里面的宏,可以写“/cast ???Spell”也可以写“/施放 ???魔法”

    引用 6 楼 woainihaha 的回复:
    不是不伦不类,而是很好很强大的功能!

    程序一但大了,变量多了,对团队合作时要求很高,交接工作量大,但是一旦可以使用中文的话将极大的减少这方面的问题,企业应用好!


    支持

    不错

    遇到过这个问题

    解决方案:

    中国=L"Unicode 文字……………"

  • Filed under: C++ Builder
  • C/C++ code
    //————————————————————————— AnsiString 取用户名() { AnsiString 中国 = "我上是中国人!"; return 中国; } void __fastcall TForm1::Button1Click(TObject *Sender) { //ShowMessage("Hello"); char * 是中 = "hello"; ShowMessage(取用户名()+是中); }

    呵呵,是啊.不过中英文混合看起来有些别扭

    全部换成宏定义,哈

    不伦不类……

    强悍!

    不是不伦不类,而是很好很强大的功能!

    程序一但大了,变量多了,对团队合作时要求很高,交接工作量大,但是一旦可以使用中文的话将极大的减少这方面的问题,企业应用好!


    我的系統是繁體中文,怎麼才可以顯示簡體中文?

    charset

    VC2005,VB6就已经支持中文编程了

    使用Unicode常量字符串,如果还出问题,再试试将源代码设定为UTF-8格式。

    好消息啊!

    其实这个功能不错!
    想起了魔兽世界里面的宏,可以写“/cast ???Spell”也可以写“/施放 ???魔法”

    引用 6 楼 woainihaha 的回复:
    不是不伦不类,而是很好很强大的功能!

    程序一但大了,变量多了,对团队合作时要求很高,交接工作量大,但是一旦可以使用中文的话将极大的减少这方面的问题,企业应用好!


    支持

    不错

    遇到过这个问题

    解决方案:

    中国=L"Unicode 文字……………"

  • Filed under: C++ Builder
  • 从www.ccrun.com的
    http://www.ccrun.com/article.asp?i=1053&d=7s1l1l
    下了1.9G的版本,然后用以前的slip文件,可以安装,但是Delphi2009Cr.exe提示版本不对了
    哪位有好用的破解,多谢了, 也想体验一下2009

    http://www.namipan.com/d/875bb8081c87059f226dd60bb8bca02a1572659400020f00

    引用 2 楼 yuanreid 的回复:
    http://www.namipan.com/d/875bb8081c87059f226dd60bb8bca02a1572659400020f00

    这个是破解好的文件,覆盖安装后的bds.exe即可。

    chinanetying@163.com
    多谢了!

  • Filed under: C++ Builder