Solved

CString to LPARAM SendMessageW

Posted on 2007-11-25
9
3,234 Views
Last Modified: 2013-12-03
Hi,

I have a class where a String is CString value. No I want to send this Cstring to a contraol with a SendMessageW function. I think I have to use a (LPARAM)mystring. But this will cause a compile error cause CString cannot convert to LPARAM. Any idea how to solve?

Ingo
0
Comment
Question by:Ocrana
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 20347051
The easiest way probably is

CString str;
LPCTSTR pstr = (LPCTSTR) str;
LPARAM lparam = (LPARAM) pstr;
0
 
LVL 86

Expert Comment

by:jkr
ID: 20347056
Or, in short:

CString str;

SendMessage(hwnd,WM_SOMETHING,0,(LPARAM)((LPCTSTR)str));

or


pWnd->SendMessage(WM_SOMETHING,0,(LPARAM)((LPCTSTR)str));
0
 

Author Comment

by:Ocrana
ID: 20347086
Hi,
 also in Unicode code?
0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
LVL 86

Expert Comment

by:jkr
ID: 20347109
Yes, that should work for both UNICODE and ANSI.
0
 

Author Comment

by:Ocrana
ID: 20347166
sorry, I get allways a compile error that the types cannot converted C2440
0
 
LVL 86

Expert Comment

by:jkr
ID: 20347180
What is the exact error and on which line do you get it when using

LPCTSTR pstr = (LPCTSTR) str;
LPARAM lparam = (LPARAM) pstr;

?
0
 

Author Comment

by:Ocrana
ID: 20347299
I get in the line:

LPCTSTR pstr = (LPCTSTR) initializePath;

the C2440 Error.
0
 
LVL 86

Expert Comment

by:jkr
ID: 20347321
That is pretty odd. What is the *exact* error message?
0
 

Author Comment

by:Ocrana
ID: 20347357
ups, sorry, the problem was the function itself. I had to set the (LPARAM)((LPCTSTR)str) in a function that calls the function that try to trhow the SendMessage. Cause the Function that send was a callback without access to the str.
I set the LPARAM in the function that set the callback and everything works fine. Many thanks.
0

Featured Post

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question