MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / FFilePaste

Function FFilePaste

wdriver.cpp:2704–2750  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2702// Implements the Paste menu command.
2703
2704flag FFilePaste(void)
2705{
2706 HFILE hfile;
2707 LONG lSize;
2708 HGLOBAL hglobal;
2709 byte *hpb;
2710 flag fText;
2711
2712 // Check for a bitmap or text on the Windows clipboard, the two formats
2713 // that Astrolog knows how to paste.
2714 if (!OpenClipboard(wi.hwnd))
2715 return fFalse;
2716 if (IsClipboardFormatAvailable(CF_DIB))
2717 fText = fFalse;
2718 else if (IsClipboardFormatAvailable(CF_TEXT))
2719 fText = fTrue;
2720 else {
2721 PrintWarning("There is nothing on the clipboard to paste.");
2722 return fFalse;
2723 }
2724
2725 // Get a memory buffer containing the Windows clipboard.
2726 hglobal = GetClipboardData(fText ? CF_TEXT : CF_DIB);
2727 if (hglobal == (HGLOBAL)NULL)
2728 return fFalse;
2729
2730 // Create a temporary file.
2731 hfile = _lcreat(szFileTemp, 0);
2732 if (hfile == HFILE_ERROR)
2733 return fFalse;
2734
2735 // Save the contents of the memory buffer to that temporary file.
2736 hpb = (byte *)GlobalLock(hglobal);
2737 lSize = (LONG)GlobalSize(hglobal);
2738 _hwrite(hfile, (char *)hpb, lSize);
2739 _lclose(hfile);
2740 GlobalUnlock(hglobal);
2741
2742 // Load the file's contents into the program.
2743 if (fText)
2744 FInputData(szFileTemp);
2745 else
2746 FLoadBmp(szFileTemp, &gi.bmpBack, fTrue);
2747 _unlink(szFileTemp);
2748 CloseClipboard();
2749 return fTrue;
2750}
2751
2752
2753// This important routine is the bottleneck to redraw the window and call into

Callers 1

NWmCommandFunction · 0.85

Calls 3

PrintWarningFunction · 0.85
FInputDataFunction · 0.85
FLoadBmpFunction · 0.85

Tested by

no test coverage detected