Rectangle 27 3

I haven't tried myself but I know of one confirmed way to mix VCL and FireMonkey in the same application using RemObjects Hydra and one unconfirmed report that you can have FireMonkey forms in a VCL application at Delphi Sorcery.

Delphi XE2: Possible to instantiate a FireMonkey Form in VCL applicati...

delphi vcl delphi-xe2 firemonkey
Rectangle 27 1

TJvImage.Picture is a standard TPicture, which means its Bitmap property is a standard TBitmap. You cannot load a PNG image into a TBitmap in VCL (you can in FireMonkey, which Delphi 7 does not support). You need to use a suitable third-party TGraphic-derived class for PNG images (Delphi 7 does not natively support PNGs, that was added in a later version), eg:

uses
  ..., PngImage;

var
  Png: TPngObject;
try
  Png := TPngObject;
  try
    stream := TMemoryStream.create;
    try
      stream.Write(bits[0], sizeof(bits));
      stream.Position:= 0;
      Png.LoadFromStream(stream);
    finally
      stream.Free;
    end;
    JvImage1.Picture.Assign(Png);
  finally
    Png.free;
  end;
end;

Update: However, that being said, the bytes you have shown are NOT a valid PNG graphic header to begin with. A PNG always starts with the following 8-byte signature:

89 50 4E 47 0D 0A 1A 0A

The bytes do not represent any PNG data chunk header, either (in case you are accidentally skipping past a PNG header).

In fact, the bytes you have shown do not appear to represent any commonly-used graphic format. So you are likely misinterpreting the memory you are trying to examine.

Regarding using TPngObject from Gustavo Daud, give me new exception EPnginvalidheader is not valid PNG. I'm sure the byte array is png header from memory address of [base_address]+0x28 is 16 array of byte "9E 20 00 00 B8 EE C4 1A F4 9E 01 00 68 59 BF 1A"

Is it possible added the 4 bytes PNG Header in first of array, am sure array in address is correct position. I'm using hex memory editor to change the value, seems image changed too.

@ahrie: The bytes you have shown DO NOT belong to a PNG header. The first 8 bytes of a PNG are always 89 50 4E 47 0D 0A 1A 0A (see Portable Network Graphics, File header). And the bytes do not belong to any PNG data chunk header, either.

@ahrie: Whatever you think you are examining in memory is not a PNG (unless you are skipping past all of the PNG header/chunk info that would tell you what the bytes represent). What does base_address actually point at, and why are you looking at +0x28 bytes into it? What are you really trying to accomplish? It sounds like you are trying to peer into another process's data, is that right?

I'm currently want to read image in game, the game using PNG to create avatar. I'm looking other tools game can read those image, but seems not in delphi its c++. Using CE to search the image address, and found [[[[[[base_address]+00376164]+0x28]+0x28]+0x00]+0x6C] as image static address. Changed value to other avatar value seems successful, am using tlhelp32 unit to read process

delphi convert byte of array to bitmap - Stack Overflow

arrays delphi bitmap delphi-7
Rectangle 27 0

The project change log on Sourceforge contains entries about BCB XE3 patches:

Packages are not required for basic Synapse classes, they can be created in code easily.

Is this only available as an lpk rather than a dpk?

We are talking about networking components. You can create them in code. Why do you need components? Surely it is not that hard to instantiate a component without having to use the mouse?

tcp - How can I use the Synapse library with Delphi XE3 and up? - Stac...

delphi tcp delphi-xe3 synapse
Rectangle 27 0

It can be convenient if you use older Delphi versions as well. For instance, you can open dpr with Delphi 7 and open dproj with the latest version. It allows you to open both old and new projects with a double click from the Windows Explorer.

Dproj files are MSBuild compatible files, which is used to compile the projects with.

The Delphi IDE itself doesn't actually need them to open the project. The dproj file does contain settings and the version number, though, which were stored in the dof file in Delphi 2006 and before. If the dproj file cannot be found, it is regenerated with default settings, whereas the dpr is required and is not regenerated. It's not possible, since it not only contains the uses-list, but also actual initialization code for your application.

It IS needed if you want your project settings including compiler defines, and project search path to be kept. :-) Delete it and everything's back to Delphi 7 level. The IDE loads them, as does the MSBUILD. The IDE adds several private areas to the .dproj file which are the new place where what used to be stored in .dof files goes now. So this is not right. -1 for misinformation.

.dproj is a sad little mashup though, and version controlling it can be troublesome.

You guys are right about the dof file. Apparently I haven't been paying attention lately. I usually don't customize the project settings, so apart from the version number being reset, I've never really noticed any issues with deleting dproj files. But indeed it stores more than just the version information, so I've altered that description. My humblest apologies for the misinformation.

