Sayfayı Yazdır | Pencereyi Kapat

Açılan Console Ekranını Kapatma

Nereden Yazdırıldığı: Clomosy | Forum
Kategori: Genel Programlama
Forum Adı: Clomosy ile değişken kullanımı
Forum Tanımlaması: TRObject dili ile değişken tanımlaması ve ekranda gösterme
URL: https://forum.clomosy.com.tr/forum_posts.asp?TID=1260
Tarih: 04 Şubat 2026 Saat 18:15
Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com


Konu: Açılan Console Ekranını Kapatma
Mesajı Yazan: M-Guney
Konu: Açılan Console Ekranını Kapatma
Mesaj Tarihi: 04 Şubat 2026 Saat 14:46
Kodumda eğer ki bilgiler yanlış girilirse timeout veriyor ve ardından bir console ekranı açılıyor o ekranı kapatmanın yolunu bulamadım. Mobilde o ekran geldikten sonra Edit inputlarını bozuyor değişmiş olan input u görmüyor eskiye sabit kalıyor.

var
  ConfigList : TClStringList;
  ConfigPath : String;
  WatchdogTimer : TClTimer;
  IsChecking : Boolean;
  InheritedForm : TclForm;
  CheckQuery : TClSqlQuery;

void InitForm(AForm : TclForm);
{
  InheritedForm = AForm;
}

void InitConfig;
{
  try
    ConfigPath = Clomosy.AppFilesPath + 'db_config.txt';
    
    if (ConfigList == nil)
    {
      ConfigList = Clomosy.StringListNew;
    }
    
    if (clFileExists('db_config.txt', Clomosy.AppFilesPath))
    {
      ConfigList.Text = clLoadFromFile(ConfigPath);
    }
  except
    ShowMessage('InitConfig Exception: ' + LastExceptionMessage);
  }
}

void SaveDBConnection(AHost, AUser, APass, ADBName : String; APort: Integer);
{
  try
    if (ConfigList == nil) { ConfigList = Clomosy.StringListNew; }
    ConfigList.Clear;
    ConfigList.Add('Host=' + AHost);
    ConfigList.Add('User=' + AUser);
    ConfigList.Add('Pass=' + APass);
    ConfigList.Add('DB=' + ADBName);
    ConfigList.Add('Port=' + IntToStr(APort));
    
    clSaveToFile(ConfigPath, ConfigList.Text);
    ShowMessage('Database configuration saved successfully.');
  except
    ShowMessage('SaveDBConnection Exception: ' + LastExceptionMessage);
  }
}

void OnHealthTimeout;
{
  if (IsChecking == True)
  {
    IsChecking = False;
    WatchdogTimer.Enabled = False;
    ShowMessage('Connection Timeout: Server 5 saniye içinde cevap vermedi.');
  }
}

void SetupTimer;
{
  if ((WatchdogTimer == nil) && (InheritedForm <> nil))
  {
    WatchdogTimer = InheritedForm.AddNewTimer(InheritedForm, 'WatchdogTimer', 5000);
    WatchdogTimer.Enabled = False;
    InheritedForm.AddNewEvent(WatchdogTimer, tbeOnTimer, 'OnHealthTimeout');
  }
}

function CheckDatabaseHealth(AHost, AUser, APass, ADBName : String; APort: Integer): Boolean;
{
  try
    Result = False;
    SetupTimer;
    
    if (WatchdogTimer == nil)
    {
      ShowMessage('Hata: Timer başlatılamadı. InitForm çağrıldığından emin olun.');
      exit;
    }

    IsChecking = True;
    WatchdogTimer.Interval = 5000; 
    WatchdogTimer.Enabled = True;

    // Step 1: Connectivity Check
    Clomosy.DBSQLServerConnect('SQL Server', AHost, AUser, APass, ADBName, APort);
    
    // Step 2: Lazy Initialization of Query
    CheckQuery.SQL.Text = 'SELECT DB_ID(' + QuotedStr(ADBName) + ') as db_found';
    CheckQuery.Open;
    
    if (IsChecking == True)
    {
      IsChecking = False;
      WatchdogTimer.Enabled = False;

      if (CheckQuery.FieldByName('db_found').AsString == '')
      {
        ShowMessage('Hata: Database bulunamadı.');
        Result = False;
      }
      else
      {
        Clomosy.DBSQLServerConnect('SQL Server', AHost, AUser, APass, ADBName, APort);
        Result = True;
      }
    }
  except
    IsChecking = False;
    if (WatchdogTimer <> nil)
    {
      WatchdogTimer.Enabled = False;
    }
    ShowMessage('Bağlantı Hatası: ' + LastExceptionMessage);
    Result = False;
  }
}

function LoadAndConnect: Boolean;
var
  vHost, vUser, vPass, vDB : String;
  vPort : Integer;
{
  InitConfig;
  try
    Result = False;
    if (ConfigList.Count > 0)
    {
      vHost = ConfigList.Values['Host'];
      vUser = ConfigList.Values['User'];
      vPass = ConfigList.Values['Pass'];
      vDB   = ConfigList.Values['DB'];
      
      if (ConfigList.Values['Port'] == '')
      {
        vPort = 1433;
      }
      else
      {
        vPort = StrToInt(ConfigList.Values['Port']);
      }
  
      Result = CheckDatabaseHealth(vHost, vUser, vPass, vDB, vPort);
    }
    else 
    {
      ShowMessage('Ayarlar bulunamadı.');
      Result = False;
    }
  except
    ShowMessage('LoadAndConnect Exception: ' + LastExceptionMessage);
    Result = False;
  }
}
{
  WatchdogTimer = nil;
}
https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">



