Board index » cppbuilder » How to scale TRichEdit->FontSize with the key: 'Control' + MOUSEWHEEL up/down..

How to scale TRichEdit->FontSize with the key: 'Control' + MOUSEWHEEL up/down..


2004-05-04 05:51:39 AM
cppbuilder47
hi dear builders,
i have a tricky question about scaling fontsize in a TRichEdit, i want
to scale up the fontsize when the key: 'control' and the mousewheel (up)
are pressed together or scale down if 'control' + mousewheel rotates down..
how is this possible ?
and how can i increment the fontsize of the TRichEdit ?
i think this will not work fine: TRichEdit->Font->Size++ ??
to check if a mousewheel is present i use this:
/*************************************************/
void __fastcall TfrmMainUnit::Button1Click(TObject *Sender)
{
bool Result = GetSystemMetrics(SM_MOUSEWHEELPRESENT);
if(Result) ShowMessage("Mouse has wheel);
else ShowMessage("Mouse has no wheel");
}
/*************************************************/
can someone give me some hints about the problem...?
Oren
 
 

Re:How to scale TRichEdit->FontSize with the key: 'Control' + MOUSEWHEEL up/down..

"Oren Halvani" < XXXX@XXXXX.COM >wrote in message
Quote
i want to scale up the fontsize when the key: 'control' and
the mousewheel (up) are pressed together
RichEdit1->Font->Size = RichEdit1->Font->Size + 1;
Quote
or scale down if 'control' + mousewheel rotates down..
RichEdit1->Font->Size = RichEdit1->Font->Size - 1;
Quote
to check if a mousewheel is present i use this:
Why not just put your code into the RichEdit's inherited OnMouseWheelUp/Down
events instead? If a mouse wheel is present, the code will be triggered
when scrolled, otherwise the code won't be triggered at all.
void __fastcall TForm1::RichEdit1MouseWheelUp(TObject* Sender,
TShiftState Shift, const TPoint &MousePos, bool &Handled)
{
if( Shift.Contains(ssCtrl) )
{
Handled = true;
int OldStart = RichEdit->SelStart;
int OldLength = RichEdit->SelLength;
RichEdit1->Lines->BeginUpdate();
try
{
RichEdit1->SelectAll();
RichEdit1->SelAttributes->Size =
RichEdit1->SelAttributes->Size + 1;
}
__finally
{
RichEdit->SelStart = OldStart;
RichEdit->SelLength = OldLength;
RichEdit1->Lines->EndUpdate();
}
}
else
Handled = false;
}
void __fastcall TForm1::RichEdit1MouseWheelDown(TObject* Sender,
TShiftState Shift, const TPoint &MousePos, bool &Handled)
{
if( Shift.Contains(ssCtrl) )
{
Handled = true;
int OldStart = RichEdit->SelStart;
int OldLength = RichEdit->SelLength;
RichEdit1->Lines->BeginUpdate();
try
{
RichEdit1->SelectAll();
RichEdit1->SelAttributes->Size =
RichEdit1->SelAttributes->Size - 1;
}
__finally
{
RichEdit->SelStart = OldStart;
RichEdit->SelLength = OldLength;
RichEdit1->Lines->EndUpdate();
}
}
else
Handled = false;
}
Gambit
 

Re:How to scale TRichEdit->FontSize with the key: 'Control' + MOUSEWHEEL up/down..

Sorry for appearing stupid, but doesn't something like this happen automatically under Windows XP? It
certainly does on my machine, and I've done no code to support this. All of my BCB apps with RichEdits on
them, scale the font up and down with the mousewheel and the left mouse button.
Try this Oren :-
Under XP, run one of your RichEdit apps, and load up some text. Then, holding down the left mousebutton
somewhere inside the RichEdit control, roll the mousewheel up and down. Hey presto! When I first discovered
this, I thought my app had gone wrong with fonts! HTH,
--
Mark Jacobs
DK Computing
www.dkcomputing.co.uk
XXXX@XXXXX.COM
"Oren Halvani" < XXXX@XXXXX.COM >wrote in message news:4096bed6$ XXXX@XXXXX.COM ...
Quote
hi dear builders,

i have a tricky question about scaling fontsize in a TRichEdit, i want
to scale up the fontsize when the key: 'control' and the mousewheel (up)
are pressed together or scale down if 'control' + mousewheel rotates down..

how is this possible ?
and how can i increment the fontsize of the TRichEdit ?

i think this will not work fine: TRichEdit->Font->Size++ ??

to check if a mousewheel is present i use this:

/*************************************************/
void __fastcall TfrmMainUnit::Button1Click(TObject *Sender)
{
bool Result = GetSystemMetrics(SM_MOUSEWHEELPRESENT);

if(Result) ShowMessage("Mouse has wheel);
else ShowMessage("Mouse has no wheel");
}
/*************************************************/

can someone give me some hints about the problem...?


Oren


 

{smallsort}

Re:How to scale TRichEdit->FontSize with the key: 'Control' + MOUSEWHEEL up/down..

Remy, the Event:
void __fastcall TForm1::RichEdit1MouseWheelUp
is not implemented under BCB 3...is there another possibility...?
Oren
 

Re:How to scale TRichEdit->FontSize with the key: 'Control' + MOUSEWHEEL up/down..

Mark, i know this trick under WinXP..
but this will not work for any Windows Version below XP...
thats hy i wanted to implement it...
Oren
 

Re:How to scale TRichEdit->FontSize with the key: 'Control' + MOUSEWHEEL up/down..

"Oren Halvani" < XXXX@XXXXX.COM >wrote in message
Quote
Remy, the Event:

void __fastcall TForm1::RichEdit1MouseWheelUp

is not implemented under BCB 3...
From now on, you need to tell people that you are still using BCB3. ALWAYS
ALWAYS ALWAYS provide details about the version of BCB you are actually
using.
Quote
is there another possibility...?
You will have to intercept the WM_MOUSEWHEEL message directly.
Gambit
 

Re:How to scale TRichEdit->FontSize with the key: 'Control' + MOUSEWHEEL up/down..

So, you are targeting some very old pcs with BCB3. No wonder you have so many requests at re-inventing the
wheel.
--
Mark Jacobs
DK Computing
www.dkcomputing.co.uk
XXXX@XXXXX.COM
"Oren Halvani" < XXXX@XXXXX.COM >wrote in message news: XXXX@XXXXX.COM ...
Quote
Mark, i know this trick under WinXP..
but this will not work for any Windows Version below XP...
thats hy i wanted to implement it...