⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cvitext.c

📁 LabVIEW宝典 .part2
💻 C
字号:
/* 
    PROGRAM:    cvitext.c  (this example was compiled using CVI4.0)

    PURPOSE:    This dll is an example of how to draw text onto a CVI panel from a DLL.
*/


/* Include files needed to compile DLL */
#include <windows.h>
#include <string.h>
#include "cvitext.h"

BOOL __stdcall DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
     /* The DllMain function is called when ever the DLL is loaded and    */
     /* unloaded. Place Initialization code for the DLL in this function. */
    if (fdwReason == DLL_PROCESS_ATTACH) {
        /* Place any initialization which needs to be done when the DLL */
        /* is loaded here. */
    } else if (fdwReason == DLL_PROCESS_DETACH) {
        /* Place any clean-up which needs to be done when the DLL */
        /* is unloaded here. */
    }
    /* return FALSE to abort if initialization fails */
    return TRUE;
}

void DLLEXPORT __stdcall DrawTextInWindow(HWND theWindow, short x, short y, char *text, char *fontName,
                             short pointSize, short bold, short italic, short shadow, long color)
{
    HDC theDC;
    HFONT hfont, hfontOld;


    theDC = GetDC (theWindow);
    if (theDC) {
        hfont = CreateFont((int)pointSize, 0, 0, 0, (bold ? FW_BOLD : FW_NORMAL),
            (BYTE)italic, 0, 0, 0, 0, 0, 0, 0, (LPCSTR)fontName);
        hfontOld = SelectObject(theDC, hfont);

        SetBkMode (theDC, TRANSPARENT);

        if (shadow != 0) {
            SetTextColor(theDC, RGB(0, 0, 0));
            TextOut (theDC, x+shadow, y+shadow, (LPCSTR)text, strlen(text));
        }
        SetTextColor(theDC, (COLORREF)color);
        TextOut (theDC, x, y, (LPCSTR)text, strlen(text));

        SelectObject(theDC, hfontOld);
        DeleteObject(hfont);

        ReleaseDC (theWindow, theDC);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -