Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

covert HWND to string.

Posted on 2007-11-28
6
Medium Priority
?
2,847 Views
Last Modified: 2012-06-27
I am looking for.

string1 = tostring( hwnd hwnd)


0
Comment
Question by:Troudeloup
[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
6 Comments
 
LVL 30

Assisted Solution

by:Axter
Axter earned 680 total points
ID: 20370221
Convert it to a number string.
0
 
LVL 22

Assisted Solution

by:grg99
grg99 earned 400 total points
ID: 20370223
A window handle is just an integer, so use sprintf or itoa or equivalent.

0
 
LVL 30

Assisted Solution

by:Axter
Axter earned 680 total points
ID: 20370227
char buf[99] = "";

sprintf(buf, "%p", hwnd);
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Assisted Solution

by:Axter
Axter earned 680 total points
ID: 20370232
FYI:
I recommend using sprintf over itoa, because it supports %p, which is the type that should be used for pointers.
0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 200 total points
ID: 20370264
in case of handlers, I suggest to use hex values, them are easier to read and compare:

char buf[9];
sprintf(buf, "%08X", hwnd);
0
 
LVL 4

Accepted Solution

by:
Ichijo earned 720 total points
ID: 20370279
Perhaps you want to get the text or title of the window:
#include <string>
 
using namespace std;
 
void HwndToString(HWND hWnd, wstring& sText)
{
    int nLength = GetWindowTextLength( hWnd );
    sText.reserve( nLength );
    GetWindowText( hWnd, &sText[0], nLength + 1 );
}

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.
Suggested Courses

610 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