.
Summary
I started trying to figure out how to use SB_GETTEXT many years ago when I was still new to C#. pInvoke in particular was always pretty confusing to me back then because of all the different C++ types. When does it matter whether I use int, uint,
IntPtr , etc when they all seem to work?! Well I know now but that's another story... I was looking through my code archive and noticed my unfinished SB_GETTEXT code so I took another look and decided that it wasn't so confusing anymore (5 years later). I was never able to find good C# examples of SB_GETTEXT so I thought I'd share mine. Have fun!
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 4:00:13 AM - Damon Carr-72.43.165.29
.
(UINT) SB_GETTEXT, // message ID
.
private const uint SB_GETTEXTLENGTH = WM_USER + 12;
.
private const uint SB_GETTEXT = WM_USER + 13;
.
uint length = (uint)SendMessage(this._handle, SB_GETTEXTLENGTH, index, 0);
.
// SB_GETTEXT tells the remote process to write out text to the remote memory we allocated.
.
StatusBar.SendMessage(this._handle, SB_GETTEXT, (IntPtr)index, allocated);
.
Documentation
[SB_GETTEXT] on MSDN