|
그냥 C 사용하듯이 하시면 됩니다.
Scanner.cpp와 Scanner.h를 생성하신후에 cpp에는 함수 구현부를 h에는 함수원형 선언을 하시고
사용하려는 cpp에서 헤더를 인클루드 하시고 쓰시면 됩니다.
굳이 클래스로 만들지 않아도 됩니다.
곽성주 님이 쓰신 글 :
: 아래와 같이 OCX를 이용하여 스캐닝하는 함수를 구현하였습니다.
: 호출은 버튼 이벤트에서 하고요... 헤더에 함수선언 해주었고요.
:
: 그런데 이함수를 unit 을 하나 추가하여 함수를 분리하려고 합니다.
: unit의 헤더와 구현을 어떻게 구성해야 할까요?
:
:
: #include <vcl.h>
: #pragma hdrstop
:
: #include "U_FuncTest.h"
: //---------------------------------------------------------------------------
: #pragma package(smart_init)
: #pragma link "TWIZLib_OCX"
: #pragma resource "*.dfm"
: TForm1 *Form1;
: //---------------------------------------------------------------------------
: __fastcall TForm1::TForm1(TComponent* Owner)
: : TForm(Owner)
: {
: }
: //---------------------------------------------------------------------------
: // 함수
: void __fastcall TForm1::wf_scanner(WideString scan_file)
: {
: Twiz1->Units=TWIZ_INCHES;
: Twiz1->PixelType=1;
: Twiz1->AcquireToFile(scan_file);
: }
: // 호출
: void __fastcall TForm1::Button1Click(TObject *Sender)
: {
:
: WideString file1;
: file1="c:\\test.bmp";
:
: wf_scanner(file1);
: }
:
: /////// 헤더 ////////////////////////////////////
: ...
: class TForm1 : public TForm
: {
: __published:
: TTwiz *Twiz1;
: TButton *Button1;
: void __fastcall Button1Click(TObject *Sender);
: private:
: public:
: __fastcall TForm1(TComponent* Owner);
: void __fastcall wf_scanner(WideString scan_file);
: };
: ...
|