组合框控件,如果里面有项为空,那么就报要用到的解决办法

  

,

  

经过在网上查询,终于找到了一个解决方案,下载到了一个不是文件

  

把这个不是文件添加到项目后,就不报错了,确实不错

  

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  

复制下面的代码,保存到,D7ComboBoxStringsGetPatch。不是即可

  

,

  

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  

单元D7ComboBoxStringsGetPatch;   

,

  

//补丁修复TCustomComboBoxStrings。Get方法为空字符串条目在Delphi 7 .

  

,

  

界面   

,

  

{$如果RTLVersion & lt;比;15.0}

  

本补丁仅供Delphi 7的;

  {$ IFEND}

  

,

  

实现   

,

  

使用   

,窗口、SysUtils StdCtrls;

  

,

  

resourcestring   

,RsPatchingFailed=' TCustomComboBoxStrings。

得到修补失败。”;   

,

  

类型   

,TPatchResult=(prNotNeeded prOk prError);

  

,

  

函数PatchCode (RoutineStartAddr:指针;PatchOffset:红衣主教;

OriginalCode:指针;   

,OriginalCodeLen:红衣主教;PatchedCode:指针;PatchedCodeLen:红衣主教):TPatchResult;

  

常量   

,JmpOpCode=25美元ff;

  

类型   

,PPackageThunk=^ TPackageThunk;

  

,TPackageThunk=包装记录

  

,,

JmpInstruction:词;   

,,

JmpAddress:如此;   

,

结束;   

var   

,

CodeStart:指针;   

,

BytesWritten:字;   

开始   

,如果FindClassHInstance (System.TObject) & lt;比;实例句柄然后

  

,,PPackageThunk (RoutineStartAddr) ^

  

,,,如果JmpInstruction=JmpOpCode然后

  

,,,,RoutineStartAddr:=JmpAddress ^

  

,,,其他

  

,,,开始

  

,,,,结果:=prError;

  

,,,,

退出;   

,,,

结束;   

,CodeStart:=指针(LongWord (RoutineStartAddr) + PatchOffset);

  

,如果CompareMem (CodeStart, OriginalCode OriginalCodeLen)然后

  

,开始

  

,,如果WriteProcessMemory (GetCurrentProcess, CodeStart、PatchedCode PatchedCodeLen, BytesWritten)和

  

,,,(BytesWritten=PatchedCodeLen)然后

  

,,开始

  

,,,FlushInstructionCache (GetCurrentProcess CodeStart PatchedCodeLen);

  

,,,结果:=prOk;

  

,,

结束   

,,其他

  

,,,结果:=prError;

  

,

结束   

,其他

  

,,结果:=prNotNeeded;

  

结束;   

,

  

类型   

,TCustomComboBoxStringsHack=类(TCustomComboBoxStrings);

  

,

  

函数AddrOfTCustomComboBoxStringsGet:指针;

  

开始   

,结果:=@TCustomComboBoxStringsHack.Get;

  

结束;   

,

  

程序PatchTCustomComboBoxStringsGet;   

常量   

,fff883 OriginalCode:红衣主教,=74美元;//CMP EAX, 1 |生理改变,+ 26美元

  

,PatchedCode:红衣主教,=$ 7 e00f883;//CMP EAX, 0 | JLE + 26美元

  

,PatchOffset,,,,,,

=$ 1 f;   

,//为都柏林城市大学调试帕维尔Rogulin

  

,OriginalCodeD:红衣主教=$ FFF07D83;

  

,PatchedCodeD:红衣主教,=$ 00 f07d83;

  

,PatchOffsetD,,,,,,=$ 2 e;

  

var   

,PatchResult: TPatchResult;

  

开始   

,PatchResult:=PatchCode (AddrOfTCustomComboBoxStringsGet、PatchOffset @OriginalCode, SizeOf (OriginalCode)

  

,,@PatchedCode SizeOf (PatchedCode));

  

,如果PatchResult=prNotNeeded然后

  

,,PatchResult:=PatchCode (AddrOfTCustomComboBoxStringsGet、PatchOffsetD @OriginalCodeD, SizeOf (OriginalCodeD)

  

,,,@PatchedCodeD SizeOf (PatchedCodeD));

  

,案例PatchResult

  

,,prError:

  

,,,开始

  

,,,,如果IsConsole

  

,,,,,WriteLn (ErrOutput RsPatchingFailed)

  

,,,,其他

  

,,,,,对话框(0,PChar (RsPatchingFailed), nil, MB_OK或MB_ICONSTOP MB_TASKMODAL);

  

,,,,

RunError (1);   

,,,

结束;   

,

结束;   

结束;   

,

  

初始化   

,PatchTCustomComboBoxStringsGet;

  

,

  

结束。   

,

  

组合框控件,如果里面有项为空,那么就报要用到的解决办法