Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CString to LPARAM SendMessageW

Posted on 2007-11-25
9
Medium Priority
?
3,290 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 2000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

671 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