Opening Delphi project files - Any downside of opening DPR instead of ...

delphi delphi-xe2
Rectangle 27 0

What you're pointing to here is a form of dependency injection (DI): you have a form that depends on an external object for correct operation. The obvious approach people take is to add a parameter to the Form's constructor. But what David said above is correct: you cannot simply ignore the 'AOwner' parameter - another value that's already required to be injected by the VCL framework.

When you create a form, it rarely lives in isolation -- only the Main Form works that way most of the time. Forms are typically used to do one of three things: (1) collect and return new data; (2) accept data for editing and return the edited data; (3) accept some data that's used to make a selection and return the selection in some fashion.

When you use data-aware controls, the forms can appear to be self-sufficient; in reality, the VCL framework is injecting (behind the scenes) all of the data-aware control mechanisms. If you don't set up the table and field data in the IDE, then you DO have to explicitly inject all of that when you create the form, although most people don't do it that way. (I mean, why bother using data-aware controls otherwise?)

If instead you make forms that do not or cannot use data-aware controls (eg., because they get their data from some other type of external interface that has no TDataset defined for it), then you need to inject the initial field values first, then fetch updated values afterwards.

That's fine if you're working with a few values -- that's when someone will usually put them in the constructor. But if you've got a bunch of them (think, say, 50), what do you do? You can't put them all on the constructor!

To make matters worse, you may need to fetch updates. If you inject them through the constructor, then you need to make some of them 'var' parameters. This is a very poor, albeit common, design practice.

So the next thing people will do is think, "Oh, I'll put all of those values into an object and then pass the object through the constructor!"

But many times those values already live inside of other objects, meaning you've just doubled your work, because now you need to pass them into and fetch them from your surrogate object -- which you created, ironically enough, in order to simplify passing them into and fetching them from the form!

Note that this approach we've been discussing is, in DI terms, called "constructor injection". Obviously, it has its limits.

An alternative is what's called "property injection" or "setter injection".

The main advantage of "constructor injection" is that the values are all set up and ready to go when the object's construction is complete. With "property/setter injection" you construct the object, THEN inject the dependent values, and then show the form. After the form has closed, you extract updated values from its properties (or getters), and then free the form if needed.

In Delphi, you may need to override the OnClose method of such forms to set the Action to caHide so it doesn't free the form when it closes. (That may be the default; I can never seem to remember.)

Here's what the code looks like, generally speaking, with constructor injection :

try
  myobj := TMyObject.Create();  // an object with initial values to feed the form
  myobj.intval := 10; 
  myobj.str := "hello world!"

  myform := TMyForm.Create( self, myobj );
  myform.ShowModal(); 
  // form could be freed here if OnClose's Action has been set to caFree
  // this means myform is no longer valid
  // however, it may be <> NIL even if it HAS been freed!
  // if not freed, then free it
  myform.Free();

  // now do something with the contents of myobj
  if (myobj.intval <> 10) then
    . . .
  if (myobj.str = '') then
    . . .
finally
  myobj.Free();
end;

Here's what property injection looks like, assuming there are individual properties with setters and getters (read/write methods) for each of the fields in the form -- intval and str in this case:

try
  myform := TMyForm.Create( self );
  myForm.intval := 10;
  myform.str := "hello world!"
  myform.ShowModal(); // ensure the form is HIDDEN when it closes, not freed!

  // now do something with the field values -- myform must still be valid!
  if (myform.intval <> 10) then
    . . .
  if (myform.str = '') then
    . . .
finally
  myform.Free();
end;

Generally speaking, property injection can be used consistently for virtually all forms in an application. The constructor injection approach almost always starts out passing a few variables on the constructor and evolves to use an object, and then that object starts to take on a life of its own independently, increasing the maintenance costs of the form.

The property injection approach can also use an object (several, in fact!), but in this case it's whatever object(s) already exist. You don't need to create new surrogate objects to ferry the data values in and out of the form. Instead, you simply add some properties and access them from outside.

If you want to implement some business logic and validation in these forms, you can do it in the OnCreate/OnDestroy for constructor injection and OnActivate/OnClose for property injection (but ensure that the OnActivate only executes once).

I maintained a system for a while that had >200 forms. They used all kinds of variations on constructor injection. I also discovered lots of subtle bugs in them because there was so little consistency from one form to the next in terms of how they did stuff. The biggest problem was that they passed lots of external objects from other units into the constructor, which created tight coupling between the forms and these external units. We'd change a property in one of these objects and get errors in a half-dozen forms! Worse, there would be errors in other forms that would show up later that the compiler couldn't detect.

