Conversion of LPWSTR TO long

Jun 10, 2011 at 12:29pm
During my session i have some doubt on the below code

len1 = GetWindowTextLength(hwndEdit1) + 1;
GetWindowText(temp1, text1, len);
len2=GetWindowTextLength(hwndEdit2)+1;
GetWindowText(temp2, text1, len);


The two variables temp2 and temp1 are LPWSTR so calculate the sum of two variables i need to convert them into long can you help me convert it,
Last edited on Jun 10, 2011 at 12:42pm
Jun 10, 2011 at 1:21pm
Last edited on Jun 10, 2011 at 1:21pm
Jun 10, 2011 at 1:35pm
Before Disch gets in, I may as well say it: GetWindowText doesn't necessarily accept wide strings. It might accept normal strings if your compiler settings are different.

There are two functions
GetWindowTextA <- asci: accepts ASCII LPSTR
GetWindowTextW <- unicode accepts Wide LPWSTR

GetWindowText becomes GetWindowTextW if wide characters are enabled, and GetWindowTextA otherwise.

Instead, you should use TCHAR and LPTSTR. It automatically takes on the form of wide or non wide as appropriate. Then the function to use is _ttol().
Last edited on Jun 10, 2011 at 2:08pm
Jun 11, 2011 at 3:15am
Jun 11, 2011 at 7:20am
I wanted to link to that, but couldn't find it...
Jun 11, 2011 at 5:28pm
closed account (zwA4jE8b)
also I noticed that you define 'len1' and 'len2' but in your GetWindowText parameters you just use 'len'
is that supposed to be?
Jun 13, 2011 at 10:16am
Thank you all for your kind support I am a beginner so I am not using standard coding format so len1, len2, are two names given to a variable. Do you need the full code to solve the problem?
if it is essential i will provide it here for you.
Last edited on Jun 13, 2011 at 10:17am
Topic archived. No new replies allowed.