Board index » cppbuilder » Sending a message to a Button

Sending a message to a Button


2003-10-02 11:32:00 PM
cppbuilder76
Hi,
First of all I am sorry to open a new topic although it is relevant with my
previous message.
I asked my previous question about "TLMDEdit problem" to LMD company. The
reply was:
Quote
>But for OnChange event of the LMDEdit1, I could not
change the caret position.<<
Does not work in this way in TLMDEdit within the OnChange event itself.
However workaround is simple: Send a message e.g. to another control
and
set cursor outside from event (as you have done it with button).
But I do not know how to send a message to a button to do something like
this.
Does anybody know this?
Huseyin Candan
 
 

Re:Sending a message to a Button

"Huseyin Candan" < XXXX@XXXXX.COM >wrote in message
Quote
>>But for OnChange event of the LMDEdit1, I could not
change the caret position.<<
Does not work in this way in TLMDEdit within the OnChange
event itself. However workaround is simple: Send a message
e.g. to another control and set cursor outside from event
(as you have done it with button).
I would suggest simply posting a custom message to the form itself
containing the new SelStart value and then let the form handle updating the
LMDEdit. Then you don't need to worry about sending messages to any other
controls at all. For example:
#define APPWM_UPDATE_SELSTART (WM_APP+1)
void __fastcall TForm1::LMDEdit1Change(TObject *Sender)
{
LMDEdit1->Text = "something";
PostMessage(Handle, APPWM_UPDATE_SELSTART, LMDEdit1->GetTextLen(),
0);
}
void __fastcall TForm1::WndProc(TMessage &Message)
{
if( Message.Msg == APPWM_UPDATE_SELSTART )
{
LMDEdit1->SelStart = Message.WParam;
Message.Result = TRUE;
}
else
TForm::WndProc(Message);
}
Gambit
 

Re:Sending a message to a Button

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >, wrote
Quote
I would suggest simply posting a custom message to the form itself
containing the new SelStart value and then let the form handle updating
the
LMDEdit. Then you don't need to worry about sending messages to any other
controls at all. For example:
Thank you for your kind interest. But it did not solve my problem (nothing
changed). I think it is related with TLMDEdit component. The only think I
require was an Edit component with Alignment property. Where can I find one?
Thanks...
Huseyin Candan
 

{smallsort}

Re:Sending a message to a Button

Or, is there any document on web explaining how to create a new component
(for example Edit with alignment property) ? So, I can do it myself and
learn creating my own components?
Thanks...
Huseyin Candan
 

Re:Sending a message to a Button

"Huseyin Candan" < XXXX@XXXXX.COM >wrote in message
Quote
The only think I require was an Edit component with
Alignment property. Where can I find one?
TEdit as it currently stands does not support alignment. You need to either
1) use SetWindowLong() to give it the desired ES_RIGHT/LEFT/CENTER style
manually, 2) use a TMemo, or 3) use a third-party or custom component.
Gambit
 

Re:Sending a message to a Button

"Huseyin Candan" < XXXX@XXXXX.COM >wrote in message
Quote
Or, is there any document on web explaining how to create a
new component (for example Edit with alignment property) ?
This topic has been discussed over and over again through the years. Have a
look through the group archives:
tinyurl.com/pi5k
Gambit
 

Re:Sending a message to a Button

Thank you for your kind interest Remmy.
I found detailed information on page you mentioned. Although I do not want
to disturb you with the questions you faced with thousands of time, I have a
problem with the ES_RIGHT.
I tried following code:
//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
//get the current style flags
LONG dwStyle = GetWindowLong(Edit1->Handle, GWL_STYLE);
//add ES_NUMBER to these
SetWindowLong(Edit1->Handle, GWL_STYLE, dwStyle | ES_NUMBER);
}
//--------------------------------------------------------------------------
-
This works fine (only integer can be written in Edit1). But when I replace
ES_NUMBER with ES_RIGHT the text in Edit is not right-aligned. I saw the
other solutions and I'm going to try them, but what is the reason for
ES_RIGHT not working? My operationg system is Win XP.
Thanks...
Huseyin Candan
 

Re:Sending a message to a Button

"Huseyin Candan" < XXXX@XXXXX.COM >wrote in message
Quote
when I replace ES_NUMBER with ES_RIGHT the text in
Edit is not right-aligned. I saw the other solutions and I'm going
to try them, but what is the reason for ES_RIGHT not working?
My operationg system is Win XP.
XP should support ES_RIGHT for a single-line edit control, MSDN even says as
much:
msdn.microsoft.com/library/en-us/shellcc/platform/commctls/editcontrols/editcontrolreference/editcontrolstyles.asp
ES_RIGHT
Windows 98/Me, Windows 2000/XP: Right aligns text in a single-line or
multiline edit control.
Windows 95, Windows NT 4.0 and earlier: Right aligns text in a multiline
edit control.
Gambit