In several cases, they even employed an explicit TObject constructor (ie., just a constructor Create(); override; method in several forms because they couldn't figure out how to get the form's constructor to initialize things in the correct order!

There were even situations where the code created an instance of the form and then proceeded to write values directly into the controls (TEdits, TRadioButtons, etc) on the form! That's a MAJOR NO-NO!!!

There are people who think you should ALWAYS use constructor injection. While I have no particular axe to grind in that respect, I can only reflect on how that tends to occur in practice, which is ... it's dangerous and leads to far too much tight coupling between unrelated units -- at least in so far as how Forms are employed in large Delphi apps.

I've seen lots of "coding standards" used on projects, and I don't ever recall seeing one that standardized on when and how to use constructor vs. property injection when working with non-data aware forms. Something to think about on your next (or current) project.

thanks...its a very nice description! :)

android - How I can use the Constructor in Delphi for transfer Objects...

android delphi constructor bluetooth delphi-xe6
Rectangle 27 0

Start a new project and add to it a DataModule. Drop TADOConnection and TADOTable on the DataModule. Save the project and see which units get added into uses of DataModule. If Your project compiles and runs successfully, copy the unit names from that test project into your working project's DataModule and try again. If that doesn't help, I can only guess that you have some issues with library paths. I don't have Delphi XE2 to try this, so I'm just guessing.

if all OP did was move some components, then indeed units missing from the datamodule's uses clause sh/would be the cause of the error message.

Your suggestion LightBulb, though not the answer, was helpful in tracking down the issue. I did as you suggested and created a new project from scratch, which did work. I'll post the full answer and explain. +1 for your suggestion.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

delphi - Class TADOConnection / TADOTable Not Found - Stack Overflow

delphi ado datamodule adoconnection tadotable
Rectangle 27 0

You require a Windows PC (32 or 64 bit, running Vista or 7 - though XP has limited support) to use Delphi XE2's IDE and compiler. These simply will not work on any other platform, so you can only develop on a Windows PC!

With only a Windows 32 (or 64) bit PC, you can build Win32, Win64 and OSX applications.

To test/run 64bit Windows applications you require a 64bit system with a 64bit edition of Windows installed.

