C > C++

「C/C++」の編集履歴(バックアップ)一覧に戻る

C/C++ - (2009/12/12 (土) 01:01:20) のソース

-------------------------------------------------------------------------
イベントの数々
http://www.river.sannet.ne.jp/yuui/WinDlg/WinMsg.html

---------------------------
ドラッグ&ドロップ イベントのの作り方
http://web.archive.org/web/20040714220349/http://zidney.define.jp/programing/wm/wm_dropfiles/
------------------------------------

ドラッグ&ドロップのサンプル


 #include "stdafx.h"
 #define MAX_LOADSTRING 100

 #include <Windows.h>
 typedef struct _DROPFILES {
    DWORD pFiles;
    POINT pt;
    BOOL fNC;
    BOOL fWide;
 } DROPFILES, *LPDROPFILES;


const char *FileNameList[]={
	"C:\\Users\\ookubo\\Desktop\\ivent.vbs",
	NULL,
};

INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR arg, INT cmdShow)
{
    HWND hwnd;
	hwnd = FindWindow(NULL,"Adobe Reader");


#if 0
	//アプリケーションの終了
	if(hwnd != NULL){
		PostMessage(hwnd,WM_CLOSE,NULL,NULL);
	}
#endif
	//ドラッグ&ドロップイベントの作成

	// ファイル名の記述に必要なメモリ量を計算
	int size=0;
	for(int i=0;FileNameList[i];i++)
		size+=strlen(FileNameList[i])+1;
	size++;
	HANDLE hMem=GlobalAlloc(GMEM_ZEROINIT,sizeof(DROPFILES)+size);
	char *p=(char *)GlobalLock(hMem);
	DROPFILES *DropFiles=(DROPFILES *)p;
	DropFiles->pFiles=sizeof(*DropFiles);
	DropFiles->pt.x=20;
	DropFiles->pt.y=30;
	DropFiles->fNC=1;
	DropFiles->fWide=0;
	p+=sizeof(*DropFiles);
	for(int i=0;FileNameList[i];i++){
		strcpy(p,FileNameList[i]);
		p+=strlen(p)+1;
	}
	*p='\0';
	GlobalUnlock(hMem);
    PostMessage(hwnd,WM_DROPFILES,(WPARAM)hMem,0);

    return 0;
}
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。