Monday, March 31, 2014

[C++ Builder] Show a form before Mainform is shown

[Reference]
http://embarcadero.newsgroups.archived.at/public.delphi.vcl.components.using/200904/0904161856.html

Sometimes, an application requires to show a form before the Mainform. This following code shows how to create and show a form (DialogSelectLanguage) before Mainform (FornMain) is show.

Notice: DialogSelectLanguage should be moved to < Avaliable forms > ( [Project] [Options...] [Form] )



int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) 

  Application->Initialize(); 
  
// Create a form before Mainform is creacted.
  DialogSelectLanguage = new TDialogSelectLanguage(Application);   // Show the form
  DialogSelectLanguage->ShowModal(); 
  ... 
  ... 
  DialogSelectLanguage->Release(); // If needed
  DialogSelectLanguage=NULL; 

  // Create Mainform  Application->CreateForm(__classid(TFormMain), &FormMain); 
  Application->Run(); 
  return 0;  
}



Friday, March 28, 2014

[C++ Builder] [ EReadError with message 'Ancestor for '' not found' ] raised when the user changes language at a multi-language application

[Reference]
http://www.delphigroups.info/2/c4/531642.html

This error is raised when the user changes language at a multi-language application. It is because there is one or more components whose Name property is empty (""). To solve this problem, the empty-Name component should be found and set a name. Please see the method to find the component whose name is empty from the application. Because the component has no name, you can identify it by its class name and which form it is only.
For example, a TLable component with no Name is found. Go to the object inspector of the form, you will see the component <Components[43]> is located at the top of object inspector and its Name property is empty, as shown in the picture. (At this example, the TLabel component is inside Panel1 )


Then you can set a name to the component and the problem solved.

[C++ Builder] How to search components in the application

The following code search the component whose Name is empty("").


TComponent *pform, *pcomponent;
AnsiString NoNameComponent;

for( int ff=0; ff< Application->ComponentCount; ff++) {   
  pform = Application->Components[ff];  // get a form
    for( int i=0; i< pform->ComponentCount; i++ ) {        
    pcomponent = pform->Components[i];  // get a component
    if( pcomponent->Name == "" )  {
      NoNameComponent = pcomponent->ClassName()
                      +" at "+pform->Name + "has no name";
    }
  }
}


Sunday, March 2, 2014

Cannot detect Sony Xperia Tablet Z in Eclipse

[Reference] http://stackoverflow.com/questions/12053720/cannot-detect-sony-xperia-in-eclipse

[Solution]  Set [USB connection mode] to [Mass storage mode (MSC)]
Xperia has very strange option:
Settings > Xperia > USB Connectivity > USB connection mode
and select Mass storage mode (MSC)

[Qt] 執行檔需要哪些 Dll?

 1. 使用 Qt  的 windeployqt.exe 工具 (在 C:\Qt\Qt5.14.1\5.14.1\msvc2017\bin\)。   a. 把執行檔 myProgram.exe 放在某個資料夾。   b. 在檔案總管這個資料夾按 Shift 和滑鼠右鍵,開啟 Po...