Qt 4.8
Classes | Macros | Functions | Variables
qcoreapplication_win.cpp File Reference
#include "qcoreapplication.h"
#include "qcoreapplication_p.h"
#include "qstringlist.h"
#include "qt_windows.h"
#include "qvector.h"
#include "qmutex.h"
#include "qfileinfo.h"
#include "qcorecmdlineargs_p.h"
#include <private/qthread_p.h>
#include <ctype.h>
#include <windowsx.h>
#include "qdebug.h"

Go to the source code of this file.

Classes

struct  FLAG_STRING_STRUCT
 
struct  KnownWM
 
class  QWinMsgHandlerCriticalSection
 

Macros

#define FLGSTR(x)   FLAG_STRING(x, #x)
 
#define GET_X_LPARAM(lp)   ((int)(short)LOWORD(lp))
 
#define GET_Y_LPARAM(lp)   ((int)(short)HIWORD(lp))
 

Functions

QString decodeMSG (const MSG &msg)
 
static const char * findWMstr (uint msg)
 
FLAG_STRING_STRUCT FLAG_STRING (uint value=0, const char *c=0)
 
QString flagCheck (uint actual,...)
 
QDebug operator<< (QDebug dbg, const MSG &msg)
 
Q_CORE_EXPORT QString qAppFileName ()
 
Q_CORE_EXPORT int qWinAppCmdShow ()
 
Q_CORE_EXPORT HINSTANCE qWinAppInst ()
 
Q_CORE_EXPORT HINSTANCE qWinAppPrevInst ()
 
Q_CORE_EXPORT void __cdecl qWinMain (HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, int cmdShow, int &argc, QVector< char *> &argv)
 
Q_CORE_EXPORT void qWinMsgHandler (QtMsgType t, const char *str)
 
QString valueCheck (uint actual,...)
 

Variables

int appCmdShow = 0
 
struct KnownWM knownWM []
 
bool usingWinMain = false
 

Macro Definition Documentation

◆ FLGSTR

#define FLGSTR (   x)    FLAG_STRING(x, #x)

Definition at line 592 of file qcoreapplication_win.cpp.

Referenced by decodeMSG().

◆ GET_X_LPARAM

#define GET_X_LPARAM (   lp)    ((int)(short)LOWORD(lp))

◆ GET_Y_LPARAM

#define GET_Y_LPARAM (   lp)    ((int)(short)HIWORD(lp))

Function Documentation

◆ decodeMSG()

QString decodeMSG ( const MSG msg)

Definition at line 645 of file qcoreapplication_win.cpp.

Referenced by operator<<(), and valueCheck().

646 {
647  const WPARAM wParam = msg.wParam;
648  const LPARAM lParam = msg.lParam;
649  QString wmmsg = QString::fromLatin1(findWMstr(msg.message));
650  // Unknown WM_, so use number
651  if (wmmsg.isEmpty())
652  wmmsg = QString::fromLatin1("WM_(%1)").arg(msg.message);
653 
654  QString rawParameters;
655  rawParameters.sprintf("hwnd(0x%p) ", (void *)msg.hwnd);
656 
657  // Custom WM_'s
658  if (msg.message > WM_APP)
659  wmmsg = QString::fromLatin1("WM_APP + %1").arg(msg.message - WM_APP);
660  else if (msg.message > WM_USER)
661  wmmsg = QString::fromLatin1("WM_USER + %1").arg(msg.message - WM_USER);
662 
663  QString parameters;
664  switch (msg.message) {
665 #ifdef WM_ACTIVATE
666  case WM_ACTIVATE:
667  {
668  QString activation = valueCheck(wParam,
669  FLAG_STRING(WA_ACTIVE, "Activate"),
670  FLAG_STRING(WA_INACTIVE, "Deactivate"),
671  FLAG_STRING(WA_CLICKACTIVE, "Activate by mouseclick"),
672  FLAG_STRING());
673  parameters.sprintf("%s Hwnd (0x%p)", activation.toLatin1().data(), (void *)msg.hwnd);
674  }
675  break;
676 #endif
677 #ifdef WM_CAPTURECHANGED
678  case WM_CAPTURECHANGED:
679  parameters.sprintf("Hwnd gaining capture (0x%p)", (void *)lParam);
680  break;
681 #endif
682 #ifdef WM_CREATE
683  case WM_CREATE:
684  {
685  LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
686  QString styles = flagCheck(lpcs->style,
687  FLGSTR(WS_BORDER),
688  FLGSTR(WS_CAPTION),
689  FLGSTR(WS_CHILD),
690  FLGSTR(WS_CLIPCHILDREN),
691  FLGSTR(WS_CLIPSIBLINGS),
692  FLGSTR(WS_DISABLED),
693  FLGSTR(WS_DLGFRAME),
694  FLGSTR(WS_GROUP),
695  FLGSTR(WS_HSCROLL),
696  FLGSTR(WS_OVERLAPPED),
697 #if defined(WS_OVERLAPPEDWINDOW) && (WS_OVERLAPPEDWINDOW != 0)
699 #endif
700 #ifdef WS_ICONIC
701  FLGSTR(WS_ICONIC),
702 #endif
704  FLGSTR(WS_MAXIMIZEBOX),
706  FLGSTR(WS_MINIMIZEBOX),
708  FLGSTR(WS_POPUP),
709 #ifdef WS_POPUPWINDOW
711 #endif
712  FLGSTR(WS_SIZEBOX),
713  FLGSTR(WS_SYSMENU),
714  FLGSTR(WS_TABSTOP),
716 #ifdef WS_TILED
717  FLGSTR(WS_TILED),
718 #endif
719 #ifdef WS_TILEDWINDOW
721 #endif
722  FLGSTR(WS_VISIBLE),
723  FLGSTR(WS_VSCROLL),
724  FLAG_STRING());
725 
726  QString exStyles = flagCheck(lpcs->dwExStyle,
727 #ifdef WS_EX_ACCEPTFILES
728  FLGSTR(WS_EX_ACCEPTFILES),
729 #endif
730 #ifdef WS_EX_APPWINDOW
731  FLGSTR(WS_EX_APPWINDOW),
732 #endif
733  FLGSTR(WS_EX_CLIENTEDGE),
734  FLGSTR(WS_EX_DLGMODALFRAME),
735 #ifdef WS_EX_LEFT
736  FLGSTR(WS_EX_LEFT),
737 #endif
738  FLGSTR(WS_EX_LEFTSCROLLBAR),
739 #ifdef WS_EX_LTRREADING
740  FLGSTR(WS_EX_LTRREADING),
741 #endif
742 #ifdef WS_EX_MDICHILD
743  FLGSTR(WS_EX_MDICHILD),
744 #endif
745 #ifdef WS_EX_NOACTIVATE
746  FLGSTR(WS_EX_NOACTIVATE),
747 #endif
748 #ifdef WS_EX_NOANIMATION
749  FLGSTR(WS_EX_NOANIMATION),
750 #endif
752  FLGSTR(WS_EX_OVERLAPPEDWINDOW),
753 #ifdef WS_EX_PALETTEWINDOW
754  FLGSTR(WS_EX_PALETTEWINDOW),
755 #endif
756 #ifdef WS_EX_RIGHT
757  FLGSTR(WS_EX_RIGHT),
758 #endif
759 #ifdef WS_EX_RIGHTSCROLLBAR
760  FLGSTR(WS_EX_RIGHTSCROLLBAR),
761 #endif
762 #ifdef WS_EX_RTLREADING
763  FLGSTR(WS_EX_RTLREADING),
764 #endif
765  FLGSTR(WS_EX_STATICEDGE),
767  FLGSTR(WS_EX_TOPMOST),
768 #ifdef WS_EX_TRANSPARENT
769  FLGSTR(WS_EX_TRANSPARENT),
770 #endif
771  FLGSTR(WS_EX_WINDOWEDGE),
772 #ifdef WS_EX_CAPTIONOKBTN
774 #endif
775  FLAG_STRING());
776 
778  if (lpcs->lpszClass != 0) {
779  if (HIWORD(lpcs->lpszClass) == 0) // Atom
780  className = QString::number(LOWORD(lpcs->lpszClass), 16);
781  else // String
782  className = QString((QChar*)lpcs->lpszClass,
783  (int)wcslen(reinterpret_cast<const wchar_t *>(lpcs->lpszClass)));
784  }
785 
786  QString windowName;
787  if (lpcs->lpszName != 0)
788  windowName = QString((QChar*)lpcs->lpszName,
789  (int)wcslen(reinterpret_cast<const wchar_t *>(lpcs->lpszName)));
790 
791  parameters.sprintf("x,y(%4d,%4d) w,h(%4d,%4d) className(%s) windowName(%s) parent(0x%p) style(%s) exStyle(%s)",
792  lpcs->x, lpcs->y, lpcs->cx, lpcs->cy, className.toLatin1().data(),
793  windowName.toLatin1().data(), (void *)lpcs->hwndParent,
794  styles.toLatin1().data(), exStyles.toLatin1().data());
795  }
796  break;
797 #endif
798 #ifdef WM_DESTROY
799  case WM_DESTROY:
800  parameters.sprintf("Destroy hwnd (0x%p)", (void *)msg.hwnd);
801  break;
802 #endif
803 #ifdef WM_IME_NOTIFY
804  case WM_IME_NOTIFY:
805  {
806  QString imnCommand = valueCheck(wParam,
807  FLGSTR(IMN_CHANGECANDIDATE),
808  FLGSTR(IMN_CLOSECANDIDATE),
809  FLGSTR(IMN_CLOSESTATUSWINDOW),
810  FLGSTR(IMN_GUIDELINE),
811  FLGSTR(IMN_OPENCANDIDATE),
812  FLGSTR(IMN_OPENSTATUSWINDOW),
813  FLGSTR(IMN_SETCANDIDATEPOS),
814  FLGSTR(IMN_SETCOMPOSITIONFONT),
815  FLGSTR(IMN_SETCOMPOSITIONWINDOW),
816  FLGSTR(IMN_SETCONVERSIONMODE),
817  FLGSTR(IMN_SETOPENSTATUS),
818  FLGSTR(IMN_SETSENTENCEMODE),
819  FLGSTR(IMN_SETSTATUSWINDOWPOS),
820  FLAG_STRING());
821  parameters.sprintf("Command(%s : 0x%p)", imnCommand.toLatin1().data(), (void *)lParam);
822  }
823  break;
824 #endif
825 #ifdef WM_IME_SETCONTEXT
826  case WM_IME_SETCONTEXT:
827  {
828  bool fSet = (BOOL)wParam;
829  DWORD fShow = (DWORD)lParam;
830  QString showFlgs = flagCheck(fShow,
831 #ifdef ISC_SHOWUICOMPOSITIONWINDOW
832  FLGSTR(ISC_SHOWUICOMPOSITIONWINDOW),
833 #endif
834 #ifdef ISC_SHOWUIGUIDWINDOW
835  FLGSTR(ISC_SHOWUIGUIDWINDOW),
836 #endif
837 #ifdef ISC_SHOWUISOFTKBD
838  FLGSTR(ISC_SHOWUISOFTKBD),
839 #endif
840  FLGSTR(ISC_SHOWUICANDIDATEWINDOW),
841  FLGSTR(ISC_SHOWUICANDIDATEWINDOW << 1),
842  FLGSTR(ISC_SHOWUICANDIDATEWINDOW << 2),
843  FLGSTR(ISC_SHOWUICANDIDATEWINDOW << 3),
844  FLAG_STRING());
845  parameters.sprintf("Input context(%s) Show flags(%s)", (fSet? "Active" : "Inactive"), showFlgs.toLatin1().data());
846  }
847  break;
848 #endif
849 #ifdef WM_KILLFOCUS
850  case WM_KILLFOCUS:
851  parameters.sprintf("Hwnd gaining keyboard focus (0x%p)", (void *)wParam);
852  break;
853 #endif
854 #ifdef WM_CHAR
855  case WM_CHAR:
856 #endif
857 #ifdef WM_IME_CHAR
858  case WM_IME_CHAR:
859 #endif
860 #ifdef WM_KEYDOWN
861  case WM_KEYDOWN:
862 #endif
863 #ifdef WM_KEYUP
864  case WM_KEYUP:
865  {
866  int nVirtKey = (int)wParam;
867  long lKeyData = (long)lParam;
868  int repCount = (lKeyData & 0xffff); // Bit 0-15
869  int scanCode = (lKeyData & 0xf0000) >> 16; // Bit 16-23
870  bool contextCode = (lKeyData && 0x20000000); // Bit 29
871  bool prevState = (lKeyData && 0x40000000); // Bit 30
872  bool transState = (lKeyData && 0x80000000); // Bit 31
873  parameters.sprintf("Virual-key(0x%x) Scancode(%d) Rep(%d) Contextcode(%d), Prev state(%d), Trans state(%d)",
874  nVirtKey, scanCode, repCount, contextCode, prevState, transState);
875  }
876  break;
877 #endif
878 #ifdef WM_INPUTLANGCHANGE
879  case WM_INPUTLANGCHANGE:
880  parameters = QLatin1String("Keyboard layout changed");
881  break;
882 #endif // WM_INPUTLANGCHANGE
883 #ifdef WM_NCACTIVATE
884  case WM_NCACTIVATE:
885  {
886  parameters = (msg.wParam? QLatin1String("Active Titlebar") : QLatin1String("Inactive Titlebar"));
887  }
888  break;
889 #endif
890 #ifdef WM_MOUSEACTIVATE
891  case WM_MOUSEACTIVATE:
892  {
893  QString mouseMsg = QString::fromLatin1(findWMstr(HIWORD(lParam)));
894  parameters.sprintf("TLW(0x%p) HittestCode(0x%x) MouseMsg(%s)", (void *)wParam, LOWORD(lParam), mouseMsg.toLatin1().data());
895  }
896  break;
897 #endif
898 #ifdef WM_MOUSELEAVE
899  case WM_MOUSELEAVE:
900  break; // wParam & lParam not used
901 #endif
902 #ifdef WM_MOUSEHOVER
903  case WM_MOUSEHOVER:
904 #endif
905 #ifdef WM_MOUSEWHEEL
906  case WM_MOUSEWHEEL:
907 #endif
908 #ifdef WM_MOUSEHWHEEL
909  case WM_MOUSEHWHEEL:
910 #endif
911 #ifdef WM_LBUTTONDBLCLK
912  case WM_LBUTTONDBLCLK:
913 #endif
914 #ifdef WM_LBUTTONDOWN
915  case WM_LBUTTONDOWN:
916 #endif
917 #ifdef WM_LBUTTONUP
918  case WM_LBUTTONUP:
919 #endif
920 #ifdef WM_MBUTTONDBLCLK
921  case WM_MBUTTONDBLCLK:
922 #endif
923 #ifdef WM_MBUTTONDOWN
924  case WM_MBUTTONDOWN:
925 #endif
926 #ifdef WM_MBUTTONUP
927  case WM_MBUTTONUP:
928 #endif
929 #ifdef WM_RBUTTONDBLCLK
930  case WM_RBUTTONDBLCLK:
931 #endif
932 #ifdef WM_RBUTTONDOWN
933  case WM_RBUTTONDOWN:
934 #endif
935 #ifdef WM_RBUTTONUP
936  case WM_RBUTTONUP:
937 #endif
938 #ifdef WM_MOUSEMOVE
939  case WM_MOUSEMOVE:
940  {
941  QString vrtKeys = flagCheck(wParam,
942  FLGSTR(MK_CONTROL),
943  FLGSTR(MK_LBUTTON),
944  FLGSTR(MK_MBUTTON),
945  FLGSTR(MK_RBUTTON),
946  FLGSTR(MK_SHIFT),
947 #ifdef MK_XBUTTON1
949 #endif
950 #ifdef MK_XBUTTON2
952 #endif
953  FLAG_STRING());
954  parameters.sprintf("x,y(%4d,%4d) Virtual Keys(%s)", GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), vrtKeys.toLatin1().data());
955  }
956  break;
957 #endif
958 #ifdef WM_MOVE
959  case WM_MOVE:
960  parameters.sprintf("x,y(%4d,%4d)", LOWORD(lParam), HIWORD(lParam));
961  break;
962 #endif
963 #if defined(WM_PAINT) && defined(WM_ERASEBKGND)
964  case WM_ERASEBKGND:
965  case WM_PAINT:
966  parameters.sprintf("hdc(0x%p)", (void *)wParam);
967  break;
968 #endif
969 #ifdef WM_QUERYNEWPALETTE
970  case WM_QUERYNEWPALETTE:
971  break; // lParam & wParam are unused
972 #endif
973 #ifdef WM_SETCURSOR
974  case WM_SETCURSOR:
975  {
976  QString mouseMsg = QString::fromLatin1(findWMstr(HIWORD(lParam)));
977  parameters.sprintf("HitTestCode(0x%x) MouseMsg(%s)", LOWORD(lParam), mouseMsg.toLatin1().data());
978  }
979  break;
980 #endif
981 #ifdef WM_SETFOCUS
982  case WM_SETFOCUS:
983  parameters.sprintf("Lost Focus (0x%p)", (void *)wParam);
984  break;
985 #endif
986 #ifdef WM_SETTEXT
987  case WM_SETTEXT:
988  parameters.sprintf("Set Text (%s)", QString((QChar*)lParam, (int)wcslen(reinterpret_cast<const wchar_t *>(lParam))).toLatin1().data()); //Unicode string
989  break;
990 #endif
991 #ifdef WM_SIZE
992  case WM_SIZE:
993  {
994  QString showMode = valueCheck(wParam,
995  FLGSTR(SIZE_MAXHIDE),
996  FLGSTR(SIZE_MAXIMIZED),
997  FLGSTR(SIZE_MAXSHOW),
998  FLGSTR(SIZE_MINIMIZED),
999  FLGSTR(SIZE_RESTORED),
1000  FLAG_STRING());
1001 
1002  parameters.sprintf("w,h(%4d,%4d) showmode(%s)", LOWORD(lParam), HIWORD(lParam), showMode.toLatin1().data());
1003  }
1004  break;
1005 #endif
1006 #ifdef WM_WINDOWPOSCHANGED
1007  case WM_WINDOWPOSCHANGED:
1008  {
1009  LPWINDOWPOS winPos = (LPWINDOWPOS)lParam;
1010  if (!winPos)
1011  break;
1012  QString hwndAfter = valueCheck(quint64(winPos->hwndInsertAfter),
1013  FLAG_STRING((qptrdiff)HWND_BOTTOM, "HWND_BOTTOM"),
1014  FLAG_STRING((qptrdiff)HWND_NOTOPMOST, "HWND_NOTOPMOST"),
1015  FLAG_STRING((qptrdiff)HWND_TOP, "HWND_TOP"),
1016  FLAG_STRING((qptrdiff)HWND_TOPMOST, "HWND_TOPMOST"),
1017  FLAG_STRING());
1018  if (hwndAfter.isEmpty())
1019  hwndAfter = QString::number((quintptr)winPos->hwndInsertAfter, 16);
1020  QString flags = flagCheck(winPos->flags,
1021  FLGSTR(SWP_DRAWFRAME),
1022  FLGSTR(SWP_FRAMECHANGED),
1023  FLGSTR(SWP_HIDEWINDOW),
1024  FLGSTR(SWP_NOACTIVATE),
1025 #ifdef SWP_NOCOPYBITS
1026  FLGSTR(SWP_NOCOPYBITS),
1027 #endif
1028  FLGSTR(SWP_NOMOVE),
1029  FLGSTR(SWP_NOOWNERZORDER),
1031  FLGSTR(SWP_NOREPOSITION),
1032 #ifdef SWP_NOSENDCHANGING
1033  FLGSTR(SWP_NOSENDCHANGING),
1034 #endif
1035  FLGSTR(SWP_NOSIZE),
1036  FLGSTR(SWP_NOZORDER),
1037  FLGSTR(SWP_SHOWWINDOW),
1038  FLAG_STRING());
1039  parameters.sprintf("x,y(%4d,%4d) w,h(%4d,%4d) flags(%s) hwndAfter(%s)", winPos->x, winPos->y, winPos->cx, winPos->cy, flags.toLatin1().data(), hwndAfter.toLatin1().data());
1040  }
1041  break;
1042 #endif
1043  default:
1044  parameters.sprintf("wParam(0x%p) lParam(0x%p)", (void *)wParam, (void *)lParam);
1045  break;
1046  }
1047  // Yes, we want to give the WM_ names 20 chars of space before showing the
1048  // decoded message, since some of the common messages are quite long, and
1049  // we don't want the decoded information to vary in output position
1050  QString message = QString::fromLatin1("%1: ").arg(wmmsg, 20);
1051  message += rawParameters;
1052  message += parameters;
1053  return message;
1054 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
#define WM_MOUSEWHEEL
Definition: qt_windows.h:116
QString & sprintf(const char *format,...)
Safely builds a formatted string from the format string cformat and an arbitrary list of arguments...
Definition: qstring.cpp:5567
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
#define WS_EX_TOOLWINDOW
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
#define FLGSTR(x)
#define WM_MOUSEHWHEEL
Definition: qt_windows.h:119
#define HWND_NOTOPMOST
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define WS_MAXIMIZE
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString flagCheck(uint actual,...)
#define MK_XBUTTON1
QString valueCheck(uint actual,...)
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
#define WM_SETCURSOR
const char * className
Definition: qwizard.cpp:137
#define WS_MINIMIZE
#define WS_TILED
#define HWND_TOPMOST
unsigned __int64 quint64
Definition: qglobal.h:943
QIntegerForSizeof< void * >::Signed qptrdiff
Definition: qglobal.h:987
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define GET_X_LPARAM(lp)
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
#define WS_EX_NOPARENTNOTIFY
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
#define SWP_NOREDRAW
#define WS_OVERLAPPEDWINDOW
#define MK_XBUTTON2
static const char * findWMstr(uint msg)
#define WS_POPUPWINDOW
#define GET_Y_LPARAM(lp)
#define WS_EX_CAPTIONOKBTN
FLAG_STRING_STRUCT FLAG_STRING(uint value=0, const char *c=0)
#define WS_THICKFRAME
#define WS_TILEDWINDOW
#define WM_MOUSELEAVE

