SendMessage() w & lparams, string stuff

HWND hWnd = cwindow1.GetSafeHwnd();
::SendMessage(hWnd, WM_KEYDOWN, wParam, lParam);

What do my W and Lparams need to be to achieve the equivalent of a CTRL+L keystroke?

Also, in FindWindow:

The window caption is ever-changing, but the first part of it is always the same.

FindWindow("className", "Application");

Application is always the start of the window handle. I want to be able to retrieve a CWnd pointer to that call to FindWindow regardless of what follows Application.

What should I do?

Thank you!
Who is Participating?
akalmaniConnect With a Mentor Commented:
Hope this helps u ?
   wParam = VK_CONTROL
   lParam = 38 which is a decimal value.
Regarding the findwindow i am not clear about the question could u elaborate more on this ?
SuperMarioAuthor Commented:
"Application" is ALWAYS present in the window's caption - it's always right before something else, like

Application - Document 1
Application - Opening File

I need to be able to find the window (meaning that that FindWindow call does not return NULL) even if the word Application has something trailing it. So, basically I need to have some variable in there but I am totally clueless how to go about that.

Thanks in advance,
Maybe you could cycle through them:

here is code which returns the HWND of the window:

HWND hwnd = NULL;
char sWinName[100] = "";

hwnd = ::FindWindowEx(NULL, NULL, "className", NULL);
while (hwnd)
    ::GetWindowText(hwnd, sWinName, 100);
    if (strncmp(sWinName, "Application", 11) == 0)
        return hwnd;
    hwnd = ::FindWindowEx(NULL, hwnd, "className", NULL);

return NULL;

//untested and no guarantees, may require fiddling.

good luck
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

SuperMarioAuthor Commented:
Well what I am really looking for is a wildcard character for use in a string.

Any ideas?

SuperMarioAuthor Commented:
Oh, hey... an asterisk works. How about that.

Akalmani, you're the one who gave me the answer to the first question - that's what I need =)

Please answer.


SuperMarioAuthor Commented:
Nevermind... An asterisk DOESN'T WORK!


I really need to find a wildcard character I can append to the end of a string to denote that it's a wildcard.

My feeling is that there is no such wildcard character, or function which accepts a wildcard character unless you write one.

The closest thing is setting lpWindowName = NULL which will match all window names.

I hope you find what you're looking for.
Use EnumWindows to enumerate all the top-level windows and use GetWindowText to retrieve the window titles and then match them.
SuperMarioAuthor Commented:
Okay... Perhaps I need to rephrase this entirely.

I don't really need to use EnumWindows. I used FindWindowEx() to locate the child window I'm looking for. It's of a class called "Edit" with which I am not familiar. I know it is an edit control, and I need to grasp the Edit control from it.

The wildcard character I took care of a while ago by setting the window name to NULL (because it says in MSDN that it matches all window names with that window class).

Dunno how to use GetEditCtrl() in this context...

That's where I'm using GetWindowText - in an edit window. Right now I have it as a CWnd * .

Thanks in advance... Sorry this is so confusing.

SuperMarioAuthor Commented:
Thank you, Akalmani.

That is all I needed from this question.

The other I am going to post again under a different title because it's currently unfair to the other users.

All Courses

From novice to tech pro — start learning today.