Move the position of a picture in RichViewEdit

General TRichView support forum. Please post your questions here
Post Reply
kkkdady
Posts: 11
Joined: Thu May 04, 2006 2:39 pm

Move the position of a picture in RichViewEdit

Post by kkkdady »

I want to move the position of a picture in RichViewEdit . When the picture is moved,it is above the words in RichViewEdit and the position of words do not change?
shmp
Posts: 140
Joined: Sun Aug 28, 2005 10:19 am
Location: Sabah, Malaysia.
Contact:

Post by shmp »

I don't quite understand your question.

If you mean vertical align, create a button or key function to adjust the picture alignment to base, centered or upper.

If you want to move a picture from on location to another, make a function when rve is clicked and if the item is a picture, create a function to copy that image then delete it. On key up function paste the copied image. This is rather a tricky bit. I cannot give you every detail because it is quite a complex procedure.

I have no idea of any link to an example regarding changing location of pictures.

Hope you have the idea.
kkkdady
Posts: 11
Joined: Thu May 04, 2006 2:39 pm

Post by kkkdady »

Thank you very much!

http://www.trichview.com/forums/viewtop ... op+picture

It gives a example in Delphi,but I only Known C++.So I have difficulties to change it to c++.Could you give me some help! Thank you!
shmp
Posts: 140
Joined: Sun Aug 28, 2005 10:19 am
Location: Sabah, Malaysia.
Contact:

Post by shmp »

I only spent a little time with C++ and therefore I am not good at it. Maybe others can help. I know Sergey is OK with the language. Anyway thanks for the link. I will have a look at it.

Henry
kkkdady
Posts: 11
Joined: Thu May 04, 2006 2:39 pm

Post by kkkdady »

Sergey :
Could you give some help?
Thank you very much!
shmp
Posts: 140
Joined: Sun Aug 28, 2005 10:19 am
Location: Sabah, Malaysia.
Contact:

Post by shmp »

Here is another clue.

I have seen the drag demo. Since the mouse move is using TObject, any items, even a cluster of them, can indeed be moved, including pictures. I have modified it a bit and tested it and the draging of most items worked without a glitch.

Hoorah!!
shmp
Posts: 140
Joined: Sun Aug 28, 2005 10:19 am
Location: Sabah, Malaysia.
Contact:

Post by shmp »

I am so absent minded that I sounded foolish.

The drag and drop have already implemented. Otherwise you have different version of rve, you do not actually need to translate the drag demo. All you have to do is focus on the picture then drag it. The drag demo automatically select the button upon clicking on it. That is all it does.

I guess the automatic selection can also be done for images.
kkkdady
Posts: 11
Joined: Thu May 04, 2006 2:39 pm

Post by kkkdady »

shmp:
Thank you very much!
I want to move the picture,and the position of the words do not change,and the picture can cover on the words.But in the rve ,when moving the picture ,the position of the words changed.

In the example above,I have some difficulties :

TButton(ctrl).OnMouseDown := ControlMouseDown;
TButton(ctrl).OnMouseMove := ControlMouseMove;
TButton(ctrl).OnClick := ButtonClick;

I do not known how to change them into c++Builder.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

In TRichView, picture cannot be placed above the text. Picture is treated like a text character.

The demo you quoted simply allows to work with controls like with pictures (enables resizing and drag&drop for them)
kkkdady
Posts: 11
Joined: Thu May 04, 2006 2:39 pm

Post by kkkdady »

Thank you very much!
Now,I think I can put a TImage on the TPanel over the rve,so I want change TPanel into transparent . But I do not know how to do. I have some codes ,when compile them,there are some errors.Could you give me some help! Thank you!

class TTransPanel :public TPanel
{
void __fastcall CreateParams(Controls::TCreateParams &Params)
{
TPanel::CreateParams(Params);
Params.ExStyle += WS_EX_TRANSPARENT;
}
void __fastcall AdjustColors(TPanelBevel Bevel,TColor& TopColor,TColor& BottomColor)
{
TopColor = clBtnHighlight;
if (Bevel == bvLowered) TopColor = clBtnShadow;
BottomColor = clBtnShadow;
if (Bevel == bvLowered) BottomColor = clBtnHighlight;
}
void __fastcall Paint()
{
DynamicArray<int> Alignments;
Alignments.set_length(3);
Alignments[taLeftJustify] = DT_LEFT;
Alignments[taCenter] = DT_CENTER;
Alignments[taRightJustify] = DT_RIGHT;
TRect Rect;
TColor TopColor, BottomColor;
int FontHeight;
Longint Flags;
Rect = GetClientRect();
if (BevelOuter != bvNone)
{
AdjustColors(BevelOuter,TopColor, BottomColor);
Frame3D(Canvas, Rect, TopColor, BottomColor, BevelWidth);
}
Frame3D(Canvas, Rect, Color, Color, BorderWidth);
if (BevelInner != bvNone)
{
AdjustColors(BevelInner,TopColor, BottomColor);
Frame3D(Canvas, Rect, TopColor, BottomColor, BevelWidth);
}
Canvas->Brush->Color = Color;
// Canvas->FillRect(Rect);
Canvas->Brush->Style = bsClear;
Canvas->Font = this->Font;
FontHeight = Canvas->TextHeight('W');

Rect.Top = ((Rect.Bottom + Rect.Top) - FontHeight) / 2;
Rect.Bottom = Rect.Top + FontHeight;
Flags = DT_EXPANDTABS | DT_VCENTER | Alignments[Alignment];
Flags = DrawTextBiDiModeFlags(Flags);
DrawText(Canvas->Handle, Caption.c_str(), -1, &Rect, Flags);
}
public:
__fastcall virtual TTransPanel(TComponent* AOwner):TPanel(AOwner)
{
ControlStyle >> csOpaque;
Width = 185;
Height = 41;
}
};
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, placing TPanel over TRichView must do the work.
Not sure if it can be transparent, though.
Alternative solution: to draw image in OnPaint event of TRichView.
kkkdady
Posts: 11
Joined: Thu May 04, 2006 2:39 pm

Post by kkkdady »

Sergey :
Thank you very much!
but I do not know whether the Picture in the transparentPanel could be Printed or to be saved together with the words in rve? Because the picture and the words are not in the same layer!
Thank you!
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

For printing, use OnPagePostPaint event for drawing these pictures.
In this event use RV_PictureToDevice procedure (from the unit RVFuncs) to draw images.

procedure RV_PictureToDevice(Canvas: TCanvas; x,y, width, height: Integer; sad:TRVScreenAndDevice; gr: TGraphic; ToScreen: Boolean);

Though gr is TGraphic, it must be TBitmap.
Width and Height parameters may be zero, in this case the image is printed at its original size.
kkkdady
Posts: 11
Joined: Thu May 04, 2006 2:39 pm

Post by kkkdady »

Thank you very much!
Post Reply