Quick question!
Hello,
Say I have a break point on the following line of code:
=============================================
static TCHAR szBufferINPUT[10];
for(i=0;i<4;i++)
{
HWND_CW2_extnl_INT_INPUT_CV[i] = CreateWindow( TEXT ("edit"), TEXT("zero"),
WS_CHILD | WS_VISIBLE | WS_BORDER |
ES_LEFT | ES_MULTILINE, extnl_INT_INPUT_MVars[i].ExtnlMVarLeft,
extnl_INT_INPUT_MVars[i].ExtnlMVarTop,
extnl_INT_INPUT_MVars[i].ExtnlMVarRight,
extnl_INT_INPUT_MVars[i].ExtnlMVarBottom,
hwnd,(HMENU)extnl_INT_INPUT_MVars[i].CW2_CV_ID,
((LPCREATESTRUCT) lParam)->hInstance,NULL);
}
===============================================
When the program execution stops at the line above and I view the locals
variables watch, the value of the handle returned from the above statement at
this point is 244842618. Obviously, I only look at the first control for
now... so at, say when i = 0.
So later in my code I click on the first edit control and I have another
break point in the code handling for this control as done so in the following
code:
=================================================
case WM_COMMAND:
if ((LOWORD(wParam) >= extnl_INT_INPUT_MVars[0].CW2_CV_ID) &&
(LOWORD(wParam) <= extnl_INT_INPUT_MVars[3].CW2_CV_ID) )
SendMessage( //***BREAKPOINT HERE***
(HWND) lParam,
EM_GETLINE,
0, (LPARAM) szBufferINPUT );
=================================================
why is it that if I put a break point at SendMessage() line above, the value
of lParam is not 244842618? It is 3212454 instead?
Isn't lParam the child control's handle? Atleast this is what I read! Okay,
okay... I actually read that it was the child Window handle! But isn't that
the same thing?
Why the different handle values?
And the second part of my question is that I am trying to retreive the value
from my edit control.... As you see as I create my edit controls I insert a
default value of "zero" in them!
Why is it that when I run the code above and when I put my cursor over the
szBufferINPUT in the following line of code I get "". Means it is reading
nothing when I expected a "zero" to be read?
SendMessage(
(HWND) lParam,
EM_GETLINE,
0, (LPARAM) szBufferINPUT );
===================================================
[2nd Part of my question]
Also, I have gone through this 6 months ago with some sympathetic news
groups fellows and it still gets the best of me because everytime I see this
I sort of generate a fear of it. But now that it is facing me one more time,
I shall persue more knowledge on it!
***DATA TYPES!***
Okay, lest try this again! If I may politely ask you to be patient, god
knows you all have! :)
***All the edit controls I have created can hold up to 4 characters max!
The help files for the EM_GETLINE message says:
"lParam
Pointer to the buffer that receives a copy of the line. Before sending the
message, set the first word of this buffer to the size, in TCHARs, of the
buffer. For ANSI text, this is the number of bytes; for Unicode text, this is
the number of characters. The size in the first word is overwritten by the
copied line."
But when we look at the prototype of this function it says that lParam
should take a
(LPARAM) or a (LPCTSTR) type right?
But LPCTSTR has been defined as so in the WINNT.H of the Windows files:
===============================================
typedef CONST WCHAR * LPCWCH, * PCWCH, * LPCWSTR, * PCWSTR
and then:
#ifdef UNICODE
.....other type def's...
typedef LPCWSTR LPCTSTR
===============================================
So if I declare my string buffer in TCHARs as stipulated above!
static TCHAR szBufferINPUT[10]; //Space for 10 characters!
then how does the prototype parameter accept a TCHAR when it should accept a
LPCTSTR? Because as typedefed above, if LPCTSTR is defined as a LPCWSTR type
and further LPCWSTR is defined as a CONST WCHAR type so then, how is does
the CONST WCHAR type defined as a TCHAR type, which is what we need right?
Could this have something to do why I read "" instead of "zero" in the 1st
part of my question?
Sorry for the lenghty post!
All help appreciated.....
P.S. Sorry for the numerous postings, this month its like almost every line
I try, turns up to be a many hours snag!
--
Best regards
Roberto