目前共有1篇帖子。 內容轉換:不轉換▼
 
點擊 回復
270 0
【原创程序】输入一段内容,生成可粘贴成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本身所不能做到的。

回復帖子

內容:
用戶名: 您目前是匿名發表
驗證碼:
(快捷鍵:Ctrl+Enter)
 

本帖信息

點擊數:270 回複數:0
評論數: ?
作者: 巨大八爪鱼
最後回復:巨大八爪鱼
最後回復時間:2016-1-12 21:18
 
©2010-2024 Arslanbar Ver2.0
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。