sendmessage() problem

closed account (zwA4jE8b)
I am simply trying to change the text of an open window, in this case notepad.
The text of notepad gets changed but to chinese characters, not the english characters. I have this working in VB but cannot figure it out in c++. I am using VS2010.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <Windows.h>
#include <string>

using namespace std;

int main()
{
	::HWND notepad = ::FindWindowW(NULL, L"Untitled - Notepad");

	::SendMessage(notepad,WM_SETTEXT,0,(LPARAM)"Message Recieved");

	return 0;
}


Thank you,
Mike

also, what are the valid datatypes to use as LPARAM.
Last edited on
Have you tried:
(LPARAM)L"Message Recieved"
Last edited on
This works for me on XP. This one compiles to 7 K instead of the 457 K yours does....

1
2
3
4
5
6
7
8
9
10
11
12
#include <Windows.h>

int main()
{
 HWND notepad=FindWindow(NULL, "Untitled - Notepad");
 if(notepad)
    SendMessage(notepad,WM_SETTEXT,0,(LPARAM)"Message Recieved");
 else
    MessageBox(0,"notepad ain't krap!","Report",MB_OK);

 return 0;
}

closed account (zwA4jE8b)
thank you guestgulkan, that L was the fix.
closed account (zwA4jE8b)
freddie, with yours I still had to insert the L before the strings but that works too.

Thanks Guys
Topic archived. No new replies allowed.