Monday, April 30, 2012

TRibbon.MoveGroup Method Parameters

Yesterday, I was working on a program which have several editions. I created the application ribbon bar at design time, but in one of the editions I had to combine two of the ribbon pages. so I tried to move all of the ribbon groups from one ribbon page to another using the TRibbon.MoveGroup method.

I was completely, unsuccessful as I always passed the name of the source group and the target page as the parameters. The method definition is this: 

void __fastcall MoveGroup(const System::UnicodeString GroupName, const System::UnicodeString PageName);

I realized that the parameters should be the Caption (not the name) of the moving ribbon group and the target ribbon page. This way the method works charmingly :) 



Thursday, April 26, 2012

Add Node/Child Node Icons

Today, I was googling a lot to find good icons for "Add Node" and "Add Child Node" commands of my application. I found some, but good ones were 16x16 in size. So, I tried to draw them myself:

I hope they can be useful for anybody who need them. Use them freely.



Wednesday, April 25, 2012

Convert to Base64 using TIdEncodeMIME when upgrading the compiler


As useful task for data streaming, we need to encode some parts of our database records to Base64 encoding format. For example, to save pictures in text base databases (such as XML), we do need to convert it to Base64 text format.
In Borland Developer Studio 2006, you can use Encode(String) method of the TIdEncodeMIME class to convert binary information into Base64 format. When upgrading to a newer version of C++Builder (or Delphi), for example Embarcadero RAD Studio XE2, you must use a newer method, EncodeStream(TStream *) instead of the Encode(String). In the new TIdEncoderMIME class, convering binary data using Encode method may cause unexpected error.

//In this example the Data->Picture is of type TMemoryStream
TIdEncoderMIME *Encoder = new TIdEncoderMIME(NULL);
ReturnValue += Encoder->EncodeStream(Data->Picture); //instead of Encode method
delete Encoder;