delphi-5

How to debug division by zero exception in Internet Explorer?

倾然丶 夕夏残阳落幕 提交于 2019-12-05 01:14:43
i am hosting Internet Explorer in a Windows application. i can scroll down to the bottom of the document. When i then try to scroll back up i get a division by zero exception : When i scroll using Page Up the crash appears to happen at the call to - IOleInPlaceActiveObject:TranslateAccelerator When i scroll using the mouse the crash happens during the call to DispatchMessage Either way, the crash is happening in Internet Explorer. The stack trace shown by Delphi at the time of the exception: Is different from the stack trace shown by Jedi's exception tracing: Exception EZeroDivide in module

How to convert float or currency to a localized string?

青春壹個敷衍的年華 提交于 2019-12-05 00:59:12
In Delphi 1 , using FloatToStrF or CurrToStrF will automatically use the DecimalSeparator character to represent a decimal mark. Unfortunately DecimalSeparator is declared in SysUtils as Char 1,2 : var DecimalSeparator: Char; While the LOCALE_SDECIMAL is allowed to be up to three characters: Character(s) used for the decimal separator, for example, "." in "3.14" or "," in "3,14". The maximum number of characters allowed for this string is four, including a terminating null character. This causes Delphi to fail to read the decimal separator correctly; falling back to assume a default decimal

Delphi: How to avoid EIntOverflow underflow when subtracting?

大憨熊 提交于 2019-12-04 18:23:47
问题 Microsoft already says, in the documentation for GetTickCount, that you could never compare tick counts to check if an interval has passed. e.g.: Incorrect (pseudo-code): DWORD endTime = GetTickCount + 10000; //10 s from now ... if (GetTickCount > endTime) break; The above code is bad because it is suceptable to rollover of the tick counter. For example, assume that the clock is near the end of it's range: endTime = 0xfffffe00 + 10000 = 0x00002510; //9,488 decimal Then you perform your check:

Can I access the string returned from a Delphi CreateProcess command?

北城余情 提交于 2019-12-04 15:57:48
问题 I'm using the Win32 CreateProcess function to perform a call to an external executable. The executable returns a string. Is there a way I can capture and interrogate the returned string after calling the executable? Failing that, I might have to write out the string to a file in the executable and read that in the calling program after the call has finished. That seems lame though. 回答1: Jedi Code Library contains function CreateDOSProcessRedirected which runs a process and provides it with

Delphi: How to remove subclasses in reverse order?

跟風遠走 提交于 2019-12-04 09:58:49
Mike Lischke's TThemeServices subclasses Application.Handle , so that it can receive broadcast notifications from Windows (i.e. WM_THEMECHANGED ) when theming changes. It subclasses the Application object's window: FWindowHandle := Application.Handle; if FWindowHandle <> 0 then begin // If a window handle is given then subclass the window to get notified about theme changes. {$ifdef COMPILER_6_UP} FObjectInstance := Classes.MakeObjectInstance(WindowProc); {$else} FObjectInstance := MakeObjectInstance(WindowProc); {$endif COMPILER_6_UP} FDefWindowProc := Pointer(GetWindowLong(FWindowHandle, GWL

How to call EnumSystemLocales in Delphi?

感情迁移 提交于 2019-12-04 02:48:07
i am trying to call EnumSystemLocales in Delphi. For example: { Called for each supported locale. } function LocalesCallback(Name: PChar): BOOL; stdcall; begin OutputDebugString(Name); Result := Bool(1); //True end; procedure TForm1.Button1Click(Sender: TObject); begin EnumSystemLocales(@LocalesCallback, LCID_SUPPORTED); end; The problem is that the callback is only being called once. Note: EnumSystemLocales is returning true, indicating success. The remarks of EnumSystemLocales says that my callback must return true to continue enumerating (or more correctly, must not return false to continue

IXMLHttpRequest.responseXml is empty, with no parse error, when responseText contains valid Xml

主宰稳场 提交于 2019-12-03 13:52:58
i am fetching some XML from a government web-site : http://www.bankofcanada.ca/stats/assets/rates_rss/noon/en_all.xml i am using the following, fairly simple code: var szUrl: string; http: IXMLHTTPRequest; begin szUrl := 'http://www.bankofcanada.ca/stats/assets/rates_rss/noon/en_all.xml'; http := CoXMLHTTP60.Create; http.open('GET', szUrl, False, '', ''); http.send(EmptyParam); Assert(http.Status = 200); Memo1.Lines.Add('HTTP/1.1 '+IntToStr(http.status)+' '+http.statusText); Memo1.Lines.Add(http.getAllResponseHeaders); Memo1.Lines.Add(http.responseText); i won't show all the body that returns,

How to export Image list of 32bit icons into single 32bit bitmap file?

天大地大妈咪最大 提交于 2019-12-03 13:23:05
问题 I want to write a small utility which will help me load a single 32bit bitmap (with alpha) from a EXE resource: ImageList1.DrawingStyle := dsTransparent; ImageList1.Handle := ImageList_LoadImage(MainInstance, 'MyBitmap32', 16, ImageList1.AllocBy, CLR_NONE, IMAGE_BITMAP, LR_CREATEDIBSECTION or LR_LOADTRANSPARENT); The above works well. So to generate that bitmap, I'm loading 32 bit transparent icons from my disk (with alpha) into an ImageList for i := 1 to 10 do ... ImageList2.AddIcon(AIcon)

Show activity indicator while the main thread is blocked (continue)

痴心易碎 提交于 2019-12-03 10:08:58
问题 Continue with previous question I want to be able to show some activity indicator even if the main thread is blocked . (based on this article). Problems based on the attached code: Using Synchronize(PaintTargetWindow); does not paint the window I sometimes get an error: Canvas does not allow drawing. In the line: {FBitmap.}StretchDraw(Rect(Left, ImageRect.Top, Right, ImageRect.Bottom), FfgPattern) here is the code I use to create the indicator thread: unit AniThread; interface uses Windows,

Can I access the string returned from a Delphi CreateProcess command?

依然范特西╮ 提交于 2019-12-03 09:08:17
I'm using the Win32 CreateProcess function to perform a call to an external executable. The executable returns a string. Is there a way I can capture and interrogate the returned string after calling the executable? Failing that, I might have to write out the string to a file in the executable and read that in the calling program after the call has finished. That seems lame though. Jedi Code Library contains function CreateDOSProcessRedirected which runs a process and provides it with input and output file. You can put required input (if any) into the input file and read process output (if any