Модераторы: Poseidon
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> [Delphi] Прозрачный текст, со случайным движением 
:(
    Опции темы
Deiv
  Дата 18.12.2006, 16:34 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 43
Регистрация: 11.2.2006
Где: ЛаПаc-Боливия (Ю жная Америка)

Репутация: нет
Всего: нет



Transparent Текст со случайным движением на любом объекте в TFORM'a
Привет,
С целью показать оживление в моей программе,   
Мне нужно показать TRANSPARENT ТЕКСТ c постоянном случайним движением ибо вообще окно TForm'a моей программы, в Form'e у меня есть ещё другие объекты как TEdit, TButton, TPanel, и.т.д. Я постарался с компонентами как:  

1.- TLabel'oм, но это тянется сзади компоненты  
2.- TPanel'oм включеннo с TPaintBox'oм, но вся Панель размещаются выше ко всем объектам моей формы  
3.- TStaticText'oм, очень хороший, I включил несколько TStaticText'ax для каждой буквы моего Текста (string), и это компонент почти в 80% чем другими объектами преодолевает с "Bring To Front", но .. .. это всегда тянет маленькие окна для каждой буквы, не выполняется Transparent.
Подскажите, пожалуйста,
- Есть такой хороший компонент - StaticText что, преодолевает выше (Bring To Front) любого другого объекта но прозрачно?,  Или использовать другой компонент?.
- Как показать TRANSPARENT ТЕКСТ c постоянном случайном колебанием выше объектах TForm'a?



Transparent Text with random movement on any object in a TForm
Hi, 
With the objective of showing an animation in my program, 
I need to show a TRANSPARENT TEXT in constant random movement for the whole window of the TForm of my program, in the TForm I also have other objects as TEdit, TButton, TPanel, etc. I have tried with components as:  
1.- TLabel, but this it is drawn behind the components  
2.- TPanel included with a TPaintBox, but the all Panel are located above to all the objects of my form  
3.- TStaticText, very good, I has included (added) several TStaticText for each letter of my Text (string), and this component almost in 80% of the other objects overcomes with "Bring To Front", but.... this always draws small windows for each letter, it's not executed transparent. 
Please tell me,
- Do you know of some component as the TStaticText that overcomes above (Bring To Front) of any other object but transparently? Maybe to use another component? 
- How to show a TRANSPARENT TEXT in constant random movement above the objects of the TForm?


PM MAIL YIM   Вверх
dimazu
Дата 18.12.2006, 19:02 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 83
Регистрация: 4.3.2006

Репутация: нет
Всего: 5



TLabel is just some internal component, made for decoration purposes only,
almost a regular TextOut on Parent with properties  smile 
TStaticText, on the other hand,  is TWinControl, so (IMHO) it can not be transparent.
The only way to make TWinControl (TStaticText or any other) appear transparent 
is to use XP manifest (or work with TPaintBox, what you already do  smile )

TextOut is always an option too...  smile 

PM MAIL   Вверх
Deiv
Дата 19.12.2006, 17:37 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 43
Регистрация: 11.2.2006
Где: ЛаПаc-Боливия (Ю жная Америка)

Репутация: нет
Всего: нет



Спасибо, но .. ..  
Я хочу привлечь мой Текст или показать ему с любым другим компонентом (прозрачным) и это позиционированно свыше, над (к фронту) Любого объекта а не сзади. TPaintBox и TextOut нет решение. Кокой компонент Вы рекомендуете?
    
Thank you, but....  
I want to draw my Text or to show with any other component (transparent) and this it is positioned for above, over (to the front) of any object and not behind. TPaintBox and TextOut not neither solution, . Which component do they recommend?

PM MAIL YIM   Вверх
dimazu
Дата 19.12.2006, 22:06 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 83
Регистрация: 4.3.2006

Репутация: нет
Всего: 5



OK,OK, got it....  smile 

If you don't want to do it youself (laaazy, I beleive  smile ),  see attached.
I've created CustomPanel with Transparent property.

You can put your text in Caption of the MyPanel or put there any Label 
with Transparent := True

But remember, THIS IS JUST AN EXAMPLE.  smile  
Enjoy!

Код

unit CustomPanel1;

interface

uses
 Windows, Messages,
  SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls;

type
  TMyPanel = class(TCustomPanel)
  private
   FTransparent: Boolean;
   procedure SetTransparent(const Value: Boolean);
    { Private declarations }
  protected
    { Protected declarations }
    procedure CreateParams(var Params: TCreateParams); override;
    procedure Paint; override;
    procedure PutCaption(ACanvas: TCanvas); dynamic;
    procedure WMEraseBkgnd(var Msg: TWMEraseBkgnd); message WM_ERASEBKGND;

  public
    { Public declarations }
   constructor Create(AOwner: TComponent); override;
  published
   property Transparent: Boolean read FTransparent write SetTransparent default False;
   property Caption;
   property Font;
   property Alignment;
   property OnClick;
   property Enabled;
   property FullRepaint;
    { Published declarations }
  end;

procedure Register;

implementation

const
  _Transparent = TRANSPARENT;


procedure TMyPanel.WMEraseBkgnd(var Msg: TWMEraseBkgnd);
begin
  Msg.Result := 1;
end;

procedure TMyPanel.PutCaption(ACanvas: TCanvas);
const
  _Alignment: array [TAlignment] of Longint = (DT_LEFT, DT_RIGHT, DT_CENTER);
var
  RectTxt: TRect;
  Flags: Longint;
begin
  with ACanvas do
  begin
    if Caption <> '' then
    begin
      ACanvas.Font := Self.Font;
      SetBkMode(Handle, _Transparent);
      Font := Self.Font;
      RectTxt := GetClientRect;
      InflateRect(RectTxt, -BorderWidth, -BorderWidth);
      Flags := DT_EXPANDTABS or _Alignment[Alignment];
      Flags := DrawTextBiDiModeFlags(Flags);
      DrawText(ACanvas.Handle, PChar(Caption), -1, RectTxt, Flags or DT_CALCRECT);
      OffsetRect(RectTxt, 0, - RectTxt.Top + (Height - (RectTxt.Bottom - RectTxt.Top)) div 2);
      case Alignment of
        taRightJustify:
          OffsetRect(RectTxt, - RectTxt.Left + (Width - (RectTxt.Right - RectTxt.Left) - BorderWidth -
            0), 0);
        taCenter:
          OffsetRect(RectTxt, -RectTxt.Left + (Width - (RectTxt.Right - RectTxt.Left)) div 2, 0);
      end;
      if not Enabled then
        Font.Color := clGrayText;
      if Transparent then
        SetBkMode(ACanvas.Handle, _Transparent);
      DrawText(ACanvas.Handle, PChar(Caption), -1, RectTxt, Flags);
    end;
  end;
end;


procedure TMyPanel.Paint;
begin
    PutCaption(Canvas);
end;


constructor TMyPanel.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FTransparent := True;
end;

procedure TMyPanel.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  if Transparent  then
  begin
    Params.ExStyle := Params.ExStyle or WS_EX_TRANSPARENT;
    ControlStyle := ControlStyle - [csOpaque];
  end
  else
  begin
    Params.ExStyle := Params.ExStyle and not WS_EX_TRANSPARENT;
    ControlStyle := ControlStyle + [csOpaque];
  end;
end;

procedure TMyPanel.SetTransparent(const Value: Boolean);
begin
  if Value <> FTransparent then
  begin
    FTransparent := Value;
    RecreateWnd;
  end;

end;

procedure Register;
begin
  RegisterComponents('Samples', [TMyPanel]);
end;

end.


Это сообщение отредактировал(а) dimazu - 20.12.2006, 04:47
PM MAIL   Вверх
Deiv
Дата 20.12.2006, 16:21 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 43
Регистрация: 11.2.2006
Где: ЛаПаc-Боливия (Ю жная Америка)

Репутация: нет
Всего: нет



Ваш Компонент, очень хороший,   
Вопрос пожалуйста, я разместил TImage (с собственностью transparent=true) внутри вашего TCustomPanel'a, бегая Программа первый раз (впервые) это показ меня отличный прозрачный над любым объектом, но двигаясь с TButton к другому положение, TCustomPanel не прозрачное, почему?; Почему TCustomPanel когда изменяется положение это не показывается прозрачный выше другие объекты? Что делать так чтобы TCustomPanel показ меня снова прозрачный как первый раз?
Код

procedure TForm1.FormCreate(Sender: TObject);
begin
   CustomPanel11.Left:=25;
   CustomPanel11.Top:=25;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
   CustomPanel11.Left:=150;
   CustomPanel11.Top:=150;
end;

Your Component, very good,   
A question please, I have placed a TImage (with the property transparent=true) inside your TCustomPanel, when running the program for the first time, it show me excellent transparent above any object, but when moving with a TButton to another position, TCustomPanel is not transparent, why?; Why TCustomPanel when it's changed position it is not shown transparent above other objects? What to do, so that TCustomPanel shows me again transparent as the first time?
Код

procedure TForm1.FormCreate(Sender: TObject);
begin
   CustomPanel11.Left:=25;
   CustomPanel11.Top:=25;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
   CustomPanel11.Left:=150;
   CustomPanel11.Top:=150;
end;

PM MAIL YIM   Вверх
dimazu
Дата 20.12.2006, 16:48 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 83
Регистрация: 4.3.2006

Репутация: нет
Всего: 5



I don't know what to tell...
I've tried your code and its working right.
May be you have an old version of
the component (I've made some changes to it).
Actually, my component will create control with name MyPanel1,
not CustomPanel11 !
Try to copy/paste and install it again, it should
solve you problem.  smile 

Это сообщение отредактировал(а) dimazu - 20.12.2006, 19:31
PM MAIL   Вверх
Deiv
  Дата 21.12.2006, 01:19 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 43
Регистрация: 11.2.2006
Где: ЛаПаc-Боливия (Ю жная Америка)

Репутация: нет
Всего: нет



Good,
I will reinstall the component later. I think that the component settles with another name CustomPanel11 because smile of it :
Код

unit CustomPanel1;

interface...............
 
Tomorrow I will say to You if it works or not, please  smile 

PM MAIL YIM   Вверх
Deiv
  Дата 22.12.2006, 01:25 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 43
Регистрация: 11.2.2006
Где: ЛаПаc-Боливия (Ю жная Америка)

Репутация: нет
Всего: нет



You were right, your component now works very well, the reason was that, you wrote its first code with CustomPanel1, then you wrote again with MyPanel. There my error was. 
 
Today I have a new question, TMyPanel draw very well when it's changed position with the TButton (OnClick), but to the event OnMouseDown (I explain to you that, I have added more events to your component) TMyPanel doesn't draw very well neither in time of design, neither in time of execution, Can You to verify moving TMyPanel to another place? (in time of design or execution), when this component drag and drop to another side it captures (it records) the whole area (part-section) of the MyPanel.   
How to solve this problem? Why is this way that?  

Код

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
const 
     SC_DragMove = $F012;
begin
     ReleaseCapture;
     MyPanel1.perform(WM_SysCommand, SC_DragMove, 0);
end;

PM MAIL YIM   Вверх
Deiv
  Дата 3.1.2007, 18:49 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 43
Регистрация: 11.2.2006
Где: ЛаПаc-Боливия (Ю жная Америка)

Репутация: нет
Всего: нет



Привет,  
Cпрaшивал меня если кто-нибудь может улучшить (implement) код этого хорошего компонентa, где Я разместил TImage внутри панели с собственностью transparent=true, и это работает очень хорошо, но двигаясь (чтобы переместить) вовремя конструкторского этого (design time) захватывает всю область TMyPanel, и вовремя выполнения (execution time) когда также подвижный TMyPanel c drag and drop:  
Код

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
  const 
     SC_DragMove = $F012;  
begin
     ReleaseCapture;
     MyPanel1.perform(WM_SysCommand, SC_DragMove, 0);
end;
   
Также захватывать область TMyPanel.  
Как изменить компонент TMyPanel так чтобы это не захватывал ту область двигаясь это?

Hello,  
I asked me if somebody can solve code this good component,  
I have placed a TImage inside the panel with property transparent=true, and it works very well, but when moving (to transfer) in time of design it captures the whole area of the TMyPanel, and in time of execution when also moving TMyPanel drag and drop with:  
Код

 procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
  const 
     SC_DragMove = $F012;  
begin
     ReleaseCapture;
     MyPanel1.perform(WM_SysCommand, SC_DragMove, 0);
end; 
  
also capture the area of TMyPanel.  
How to modify the component TMyPanel so that it doesn't capture that area when moving it?

PM MAIL YIM   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Центр помощи"

ВНИМАНИЕ! Прежде чем создавать темы, или писать сообщения в данный раздел, ознакомьтесь, пожалуйста, с Правилами форума и конкретно этого раздела.
Несоблюдение правил может повлечь за собой самые строгие меры от закрытия/удаления темы до бана пользователя!


  • Название темы должно отражать её суть! (Не следует добавлять туда слова "помогите", "срочно" и т.п.)
  • При создании темы, первым делом в квадратных скобках укажите область, из которой исходит вопрос (язык, дисциплина, диплом). Пример: [C++].
  • В названии темы не нужно указывать происхождение задачи (например "школьная задача", "задача из учебника" и т.п.), не нужно указывать ее сложность ("простая задача", "легкий вопрос" и т.п.). Все это можно писать в тексте самой задачи.
  • Если Вы ошиблись при вводе названия темы, отправьте письмо любому из модераторов раздела (через личные сообщения или report).
  • Для подсветки кода пользуйтесь тегами [code][/code] (выделяйте код и нажимаете на кнопку "Код"). Не забывайте выбирать при этом соответствующий язык.
  • Помните: один топик - один вопрос!
  • В данном разделе запрещено поднимать темы, т.е. при отсутствии ответов на Ваш вопрос добавлять новые ответы к теме, тем самым поднимая тему на верх списка.
  • Если вы хотите, чтобы вашу проблему решили при помощи определенного алгоритма, то не забудьте описать его!
  • Если вопрос решён, то воспользуйтесь ссылкой "Пометить как решённый", которая находится под кнопками создания темы или специальным флажком при ответе.

Более подробно с правилами данного раздела Вы можете ознакомится в этой теме.

Если Вам помогли и атмосфера форума Вам понравилась, то заходите к нам чаще! С уважением, Poseidon, Rodman

 
1 Пользователей читают эту тему (1 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Центр помощи | Следующая тема »


 




[ Время генерации скрипта: 0.0679 ]   [ Использовано запросов: 21 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.