milosev.com
  • Home
    • List all categories
    • Sitemap
  • Downloads
    • WebSphere
    • Hitachi902
    • Hospital
    • Kryptonite
    • OCR
    • APK
  • About me
    • Gallery
      • Italy2022
      • Côte d'Azur 2024
    • Curriculum vitae
      • Resume
      • Lebenslauf
    • Social networks
      • Facebook
      • Twitter
      • LinkedIn
      • Xing
      • GitHub
      • Google Maps
      • Sports tracker
    • Adventures planning
  1. You are here:  
  2. Home

Exception handling

Details
Written by: Stanko Milosev
Category: dbExpress
Published: 08 August 2008
Last Updated: 25 January 2010
Hits: 6724

Problem with dbExpress is that it does not raise an exception if anything is wrong in database (for example, if you try to add primary key which already exist). So, to get an exception, best would be to use OnReconcileError in TClientDataSet... Small example:

 

 procedure Tdm.cdsReconcileError(DataSet: TCustomClientDataSet;
  E: EReconcileError; UpdateKind: TUpdateKind; var Action: TReconcileAction);
begin
  ShowMessage(e.Message);
end;

Get handle of IE8 window.

Details
Written by: Stanko Milosev
Category: Web
Published: 23 March 2009
Last Updated: 18 December 2011
Hits: 12198

If you need to automate IE8, popup windows, then read this article 

Window structure go like this:

Frame Tab,
TabWindowClass,
Shell DocObject View,
Internet Explorer_Server.

So, code would go something like this:

var  
  Wnd: HWND;
  WndChild: HWND;
  IE: iwebbrowser2;
begin
  webBrowser.Quit;
  try
    Wnd := FindWindow('IEFrame', nil);
    if Wnd = 0 then //No running instance of Internet Explorer so stop!
    begin
      showmessage('No Running instance of Internet Explorer');
      exit;
    end;
    WndChild := FindWindowEX(Wnd , 0, 'Frame Tab', nil);
    Wnd := FindWindowEX(WndChild, 0, 'TabWindowClass', nil);
    Wnd := FindWindowEX(Wnd, 0, 'Shell DocObject View', nil);
    Wnd := FindWindowEX(Wnd, 0, 'Internet Explorer_Server', nil);
    if Wnd <> 0 then
    begin
      GetIEFromHWnd(Wnd, IE); //Get Iwebbrowser2 from Handle
      Result := IE;
    end;
  except
  on e: Exception do
    ShowMessage('GetIE' + e.Message);
  end;
end

function .GetIEFromHWND(WHandle: HWND; var IE: IWebbrowser2): HRESULT;
var
 hInst: HWND;
  lRes: Cardinal;
  MSG: Integer;
  pDoc: IHTMLDocument2;
  ObjectFromLresult: TObjectFromLresult;
begin
  hInst := LoadLibrary('Oleacc.dll');
  @ObjectFromLresult := GetProcAddress(hInst, 'ObjectFromLresult');
  if @ObjectFromLresult <> nil then 
  begin
    try
      MSG := RegisterWindowMessage('WM_HTML_GETOBJECT');
      SendMessageTimeOut(WHandle, MSG, 0, 0, SMTO_ABORTIFHUNG, 1000, lRes);
      Result := ObjectFromLresult(lRes, IHTMLDocument2, 0, pDoc);
      if Result = S_OK then
  (pDoc.parentWindow as IServiceprovider).QueryService(IWebbrowserApp, IWebbrowser2, IE);
    finally
      FreeLibrary(hInst);
    end;
  end;
end;

I was using myCatch, to get windows structure.

This code which I left here is just to give you idea, I hope that soon I will upload example of automation IE6, IE7 and IE8...

Google maps

Details
Written by: Stanko Milosev
Category: Web
Published: 11 March 2009
Last Updated: 11 March 2009
Hits: 6118

One way to show user location on the google maps, in his/her default browser:

http://maps.google.com/maps?q=pot%20na%20hrese%2C+Ljubljana

Where, of course, you should put instead of:

pot%20na%20hrese%2C+Ljubljana

adress you would like to search...

How to fill a form of PhpBB3 with Delphi?

Details
Written by: Stanko Milosev
Category: Web
Published: 04 September 2008
Last Updated: 07 September 2008
Hits: 7319

I was using TEmbeddedWB:

EmbeddedWb1.ElementByID['username'].SetAttribute('value', 'stanko', 0)

This is if you ger error:

Exception class EOleError with message 'Method 'Name' not supported by automation object

In TEmbeddedWB.

  1. Nostalgia
  2. 64 bit.
  3. TObject(Sender) vs. (Sender as TObject)
  4. Find if field exists in a dataset

Subcategories

C#

Azure

ASP.NET

JavaScript

Software Development Philosophy

MS SQL

IBM WebSphere MQ

MySQL

Joomla

Delphi

PHP

Windows

Life

Lazarus

Downloads

Android

CSS

Chrome

HTML

Linux

Eclipse

Page 92 of 164

  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96