C++Builder 程序员博客
5 Sep
我的DBgrideh其中一个字段有picklist数据在里面,可以下拉,这个字段旁边理所当然有一个向下的三角形符号,给用户点击实现下拉,但是我想用代码来控制他在适当的时候下拉,我用代码: DBGridEh1->Columns->Items[1]->DropDown();,但实际运行并没有出现下拉列表,非要我按那个向下的三角形符号,下拉列表才会显示出来
(1)如何用代码控制下拉列表显示出来(不用说设置AutoDropDown属性)
(2)如何用代码控制下拉列表收起来
26 Aug
谁作过统计相关的程序,在录入时遍录遍审.是定义好的公式放在数据表中,然后读取根据公式来动态判断,最好公式不依赖控件,就是单独的公式,然后再读入公式后进行解析,再组合判断.
这个没有做过不知这么办!各位高手谁有这方面的代码贴出来看看。谢谢了!更复杂的如果有函数怎么办例如len StrToInt 等等
编录编审确实不能实现非常复杂的审核,比如跨期审核。我只想完成录入中的判断,如某一项等于其他某几项之和,等等
有人做过吗?那位高手能写出代码来看看
可以参考计算器的函数适当修改达到此目的。
谁做过统计这方面的程序呀!难道一个都没有
lurel
城市陌生人
能贴出这放面的代码看看吗?
这种程序与实际紧密相连,得根据实际情况来做。
该回复于2008-07-10 02:48:52被版主删除
26 Aug
for(int x=0;x <10;x++)
{
ProgressBarx->Position = 10;
Labelx->Caption = 10 ;
}
因为x是变量
我用了~~但是BCB还是提示"Labelx"是不确定的符号
是不是我加错地方了?
for(int x=0;x <10;x++)
{
char sz[32]={0};
sprintf(sz,"%d",x);
Labelx->Caption = sz ;
}
感觉是不行的,不过你可以用数组来管理,把所有的Labelx、ProgressBarx都放到数组里,
然后:
for(int x=0;x <10;x++)
{
ProgressBar[x]->Position = 10;
Label[x]->Caption = 10 ;
}
那在新建label的时候怎么把所以的label放到数组里?
TLabel *Label[10];
Label[0]=Label0;
Label[1]=Label1;
…
Label[9]=Label9;
如果是动态生成Label的话,那就直接:
for(int x=0;x <10;x++)
{
Label[x]=new TLabel();
….//设置Label的属性
}
你的代码不能用循环x
还是写上10个Label1 .. Label10的赋值吧.
编译之后就没这东西了,你还循环啥.
用了~~结果和上面那位一样~~不过如果你的方法可以的话,我可以省好多力气
还是在Label[x]的时候编译不过..
lz的想法很强,呵呵
其实可以用控件数组的,动态创建就是了~
whomin 的方法是可以的~ 刚刚是我自身问题
见谅~~~我算是新接触BCB吧
26 Aug
各位高人
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TProgressBar* ProgressBar = new TProgressBar(this);
ProgressBar->Top = 20;
ProgressBar->Left = 10;
ProgressBar->Height = 100 ;
ProgressBar->Width = 10;
ProgressBar->Max = 100;
ProgressBar->Orientation = pbVertical;
ProgressBar->Position = 50;
ProgressBar->Name = "ProgressBar1";
ProgressBar->Visible = true;
}
为什么我这段程序写上去click以后 即不报错,progressbar也在form上不出来呢?
嗯~~!!行了~~thank you
24 Aug
最进想做个加壳工具,不知道有人有源代码让我看看吗?QQ:333927
e-mail:85whx@163.com
学习
你看看这个:
http://upx.sourceforge.net/
没有。我要C++的代码。。
www.2ccc.com上面有一个带源码的
有个经典加壳工具源码是开放的,你可以找找看
upx,aspack…
用第三方控件固然好
UPX是开源的,但是算法是要自己想的,同时参考一下www.pediy.com很多相关资料,aspack开源吗?只有SDK吧~
up
22 Aug
如下代码在创建码表时不正确,请高手指点,不胜感谢!
void CRC32::BuildTable32()
{
int i,j;
long crc;
for (i = 0; i < 256; i++)
{
crc = i;
for (j = 0; j < 8; j++)
{
if (crc & 1)
crc = (crc >> 1) ^ 0xEDB88320;
else
crc >>= 1;
}
TableCRC32[i] = crc;
}
}
请高人赐教啊!
CRC要确定初始状态和多项式,计算结果也可以取反,所以一个串数值会有不同的CRC结果。
所以你要了解你需要的是什么CRC多项式和初始值,计算结果取不取反。
多谢liskman,问题已解决。
4 Aug
rt,百分酬谢
procedure btnEncryptClick(Sender: TObject); var Cipher: TDCP_cipher; // the cipher to use CipherIV: array of byte; // the initialisation vector (for chaining modes) Hash: TDCP_hash; // the hash to use HashDigest: array of byte; // the result of hashing the passphrase with the salt Salt: array[0..7] of byte; // a random salt to help prevent precomputated attacks strmInput, strmOutput: TFileStream; i: integer; begin if FileExists(boxOutputFile.Text) then if (MessageDlg(‘Output file already exists. Overwrite?‘,mtConfirmation,mbYesNoCancel,0) <> mrYes) then Exit; strmInput := nil; strmOutput := nil; try strmInput := TFileStream.Create(boxInputFile.Text,fmOpenRead); strmOutput := TFileStream.Create(boxOutputFile.Text,fmCreate); Hash := TDCP_hash(cbxHash.Items.Objects[cbxHash.ItemIndex]); SetLength(HashDigest,Hash.HashSize div 8); for i := 0 to 7 do Salt[i] := Random(256); // just fill the salt with random values (crypto secure PRNG would be better but not _really_ necessary) strmOutput.WriteBuffer(Salt,Sizeof(Salt)); // write out the salt so we can decrypt! Hash.Init; Hash.Update(Salt[0],Sizeof(Salt)); // hash the salt Hash.UpdateStr(boxPassphrase.Text); // and the passphrase Hash.Final(HashDigest[0]); // store the output in HashDigest Cipher := TDCP_cipher(cbxCipher.Items.Objects[cbxCipher.ItemIndex]); if (Cipher is TDCP_blockcipher) then // if the cipher is a block cipher we need an initialisation vector begin SetLength(CipherIV,TDCP_blockcipher(Cipher).BlockSize div 8); for i := 0 to (Length(CipherIV) - 1) do CipherIV[i] := Random(256); // again just random values for the IV strmOutput.WriteBuffer(CipherIV[0],Length(CipherIV)); // write out the IV so we can decrypt! Cipher.Init(HashDigest[0],Min(Cipher.MaxKeySize,Hash.HashSize),CipherIV); // initialise the cipher with the hash as key TDCP_blockcipher(Cipher).CipherMode := cmCBC; // use CBC chaining when encrypting end else Cipher.Init(HashDigest[0],Min(Cipher.MaxKeySize,Hash.HashSize),nil); // initialise the cipher with the hash as key Cipher.EncryptStream(strmInput,strmOutput,strmInput.Size); // encrypt the entire file Cipher.Burn; // important! get rid of keying information strmInput.Free; strmOutput.Free; MessageDlg(‘File encrypted‘,mtInformation,[mbOK],0); except strmInput.Free; strmOutput.Free; MessageDlg(‘An error occurred while processing the file‘,mtError,[mbOK],0); end; end;
顺问,有人成功在bcb2007上使用dcpcrypt过么?
http://blog.csdn.net/phphot/archive/2008/03/13/2176280.aspx
看看这个,很容易改的
要注意其中CipherIV、HashDigest用到了pascal动态数组SetLength(),你要自己改成
char *CipherIV,*HashDigest;
CipherIV=new char[TDCP_blockcipher(Cipher).BlockSize/8];
HashDigest=new char[Hash.HashSize/8];
最后别忘了释放
delete CipherIV;
delete HashDigest;
31 Jul
请教高手:VS2005中,怎样将代码生成DLL文件?
新建一个dll工程。
能不能具体点,最好是一步一步的来,手把手的来,我是fresh fish
http://msdn2.microsoft.com/zh-cn/library/s2zy4kwk.aspx
建个dll工程,将接口输出,实现接口功能,编译,ok
30 Jul
求C++ Builder 的代码格式化工具。
谢谢
以前用过一个叫"C++Builder Source Format Expert"的插件,不过貌似有BUG,偶然的一次竟然把偶一个单元的文件给优化没了。从此拒绝使用这些插件,完全手工排版。
delphi用过
手动的比较好噢。。。。
等待好的介绍~~
关注!
呵呵
至少目前都是手动输入空格和其他.
关注
SourceFormat Utility
该回复于2008-07-07 15:23:07被版主删除
Borland C++Builder 5/6
C++ Formatting Expert
http://www.frasersoft.net/program/
http://www.frasersoft.net/program/fsexpert.zip
Borland C++Builder 2005/2006
Code Beautifier Collection 5
http://gforge.oss.org.cn/projects/codebeautifiers
Borland C++Builder 2007
Code Beautifier Collection 6
http://code.google.com/p/lextudio/
这种问题一般没办法完全避免。但是只要有代码版本控制,不过就是一个Revert而已。
这个插件我也用过,遇到把文件内容优化没了的情况已有多次了,建议不要使用。
非常同意ccrun的意见。
我一般使用 VC6 重新排版别人写的代码 (Alt+F8)
或者使用 UltraEdit 也是可以的
1. 使用 UltraEdit
2. 存为 C 或者 CPP 文件
3. 选择代码段
4. Format /ReIndent Selection 重新排版
5. 一行中 { 不能跟在任何代码之后
6. { 或者 } 只能单独存在一行中 (可以在后面跟注释代码)
7. switch 语句中的 case 语句不太正常,也会加了一个 Tab
8. 一般显示中可以通过调整 Tab Stop Value、Indent Spaces 为 4
用vim也可以很方便,在直接键入gg=G就排版好了。
在BCB里我用的是一个叫C++ Formatter的BCB修改版,它使用astyle库。这个还行吧,目前还没遇到把内容优化没了的情况(可能是代码不够复杂)。以前在这个版里发过的,楼主可以找找。
另外不知道这个怎样:http://cc.codegear.com/Item.aspx?id=20244
复制到VC里面排版再复制回来
手动排版
先将代码copy到VC中,然后Ctrl+K+F,再copy回来,就可以了:)
这个方法强,呵呵.
如何确认无误呢?一个办法就是编译格式化过后的单元文件(或所在的工程文件),看有没有错误;当然除此之外还有其他很多方法。
所以,这个插件还是可用的,当然如果作者能修复BUG(我还没碰到,嘻嘻)是最好不过了。
30 Jul
Sub FshComm(lw As Byte, hi As Byte)
On Error Resume Next
Dim bb(1) As Byte
If fshComN <> 1 And fshComN <> 2 Then fshComN = 1
MSComm1.PortOpen = False
MSComm1.CommPort = 1
MSComm1.Settings = "9600,n,8,1"
MSComm1.PortOpen = True
bb(0) = lw: bb(1) = hi ' (CByte(Text3(0).Text)) 'lw)
MSComm1.Output = bb ' Buffer
MSComm1.OutBufferCount = 0
MSComm1.PortOpen = False
End Sub
Private Sub Command1_Click()'等闪
Dim lptms As Integer
lptms = 5000 / 30 '??这里是30,可以闪
FshComm lptms Mod 256, &H80 + Fix(lptms / 256)
End Sub
Private Sub Command2_Click()'等亮
FshComm 0, 0
End Sub
下面是等BCB的
void __fastcall TForm1::FormCreate(TObject *Sender)
{
MSComm1->CommPort =1;
MSComm1->PortOpen =true;
}
void __fastcall TForm1::btn1Click(TObject *Sender)//等闪
{
int lptms;
int aa,bb;
lptms = 5000.0/10+0.5 ; //??这里是10,若是30灯就不闪了
aa= lptms%256;
bb= 128+lptms/256;
OleVariant ovTxtBuf = VarArrayCreate(OPENARRAY(int, (0, 2)), varByte);
ovTxtBuf.PutElement(aa, 0);
ovTxtBuf.PutElement(bb, 1);
MSComm1->Output = ovTxtBuf;
MSComm1->OutBufferCount =0;
}
void __fastcall TForm1::btn2Click(TObject *Sender)
{
OleVariant ovTxtBuf = VarArrayCreate(OPENARRAY(int, (0, 2)), varByte);
ovTxtBuf.PutElement(0, 0); //停止闪动
ovTxtBuf.PutElement(0, 1);
MSComm1->Output = ovTxtBuf;
}
上面??处,若为20以下灯都可以闪,若大于20,vb写的可以闪,bcb的不可以闪,我看了下。得到的数值(aa,bb)是一样的
应该没有什么区别吧?