C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[28227] Re:[질문] 프로그래스바를 폼위에 올려놓고 돌릴 경우의 문제!
김용수 [heredity] 999 읽음    2003-12-17 00:31
Timer를 이용해서 Form2->ProgressBar1을 조작해 봤습니다.
Form2가 Form1의 작업 진행 상황을 보이는 용도라면 ShowModal()보단
Show()가 더 적당할 것 같아 Form2의 FormStyle을 fsStayOnTop으로 하여
Form2가 언제나 보이도록 한 후 Form2->Show()로 처리하도록 하였습니다.
글구 ... Form2는 Project/Option Menu의 Forms tab에서 Available Forms로
이동시킨후 실행해 주세요.
즐거운 하루되세요.

=========
Unit1.Cpp
=========

  //---------------------------------------------------------------------------
  #include <vcl.h>
  #pragma hdrstop

  #include "Unit1.h"
  #include "Unit2.h"
  //---------------------------------------------------------------------------
  #pragma package(smart_init)
  #pragma resource "*.dfm"
  TForm1 *Form1;
  //---------------------------------------------------------------------------
  __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
  {
    Form2 = NULL;
  }
  //---------------------------------------------------------------------------
  __fastcall TForm1::~TForm1( void )
  {
    if( Form2 != NULL ) {
      delete Form2;
      Form2 = NULL;
    }
  }
  //---------------------------------------------------------------------------
  void __fastcall TForm1::Button1Click(TObject *Sender)
  {
    if( Form2 == NULL ) {
      Form2 = new TForm2( this );
      Form2->FormStyle = fsStayOnTop;
    }

    Form2->Show();
    Form2->ProgressBar1->Position = Form2->ProgressBar1->Min;
  }
  //---------------------------------------------------------------------------
  void __fastcall TForm1::Timer1Timer(TObject *Sender)
  {
    if( Form2 != NULL ) {
      if( Form2->ProgressBar1->Position < Form2->ProgressBar1->Max ) {
        Form2->ProgressBar1->Position = Form2->ProgressBar1->Position + 1;
      }
      else {
        Form2->Hide();
      }
    }
  }
  //---------------------------------------------------------------------------


=======
Unit1.H
=======

  //---------------------------------------------------------------------------

  #ifndef Unit1H
  #define Unit1H
  //---------------------------------------------------------------------------
  #include <Classes.hpp>
  #include <Controls.hpp>
  #include <StdCtrls.hpp>
  #include <Forms.hpp>
  #include <ExtCtrls.hpp>
  //---------------------------------------------------------------------------
  class TForm1 : public TForm
  {
  __published:    // IDE-managed Components
    TButton *Button1;
    TTimer *Timer1;
    void __fastcall Button1Click(TObject *Sender);
    void __fastcall Timer1Timer(TObject *Sender);
  private:    // User declarations
  public:        // User declarations
    __fastcall TForm1(TComponent* Owner);
    __fastcall ~TForm1( void );
  };
  //---------------------------------------------------------------------------
  extern PACKAGE TForm1 *Form1;
  //---------------------------------------------------------------------------
  #endif


=========
Unit1.DFM
=========

  object Form1: TForm1
    Left = 355
    Top = 227
    Width = 783
    Height = 540
    Caption = 'Form1'
    Color = clBtnFace
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    OldCreateOrder = False
    PixelsPerInch = 96
    TextHeight = 13
    object Button1: TButton
      Left = 40
      Top = 20
      Width = 75
      Height = 25
      Caption = 'Button1'
      TabOrder = 0
      OnClick = Button1Click
    end
    object Timer1: TTimer
      Interval = 100
      OnTimer = Timer1Timer
      Left = 124
      Top = 20
    end
  end


=========
Unit2.Cpp
=========

  //---------------------------------------------------------------------------

  #include <vcl.h>
  #pragma hdrstop

  #include "Unit2.h"
  //---------------------------------------------------------------------------
  #pragma package(smart_init)
  #pragma resource "*.dfm"
  TForm2 *Form2;
  //---------------------------------------------------------------------------
  __fastcall TForm2::TForm2(TComponent* Owner)
    : TForm(Owner)
  {
  }
  //---------------------------------------------------------------------------


=======
Unit2.h
=======

  //---------------------------------------------------------------------------

  #ifndef Unit2H
  #define Unit2H
  //---------------------------------------------------------------------------
  #include <Classes.hpp>
  #include <Controls.hpp>
  #include <StdCtrls.hpp>
  #include <Forms.hpp>
  #include <ComCtrls.hpp>
  //---------------------------------------------------------------------------
  class TForm2 : public TForm
  {
  __published:    // IDE-managed Components
    TProgressBar *ProgressBar1;
  private:    // User declarations
  public:        // User declarations
    __fastcall TForm2(TComponent* Owner);
  };
  //---------------------------------------------------------------------------
  extern PACKAGE TForm2 *Form2;
  //---------------------------------------------------------------------------
  #endif



=========
Unit2.DFM
=========

  object Form2: TForm2
    Left = 307
    Top = 157
    Width = 354
    Height = 129
    Caption = 'Form2'
    Color = clBtnFace
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    OldCreateOrder = False
    PixelsPerInch = 96
    TextHeight = 13
    object ProgressBar1: TProgressBar
      Left = 4
      Top = 40
      Width = 337
      Height = 16
      Min = 0
      Max = 100
      TabOrder = 0
    end
  end

--------------------------------------------------------------------

볼로 님이 쓰신 글 :
: Form A에서 선택한 데이터틀 순서데로 출력하는 동안
:
: ProgressBar를 가진 Form B를 띄워 진행 상태를 나타내려 합니다.
:
: 그런데 Form B를 ShowModal()로하면 FormA와 FormB가 서로 데이터를 주고 받지 못하는 군요.
:
: modaless로 할 경우에는 정상적으로 동작합니다만.
:
: 어떻게하면 ShowModal()로 띄우고 Form A와 Form B가 서로 데이터를 주고 받을 수 있을 까요?

+ -

관련 글 리스트
28212 [질문] 프로그래스바를 폼위에 올려놓고 돌릴 경우의 문제! 볼로 839 2003/12/16
28233     Re:[감사 합니다.] 문제를 해결했습니다. 볼로 849 2003/12/17
28227     Re:[질문] 프로그래스바를 폼위에 올려놓고 돌릴 경우의 문제! 김용수 999 2003/12/17
28220     Re:[질문] 프로그래스바를 폼위에 올려놓고 돌릴 경우의 문제! 유영인 Cuperido 1132 2003/12/16
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.