目前共有2篇帖子。
字體大小:較小 - 100% (默認)  內容轉換:不轉換
 
點擊 回復
1216 1
【原创程序】输入一段内容,生成可粘贴成RMXP事件编辑器中“显示文章”指令的C++程序
巨大八爪鱼
武林盟主 二十一級
回復
1樓 發表於:2016-1-12 21:18
// CreateClipboardData.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <Windows.h>

#define LINE_LEN 430

int _tmain(int argc, _TCHAR* argv[])
{
    char str[LINE_LEN + 1];
    const int line = 1;
    char header[] = "\x04\x08\x5b\x05o:\x16RPG::EventCommand\x08:\x10@parameters[\x06\"\x05";
    char footer[] = ":\x0c@indenti\0\x3a\xa@codeij";
    header[3] += line;
    gets_s(str, LINE_LEN);

    int strlength = strlen(str);
    int count = 4;
    char data[200];
    int size = sizeof(header) - 1;
    header[size - 1] += strlength;
    memcpy(data + count, header, size);
    count += size;
    size = strlength;
    memcpy(data + count, str, size);
    count += size;
    size = sizeof(footer) - 1;
    memcpy(data + count, footer, size);
    count += size;
    size = count - 0x04;
    data[0] = size & 0xff;
    data[1] = size >> 8 & 0xff;
    data[2] = size >> 16 & 0xff;
    data[3] = size >> 24 & 0xff;
    
    OpenClipboard(NULL);
    EmptyClipboard();
    HGLOBAL hMem = GlobalAlloc(GMEM_FIXED, count);
    char *space = (char *)GlobalLock(hMem);
    memcpy(space, data, count);

    /*FILE *fp;
    fopen_s(&fp, "mem.dat", "wb");
    fwrite(space, count, 1, fp);
    fclose(fp);*/

    GlobalUnlock(hMem);
    SetClipboardData(50287, hMem);
    CloseClipboard();

    return 0;
}

【技巧】
运行该程序时,可以输入一段超长内容:


粘贴到RMXP的事件编辑器后,可以看到这一长串a独占了一行文字,没有任何换行。
这是RMXP本身所不能做到的。

巨大八爪鱼
武林盟主 二十一級
回復
2樓 發表於:2025-12-29 10:56
回覆帖子
內容:
用戶名: 您目前是匿名發表。
驗證碼:
看不清?換一張
(快捷鍵:Ctrl+Enter)
本帖信息
點擊數:1216 回複數:1
作者:巨大八爪鱼
最後回覆:巨大八爪鱼
最後回復時間:2025-12-29 10:56
公告板