◆ findWMstr()

static const char* findWMstr ( uint  msg)
static

Definition at line 568 of file qcoreapplication_win.cpp.

Referenced by decodeMSG().

569 {
570  uint i = 0;
571  const char* result = 0;
572  // Known WM_'s
573  while (knownWM[i].str && (knownWM[i].WM != msg))
574  ++i;
575  result = knownWM[i].str;
576  return result;
577 };
struct KnownWM knownWM[]
const char * str
unsigned int uint
Definition: qglobal.h:996

◆ FLAG_STRING()

FLAG_STRING_STRUCT FLAG_STRING ( uint  value = 0,
const char *  c = 0 
)

Definition at line 586 of file qcoreapplication_win.cpp.

Referenced by decodeMSG().

587 {
588  FLAG_STRING_STRUCT s = {value, c};
589  return s;
590 }
unsigned char c[8]
Definition: qnumeric_p.h:62

◆ flagCheck()

QString flagCheck ( uint  actual,
  ... 
)

Definition at line 597 of file qcoreapplication_win.cpp.

Referenced by decodeMSG().

598 {
599  va_list ap;
600  va_start(ap, actual);
601 
602  QString result;
603  int count = 0;
605  while((v=va_arg(ap,FLAG_STRING_STRUCT)).str) {
606  if ((actual & v.value) == v.value) {
607  if (count++)
608  result += QLatin1String(" | ");
609  result += QString::fromLatin1(v.str);
610  }
611  }
612  va_end(ap);
613  return result;
614 };
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188