Cevaplar:
Mesajı Yazan: M-Guney
Mesaj Tarihi: 04 Şubat 2026 Saat 14:50
Kodun Doğru Hali





var
  ConfigList : TClStringList;
  ConfigPath : String;
  WatchdogTimer : TClTimer;
  IsChecking : Boolean;
  InheritedForm : TclForm;
  CheckQuery : TClSqlQuery;

void InitForm(AForm : TclForm);
{
  InheritedForm = AForm;
}

void InitConfig;
{
  try
    ConfigPath = Clomosy.AppFilesPath + 'db_config.txt';
    
    if (ConfigList == nil)
    {
      ConfigList = Clomosy.StringListNew;
    }
    
    if (clFileExists('db_config.txt', Clomosy.AppFilesPath))
    {
      ConfigList.Text = clLoadFromFile(ConfigPath);
    }
  except
    ShowMessage('InitConfig Exception: ' + LastExceptionMessage);
  }
}

void SaveDBConnection(AHost, AUser, APass, ADBName : String; APort: Integer);
{
  try
    if (ConfigList == nil) { ConfigList = Clomosy.StringListNew; }
    ConfigList.Clear;
    ConfigList.Add('Host=' + AHost);
    ConfigList.Add('User=' + AUser);
    ConfigList.Add('Pass=' + APass);
    ConfigList.Add('DB=' + ADBName);
    ConfigList.Add('Port=' + IntToStr(APort));
    
    clSaveToFile(ConfigPath, ConfigList.Text);
    ShowMessage('Database configuration saved successfully.');
  except
    ShowMessage('SaveDBConnection Exception: ' + LastExceptionMessage);
  }
}

void OnHealthTimeout;
{
  if (IsChecking == True)
  {
    IsChecking = False;
    WatchdogTimer.Enabled = False;
    ShowMessage('Connection Timeout: Server 5 saniye içinde cevap vermedi.');
  }
}

void SetupTimer;
{
  if ((WatchdogTimer == nil) && (InheritedForm <> nil))
  {
    WatchdogTimer = InheritedForm.AddNewTimer(InheritedForm, 'WatchdogTimer', 5000);
    WatchdogTimer.Enabled = False;
    InheritedForm.AddNewEvent(WatchdogTimer, tbeOnTimer, 'OnHealthTimeout');
  }
}

function CheckDatabaseHealth(AHost, AUser, APass, ADBName : String; APort: Integer): Boolean;
{
  try
    Result = False;
    SetupTimer;
    
    if (WatchdogTimer == nil)
    {
      ShowMessage('Hata: Timer başlatılamadı. InitForm çağrıldığından emin olun.');
      exit;
    }

    IsChecking = True;
    WatchdogTimer.Interval = 5000; 
    WatchdogTimer.Enabled = True;

    // Step 1: Connectivity Check
    Clomosy.DBSQLServerConnect('SQL Server', AHost, AUser, APass, ADBName, APort);
    
    // Step 2: Lazy Initialization of Query
    CheckQuery = Clomosy.DBSQLServerQuery;
    CheckQuery.SQL.Text = 'SELECT DB_ID(' + QuotedStr(ADBName) + ') as db_found';
    CheckQuery.Open;
    
    if (IsChecking == True)
    {
      IsChecking = False;
      WatchdogTimer.Enabled = False;

      if (CheckQuery.FieldByName('db_found').AsString == '')
      {
        ShowMessage('Hata: Database bulunamadı.');
        Result = False;
      }
      else
      {
        Clomosy.DBSQLServerConnect('SQL Server', AHost, AUser, APass, ADBName, APort);
        Result = True;
      }
    }
  except
    IsChecking = False;
    if (WatchdogTimer <> nil)
    {
      WatchdogTimer.Enabled = False;
    }
    ShowMessage('Bağlantı Hatası: ' + LastExceptionMessage);
    Result = False;
  }
}

function LoadAndConnect: Boolean;
var
  vHost, vUser, vPass, vDB : String;
  vPort : Integer;
{
  InitConfig;
  try
    Result = False;
    if (ConfigList.Count > 0)
    {
      vHost = ConfigList.Values['Host'];
      vUser = ConfigList.Values['User'];
      vPass = ConfigList.Values['Pass'];
      vDB   = ConfigList.Values['DB'];
      
      if (ConfigList.Values['Port'] == '')
      {
        vPort = 1433;
      }
      else
      {
        vPort = StrToInt(ConfigList.Values['Port']);
      }
  
      Result = CheckDatabaseHealth(vHost, vUser, vPass, vDB, vPort);
    }
    else 
    {
      ShowMessage('Ayarlar bulunamadı.');
      Result = False;
    }
  except
    ShowMessage('LoadAndConnect Exception: ' + LastExceptionMessage);
    Result = False;
  }
}
{

  WatchdogTimer = nil;
}





https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">



Sayfayı Yazdır | Pencereyi Kapat

Forum Software by Web Wiz Forums® version 12.07 - https://www.webwizforums.com
Copyright ©2001-2024 Web Wiz Ltd. - https://www.webwiz.net