1
0

cdrapi.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include "cdrapi.h"
  4. void BeginOpt(corel *cdr)
  5. {
  6. auto name = _bstr_t("Undo");
  7. cdr->EventsEnabled = false;
  8. cdr->ActiveDocument->BeginCommandGroup(name);
  9. cdr->ActiveDocument->Unit = cdrMillimeter;
  10. cdr->Optimization = true;
  11. }
  12. void EndOpt(corel *cdr)
  13. {
  14. cdr->EventsEnabled = true;
  15. cdr->Optimization = false;
  16. cdr->EventsEnabled = true;
  17. cdr->ActiveDocument->ReferencePoint = cdrBottomLeft;
  18. cdr->Application->Refresh();
  19. cdr->ActiveDocument->EndCommandGroup();
  20. }
  21. void Active_CorelWindows(HWND hDlg)
  22. {
  23. // 将焦点返回到父窗口 关闭对话框窗口
  24. SetFocus(GetParent(hDlg));
  25. }
  26. double GetTextValue(HWND hDlg, int IDITEM) {
  27. char ibuf[64];
  28. memset(ibuf, 0, sizeof(ibuf));
  29. // 获取文本
  30. if (GetWindowText(::GetDlgItem(hDlg, IDITEM), ibuf, sizeof(ibuf)) == 0) {
  31. return 0.0;
  32. }
  33. double exp = 0.0;
  34. if (sscanf_s(ibuf, "%lf", &exp) != 1) {
  35. return 0.0;
  36. }
  37. return exp;
  38. }
  39. void PutTextValue(HWND hDlg, int IDITEM, char *buf) {
  40. SetWindowText(::GetDlgItem(hDlg, IDITEM), buf);
  41. }