13,826
社区成员
发帖
与我相关
我的任务
分享
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
// 假设Form3是主窗体
Application->CreateForm(__classid(TForm3), &Form3);
Application->Run();
...
}
#include "Unit1.h"
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner)
{
TForm1 *frm = new TForm1(this);
int n = frm->ShowModal();
delete frm;
if (n != mrOk) // 假设登录成功
{
PostQuitMessage(0);
return;
}
// 后续代码略
...
}
// 判断用户名和密码匹配的代码略
...
if (匹配成功)
ModalResult = mrOk;
else
{
提示(登录失败);
Close();
}
Project1.cpp
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->CreateForm(__classid(TForm3), &Form3);
Application->CreateForm(__classid(TForm1), &Form1);
Application->CreateForm(__classid(TForm2), &Form2);
Application->Run();
}
Unit3.cpp
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner)
{
if(Form1->ShowModal()==1){
Form1->Release();
return;
}
}
Unit1.cpp
if (database->Count()<=0)
{
ShowMessage("xxxxxxxxxx");
return ;
}
else
{
ShowMessage(database->FieldString("name"));
ShowMessage(database->FieldString("passWord"));
Form1->ModalResult =1;
this->Close();
}