To test/run OSX Applications, a Mac system running 10.6 (Snow Leopard) or 10.7 (Lion) is required. A "Hackintosh" or VM running MacOSX will not work (and is a violation of Apple's EULA)!

To produce iOS Applications, you require the same criteria as stated above for testing OSX applications, with the additional requirement of installing the FireMonkey iOS package (containing the FreePascal compiler and FireMonkey libraries), XCode, and the iOS emulator.

The iOS Emulator will run Delphi-made iOS applications, though of course testing on the physical device is often considered better.

Can you explain why a MacOSX VM doesn't work (I understand the license issue)?

As I understand it, the Assembly generated by Delphi's new OSX compiler simply does not function on a VM. As for the specific reason behind that, I haven't a clue!

From what I googled OSX inside of VM does not have required hardware access to OpenGL to function properly. As I tried last week creating OpenGL apps in XE2-FM they always ended with "invalid pixel format" error. But when I bought MacMini yesterday they surprisingly worked fine on it.

I recommend iMac with Mac OSX 10.7, iPhone 4 with latest iOS, Parallels and Windows XP SP3 or Windows 7 running in Parallels. Pretty expensive but hey who said it should be cheap.

What hardware/software is necessary to develop Mac or iOS apps in Delp...

delphi delphi-xe2
Rectangle 27 0

By the looks of it according to the documentation of the Android WebView, which I currently assume (without having resource to the source) to be behind TWebBrowser, you'd need to pull out the underlying Android WebView and call its add JavascriptInterface() method (documentation here).

Whether anyone's already done that, I don't know. But that looks to be the requirement. The next step is working out how to access the underlying WebView. I'd imagine that is tucked away int he Android implementation unit for the web browser, so that will be tricky, and may require you to modify the source files.

Thank You for the answer. I thought about it but it is solution only for ANDROID but TWebBrowser works on all platforms. Maybe embded webbrowser like chromium, but I Don't know if it works on other platforms than WIN. Maybe you know answer ??

The question was tagged for Android, so I gave an Android-oriented answer, indeed. I'm not sure you'd readily get a cross-platform solution without some level of abstraction over separate implementations, much like TWebBrowser already employs in its implementation.

I found that Delphi has Androidapi.JNI.WebKit but can someone help me how to create and show the browser in my fmx window ? Please give me some direction.... Thank you

Btw, perhaps you can outline how you solved it in case someone in the future would Google here. He'd be helped with your road marks more than just " it is possible". Stack Overflow aims at being the ultimate documentation for everything, so the more of solution the question has - the better it gets

How can I use javascript in TWebBrowser in Delphi XE5 on all platforms...

javascript android google-maps twebbrowser delphi-xe5
Rectangle 27 0

I saw an example that wrote the static html to a local file, then loaded the local file.

If you find a solution that works in iOS and Android, I'd love to hear about it.

Struggling with the same issue right now.

How can I use javascript in TWebBrowser in Delphi XE5 on all platforms...

javascript android google-maps twebbrowser delphi-xe5
Rectangle 27 0

I'm using Synopse mORMot with all my lastest projects. It's free and open source, has good support of the author by the forum. Supports static linking of SQLite DLL and encryption by AES. Besides, you can use it on server/client application over the HTTP protocol. Yes, the framework is very big and has many functions but you don't need to use all of them. I use only a small part in my applications without any problem. Maybe it's a little bit complicated to start with (I'm not a Delphi Expert) but after this your possibilities are limitless.

I downloaded the latest version of mORMot and it doesn't contain any file named SynSQLite3Static.pas as described in that blog post. How do I get SQLite to statically link ?

Download last version from "Timeline" menu and you will find SynSQLite3Static.pas, the current "beta" version is a bit different from last stable version. However the "timeline" version works very well.

Delphi SQLite Wrapper with Static Linking and Encryption support - Sta...

delphi encryption sqlite3 delphi-xe2 anydac
Rectangle 27 0

All controls added to the TVertScrollBox then need to have their HitTest property (if it exists) set to False. After that it just works!

ios - How can I use gestures on iPhone apps using Delphi Firemonkey? -...

iphone ios delphi gestures firemonkey
Rectangle 27 0

I'm using the multi-image view from the ImageEn library. It does everything you asked for, and it's very fast. I'm happy with it. You can still get an older, free version from Torry that works with Delphi 7 (I haven't tried it on XE2).

The methods aren't exactly intuitive, but once you get the hang of it (nice help file included), it works great.

The latest version has some more features, and it's not expensive if you do decide to license it.

They even have a Flow View control that looks like the slide show on a Mac.

delphi - Looking for a custom image grid - Stack Overflow

image delphi grid delphi-7 delphi-xe2
Rectangle 27 0

If you want to do an app, and not just build a website that can be accessed via the browser, your best bet would be to use a product like Adobe Flash Builder or Delphi Prism which will allow you to code in a cross platform way, but compile into native ios bytecode. The big problem with this approach as I see it is native access to the phones hardware (like GPS, etc)., and debugging. Since there isn't a good emulator to use to test off of.

objective c - What are my options for iOS app development on windows? ...

objective-c ios windows
Rectangle 27 0

If you have a framework file it usually includes a set of header files and a static library. You can extract the static library (the file with the same name as the framework) and rename it by adding an '.a' extension. You can then use that file directly your Delphi project. I have done this with XE8 to X10.

Simply put the static library in your path when you build and you also need to trick the Delphi compiler to link it. Just add a line of code to your implementation section of your unit such as:

procedure LibWhatever2; cdecl; external 'libWhatever.a' name 'OBJC_CLASS_$_SomeClassName'

Using 3rd party framework for IOS in Delphi Firemonkey - Stack Overflo...

ios delphi frameworks firemonkey
Rectangle 27 0

1) Asumming which you are using a new version of delphi (>=2010) you can get the unit name of a type using the QualifiedName property , from there you must check the IsInstance property to determine if is a class.

{$APPTYPE CONSOLE}

{$R *.res}

uses
  Rtti,
  System.SysUtils;

procedure Test;
Var
 t : TRttiType;
  //extract the unit name from the  QualifiedName property
  function GetUnitName(lType: TRttiType): string;
  begin
    Result := StringReplace(lType.QualifiedName, '.' + lType.Name, '',[rfReplaceAll])
  end;

begin
 //list all the types of the System.SysUtils unit
  for t in TRttiContext.Create.GetTypes do
   if SameText('System.SysUtils',GetUnitName(t)) and (t.IsInstance) then
     Writeln(t.Name);
end;

begin
  try
    Test;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
  Readln;
end.

2) The Rtti can't list the instances of the classes. because the Rtti is about type information and not of instances.

Yeah this will work too, unfortunally the DeclaringUnitName is part of specific rtti types, but in this case for instances is ok. In the answer I recommend parse the QualifiedName to get the unit name because in the past I found some cases where the unit name is not present in some types check ths question for more info Getting the Unit Name wich belongs to any type (TRttiType)

