Sunday, December 30, 2012

Linker error: Unable to open CHART.OBJ

從 C++ Builder 2010 升級至 C++ Builder XE3 時出現這個問題。
解決方法:
C++ Builder 2010 會在使用 TeeChart 的 .cpp 中,加入:


#pragma link "Chart"
#pragma link "TeEngine"
#pragma link "TeeProcs"
#pragma link "Series"


等連結資訊。

C++ Builder XE3 將這些 .obj 檔都包裝成 tee.lib,所以把這幾行刪除即可。

請同時參考:
http://www.teechart.net/support/viewtopic.php?f=3&t=13210

Wednesday, December 19, 2012

MFC 的錯誤訊息( Invalid address specified to RtlValidateHeap)

原因:不同模組共用 dll 時,產生了記憶體衝突。
解決方法:改變 linker 的設定,將"靜態"改為"共用"。

(感謝 SBH 經驗分享)

Thursday, November 22, 2012

C++ Builder: [ILINK32 Error] Error: Unresolved external 'WinMain' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\RAD STUDIO\7.0\LIB\C0W32.OBJ

Build 時出現以下錯誤訊息:
[ILINK32 Error] Error: Unresolved external 'WinMain' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\RAD STUDIO\7.0\LIB\C0W32.OBJ

解決方法:
 
如下圖,是 Console Application 的話,就別手殘把那個 Checkbox Uncheck!



Friday, November 16, 2012

VMWare 安裝 Mac OS X 10.7 開機當機?

安裝後或升級後重開機, 畫面停在起始灰色蘋果!!

再等等吧! VM 開機比較慢,也會做一些必要的調整,開機需要約10-30分鐘。

網路磁碟機無法連線

看這裏
http://social.technet.microsoft.com/Forums/en/w7itpronetworking/thread/1f22d98f-e150-4a54-9967-1641fa86dbc5

Wednesday, November 14, 2012

InstallAWare web updates 的一些設定

1. 軟體更新伺服器上的 .ini 和 .msi 檔名大小寫有分!(在 Google 協作平台)
2. ini 檔中的 [Update Packs for Versions] , Version 編號指的是舊版本在安裝時(.msi) 儲存的編號。
    版本編號必須一致,才能找到程式新版本。
3. ini 檔中的 URL 是下載新版程式的路徑。
所以,產生新版 .msi 時:
1. 修改 Product Version:Application Information > Project Properties > Product Version。
2. 修改 Update Packs for Versions:Web Updates > Versions

Saturday, November 10, 2012

Working with version information at C++ Builder

From: http://bcbjournal.org/articles/vol3/9901/Working_with_version_information.htm?PHPSESSID=eb3eea609943c3d1bb8294288b945696


January 1999

Working with version information

by John M. MianoIn order to understand the mechanics of our technique in the article, "A component for reading version information from a program file," you must be familiar with the way C++Builder works with component information. Let's quickly review version resources.

Creating version resources

In C++Builder, you set the version information for a program on the Version Info tab in the Project Options dialog box, as shown in Figure A. You must check the Include Version Information In Project check box in order to write the version resources to the executable file.Figure A: Enter version information page in the Project Options dialog box.

At the bottom of the Version Info tab, you'll find a list of version keywords to which you can assign values. C++Builder automatically creates a set of predefined keywords--you should use these keywords if possible, but you can add your own keywords to this list, if you have the need.

Reading version information

The GetFileVersionInfoSize Windows API function returns the number of bytes of version information stored in the image:
DWORD unusedparam ;
DWORD versionsize = GetFileVersionInfoSize (
Application->ExeName.c_str (),
&unusedparam) ;

You also use this function to determine whether your application actually contains version information. The only important parameter to this function is the name of the file. The GetFileVersionInfo API function copies the version resource information to a buffer so your program can access it:
if (versionsize != 0)
{
char *buffer = new char [versionsize] ;
bool status = GetFileVersionInfo (
Application>ExeName.c_str (),
unusedparam,
versionsize,
(void *) buffer) ;
}

Getting the language information

To extract individual items from the version information, you use the VerQueryValue API function. A unique string key identifies each version-information item. The format of this key string is
\StringFileInfo\LLLLCCCC\KeyName

where KeyName is the keyword defined in the Project Options dialog box and LLLL and CCCC are hexadecimal representations of the language and character-set identifiers used. The language and character-set identifiers may seem like extra information, because C++Builder allows you to enter version information for only one language. However, a program can contain version information in multiple languages and character sets. If you have access to a full-featured Windows resource editor, you can create multi-language resource information.The key value \VarFileInfo\Translation references a list of language translations contained in the version information. This fragment returns a pointer to an array containing information about each language contained in the version information:
UINT datasize ;
struct
{
unsigned short language ;
unsigned short character_set ;
} *translation ;
status = VerQueryValue(
buffer,
"\\VarFileInfo\\Translation",
(void **) &translation,
&datasize) ;
int translationcount
= datasize
/ sizeof (*translation)

The full key for the FileVersion keyword would be
String key
= "\\StringFileInfo\\"
+ String::IntToHex (translation
[0].language, 4)
+ String::IntToHex (translation
[0].character_set, 4)
+ "FileVersion" ;

