PDA

View Full Version : FormatMessageFunction



AnithaRagupathy
14th October 2007, 06: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 ?????????

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

wysota
14th October 2007, 10: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).

kernel_panic
14th October 2007, 11: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...

marcel
14th October 2007, 11:40
"Resistence is futile"
:)

wysota
14th October 2007, 12: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 :)

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

wysota
14th October 2007, 22: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 ;)

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

::FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEm// DWORD dwFlags, // source and processing options
| FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_IGNORE_INSERTS,
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

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

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

wysota
24th October 2007, 08: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.

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

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