Delphi

TBitmap32.LoadFromStream() Auto-Recognize Image Format

孤人 提交于 2020-01-14 10:23:23
问题 I'm using Delphi XE2 (Update 3) and GR32. I am unable to use TBitmap32.LoadFromStream() to load the image data. It raises the following exception: Project MyApp.exe raised exception class EInvalidGraphic with message 'Bitmap image is not valid'. Code uses GR32, GifImg, PngImage, Vcl.Graphics; var pic: TBitmap32; bs: TBytesStream; begin bs := TBytesStream.Create(TClientDataSet(cds).FieldByName('filedata').AsBytes); try pic := TBitmap32.Create; try // bs.SaveToFile('c:\delme.png'); // pic

CreateEvent from Windows-7 Logon Screen

馋奶兔 提交于 2020-01-14 10:14:17
问题 I'm asking this question because it turns out that there's some difficulty in writing a screensaver app in Delphi that's capable of running from the Logon screen. See question: Windows 7 logon screensaver in Delphi I've narrowed down the problem (or at least one problem) to a particular Win API call CreateEvent . SyncEvent := CreateEvent(nil, True, False, ''); if SyncEvent = 0 then RaiseLastOSError; This code only fails if called from the Logon screen. And GetLastError returns that access is

CreateEvent from Windows-7 Logon Screen

Deadly 提交于 2020-01-14 10:13:10
问题 I'm asking this question because it turns out that there's some difficulty in writing a screensaver app in Delphi that's capable of running from the Logon screen. See question: Windows 7 logon screensaver in Delphi I've narrowed down the problem (or at least one problem) to a particular Win API call CreateEvent . SyncEvent := CreateEvent(nil, True, False, ''); if SyncEvent = 0 then RaiseLastOSError; This code only fails if called from the Logon screen. And GetLastError returns that access is

Can Indy run Javascript?

不想你离开。 提交于 2020-01-14 09:14:05
问题 There is a software product called AnyChart which is great for embedding Flashed based charts in web pages. AnyCharts can also export to PNG file format. Here is an example: <script type="text/javascript" language="javascript"> //<![CDATA[ var chart = new AnyChart('http://www.mysite.com/swf/AnyChart.swf'); chart.width = 600; chart.height = 300; chart.setXMLFile('http://www.mysite.com/anychart.xml'); chart.addEventListener("draw", function() { saveChartAsImage(chart); }); chart.write("content

Floodfill part of an Image

流过昼夜 提交于 2020-01-14 09:07:14
问题 I have an image like bellow i want to make the image become like I already make the code, like this : var Tx,Ty, R,G,B,A, posX, posY : integer; begin posX :=-1; posY := -1; for Ty:= 0 to Image1.Height-1 do begin for Tx:= 0 to Image1.Width-1 do begin R:= GetRValue(image1.Canvas.Pixels[Tx, Ty]); G:= GetGValue(image1.Canvas.Pixels[Tx, Ty]); B:= GetBValue(image1.Canvas.Pixels[Tx, Ty]); A:= (R + G + B) Div 3; if (A > 50) then begin Image1.Canvas.Pixels[Tx,Ty] := rgb(255,255,255); end else begin

Why doesn't THashedStringList ignore duplicates?

白昼怎懂夜的黑 提交于 2020-01-14 08:09:31
问题 I have the following code: var sl: THashedStringList; begin sl:= THashedStringList.Create; sl.Duplicates := dupIgnore; sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); ShowMessage(IntToSTr(sl.Count)); end; But when I see sl.Count , it gives me 7. What is the bug in this? 回答1: You need to set the Sorted property to TRUE in order to have the list ignore duplicates. The property is inherited from TStringList , and if you look

Why doesn't THashedStringList ignore duplicates?

你离开我真会死。 提交于 2020-01-14 08:08:06
问题 I have the following code: var sl: THashedStringList; begin sl:= THashedStringList.Create; sl.Duplicates := dupIgnore; sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); ShowMessage(IntToSTr(sl.Count)); end; But when I see sl.Count , it gives me 7. What is the bug in this? 回答1: You need to set the Sorted property to TRUE in order to have the list ignore duplicates. The property is inherited from TStringList , and if you look

Delphi运算符列表

孤人 提交于 2020-01-14 07:41:55
1, 有序类型运算符 ord:返回有序值在值域中的序数 如:ord('A') = 65 pred:返回指定值的前一个值 pred('B') = A succ:返回指定值的下一个值 succ('A') = B high:返回变量能够表示的最大值或某类型的上界 high(byte) = 255 low:与high相反 2, 数学运算符 + - * / div 整除 mod 求余 3, 逻辑运算符 not 反 and 且 or 或 xor 异或 4, 位运算符 not 按位取反 and 按位取且 or 按位取或 xor 按位取异或 shl 左移 shr 右移 5, 字符串运算符 + 将字符串连接 6, 集合运算符 + 并集 - 差集 * 交集 <= 子集 >= 超集 = 相等 <> 不等 in 成员 7, 关系运算符 = 相等 <> 不等 < 小于 > 大于 <= 小于或等于 >= 大于或等于 8, 类运算符 s 转换 is 判断 来源: CSDN 作者: 木生火 链接: https://blog.csdn.net/msh2016/article/details/103758296

Using .AsString or .Text?

寵の児 提交于 2020-01-14 07:34:08
问题 I have just seen a bit of code (D5) where they used... aStr:=tblAcct.FieldByName('Name').Text; It seems to work fine but I have always used... aStr:=tblAcct.FieldByName('Name').AsString; I have used both when loading a TMemo and again there seems no difference. aMemo.Lines.Text:=tblAcct.FieldByName('History').Text; aMemo.Lines.Text:=tblAcct.FieldByName('History').AsString; Is there a reason why I should use one over the other? If so, which one? Actually for TMemo, I usually use... aMemo.Lines

Why I can access btn.Caption when btn is NIL?

谁说胖子不能爱 提交于 2020-01-14 07:11:29
问题 Why this code does not crash? T is nil. How it is possible to access Caption if T is nil ? procedure Crash; VAR T: TButton; begin T:= NIL; T.Caption:= ''; <---------- this works end; 回答1: The TButton control is a wrapper around the Win32 Button control. It uses the Windows messaging system to operate upon it. And the core method for doing so, TControl.Perform() , has a built in safeguard against sending messages if Self is nil : function TControl.Perform(Msg: Cardinal; WParam: WPARAM; LParam: