TMemo – Markierte Zeile ermitteln
28. April 2007 Feedback schreibenAb und an wird auch mal die Zeilennummer der markierten Zeile in einem TMemo gebraucht hier ein Beispiel was ich ganz praktisch finde:
void __fastcall TForm1::Memo1Click(TObject *Sender)
{
int Zeile;
Zeile = SendMessageA(Memo1->Handle, EM_LINEFROMCHAR, Memo1->SelStart, 0);
Edit1->Text = IntToStr(Zeile+1);
}
TFileListBox – Multiselectionen abarbeiten
28. April 2007 Feedback schreibenfor (int i = 0; i < FileListBox1->Items->Count; i++)
{
if (FileListBox1->Selected[i])
{
ShowMessage(FileListBox1->Items->Strings[i]);
}
}
TIdFTP mit TProgressBar verbinden
28. April 2007 Feedback schreibenlong dlsize=IdFTP1->Size(“filename”);
void __fastcall TForm1::IdFTP1WorkBegin(TObject *Sender, TWorkMode AWorkMode, const int AWorkCountMax)
{
if (AWorkCountMax > 0)
{
ProgressBar1->Max=AWorkCountMax;
}else
{
ProgressBar1->Max=dlsize;
}
}
Blinkendes TLabel
28. April 2007 Feedback schreibenvoid __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Label1->Visible = !Label1->Visible;
}
ScreenShot erstellen und JPG-Datei speichern
28. April 2007 Feedback schreiben#include <jpeg.hpp>
HDC dc = GetDC(NULL);
TJPEGImage *pJPG_Bild = new TJPEGImage();
Graphics::TCanvas *ScreenCanvas = new Graphics::TCanvas();
ScreenCanvas->Handle = dc;
thescreen->AutoSize = true;
thescreen->Center = true;
thescreen->Top = 0;
thescreen->Left = 0;
thescreen->Picture->Bitmap->Width = Screen->Width;
thescreen->Picture->Bitmap->Height= Screen->Height;
TRect rect = Rect(0,0,Screen->Width, Screen->Height);
thescreen->Picture->Bitmap->Canvas->CopyRect(rect, ScreenCanvas, rect);
ReleaseDC(NULL,dc);
pJPG_Bild->Assign(thescreen->Picture->Bitmap);
pJPG_Bild->CompressionQuality = 50;
pJPG_Bild->SaveToFile(“test.jpg”);
delete pJPG_Bild;
delete ScreenCanvas;
MultiLineCheckBox
28. April 2007 Feedback schreibenvoid MultiLineCheckbox(TButtonControl* pmlcheckbox)
{
SetWindowLong(pmlcheckbox->Handle, GWL_STYLE,
GetWindowLong(pmlcheckbox->Handle, GWL_STYLE) | BS_MULTILINE);
}
MultiLineCheckbox(CheckBox1);
CheckBox1->Caption = “Line1 Line2″;
Automatisches scrollen im TRichEdit
28. April 2007 Feedback schreibenRichEdit1->HideSelection = false;
RichEdit1->SelStart=RichEdit1->Lines->Text.Length();
Canvas mit Farbverlauf
28. April 2007 Feedback schreibenint h=Height;
int w=Width;
int mycolor=0;
for(int i=0;i{
mycolor=255*i/h;
Canvas->Pen->Color=TColor(RGB(mycolor,200,200));
Canvas->MoveTo(0,i);
Canvas->LineTo(w,i);
}
Maus – CursorPostion ermitteln
28. April 2007 Feedback schreibenTPoint *mausxy = new TPoint;
GetCursorPos(mausxy);
int x = mausxy->x – Form1->Left;
int y = mausxy->y – Form1->Top;
Label1->Caption = “X= ” + IntToStr(x) + ” Y= ” + IntToStr(y);
delete mausxy;
mehr...Standalone EXE- Datei erstellen
28. April 2007 Feedback schreibenGeh ins Menue “Projekt” -> “Optionen”.
Da deaktivierst du unter Registerkarte Linker
“dynamische RTL verwenden”
und unter Registerkarte Packages
“mit Laufzeit-Packages kompilieren”.
Jetzt sollte deine EXE- Datei auch auf Rechnern
laufen die kein BCB installiert haben.



