Page 1 of 1
Move the position of a picture in RichViewEdit
Posted: Sun May 07, 2006 8:38 am
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?
Posted: Mon May 08, 2006 4:48 am
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.
Posted: Mon May 08, 2006 7:52 am
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!
Posted: Tue May 09, 2006 1:31 am
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
Posted: Tue May 09, 2006 7:39 am
by kkkdady
Sergey :
Could you give some help?
Thank you very much!
Posted: Tue May 09, 2006 11:52 pm
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!!
Posted: Wed May 10, 2006 3:34 am
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.
Posted: Wed May 10, 2006 5:22 am
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.
Posted: Mon May 15, 2006 2:30 pm
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)
Posted: Tue May 16, 2006 1:17 pm
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;
}
};
Posted: Thu May 18, 2006 5:45 pm
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.
Posted: Fri May 19, 2006 4:07 am
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!
Posted: Sun May 21, 2006 10:44 am
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.
Posted: Mon May 22, 2006 4:37 am
by kkkdady
Thank you very much!