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