Thanks a lot. Oh, one more Q while I have your ear. Are IsInstance and AsInstance the idiomatic ways to do this as opposed to is or as operators?

@DavidHeffernan AsInstance try to cast the type to TRttiInstanceType so will fail to types which not are instances (classes).

I read that other question now. It looks like the issue it refers to is when trying to find the unit name for any variety of TRttiType. But for an instance, and you are writing IsInstance, surely it's simpler and cleaner to use DeclaringUnitName?

delphi - Getting the whole list of classes and objects defined in a un...

delphi delphi-xe2 rtti
Rectangle 27 0

As David says, Mac applications in Delphi are only supported using the new FireMonkey framework, as opposed to the VCL controls in previous versions of Delphi. You can still use VCL in XE2 (and later), but only for developing Windows applications. FireMonkey can be used for developing both Mac and Windows applications.

FireMonkey has a memo control, just as the VCL does, and this also has a Text property, so this line of code would be perfectly valid in both a VCL and a FireMonkey (FMX) application:

Memo1.Text := 'Line 1'#10'Line 2'#10'Line 3'#13#10'Final Line';

Where Memo1 is a VCL or FMX Memo control.

However, the VCL control (as of XE4 at least) still does not properly support the #10 (LF) line breaks, but the FMX control does, on both Windows and Mac so although the code above can be used in both VCL and FMX applications, the results will be different.

In VCL (Windows) you will get the following content in the memo:

Line 1Line 2Line 3
Line

Where as with FireMonkey on Windows and/or Mac you will get:

Line 1
Line 2
Line 3
Final Line

So the answer is that FMX behaves differently than the VCL and respects both #10 and #13#10 line break sequences, irrespective of platform where-as the VCL memo behaviour remains unchanged and is only supported on Windows.

delphi - How does TMemo handle the enter (CRLF) issue on Mac? - Stack ...

delphi delphi-xe2 delphi-xe
Rectangle 27 0

You can use the ChromiumEmbedded package for Delphi. There's a TChromiumFMX component which is suited for FireMonkey applications. I've tested the demo project from the repository and it works fine for 32-bit Windows.

However I can't tell you if nor how to build and use it in Mac OS. The only thing I can tell you is that the ChromiumEmbedded for Delphi is distributed only with Windows binaries, the binaries for Mac OS you can download from here.

I downloaded CEF3, but TChromiumFMX wasn't included with the package it seems. Any ideas?

@petersmileyface, it seems that there won't be any as Jrgen Opsand cited here from the linked thread.

@Mohammad, make sure you have core libraries visible to your executable. That's the most common mistake. But that's all I can tell you, because I don't know what error you got, when, nor which version of DCEF you used.

Thank you @TLama. I had the core library but seems I was using an old version. however it supped to work on XE2. Anyway, I got a newer version from code.google.com/p/dcef3 and worked perfectly :)

delphi - Is there a web browser component for use in FireMonkey applic...

delphi webbrowser-control delphi-xe2 firemonkey
Rectangle 27 0

If you want to do an app, and not just build a website that can be accessed via the browser, your best bet would be to use a product like Adobe Flash Builder or Delphi Prism which will allow you to code in a cross platform way, but compile into native ios bytecode. The big problem with this approach as I see it is native access to the phones hardware (like GPS, etc)., and debugging. Since there isn't a good emulator to use to test off of.

objective c - What are my options for iOS app development on windows? ...

objective-c ios windows
Rectangle 27 0

The inherited constructor that you are calling expects to be passed an owner parameter. You are not doing that.

You should add an owner parameter to the constructor, and pass it to the inherited constructor:

constructor TForm2.Create(AOwner: TComponent; Config: TAndroidBluetooth);
begin
  inherited Create(AOwner);
  ....
end;

Then pass an owner when you create the form:

form := TForm2.Create(Self, bt);

Perhaps you might wish to use a different owner, I cannot tell from here.

One final word of advice. When asking a question about a compilation error, always include the compilation error text in the question so that we know what you are asking about.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

android - How I can use the Constructor in Delphi for transfer Objects...

android delphi constructor bluetooth delphi-xe6
Rectangle 27 0

TWebBrowser.Document AS IHTMLDocument2

and then check OnKeyDown event what is the caption of all inputs objects in DOM.

Hope it helps... I'm not the God of XE5 :-)

How can I use javascript in TWebBrowser in Delphi XE5 on all platforms...

javascript android google-maps twebbrowser delphi-xe5