Board index » cppbuilder » How to draw onto standard controls like TMemo?
Jim Stee
![]() CBuilder Developer |
Mon, 23 Feb 2004 21:04:25 GMT
|
Jim Stee
![]() CBuilder Developer |
Mon, 23 Feb 2004 21:04:25 GMT
How to draw onto standard controls like TMemo?
Is there a way to draw onto some standard control like the TMemo?
For example if I'd like to create a custom control derived from TMemo and would like to draw a custom border? What would I do? I would disable the default TMemo border and draw an alternate one. But how do I draw onto the control? Thanks in advance, |
Remy Lebea
![]() CBuilder Developer |
Tue, 24 Feb 2004 00:33:12 GMT
Re:How to draw onto standard controls like TMemo?Use a MESSAGE_MAP to intercept WM_PAINT messages, and associate a TControlCanvas to the TMemo for the actual painting. Gambit Quote"Jim Steele" <j...@codeland.org> wrote in message Quote> Is there a way to draw onto some standard control like the TMemo? |
Jim Stee
![]() CBuilder Developer |
Tue, 24 Feb 2004 04:37:18 GMT
Re:How to draw onto standard controls like TMemo?Hi Remy, thanks for your quick answer. First off sorry for posting this There is still another small problem I have. I now assigned a This results in heavy flickering and in high system load. The flickering is surely a result of the default WM_PAINT Thanks in advance, Quote> "Remy Lebeau" wrote: |
Remy Lebea
![]() CBuilder Developer |
Tue, 24 Feb 2004 04:57:18 GMT
Re:How to draw onto standard controls like TMemo?Quote"Jim Steele" <j...@codeland.org> wrote in message Quote> thanks for your quick answer. First off sorry for posting this Quote> The flickering is surely a result of the default WM_PAINT Gambit |
Jim Stee
![]() CBuilder Developer |
Tue, 24 Feb 2004 05:23:10 GMT
Re:How to draw onto standard controls like TMemo?"Remy Lebeau" <gambi...@gte.net> wrote in <3b97e4fe$1_1@dnews>: Quote
In header file: class PACKAGE TMyMemo : public TMemo public: ... Quote}; // ctor // somehow this does not work // create control canvas Quote} __fastcall TMyMemo::~TMyMemo() { if (FCanvas != NULL) delete FCanvas; Quote} void __fastcall TMyMemo::WndProc(Messages::TMessage &Message) { switch (Message.Msg) { case WM_PAINT: if (FCanvas) { FCanvas->Pen->Color = clBlack; FCanvas->Rectangle(10,10,100,100); } break; default: Quote} Thanks, |
Bren
![]() CBuilder Developer |
Tue, 24 Feb 2004 06:24:36 GMT
Re:How to draw onto standard controls like TMemo?Hi Jim, I think I know what your intentions might be. To draw a background image or Problem you are experiencing at design time is related to this I believe, Hope that helps, Brent The fact that I |
Jim Stee
![]() CBuilder Developer |
Tue, 24 Feb 2004 07:18:07 GMT
Re:How to draw onto standard controls like TMemo?"Brent" <b.kni...@NOSPAM.mcauley.acu.edu.au> wrote in <3b97f7a8_2@dnews>: Hi Brent, thanks for the hint. It really helped. The disadvantage is Quote> Everytime it blinked, it would cause a redraw. But whenever I enter some text in the memo it disturbs the rect that I have drawn. Same with bitmaps, etc. - I tried to Invalid ate() the control every time the user changes it, presses a key, and/or uses the mouse to do something. That worked, but it is surely _not_ a nice solution. Something else: I've seen code for a transparent memo. What do you Thanks, |
Remy Lebea
![]() CBuilder Developer |
Tue, 24 Feb 2004 07:50:06 GMT
Re:How to draw onto standard controls like TMemo?First thing you're missing is that you have to return 0 to let Windows know that you processed the WM_PAINT message, otherwise it'll end up going to the default handler and being processed a second time. That might be why it's flickering. Second, now that I experiment with your code, I see WM_PAINT is not a good I see you mentioned you have code for a transparent Memo. Your idea for Gambit Quote"Jim Steele" <j...@codeland.org> wrote in message Quote> Here's some code: |
Jim Stee
![]() CBuilder Developer |
Tue, 24 Feb 2004 08:17:01 GMT
Re:How to draw onto standard controls like TMemo?Quote>First thing you're missing is that you have to return 0 Quote>drawn starting at (0, 0), and it's drawn with a solid recreated with new window params. Quote>I see you mentioned you have code for a transparent Memo. I'm able to port it ;-) If you're interested here is the URL to the code I mentioned: http://www.efg2.com/Lab/Library/UseNet/2000/1129a.txt Thanks, |
Jim Stee
![]() CBuilder Developer |
Tue, 24 Feb 2004 09:44:15 GMT
Re:How to draw onto standard controls like TMemo?Quote
However I tried to change my component a bit and base it on FMemo = new TMemo(this); // 'this' = TCustomPanel Referring to the TMemo in a TCustomPanel container: My questions might sound extremely stupid, but though I hope Thanks, |
Bren
![]() CBuilder Developer |
Tue, 24 Feb 2004 10:18:36 GMT
Re:How to draw onto standard controls like TMemo?Hi Jim, The Transparent Memo sounds really cool. Do you still have or know where Using transparent controls certainly sounds better than what I tried to do Cheers, Brent |
Bren
![]() CBuilder Developer |
Tue, 24 Feb 2004 10:15:37 GMT
Re:How to draw onto standard controls like TMemo?Hi Jim, The Parent is where the component is going to be placed. Without a parent, FMemo = new TMemo(this); // 'this' = TCustomPanel signifies that this (TCustomPanel) owns the Memo control. It will be HTH, Brent |
Jim Stee
![]() CBuilder Developer |
Tue, 24 Feb 2004 11:07:36 GMT
Re:How to draw onto standard controls like TMemo?"Brent" <b.kni...@NOSPAM.mcauley.acu.edu.au> wrote in <3b982dcd_1@dnews>: Quote>The Parent is where the component is going to be placed. Without a when I properly write: FMemo = new TMemo(this); // 'this' = TCustomPanel Quote>signifies that this (TCustomPanel) owns the Memo control. Thanks, |
Jim Stee
![]() CBuilder Developer |
Tue, 24 Feb 2004 11:19:36 GMT
Re:How to draw onto standard controls like TMemo?"Brent" <b.kni...@NOSPAM.mcauley.acu.edu.au> wrote in <3b982dcd_1@dnews>: Oh, sorry. I think I misunderstood. Okay, I set the Jim. |
Remy Lebea
![]() CBuilder Developer |
Tue, 24 Feb 2004 11:52:04 GMT
Re:How to draw onto standard controls like TMemo?Because you *forgot* to set the Parent, that's what Brent was trying to tell you FMemo->Parent = this; Gambit Quote"Jim Steele" <j...@codeland.org> wrote in message Quote> Yes, i know. But why do I get this error message |
1. I need to draw onto all the controls of a form
2. I need to draw onto all the controls of a form
3. Getting list of controls liked to TDataSource
4. Problem on saving TMemo onto paradox table
5. ANN: AfalinaSoft Flat Controls 1.52 - MS Office style for all standard VCL controls
6. Drawing onto canvas of QuickReport
9. XORing a line onto a drawing
10. off-screen drawing and BitBlt onto drawgrid.canvas problem