The file version is returned like this:
char *version ;
UNIT versionsize
status = VerQueryValue(
buffer,
key.c_str (),
(void **) &translation,
&versionsize) ;


Wednesday, November 7, 2012

!! Two visitors !!

第一次看到這個筆記小格同時有二個訪客在線上(一個是我自己啦!),紀念一下。




Sunday, November 4, 2012

關於 OpenGL 的 Display List

1. 是 OpenGL 繪圖指令的集合。
2. 使用主記憶體,因為可記錄的指令數量與可用的記憶體數量有關。

比較:

glVertexPointerglInterleavedArrays

Friday, October 26, 2012

Ambiguity between 'Graphics' and 'Gdiplus::Graphics' : C++ Builder

1. Add "STRICT" to conventional defines.
2. Arrange header files in the following order:

    #include <algorithm>
    using std::min;
    using std::max;
    #include <gdiplus.h>

Tuesday, October 23, 2012

Thursday, October 18, 2012

在C++ Builder 使用 QHull

QHull: 一個很有效率的工具,用來建立一群點的凸多邊形、Delaunay TIN、Voronoi diagram。
有完整的原始 c 與 c++ 程式碼可下載,並提供 Visual C++ 的專案檔。

而在 C++ Builder build QHull 時,需修改下列設定:
1. Conventional 增加 __STDC__。
2. 在 user.h 增加 #define qh_QHpointer 1。
3. PointCoordinates.h 中有多個成員函式的定義需要修改。主要是變數形態轉換的問題,另有幾個重複定義的函數,remark 即可。

vector 的缺點 (vs. MXArray)

數量太大時無法配置足夠的記憶體。

Saturday, July 14, 2012

[OpenCV] 將二張影像合併為一張(使用cv::Mat)

以下程式碼使用 cv::Mat 將二張相同大小的影像,橫向合併為一張。


Mat img1 = imread(imageleft, -1);
Mat img2 = imread(imageright, -1);
Size img_size = img1.size();


Mat img_new(img_size.height, img_size.width*2, img1.type() );Mat part;
part = img_new(cv::Rect(0,0,img_size.width,img_size.height)); 
img1.copyTo(part);
//重點在這裏, 將 part 指向新影像的右半邊, 然後將第二張影像(img2)複製過去。
part =  pair(cv::Rect(img_size.width,0,img_size.width,img_size.height)); 
img2.copyTo(part);
imwrite( new_image_naem, img_new);

Thursday, July 12, 2012

[OpenCV] cv::Mat 與 CvMat, IplImage 之轉換

參考資料:http://hi.baidu.com/windroc/blog/item/e5c2d3c4707fead938db4907.html

1. IplImage => cv::Mat

IplImage *iplImage = cvLoadImage( image_filename, 1);

cv::Mat mat_image(iplImage);

or

cv::Mat mat_image = iplImage;


2. cv::Mat => IplImage

cv::Mat mat_image;

IplImage iplImage = mat_image ;


3. CvMat => cv::Mat

CvMat *cvmat_image;

cv::Mat mat_image(cvmat_image);


4. cv::Mat => CvMat

cv::Mat mat_image;

CvMat cvmat_image = mat_image ;

Tuesday, July 10, 2012

MDI Application 啟動時檢查命令列參數並開啟 MDI Child Form (C++ Builder)

在MDI Application 啟動時檢查命令列參數並開啟 MDI Child Form。
在程式啟動時,若於 MDI Form 尚未建立完成時,例如Constructro, OnCreate, OnShow 等函數開啟 MDI Child Form 會產生以下錯誤:

Cannot create form. No MDI forms are currently active.

MDI Child Form 必須等 MDI Form 物件建立之後才可開啟。

這個問題有二個解決方法:參考來源:http://www.delphigroups.info/3/4/437727.html


法一:增加自建訊息(Message)

1. 增加一個自建設息,例如:APPWM_CHECKPARAMS

2. 在 MDI Form 的 Constructor 送出這個訊息

PostMessage(Handle, APPWM_CHECKPARAMS, 0, 0);

3. 覆寫 MDIForm 的 WndProc,若 MDIForm收到 APPWM_CHECKPARAMS 則檢查命令列參數並開啟 MDI Chile Form。

void __fastcall TForm1::WndProc(TMessage &Message)

{
    if( Message.Msg == APPWM_CHECKPARAMS )
    {
        // check for the filename here, opening child windows if needed...
    }
    else
        TForm::WndProc(Message);
    }
}


法二:在 OnPaint

(參考來源)

在程式中增加一個布林變數,判斷OnPaint是否為第一次執行。若是第一次則檢查命令列參數並開啟 MDI Chile Form。但因為每次 OnPaint 是都必須判斷,不是好的方法。

Monday, July 2, 2012

螢幕錄製程式(Free)

CamStudio Recorder

錄製軟體操作示範影片,操作簡易。錄製的影片可用 AVI 或 flash 格式儲存。
 
官方網站:http://camstudio.org/
其他高手的介紹文章:http://a55951234.twgg.org/?p=575

