qpushbutton.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * The MiniQt Library
  3. *
  4. * Copyright (C) 1999 Sandro Sigala <ssigala@globalnet.it>
  5. */
  6. #include <windows.h>
  7. #include "qapplication.h"
  8. #include "qpushbutton.h"
  9. QPushButton::QPushButton(const QString& caption, QWidget *parent, const char *name)
  10. : QWidget(parent, name, WType_Child)
  11. {
  12. #ifdef DEBUG
  13. qDebug("obj", "QPushButton::constructor of \"%s\"", name ? name : "unnamed");
  14. #endif
  15. HWND hwnd = CreateWindow(
  16. "BUTTON", // class name
  17. caption, // window name
  18. WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, // style
  19. CW_USEDEFAULT, // geometry
  20. CW_USEDEFAULT,
  21. CW_USEDEFAULT,
  22. CW_USEDEFAULT,
  23. parent->winId(),
  24. (HMENU)NULL, // class menu used
  25. hInstance, // instance handle
  26. NULL); // no window creation data
  27. setCaption(caption);
  28. if (hwnd == (HWND)0)
  29. qFatal("cannot create button");
  30. setWinId(hwnd);
  31. registerWinId(hwnd, this);
  32. }
  33. QPushButton::~QPushButton()
  34. {
  35. #ifdef DEBUG
  36. qDebug("obj", "QPushButton::destructor of \"%s\"", name("unnamed"));
  37. #endif
  38. }
  39. void QPushButton::mouseReleaseEvent(QMouseEvent * /*e*/)
  40. {
  41. emit clicked();
  42. }