add GFX2_Get_Window_Handle() to get the win32 HWND
and use it
This commit is contained in:
parent
b6dec6d3f7
commit
cb2d479867
@ -25,10 +25,6 @@
|
||||
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||
#include <SDL_syswm.h>
|
||||
#endif
|
||||
|
||||
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
|
||||
#include <proto/dos.h>
|
||||
#include <sys/types.h>
|
||||
@ -95,21 +91,11 @@ byte Native_filesel(byte load)
|
||||
#if WIN32
|
||||
OPENFILENAME ofn;
|
||||
char szFileName[MAX_PATH] = "";
|
||||
HWND hwnd;
|
||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||
SDL_SysWMinfo wminfo;
|
||||
|
||||
SDL_VERSION(&wminfo.version);
|
||||
SDL_GetWMInfo(&wminfo);
|
||||
hwnd = wminfo.window;
|
||||
#else
|
||||
hwnd = GetActiveWindow();
|
||||
#endif
|
||||
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = hwnd;
|
||||
ofn.hwndOwner = GFX2_Get_Window_Handle();
|
||||
ofn.lpstrFilter = TEXT("Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0");
|
||||
#ifdef UNICODE
|
||||
#else
|
||||
|
||||
16
src/init.c
16
src/init.c
@ -52,9 +52,6 @@
|
||||
#if defined(WIN32)
|
||||
#include <windows.h> // GetLogicalDrives(), GetDriveType(), DRIVE_*
|
||||
#endif
|
||||
#if !defined(__GP2X__) && defined(USE_SDL)
|
||||
#include <SDL_syswm.h>
|
||||
#endif
|
||||
#if defined (__MINT__)
|
||||
#include <mint/osbind.h>
|
||||
#endif
|
||||
@ -85,6 +82,7 @@
|
||||
#include "mountlist.h" // read_file_system_list
|
||||
#include "operatio.h"
|
||||
#include "palette.h"
|
||||
#include "screen.h"
|
||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||
#include "sdlscreen.h"
|
||||
#endif
|
||||
@ -3112,9 +3110,6 @@ void Define_icon(void)
|
||||
LPVOID lpResIcon32;
|
||||
HGLOBAL hMem;
|
||||
WORD nID;
|
||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||
SDL_SysWMinfo info;
|
||||
#endif
|
||||
|
||||
hInstance = (HINSTANCE)GetModuleHandle(NULL);
|
||||
if (hInstance==NULL)
|
||||
@ -3136,11 +3131,6 @@ void Define_icon(void)
|
||||
if (lpResIconDir==NULL)
|
||||
break;
|
||||
|
||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||
SDL_VERSION(&info.version);
|
||||
SDL_GetWMInfo(&info);
|
||||
#endif
|
||||
|
||||
//
|
||||
// 16x16
|
||||
//
|
||||
@ -3175,7 +3165,7 @@ void Define_icon(void)
|
||||
|
||||
// Set it
|
||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||
SetClassLongPtr(info.window, GCL_HICONSM, (LONG_PTR)hicon);
|
||||
SetClassLongPtr(GFX2_Get_Window_Handle(), GCL_HICONSM, (LONG_PTR)hicon);
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
@ -3215,7 +3205,7 @@ void Define_icon(void)
|
||||
|
||||
// Set it
|
||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||
SetClassLongPtr(info.window, GCL_HICON, (LONG_PTR)hicon);
|
||||
SetClassLongPtr(GFX2_Get_Window_Handle(), GCL_HICON, (LONG_PTR)hicon);
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
|
||||
39
src/main.c
39
src/main.c
@ -45,11 +45,18 @@
|
||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||
#include <SDL.h>
|
||||
#include <SDL_image.h>
|
||||
|
||||
// There is no WM on the GP2X...
|
||||
#if !defined(__GP2X__) && !defined(__WIZ__) && !defined(__CAANOO__) && !defined(GCWZERO)
|
||||
#include <SDL_syswm.h>
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
#include <shlwapi.h>
|
||||
#elif defined (__MINT__)
|
||||
#include <mint/osbind.h>
|
||||
#elif defined(__macosx__)
|
||||
#import <CoreFoundation/CoreFoundation.h>
|
||||
#import <sys/param.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include "const.h"
|
||||
@ -80,18 +87,6 @@
|
||||
#include "win32screen.h"
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
#include <shlwapi.h>
|
||||
#elif defined (__MINT__)
|
||||
#include <mint/osbind.h>
|
||||
#elif defined(__macosx__)
|
||||
#import <CoreFoundation/CoreFoundation.h>
|
||||
#import <sys/param.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (WIN32) && (defined(USE_SDL) || defined(USE_SDL2))
|
||||
// On Windows, SDL_putenv is not present in any compilable header.
|
||||
@ -859,11 +854,8 @@ int Init_program(int argc,char * argv[])
|
||||
{
|
||||
//RECT r;
|
||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||
static SDL_SysWMinfo pInfo;
|
||||
SDL_VERSION(&pInfo.version);
|
||||
SDL_GetWMInfo(&pInfo);
|
||||
//GetWindowRect(pInfo.window, &r);
|
||||
SetWindowPos(pInfo.window, 0, Config.Window_pos_x, Config.Window_pos_y, 0, 0, SWP_NOSIZE);
|
||||
//GetWindowRect(window, &r);
|
||||
SetWindowPos(GFX2_Get_Window_Handle(), 0, Config.Window_pos_x, Config.Window_pos_y, 0, 0, SWP_NOSIZE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -1071,10 +1063,7 @@ void Program_shutdown(void)
|
||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||
{
|
||||
RECT r;
|
||||
static SDL_SysWMinfo pInfo;
|
||||
|
||||
SDL_GetWMInfo(&pInfo);
|
||||
GetWindowRect(pInfo.window, &r);
|
||||
GetWindowRect(GFX2_Get_Window_Handle(), &r);
|
||||
|
||||
Config.Window_pos_x = r.left;
|
||||
Config.Window_pos_y = r.top;
|
||||
|
||||
@ -47,9 +47,6 @@
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#if defined(USE_SDL)
|
||||
#include <SDL_syswm.h>
|
||||
#endif
|
||||
|
||||
#elif defined __HAIKU__
|
||||
#include "haiku.h"
|
||||
@ -307,18 +304,7 @@ static char* getClipboard(word * * unicode)
|
||||
{
|
||||
#ifdef WIN32
|
||||
char* dst = NULL;
|
||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||
SDL_SysWMinfo info;
|
||||
|
||||
SDL_VERSION(&info.version);
|
||||
|
||||
if ( SDL_GetWMInfo(&info) )
|
||||
{
|
||||
if (OpenClipboard(info.window) )
|
||||
#else
|
||||
{
|
||||
if (OpenClipboard(GetActiveWindow()))
|
||||
#endif
|
||||
if (OpenClipboard(GFX2_Get_Window_Handle()))
|
||||
{
|
||||
HANDLE hMem;
|
||||
if ( IsClipboardFormatAvailable(CF_TEXT) )
|
||||
@ -346,7 +332,6 @@ static char* getClipboard(word * * unicode)
|
||||
}
|
||||
CloseClipboard();
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
#elif defined(__AROS__)
|
||||
|
||||
|
||||
@ -29,6 +29,9 @@
|
||||
#ifndef SCREEN_H_INCLUDED
|
||||
#define SCREEN_H_INCLUDED
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h> // for HWND
|
||||
#endif
|
||||
#include "struct.h"
|
||||
#include "global.h"
|
||||
|
||||
@ -63,4 +66,8 @@ void Allow_drag_and_drop(int flag);
|
||||
void GFX2_UpdateScreen(void);
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
HWND GFX2_Get_Window_Handle(void);
|
||||
#endif
|
||||
|
||||
#endif // SCREEN_H_INCLUDED
|
||||
|
||||
@ -502,18 +502,23 @@ void Clear_border(byte color)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
HWND GFX2_Get_Window_Handle(void)
|
||||
{
|
||||
SDL_SysWMinfo wminfo;
|
||||
|
||||
SDL_VERSION(&wminfo.version);
|
||||
SDL_GetWMInfo(&wminfo);
|
||||
return wminfo.window;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Activates or desactivates file drag-dropping in program window.
|
||||
void Allow_drag_and_drop(int flag)
|
||||
{
|
||||
// Inform Windows that we accept drag-n-drop events or not
|
||||
#ifdef __WIN32__
|
||||
SDL_SysWMinfo wminfo;
|
||||
HWND hwnd;
|
||||
|
||||
SDL_VERSION(&wminfo.version);
|
||||
SDL_GetWMInfo(&wminfo);
|
||||
hwnd = wminfo.window;
|
||||
DragAcceptFiles(hwnd,flag?TRUE:FALSE);
|
||||
DragAcceptFiles(GFX2_Get_Window_Handle(), flag?TRUE:FALSE);
|
||||
SDL_EventState (SDL_SYSWMEVENT,flag?SDL_ENABLE:SDL_DISABLE );
|
||||
#else
|
||||
(void)flag; // unused
|
||||
|
||||
@ -44,6 +44,11 @@ static int Windows_DIB_height = 0;
|
||||
static HWND Win32_hwnd = NULL;
|
||||
static int Win32_Is_Fullscreen = 0;
|
||||
|
||||
HWND GFX2_Get_Window_Handle()
|
||||
{
|
||||
return Win32_hwnd;
|
||||
}
|
||||
|
||||
static void Win32_Repaint(HWND hwnd)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
@ -421,4 +426,5 @@ volatile int Allow_colorcycling = 0;
|
||||
/// Activates or desactivates file drag-dropping in program window.
|
||||
void Allow_drag_and_drop(int flag)
|
||||
{
|
||||
DragAcceptFiles(GFX2_Get_Window_Handle(), flag?TRUE:FALSE);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user