fixes for vs

This commit is contained in:
arturoc 2013-07-12 17:34:02 +02:00
parent 931097811c
commit 11cb59cc35
3 changed files with 21 additions and 15 deletions

View File

@ -209,6 +209,9 @@ int _glfwPlatformInit(void)
if (!_glfwInitContextAPI()) if (!_glfwInitContextAPI())
return GL_FALSE; return GL_FALSE;
_glfw.win32.dropString = (char*)malloc(1000);
_glfw.win32.dropStringSize = 1000;
_glfwInitTimer(); _glfwInitTimer();
_glfwInitJoysticks(); _glfwInitJoysticks();

View File

@ -168,6 +168,7 @@ typedef struct _GLFWlibraryWin32
DWORD foregroundLockTimeout; DWORD foregroundLockTimeout;
char* clipboardString; char* clipboardString;
char* dropString; char* dropString;
int dropStringSize;
// Timer data // Timer data
struct { struct {

View File

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h> #include <malloc.h>
#include <Windows.h>
#include <windowsx.h> #include <windowsx.h>
#include <Shellapi.h> #include <Shellapi.h>
@ -718,31 +719,32 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
} }
case WM_DROPFILES: case WM_DROPFILES:
{ {
TCHAR szName[MAX_PATH]; TCHAR szName[MAX_PATH];
HDROP hDrop = (HDROP)wParam; HDROP hDrop = (HDROP)wParam;
POINT pt; POINT pt;
int numFiles = DragQueryFile(hDrop, 0xFFFFFFFF, szName, MAX_PATH);
int currentSize = 1;
int i;
char* utf8str;
DragQueryPoint(hDrop, &pt); DragQueryPoint(hDrop, &pt);
// Move the mouse to the position of the drop // Move the mouse to the position of the drop
_glfwInputCursorMotion(window,pt.x,pt.y); _glfwInputCursorMotion(window,pt.x,pt.y);
// Retrieve the names of the dropped objects memset(_glfw.win32.dropString, 0, _glfw.win32.dropStringSize);
int count = DragQueryFile(hDrop, 0xFFFFFFFF, szName, MAX_PATH); for(i = 0; i < numFiles; i++)
char s[MAX_PATH*count];
s[0] = 0;
int i;
for(i = 0; i < count; i++)
{ {
DragQueryFile(hDrop, i, szName, MAX_PATH); DragQueryFile(hDrop, i, szName, MAX_PATH);
char* utf8str = _glfwCreateUTF8FromWideString((const wchar_t*)szName); utf8str = _glfwCreateUTF8FromWideString((const wchar_t*)szName);
strcat(s, utf8str); currentSize += strlen(utf8str);
strcat(s, "\n"); if(_glfw.win32.dropStringSize < currentSize){
_glfw.win32.dropStringSize *= 2;
_glfw.win32.dropString = (char*)realloc(_glfw.win32.dropString,_glfw.win32.dropStringSize);
}
strcat(_glfw.win32.dropString, utf8str);
strcat(_glfw.win32.dropString, "\n");
free(utf8str); free(utf8str);
} }
free(_glfw.win32.dropString);
_glfw.win32.dropString = strdup(s);
free(s);
_glfwInputDrop(window,_glfw.win32.dropString); _glfwInputDrop(window,_glfw.win32.dropString);
DragFinish(hDrop); DragFinish(hDrop);