Friday, June 22, 2012

Error during build: List index out of bounds (-1) - InstallAware 2010

問題描述:
    InstallAWare 2012 建置 (build) 軟體安裝( setup )檔時,產生此錯誤,建置失敗。

解決方法:
   刪除或修正檔案副檔名類型 (file type extension) 之設定。
   

Saturday, June 9, 2012

OpenGL 啟動燈光時使模型以本身的顏色展示

[OpenGL] [M LiDAR Viewer]
若要在啟動燈光時,使模型以本身的顏色展示,則應啟用 GL_COLOR_MATERIAL :

glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);

glEnable( GL_COLOR_MATERIAL );   //這一行必須在 glColorMaterial 之後

前三行可更改物體反射光線的性質。

 [M LiDAR Viewer]

Tuesday, April 10, 2012

Select Folder Dialog (C++ Builder)

問題:TOpenDialog 可用來選擇要開啟的檔案, 但如何選擇某一個資料夾。

回答:用 SelectDirectory()

語法:
bool __fastcall SelectDirectory(System::UnicodeString & Directory, 
     System::Set<Filectrl::TSelectDirOpt,0,2> Options, int HelpCtx);
標頭檔:
  FileCtrl.hpp
範例:
#include "FileCtrl.hpp"
const SELDIRHELP = 1000;
void __fastcall Form1::Button1Click(TObject *Sender)
{
    String Dir = "C:\\Program Files";
    if (SelectDirectory(Dir, TSelectDirOpts() << sdAllowCreate << sdPerformCreate << sdPrompt,SELDIRHELP))
{
              Label1->Caption = Dir;
}
}

官方說明:
Unit: FileCtrl
Type: function

Description

Brings up a dialog to allow the user to enter a directory name.

Call SelectDirectory to let the user enter a directory name.
Use the first syntax to call the Select Directory dialog box. The directory passed to the function with the Directory parameter appears as the currently selected directory when the dialog box appears. The name of the directory the user selects becomes the value of Directory when the function returns.
The HelpCtx parameter is the help context ID number.
Use the second syntax to display the Windows directory browser. The Caption parameter specifies a caption for the dialog. The Root parameter specifies the root directory from which to browse. The selected directory is returned as the Directory parameter. When using this syntax, SelectDirectory does not change the value of the current directory.
Warning:  You can't use the same variable for the Root parameter and the Directory parameter.
The Options parameter is a set of values. If Options is the empty set, the user can only select a directory that already exists. No edit box is provided for the user to enter a new directory name. If Options is not empty, the included values determine how the dialog responds when the user types a nonexistent directory name.
With either syntax, SelectDirectory returns true if the user selected a directory and chose OK, and false if the user chose Cancel or closed the dialog box without selecting a directory.

See Also

  • DirectoryExists
  • ForceDirectories

Thursday, March 15, 2012

C++ Builder 2010啟動時出現"堆疊空間不足"訊息

問題: C++ Builder 2010啟動時出現"堆疊空間不足"訊息, 接著無回應。工作管理員中顯示C++ Builder 2010使用的記憶體超過1GB.



修正方法:

 參考來源


从 Delphi 2010 启动菜单上点右键 -> 查看属性:
"C:\Program Files\CodeGear\RAD Studio\7.0\bin\bds.exe" -pDelphi
这里已经有了一个启动参数: -pDelphi; 当然也可以是: -pDelphiDotNet 或 -pCBuilder
再给一个 -np 参数即可去掉那个讨厌的 Start Page, 像这样:
"C:\Program Files\CodeGear\RAD Studio\7.0\bin\bds.exe" -pDelphi -np
如果再给一个 -ns 连启动画面也可以省略.

Monday, March 12, 2012

垂直排列的 Toolbar : C++ Builder

Toolbar->Align = alNone;
Toolbar->AutoSize = true;

Toolbutton->Wrap = true;

停用桌面轉譯緩衝處理

 [M LiDAR Viewer]
Windows 7 環境下, 在OpenGL視窗使用GDI即時繪圖,例如操作滑鼠繪出框選矩形時, 原來在視窗上的圖案會被清除。此時必須關閉[桌面轉譯緩衝處理]。

1.在程式的圖案上按滑鼠右鍵, 開啟程式[內容]對話盒.
2.按[相容性]頁面.
3.勾選[停用桌面轉譯緩衝處理].
4.按[確定]關閉對話盒.



設定完成後, Registry 中會新增一筆設定資料如下:

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"D:\\m\\code\\Source\\Garfields\\MLidarSystem\\bin\\release\\MLidarViewer.exe"="DISABLEDWM"

 [M LiDAR Viewer]

Gesture (Debug) Link Error : C++ Builder 2010

問題: [ILINK32 Error] Fatal: Type index 2147479550 is bad in module Gestures.pas


原因: 
    C++ Builder 2010 Debug 版本的 vcltouch.lib 有bug, 導致連結錯誤.


解決方法:
    以 Release 版的 vcltouch.lib 取代(覆蓋) Debug 版的 vcltouch.lib.

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

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