Results 1 to 14 of 14

Thread: FormatMessageFunction

  1. #1
    Join Date
    Oct 2007
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question FormatMessageFunction

    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 ?????????

  2. #2
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: FormatMessageFunction

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

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: FormatMessageFunction

    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).

  4. #4
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: FormatMessageFunction

    @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...

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: FormatMessageFunction

    "Resistence is futile"

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: FormatMessageFunction

    Quote Originally Posted by kernel_panic View Post
    @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

  7. #7
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: FormatMessageFunction

    lol...
    star trek and c++ a must have, right?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: FormatMessageFunction

    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

  9. #9
    Join Date
    Oct 2007
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: FormatMessageFunction

    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

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: FormatMessageFunction

    If you have the formatted message, you can construct a QString from it and display it using QErrorMessage for example...

  11. #11
    Join Date
    Oct 2007
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: FormatMessageFunction

    I want to use QT for both windows and linux.So i need a function that does the job of formatMessage function effectively.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: FormatMessageFunction

    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.

  13. #13
    Join Date
    Oct 2007
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: FormatMessageFunction

    So u mean to say that this strerror() function in linux does the job of formatmessage function in windows.

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: FormatMessageFunction

    No, I don't say that. I say that strerror returns an error description for an error number you give it.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.