Меню сайта
Категории раздела
Простые примеры [34] |
OpenGL [4] |
Фрактал [9] |
Windows API [2] |
Консоль [12] |
ДРУЗЬЯ САЙТА
Вызвать мастера в Красноярске
8 983 207 5474
8 902 918 9334
8 933 332 3164
---------------------------------
Запчасти бытткхники
Радиодетали
Электрика
ЗАКЛАДКИ
Поиск
Статистика
Онлайн всего: 1
Гостей: 1
Пользователей: 0
Главная » Статьи » C++ Builder » Простые примеры |
C++ Builder XE2 реактивное сопротивление ёмкости расчет по формуле
Практическое применение C++ Builder XE2 в радиолюбительской практике //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- /* Расчет по формуле Cx=1/(2*Pi*F*C) присвоение полученного значения Label2
*/ void __fastcall TForm1::Button1Click(TObject *Sender) { if( Edit1->Text != "" && Edit2->Text != "" ){ Label2->Caption=FloatToStr( 1 / (2 * 3.14159 * StrToFloat(Edit1->Text) * StrToFloat(Edit2->Text) / 1000000 ) ); } } //--------------------------------------------------------------------------- /* Запрет контекстного меню в Edit1 */ void __fastcall TForm1::Edit1ContextPopup(TObject *Sender, TPoint &MousePos, bool &Handled) { Handled=true; } //--------------------------------------------------------------------------- /* Проверка вводимых символов: только цифры, запятая, забой */ void __fastcall TForm1::Edit1KeyPress(TObject *Sender, System::WideChar &Key) { if( Key == ',' && Edit1->Text.Pos(",") > 0 ) { Key=0; return; } if(Key >= '0' && Key <= '9' || Key == VK_BACK || Key == ',') return; Key=0; } //--------------------------------------------------------------------------- /* Запрет контекстного меню в Edit2 */ void __fastcall TForm1::Edit2ContextPopup(TObject *Sender, TPoint &MousePos, bool &Handled) { Handled=true; } //--------------------------------------------------------------------------- /* Проверка вводимых символов: только цифры, запятая, забой */ void __fastcall TForm1::Edit2KeyPress(TObject *Sender, System::WideChar &Key) { if( Key == ',' && Edit2->Text.Pos(",") > 0 ) { Key=0; return; } if(Key >= '0' && Key <= '9' || Key == VK_BACK || Key == ',') return; Key=0; } //--------------------------------------------------------------------------- /* Очистка */ void __fastcall TForm1::Button2Click(TObject *Sender) { Edit1->Text=""; Edit2->Text=""; Label2->Caption=""; } //--------------------------------------------------------------------------- Заголовочный файл //--------------------------------------------------------------------------- #ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include <System.Classes.hpp> #include <Vcl.Controls.hpp> #include <Vcl.StdCtrls.hpp> #include <Vcl.Forms.hpp> //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TLabel *Label1; TEdit *Edit1; TEdit *Edit2; TButton *Button1; TLabel *Label2; TLabel *Label3; TLabel *Label4; TLabel *Label5; TButton *Button2; void __fastcall Button1Click(TObject *Sender); void __fastcall Edit1ContextPopup(TObject *Sender, TPoint &MousePos, bool &Handled); void __fastcall Edit1KeyPress(TObject *Sender, System::WideChar &Key); void __fastcall Edit2ContextPopup(TObject *Sender, TPoint &MousePos, bool &Handled); void __fastcall Edit2KeyPress(TObject *Sender, System::WideChar &Key); void __fastcall Button2Click(TObject *Sender); private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif | |
Просмотров: 2245 | Рейтинг: 0.0/0 |