qicon.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #define MINIQTLIB
  4. #include "qapplication.h"
  5. #include "qicon.h"
  6. struct QIconPrivate {
  7. HICON hIcon;
  8. };
  9. QIcon::QIcon(QWidget *parent, const char *name)
  10. : QWidget(parent, name, WType_Child)
  11. {
  12. d = new QIconPrivate;
  13. HWND hwnd = CreateWindow(
  14. "STATIC", // class name
  15. caption(), // window name
  16. WS_VISIBLE|WS_CHILD, // style
  17. CW_USEDEFAULT, // geometry
  18. CW_USEDEFAULT,
  19. CW_USEDEFAULT,
  20. CW_USEDEFAULT,
  21. parent->winId(),
  22. (HMENU)NULL, // class menu used
  23. hInstance, // instance handle
  24. NULL); // no window creation data
  25. if (hwnd == (HWND)0) {
  26. fprintf(stderr, "cannot create icon\n");
  27. exit(1);
  28. }
  29. setWinId(hwnd);
  30. registerWinId(hwnd, this);
  31. d->hIcon = LoadIcon(NULL, IDI_WINLOGO);
  32. }
  33. QIcon::~QIcon()
  34. {
  35. delete d;
  36. unregisterWinId(winId());
  37. printf("destroing icon %p name=\"%s\"\n", this, name());
  38. }