View Full Version : FormatMessageFunction

14th October 2007, 07:28
hi ,
In vc++ there is a function named FormatMessage Function. I need to simulate the same thing in qt.Which function to use for this ?????????

14th October 2007, 09:20
I think FormatMessage is standard windows api. you can use this, too in qt.
With QString, WCHAR and QString::fromUtf16()

14th October 2007, 11:12
For Qt functions you don't need such a function. Qt doesn't return cryptic error identifiers, but proper error strings. For WinAPI functions, use WinAPI error handling, as kernel_panic suggested (and I guess you won't need QString for that, as you're operating on WinAPI types to use WinAPI functions anyway).

14th October 2007, 12:34
@wysota why do you always try to refute me? this sucks man! this is real shit....
if he wants to use FormatMessage maybe he wants to display it in a qt-control. than he needs a qstring. im thinking when i post something! you should stop flaming around...

14th October 2007, 12:40
"Resistence is futile"

14th October 2007, 13:47
@wysota why do you always try to refute me? this sucks man! this is real shit....
I don't. I answered the original post, not yours and I don't see how my post is related to yours, except that I mentioned you were right to suggest the use of the same call and suggested that using QString might not be needed. But of course you can disagree.

@marcel: Right, but I'm not Borg ;) I do love your comments nevertheless, man :)

14th October 2007, 14:22
star trek and c++ a must have, right?

14th October 2007, 23:07
Trolls organize a Geek vs Nerds trivia quiz during DevDays and there are question categories related to SciFi and comics and I must admit they consider "classic" things I don't have a slightest idea about, so I guess it really depends.

For instance I think Jacek's favourite is SW and LotR (not sure about the latter), while I prefer ST, B5 and Dune :) But in general - yes, these two go well together ;)

24th October 2007, 07:51
Actually i need to incorporate this in qt.
Here m_nLast error is the error message that i have got ..

FORMAT_MESSAGE_FROM_SYSTEm// DWORD dwFlags, // source and processing options
0, //LPCVOID lpSource, // pointer to message source
m_nLastError, // DWORD dwMessageId, // requested message identifier
0, //DWORD dwLanguageId,

// language identifier for requested message
(LPTSTR)&lpszTemp, // LPTSTR lpBuffer, // pointer to message buffer
0, //DWORD nSize, // maximum size of message buffer
0); // va_list *Arguments // address of array of message inserts

24th October 2007, 09:05
If you have the formatted message, you can construct a QString from it and display it using QErrorMessage for example...

24th October 2007, 09:12
I want to use QT for both windows and linux.So i need a function that does the job of formatMessage function effectively.

24th October 2007, 09:35
There is no equivalent in linux, because it doesn't return cryptic error codes. You might take a look at strerror() (man strerror) but I don't know if that is what you are looking for.

24th October 2007, 09:42
So u mean to say that this strerror() function in linux does the job of formatmessage function in windows.

24th October 2007, 12:07
No, I don't say that. I say that strerror returns an error description for an error number you give it.