GTBuilder
25th March 2008, 11:57
My application requires me to obtain the first 7 characters from a window title strip. I've tried the following:
#include <QWidget>
#include <windows.h>
HWND hChild;
PTSTR pTitle;
QString szTitle;
hChild = GetForegroundWindow();
pTitle = (PTSTR) malloc ( 8 * sizeof (QChar)) ;
int iFlag = GetWindowText( hChild, pTitle, 8);
szTitle = *pTitle;
labelTitle->setText( szTitle);
While szTitle is a buffer of TCHAR, QString is unicode so I set the datatype to QString in line 6.
The above compiles, but line 12 returns 1 and line 15 only prints the first character in the title.
I tried changing line 6 to TCHAR, but then I get a compile error at line 15, "invalid conversion from TCHAR to char *.
An suggestions? :confused:
#include <QWidget>
#include <windows.h>
HWND hChild;
PTSTR pTitle;
QString szTitle;
hChild = GetForegroundWindow();
pTitle = (PTSTR) malloc ( 8 * sizeof (QChar)) ;
int iFlag = GetWindowText( hChild, pTitle, 8);
szTitle = *pTitle;
labelTitle->setText( szTitle);
While szTitle is a buffer of TCHAR, QString is unicode so I set the datatype to QString in line 6.
The above compiles, but line 12 returns 1 and line 15 only prints the first character in the title.
I tried changing line 6 to TCHAR, but then I get a compile error at line 15, "invalid conversion from TCHAR to char *.
An suggestions? :confused: