Solved

covert HWND to string.

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

string1 = tostring( hwnd hwnd)


0
Comment
Question by:Troudeloup
6 Comments
 
LVL 30

Assisted Solution

by:Axter
Axter earned 170 total points
Comment Utility
Convert it to a number string.
0
 
LVL 22

Assisted Solution

by:grg99
grg99 earned 100 total points
Comment Utility
A window handle is just an integer, so use sprintf or itoa or equivalent.

0
 
LVL 30

Assisted Solution

by:Axter
Axter earned 170 total points
Comment Utility
char buf[99] = "";

sprintf(buf, "%p", hwnd);
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 30

Assisted Solution

by:Axter
Axter earned 170 total points
Comment Utility
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 50 total points
Comment Utility
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 180 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now