I've solved the problem. The following code gives me what I want.
#include <QWidget>
#include <windows.h>
HWND hChild;
PTSTR pTitle;
char cTitle[8];
hChild = GetForegroundWindow();
pTitle = (PTSTR) malloc ( 8 * sizeof (TCHAR)) ;
GetWindowText( hChild, pTitle, 8);
for( int i=0; i<7; i++)
{
cTitle[i] = static_cast<char>( *(pTitle + i));
str.append( cTitle[i]);
}
labelTitle->setText( str);
#include <QWidget>
#include <windows.h>
HWND hChild;
PTSTR pTitle;
QString str;
char cTitle[8];
hChild = GetForegroundWindow();
pTitle = (PTSTR) malloc ( 8 * sizeof (TCHAR)) ;
GetWindowText( hChild, pTitle, 8);
for( int i=0; i<7; i++)
{
cTitle[i] = static_cast<char>( *(pTitle + i));
str.append( cTitle[i]);
}
labelTitle->setText( str);
To copy to clipboard, switch view to plain text mode
Not sure how universal such an approach is, but my target platform is specific, so not a problem.
Bookmarks