◆ operator<<()

QDebug operator<< ( QDebug  dbg,
const MSG msg 
)

Definition at line 1058 of file qcoreapplication_win.cpp.

1059 {
1060  dbg << decodeMSG(msg);
1061  return dbg.nospace();
1062 }
QString decodeMSG(const MSG &msg)
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92

◆ qAppFileName()

Q_CORE_EXPORT QString qAppFileName ( )

Definition at line 82 of file qcoreapplication_win.cpp.

Referenced by QCoreApplication::applicationFilePath(), QCoreApplicationPrivate::appName(), and QSystemLibrary::load().

83 {
84  // We do MAX_PATH + 2 here, and request with MAX_PATH + 1, so we can handle all paths
85  // up to, and including MAX_PATH size perfectly fine with string termination, as well
86  // as easily detect if the file path is indeed larger than MAX_PATH, in which case we
87  // need to use the heap instead. This is a work-around, since contrary to what the
88  // MSDN documentation states, GetModuleFileName sometimes doesn't set the
89  // ERROR_INSUFFICIENT_BUFFER error number, and we thus cannot rely on this value if
90  // GetModuleFileName(0, buffer, MAX_PATH) == MAX_PATH.
91  // GetModuleFileName(0, buffer, MAX_PATH + 1) == MAX_PATH just means we hit the normal
92  // file path limit, and we handle it normally, if the result is MAX_PATH + 1, we use
93  // heap (even if the result _might_ be exactly MAX_PATH + 1, but that's ok).
94  wchar_t buffer[MAX_PATH + 2];
95  DWORD v = GetModuleFileName(0, buffer, MAX_PATH + 1);
96  buffer[MAX_PATH + 1] = 0;
97 
98  if (v == 0)
99  return QString();
100  else if (v <= MAX_PATH)
101  return QString::fromWCharArray(buffer);
102 
103  // MAX_PATH sized buffer wasn't large enough to contain the full path, use heap
104  wchar_t *b = 0;
105  int i = 1;
106  size_t size;
107  do {
108  ++i;
109  size = MAX_PATH * i;
110  b = reinterpret_cast<wchar_t *>(realloc(b, (size + 1) * sizeof(wchar_t)));
111  if (b)
112  v = GetModuleFileName(NULL, b, size);
113  } while (b && v == size);
114 
115  if (b)
116  *(b + size) = 0;
118  free(b);
119 
120  return res;
121 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ qWinAppCmdShow()

Q_CORE_EXPORT int qWinAppCmdShow ( )

Definition at line 68 of file qcoreapplication_win.cpp.

69 {
70 #if defined(Q_OS_WINCE)
71  return appCmdShow;
72 #else
73  STARTUPINFO startupInfo;
74  GetStartupInfo(&startupInfo);
75 
76  return (startupInfo.dwFlags & STARTF_USESHOWWINDOW)
77  ? startupInfo.wShowWindow
78  : SW_SHOWDEFAULT;
79 #endif
80 }
int appCmdShow

◆ qWinAppInst()

Q_CORE_EXPORT HINSTANCE qWinAppInst ( )

◆ qWinAppPrevInst()

Q_CORE_EXPORT HINSTANCE qWinAppPrevInst ( )

Definition at line 63 of file qcoreapplication_win.cpp.

64 {
65  return 0;
66 }

◆ qWinMain()

Q_CORE_EXPORT void __cdecl qWinMain ( HINSTANCE  instance,
HINSTANCE  prevInstance,
LPSTR  cmdParam,
int  cmdShow,
int &  argc,
QVector< char *> &  argv 
)

Definition at line 170 of file qcoreapplication_win.cpp.

Referenced by qax_stopServer(), and WinMain().

177 {
178  static bool already_called = false;
179 
180  if (already_called) {
181  qWarning("Qt: Internal error: qWinMain should be called only once");
182  return;
183  }
184  already_called = true;
185  usingWinMain = true;
186 
187  // Install default debug handler
189 
190  // Create command line
191  argv = qWinCmdLine<char>(cmdParam, int(strlen(cmdParam)), argc);
192 
193  appCmdShow = cmdShow;
194 
195  // Ignore Windows parameters
196  Q_UNUSED(instance);
197  Q_UNUSED(prevInstance);
198 }
Q_CORE_EXPORT void qWinMsgHandler(QtMsgType t, const char *str)
int appCmdShow
bool usingWinMain
Q_CORE_EXPORT void qWarning(const char *,...)
QtMsgHandler qInstallMsgHandler(QtMsgHandler h)
Definition: qglobal.cpp:2698
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ qWinMsgHandler()

Q_CORE_EXPORT void qWinMsgHandler ( QtMsgType  t,
const char *  str 
)

Definition at line 143 of file qcoreapplication_win.cpp.

Referenced by QClassFactory::CreateInstanceHelper(), qax_winEventFilter(), qInstallMsgHandler(), qt_error_string(), and qWinMain().

144 {
145  Q_UNUSED(t);
146  // OutputDebugString is not threadsafe.
147 
148  // cannot use QMutex here, because qWarning()s in the QMutex
149  // implementation may cause this function to recurse
150  static QWinMsgHandlerCriticalSection staticCriticalSection;
151 
152  if (!str)
153  str = "(null)";
154 
155  staticCriticalSection.lock();
156 
158  s += QLatin1Char('\n');
159  OutputDebugString((wchar_t*)s.utf16());
160 
161  staticCriticalSection.unlock();
162 }
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ valueCheck()

QString valueCheck ( uint  actual,
  ... 
)

Definition at line 619 of file qcoreapplication_win.cpp.

Referenced by decodeMSG().

620 {
621  va_list ap;
622  va_start(ap, actual);
623 
624  QString result;
626  while((v=va_arg(ap,FLAG_STRING_STRUCT)).str && (actual != v.value))
627  ;
628  result = QString::fromLatin1(v.str);
629 
630  va_end(ap);
631  return result;
632 };
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188

Variable Documentation

◆ appCmdShow

int appCmdShow = 0

Definition at line 56 of file qcoreapplication_win.cpp.

Referenced by qWinAppCmdShow(), and qWinMain().

◆ knownWM

struct KnownWM knownWM[]

Referenced by findWMstr().

◆ usingWinMain

bool usingWinMain = false

Definition at line 55 of file qcoreapplication_win.cpp.

Referenced by qInstallMsgHandler(), qt_error_string(), and qWinMain().