controls position
controls position
hi everybody,
short question:
how can I get the absolute position for a control in a document?
thx
( always tables, I'll never understand it! ;o))) )
short question:
how can I get the absolute position for a control in a document?
thx
( always tables, I'll never understand it! ;o))) )
oh, no anwsers.
maybe I have to concretize it.
Wanna use RV as an report designer.
The problem is while printing controls (tmemo).
Preview looks fine, but not print out.
So I wanna replace the image and draw text
directly to printer canvas.
So I need exactly the position of this control.
maybe know anyone knows, how to realize.
henri
maybe I have to concretize it.
Wanna use RV as an report designer.
The problem is while printing controls (tmemo).
Preview looks fine, but not print out.
So I wanna replace the image and draw text
directly to printer canvas.
So I need exactly the position of this control.
maybe know anyone knows, how to realize.
henri
-
- Posts: 27
- Joined: Tue Jun 20, 2006 7:34 pm
- Location: Europe
hi jacek,
well, your're right. GetItemCoords works.
But not in table.
the way I tried:
When I use getItemCoords in tables I get coords of table.
but how to get position in table? The code above don't work.
But I always have problems with tables. Maybe I not understood
the system with tables ;o))
henri
well, your're right. GetItemCoords works.
But not in table.
the way I tried:
Code: Select all
if(Sender->rv->RVData->GetItemStyle(ItemNo) == rvsTable) {
TRVTableItemInfo *table = (TRVTableItemInfo *) ((TRichViewEdit*) (TRVReportHelper * ) Sender)->RichView)->GetItem(ItemNo);
TRVTableItemInfo *table = (TRVTableItemInfo *) ((TRichViewEdit *) ((TRVReportHelper * ) Sender)->RichView)->GetItem(ItemNo);
table->GetCellWhichOwnsControl(PrintMe, row, col, x);
Cell1 = table->Cells[row][col];
Cell1->GetItemCoords(Cell1->FindControlItemNo(PrintMe), l,t);
}
else {
Sender->rv->RVData->GetItemCoords(ItemNo,l,t);
}
but how to get position in table? The code above don't work.
But I always have problems with tables. Maybe I not understood
the system with tables ;o))
henri
-
- Posts: 27
- Joined: Tue Jun 20, 2006 7:34 pm
- Location: Europe
Hmm. Why don't you simply print TMemo Canvas?
Code: Select all
TCanvas *C = new TCanvas;
C->Handle=GetDC(Memo1->Handle);
//example: show memo in TImage
Image1->Canvas->Handle=C->Handle;
//printing C
ReleaseDC(Memo1->Handle,C->Handle);
C->Free();
the problem is, I'm not really a c++ developer but have to solve this
problem.
this image shows, what happen without replacing memo.
So I tested your code. but no image returns
I also thought about, using other controls as a memo. but no idea.
problem.
this image shows, what happen without replacing memo.
So I tested your code. but no image returns
Code: Select all
void __fastcall TFormDruck::rvhHeaderPrintComponent1(TCustomRVPrint *Sender,
TControl *PrintMe, Graphics::TBitmap *&ComponentImage)
{
TMemo *Memo = (TMemo *) PrintMe;
TCanvas *C = new TCanvas;
C->Handle=GetDC(Memo->Handle);
Graphics::TBitmap *Img = new Graphics::TBitmap;
Img->Canvas->Handle = C->Handle;
//ReleaseDC(Memo->Handle,C->Handle);
//C->Free();
ComponentImage = Img;
}
-
- Posts: 27
- Joined: Tue Jun 20, 2006 7:34 pm
- Location: Europe
Try it.
Greetings, Jacek.
Code: Select all
TCanvas *C = new TCanvas;
C->Handle=GetDC(Memo->Handle);
Graphics::TBitmap *Img = new Graphics::TBitmap;
Img->Handle=CreateCompatibleBitmap(C->Handle, Memo->Width, Memo->Height);
TRect rect = TRect(0,0,Memo->Width,Memo->Height);
Img->Canvas->CopyRect(rect,C,rect);
ReleaseDC(Memo->Handle,C->Handle);
C->Free();
ComponentImage = Img;
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
TPoint ClientCoords = ctrl->ClientToParent(Point(0,0), RichViewEdit1);
TPoint DocCoords = RichViewEdit1->ClientToDocument(ClientCoords);
But it will not help you with printing, because a position on page is not a position on screen.
If you want to customize printing, process RVPrint->OnPrintComponent event. In this event, you create a bitmap with the control image, and RVPrint will print the bitmap at the proper position.
If you want a high quality printing, you can:
- create a lager bitmap in this event, it was scaled down to the proper size on printing, providing higher quality printing output;
or
- create your own TRichView item type for your controls, see Demos\Addins\ChartItem\ for an example.
TPoint DocCoords = RichViewEdit1->ClientToDocument(ClientCoords);
But it will not help you with printing, because a position on page is not a position on screen.
If you want to customize printing, process RVPrint->OnPrintComponent event. In this event, you create a bitmap with the control image, and RVPrint will print the bitmap at the proper position.
If you want a high quality printing, you can:
- create a lager bitmap in this event, it was scaled down to the proper size on printing, providing higher quality printing output;
or
- create your own TRichView item type for your controls, see Demos\Addins\ChartItem\ for an example.