Board index » delphi » Different ways of setting text..

Different ways of setting text..

whats the difference?

1) SendMessage(SomehWnd, WM_SETTEXT, 255, LongInt(PChar(Src)));
2) SendMessage(SomehWnd, WM_SETTEXT, 0, integer(@Src[1]));

Thanks

 

Re:Different ways of setting text..


Take a look at the windows API help

LRESULT SendMessage(
    HWND hWnd, // handle of destination window
    UINT Msg, // message to send
    WPARAM wParam, // first message parameter
    LPARAM lParam  // second message parameter
   );

hWnd - Identifies the window whose window procedure will receive the
message. If this parameter is HWND_BROADCAST, the message is sent to all
top-level windows in the system, including disabled or invisible unowned
windows, overlapped windows, and pop-up windows; but the message is not sent
to child windows.

Msg- Specifies the message to be sent.

wParam - Specifies additional message-specific information.

lParam -Specifies additional message-specific information.

Quote
"Some User" <webvolution...@nospam.cox.net> wrote in message

news:pofZ8.91277$%%2.3906535@news2.east.cox.net...
Quote
> whats the difference?

> 1) SendMessage(SomehWnd, WM_SETTEXT, 255, LongInt(PChar(Src)));
> 2) SendMessage(SomehWnd, WM_SETTEXT, 0, integer(@Src[1]));

> Thanks

Re:Different ways of setting text..


In article <pofZ8.91277$%%2.3906...@news2.east.cox.net>, "Some User"

Quote
<webvolution...@nospam.cox.net> writes:
>1) SendMessage(SomehWnd, WM_SETTEXT, 255, LongInt(PChar(Src)));
>2) SendMessage(SomehWnd, WM_SETTEXT, 0, integer(@Src[1]));

They're the same.

The third parameter of SendMessage for (or wParam of) a WM_SETTEXT message is
said to be ignored and should not be used. The  fourth parameter (or lParam of
the message) is a pointer to a null-terminated string of the text. If Src is a
long string then the above are the same because long strings always have a zero
byte appended to them.. Type-casting a long string to a PChar changes the
reference to the string to be the address of (ie pointer to) the first
character of the string - ie @Src[1]. For 32-bit computers a LongInt and an
integer are the same, taking four bytes.

Alan Lloyd
alangll...@aol.com

Other Threads