mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-02-03 12:31:15 +00:00
Try making miniwin compatible with qt6 on mingw
This commit is contained in:
parent
0fc5c8e79a
commit
9a1492527b
@ -511,11 +511,11 @@ MxResult IsleApp::SetupWindow()
|
|||||||
SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, WINDOW_TITLE);
|
SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, WINDOW_TITLE);
|
||||||
|
|
||||||
window = SDL_CreateWindowWithProperties(props);
|
window = SDL_CreateWindowWithProperties(props);
|
||||||
#ifndef MINIWIN
|
#ifdef MINIWIN
|
||||||
|
m_windowHandle = reinterpret_cast<HWND>(window);
|
||||||
|
#else
|
||||||
m_windowHandle =
|
m_windowHandle =
|
||||||
(HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
(HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||||
#else
|
|
||||||
m_windowHandle = window;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_DestroyProperties(props);
|
SDL_DestroyProperties(props);
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
add_library(miniwin STATIC EXCLUDE_FROM_ALL
|
add_library(miniwin STATIC EXCLUDE_FROM_ALL
|
||||||
# Core
|
# Core
|
||||||
src/windows/windows.cpp
|
src/windows/windows.cpp
|
||||||
src/mfc/mfc.cpp
|
|
||||||
|
|
||||||
# DDraw
|
# DDraw
|
||||||
src/ddraw/ddraw.cpp
|
src/ddraw/ddraw.cpp
|
||||||
@ -136,16 +135,3 @@ if(ISLE_COMPILE_SHADERS)
|
|||||||
DEPENDS "${py_gencshadersource}" ${shader_headers} ${shader_jsons})
|
DEPENDS "${py_gencshadersource}" ${shader_headers} ${shader_jsons})
|
||||||
endif()
|
endif()
|
||||||
target_sources(miniwin PRIVATE "${index}" "${index_cpp}")
|
target_sources(miniwin PRIVATE "${index}" "${index_cpp}")
|
||||||
|
|
||||||
# Minimfc lib
|
|
||||||
add_library(minimfc STATIC EXCLUDE_FROM_ALL
|
|
||||||
src/mfc/mfc.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(minimfc
|
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/internal
|
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_definitions(minimfc PUBLIC MINIMFC)
|
|
||||||
target_link_libraries(minimfc PRIVATE SDL3::SDL3 miniwin)
|
|
||||||
|
|||||||
@ -1,304 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "miniwin/windows.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// --- Defines and Macros ---
|
|
||||||
|
|
||||||
// Remove WinAPI stuff
|
|
||||||
#define BEGIN_MESSAGE_MAP(class_name, base_class_name)
|
|
||||||
#define DECLARE_MESSAGE_MAP()
|
|
||||||
#ifndef __cdecl
|
|
||||||
#define __cdecl
|
|
||||||
#endif
|
|
||||||
#define END_MESSAGE_MAP()
|
|
||||||
#define ON_COMMAND(id, func)
|
|
||||||
#define ON_LBN_SELCHANGE(id, func)
|
|
||||||
#define ON_WM_DESTROY()
|
|
||||||
#define ON_WM_PAINT()
|
|
||||||
#define ON_WM_QUERYDRAGICON()
|
|
||||||
#define ON_WM_SYSCOMMAND()
|
|
||||||
|
|
||||||
#define FAILED(hr) (((HRESULT) (hr)) < 0)
|
|
||||||
#define InterlockedIncrement(x) __sync_add_and_fetch(x, 1)
|
|
||||||
#define HKEY_LOCAL_MACHINE ((HKEY) 0x80000002)
|
|
||||||
#define LOWORD(l) ((WORD) (((DWORD_PTR) (l)) & 0xffff))
|
|
||||||
#define MAKEINTRESOURCE(i) (reinterpret_cast<LPCTSTR>((ULONG_PTR) ((WORD) (i))))
|
|
||||||
|
|
||||||
#define ICON_BIG 1
|
|
||||||
#define ICON_SMALL 0
|
|
||||||
|
|
||||||
#define KEY_READ 0x20019
|
|
||||||
#define KEY_WRITE 0x20006
|
|
||||||
|
|
||||||
#define LB_ADDSTRING 0x180
|
|
||||||
#define LB_GETCURSEL 0x0188
|
|
||||||
#define LB_SETCURSEL 0x185
|
|
||||||
|
|
||||||
#define MF_SEPARATOR 0x80000000
|
|
||||||
#define MF_STRING 0x00000000
|
|
||||||
|
|
||||||
#define SM_CXICON 11
|
|
||||||
#define SM_CYICON 12
|
|
||||||
|
|
||||||
#define WM_ICONERASEBKGND 0x0027
|
|
||||||
#define WM_SETICON 0x804
|
|
||||||
|
|
||||||
#define ERROR_SUCCESS 0
|
|
||||||
#define GENERIC_READ 0x80000000L
|
|
||||||
#define OPEN_EXISTING 3
|
|
||||||
#define REG_SZ 1
|
|
||||||
#define RT_GROUP_ICON 0x00000007
|
|
||||||
#define SW_RESTORE 9
|
|
||||||
|
|
||||||
// --- Typedefs ---
|
|
||||||
typedef char CHAR;
|
|
||||||
typedef BYTE* LPBYTE;
|
|
||||||
typedef char* LPTSTR;
|
|
||||||
typedef const char* LPCTSTR;
|
|
||||||
typedef intptr_t INT_PTR, *PINT_PTR;
|
|
||||||
typedef uintptr_t UINT_PTR, *PUINT_PTR;
|
|
||||||
typedef intptr_t LONG_PTR, *PLONG_PTR;
|
|
||||||
typedef uintptr_t ULONG_PTR, *PULONG_PTR;
|
|
||||||
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
|
||||||
typedef UINT_PTR WPARAM;
|
|
||||||
typedef LONG_PTR LPARAM, LRESULT;
|
|
||||||
typedef HKEY* PHKEY;
|
|
||||||
typedef BITMAPINFO* LPBITMAPINFO;
|
|
||||||
typedef GUID REFIID;
|
|
||||||
|
|
||||||
// --- Structs ---
|
|
||||||
struct OSVERSIONINFOA {
|
|
||||||
DWORD dwOSVersionInfoSize;
|
|
||||||
DWORD dwMajorVersion;
|
|
||||||
DWORD dwBuildNumber;
|
|
||||||
DWORD dwPlatformId;
|
|
||||||
};
|
|
||||||
typedef struct IUnknown* LPUNKNOWN;
|
|
||||||
|
|
||||||
struct CWnd {
|
|
||||||
HWND m_hWnd;
|
|
||||||
void EnableWindow(bool bEnable);
|
|
||||||
void SetWindowText(const char* text);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CDataExchange {
|
|
||||||
bool m_bSaveAndValidate;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CDialog {
|
|
||||||
HWND m_hWnd;
|
|
||||||
int m_nIDTemplate;
|
|
||||||
CWnd* m_pParentWnd;
|
|
||||||
CDialog();
|
|
||||||
CDialog(int nIDTemplate);
|
|
||||||
CDialog(int nIDTemplate, CWnd* pParent);
|
|
||||||
virtual BOOL OnInitDialog();
|
|
||||||
void OnCancel();
|
|
||||||
virtual void OnOK();
|
|
||||||
virtual void DoModal();
|
|
||||||
virtual void Default();
|
|
||||||
virtual void EndDialog(int nResult);
|
|
||||||
virtual void DoDataExchange(CDataExchange* pDX);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CPaintDC {
|
|
||||||
void* m_hDC;
|
|
||||||
CPaintDC(CDialog* hWnd);
|
|
||||||
void Draw();
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CMenu {
|
|
||||||
void* m_hMenu;
|
|
||||||
CMenu() : m_hMenu(nullptr) {}
|
|
||||||
static CMenu* FromHandle(void* hMenu)
|
|
||||||
{
|
|
||||||
CMenu* pMenu = new CMenu();
|
|
||||||
pMenu->m_hMenu = hMenu;
|
|
||||||
return pMenu;
|
|
||||||
}
|
|
||||||
bool InsertMenu(UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCTSTR lpszNewItem);
|
|
||||||
bool RemoveMenu(UINT uPosition, UINT uFlags);
|
|
||||||
bool SetMenuItemInfo(UINT uIDItem, const void* pMenuItemInfo, bool fByPosition = false);
|
|
||||||
int GetMenuItemCount() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CWinApp {
|
|
||||||
CWinApp();
|
|
||||||
~CWinApp() = default;
|
|
||||||
virtual BOOL InitInstance() = 0;
|
|
||||||
virtual int ExitInstance();
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MEMORYSTATUS {
|
|
||||||
DWORD dwLength;
|
|
||||||
DWORD dwTotalPhys;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CCommandLineInfo {
|
|
||||||
virtual void ParseParam(LPCSTR pszParam, BOOL bFlag, BOOL bLast) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- Classs ---
|
|
||||||
class CString {
|
|
||||||
public:
|
|
||||||
CString(const char* str = "") : m_str(str) {}
|
|
||||||
void LoadString(int str) {}
|
|
||||||
operator const char*() const { return m_str; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char* m_str;
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- Functions ---
|
|
||||||
inline WINBOOL WINAPI SetForegroundWindow(HWND hWnd)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL ShowWindow(HWND hWnd, int nCmdShow)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL SetWindowPos(CWinApp** hWnd, int X, int Y, int cx, int cy, UINT uFlags)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL GetWindowRect(HWND hDlg, struct RECT* Rect);
|
|
||||||
|
|
||||||
inline BOOL GetClientRect(LPRECT lpRect)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL IsIconic()
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int GetSystemMetrics(int nIndex)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL GetVersionEx(OSVERSIONINFOA* version);
|
|
||||||
|
|
||||||
void GlobalMemoryStatus(MEMORYSTATUS* memory_status);
|
|
||||||
|
|
||||||
inline BOOL DrawIcon(HDC hdc, int x, int y, HICON hIcon)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool AppendMenu(void* menu, UINT uFlags, UINT_PTR uIDNewItem, LPCTSTR lpszNewItem)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LSTATUS RegOpenKeyEx(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LSTATUS RegQueryValueEx(
|
|
||||||
HKEY hKey,
|
|
||||||
LPCSTR lpValueName,
|
|
||||||
LPDWORD lpReserved,
|
|
||||||
LPDWORD lpType,
|
|
||||||
BYTE* lpData,
|
|
||||||
LPDWORD lpcbData
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LSTATUS RegCloseKey(HKEY hKey)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LSTATUS RegSetValueEx(
|
|
||||||
HKEY hKey,
|
|
||||||
LPCSTR lpValueName,
|
|
||||||
DWORD Reserved,
|
|
||||||
DWORD dwType,
|
|
||||||
const BYTE* lpData,
|
|
||||||
DWORD cbData
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LSTATUS RegCreateKeyEx(
|
|
||||||
HKEY hKey,
|
|
||||||
LPCSTR lpSubKey,
|
|
||||||
DWORD Reserved,
|
|
||||||
const char* lpClass,
|
|
||||||
DWORD dwOptions,
|
|
||||||
REGSAM samDesired,
|
|
||||||
void* lpSecurityAttributes,
|
|
||||||
PHKEY phkResult,
|
|
||||||
LPDWORD lpdwDisposition
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputDebugString(const char* lpOutputString);
|
|
||||||
|
|
||||||
void* GetProcAddress(HMODULE module, const char* name);
|
|
||||||
|
|
||||||
int miniwin_stricmp(const char* str1, const char* str2);
|
|
||||||
#define _stricmp miniwin_stricmp
|
|
||||||
|
|
||||||
HICON LoadIcon(HINSTANCE hInstance, LPCSTR lpIconName);
|
|
||||||
|
|
||||||
int lstrcmpi(LPCSTR lpString1, LPCSTR lpString2);
|
|
||||||
|
|
||||||
HINSTANCE AfxFindResourceHandle(LPCTSTR lpszResourceName, int lpszResourceType);
|
|
||||||
|
|
||||||
HMODULE LoadLibrary(const char* name);
|
|
||||||
|
|
||||||
int FreeLibrary(void* hModule);
|
|
||||||
|
|
||||||
HMENU GetSystemMenu(HWND hWnd, bool bRevert);
|
|
||||||
|
|
||||||
HWND WINAPI FindWindow(LPCSTR lpClassName, LPCSTR lpWindowName);
|
|
||||||
|
|
||||||
LRESULT SendMessage(UINT Msg, WPARAM wParam, LPARAM lParam);
|
|
||||||
|
|
||||||
LRESULT SendMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
|
||||||
|
|
||||||
BOOL IsDlgButtonChecked(int nIDButton);
|
|
||||||
|
|
||||||
CWnd* GetDlgItem(int id);
|
|
||||||
|
|
||||||
BOOL OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam);
|
|
||||||
|
|
||||||
BOOL CheckRadioButton(int nIDFirstButton, int nIDLastButton, int nIDCheckButton);
|
|
||||||
|
|
||||||
BOOL CheckDlgButton(int nIDButton, BOOL uCheck);
|
|
||||||
|
|
||||||
void Enable3dControls();
|
|
||||||
|
|
||||||
void ParseCommandLine(CCommandLineInfo& cmdInfo);
|
|
||||||
|
|
||||||
struct AFX_MODULE_STATE {
|
|
||||||
CWinApp* m_pCurrentWinApp;
|
|
||||||
};
|
|
||||||
extern char* afxCurrentAppName;
|
|
||||||
extern CWinApp* wndTop;
|
|
||||||
extern AFX_MODULE_STATE g_CustomModuleState;
|
|
||||||
#define afxCurrentWinApp AfxGetModuleState()->m_pCurrentWinApp
|
|
||||||
inline AFX_MODULE_STATE* AfxGetModuleState()
|
|
||||||
{
|
|
||||||
g_CustomModuleState.m_pCurrentWinApp = wndTop;
|
|
||||||
return &g_CustomModuleState;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AfxMessageBox(const char* message);
|
|
||||||
@ -60,7 +60,8 @@
|
|||||||
// --- Typedefs ---
|
// --- Typedefs ---
|
||||||
typedef uint8_t BYTE, byte;
|
typedef uint8_t BYTE, byte;
|
||||||
typedef int32_t LONG;
|
typedef int32_t LONG;
|
||||||
typedef uint32_t ULONG, DWORD, HRESULT;
|
typedef uint32_t ULONG, DWORD;
|
||||||
|
typedef long HRESULT;
|
||||||
typedef DWORD* LPDWORD;
|
typedef DWORD* LPDWORD;
|
||||||
typedef int BOOL, WINBOOL, INT;
|
typedef int BOOL, WINBOOL, INT;
|
||||||
typedef unsigned int UINT;
|
typedef unsigned int UINT;
|
||||||
@ -70,10 +71,16 @@ typedef void* LPVOID;
|
|||||||
typedef char* LPSTR;
|
typedef char* LPSTR;
|
||||||
typedef const char* LPCSTR;
|
typedef const char* LPCSTR;
|
||||||
typedef void* HANDLE;
|
typedef void* HANDLE;
|
||||||
typedef HANDLE HICON, HFONT;
|
typedef struct HICON__* HICON;
|
||||||
|
typedef struct HFONT__* HFONT;
|
||||||
typedef struct HINSTANCE__* HINSTANCE;
|
typedef struct HINSTANCE__* HINSTANCE;
|
||||||
typedef SDL_Window *HMENU, *HWND;
|
typedef struct HMENU__* HMENU;
|
||||||
typedef HANDLE HMODULE, HDC, HPALETTE, HFILE, HCURSOR;
|
typedef struct HWND__* HWND;
|
||||||
|
typedef HINSTANCE HMODULE;
|
||||||
|
typedef struct HDC__* HDC;
|
||||||
|
typedef struct HPALETTE__* HPALETTE;
|
||||||
|
typedef struct HCURSOR__* HCURSOR;
|
||||||
|
typedef HANDLE HFILE;
|
||||||
typedef int LSTATUS, HKEY, REGSAM;
|
typedef int LSTATUS, HKEY, REGSAM;
|
||||||
|
|
||||||
// --- Structs ---
|
// --- Structs ---
|
||||||
|
|||||||
@ -279,7 +279,8 @@ HRESULT DirectDrawImpl::RestoreDisplayMode()
|
|||||||
|
|
||||||
HRESULT DirectDrawImpl::SetCooperativeLevel(HWND hWnd, DDSCLFlags dwFlags)
|
HRESULT DirectDrawImpl::SetCooperativeLevel(HWND hWnd, DDSCLFlags dwFlags)
|
||||||
{
|
{
|
||||||
if (hWnd) {
|
SDL_Window* sdlWindow = reinterpret_cast<SDL_Window*>(hWnd);
|
||||||
|
if (sdlWindow) {
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
if ((dwFlags & DDSCL_NORMAL) == DDSCL_NORMAL) {
|
if ((dwFlags & DDSCL_NORMAL) == DDSCL_NORMAL) {
|
||||||
fullscreen = false;
|
fullscreen = false;
|
||||||
@ -291,10 +292,10 @@ HRESULT DirectDrawImpl::SetCooperativeLevel(HWND hWnd, DDSCLFlags dwFlags)
|
|||||||
return DDERR_INVALIDPARAMS;
|
return DDERR_INVALIDPARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SDL_SetWindowFullscreen(hWnd, fullscreen)) {
|
if (!SDL_SetWindowFullscreen(sdlWindow, fullscreen)) {
|
||||||
return DDERR_GENERIC;
|
return DDERR_GENERIC;
|
||||||
}
|
}
|
||||||
DDWindow = hWnd;
|
DDWindow = sdlWindow;
|
||||||
}
|
}
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,332 +0,0 @@
|
|||||||
#include "miniwin/mfc.h"
|
|
||||||
|
|
||||||
#include "miniwin.h"
|
|
||||||
|
|
||||||
#include <SDL3/SDL.h>
|
|
||||||
#include <SDL3/SDL_main.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
char* afxCurrentAppName;
|
|
||||||
AFX_MODULE_STATE g_CustomModuleState;
|
|
||||||
CWinApp* wndTop;
|
|
||||||
|
|
||||||
SDL_Window* window;
|
|
||||||
const char* title = "Configure LEGO Island";
|
|
||||||
|
|
||||||
void CWnd::EnableWindow(bool bEnable)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
void CWnd::SetWindowText(const char* text)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
CDialog::CDialog() : m_nIDTemplate(0), m_pParentWnd(nullptr)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
CDialog::CDialog(int nIDTemplate) : m_nIDTemplate(nIDTemplate), m_pParentWnd(nullptr)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
CDialog::CDialog(int nIDTemplate, CWnd* pParent) : m_nIDTemplate(nIDTemplate), m_pParentWnd(pParent)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CDialog::OnInitDialog()
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDialog::OnCancel()
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDialog::OnOK()
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDialog::DoModal()
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDialog::Default()
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDialog::EndDialog(int nResult)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDialog::DoDataExchange(CDataExchange* pDX)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
CPaintDC::CPaintDC(CDialog* hWnd)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMenu::InsertMenu(UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCTSTR lpszNewItem)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMenu::RemoveMenu(UINT uPosition, UINT uFlags)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMenu::SetMenuItemInfo(UINT uIDItem, const void* pMenuItemInfo, bool fByPosition)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CMenu::GetMenuItemCount() const
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CPaintDC::Draw()
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
CWinApp::CWinApp()
|
|
||||||
{
|
|
||||||
if (wndTop != NULL) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "There can only be one CWinApp!");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
wndTop = this;
|
|
||||||
|
|
||||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK)) {
|
|
||||||
SDL_Log("SDL_Init: %s\n", SDL_GetError());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
window = SDL_CreateWindow(title, 640, 480, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CWinApp::ExitInstance()
|
|
||||||
{
|
|
||||||
SDL_Quit();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char* get_base_filename(const char* path)
|
|
||||||
{
|
|
||||||
for (;;) {
|
|
||||||
const char* next = SDL_strpbrk(path, "/\\");
|
|
||||||
if (next == NULL) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
path = next + 1;
|
|
||||||
}
|
|
||||||
const char* end = SDL_strchr(path, '.');
|
|
||||||
size_t len;
|
|
||||||
if (end == NULL) {
|
|
||||||
len = SDL_strlen(path);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
len = end - path;
|
|
||||||
}
|
|
||||||
char* filename = new char[len + 1];
|
|
||||||
SDL_memcpy(filename, path, len);
|
|
||||||
filename[len] = '\0';
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
afxCurrentAppName = get_base_filename(argv[0]);
|
|
||||||
if (wndTop == NULL) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No CWinApp created");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
wndTop->InitInstance();
|
|
||||||
|
|
||||||
SDL_Event event;
|
|
||||||
bool running = true;
|
|
||||||
while (running) {
|
|
||||||
while (SDL_PollEvent(&event)) {
|
|
||||||
if (event.type == SDL_EVENT_QUIT) {
|
|
||||||
running = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Delay(16); // 60 FPS
|
|
||||||
}
|
|
||||||
|
|
||||||
int result = wndTop->ExitInstance();
|
|
||||||
delete[] afxCurrentAppName;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AfxMessageBox(const char* message)
|
|
||||||
{
|
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL GetWindowRect(HWND hWnd, RECT* Rect)
|
|
||||||
{
|
|
||||||
int x, y, w, h;
|
|
||||||
if (!Rect) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (hWnd == NULL) {
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
SDL_GetWindowPosition(hWnd, &x, &y);
|
|
||||||
SDL_GetWindowSize(hWnd, &w, &h);
|
|
||||||
|
|
||||||
Rect->right = x;
|
|
||||||
Rect->top = y;
|
|
||||||
Rect->left = w + x;
|
|
||||||
Rect->bottom = h + y;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL GetVersionEx(OSVERSIONINFOA* version)
|
|
||||||
{
|
|
||||||
version->dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
|
|
||||||
version->dwMajorVersion = 5; // Win2k/XP
|
|
||||||
version->dwPlatformId = 2; // NT
|
|
||||||
version->dwBuildNumber = 0x500;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputDebugString(const char* lpOutputString)
|
|
||||||
{
|
|
||||||
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "%s", lpOutputString);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* GetProcAddress(HMODULE module, const char* name)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int miniwin_stricmp(const char* str1, const char* str2)
|
|
||||||
{
|
|
||||||
return SDL_strcasecmp(str1, str2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalMemoryStatus(MEMORYSTATUS* memory_status)
|
|
||||||
{
|
|
||||||
memory_status->dwLength = sizeof(*memory_status);
|
|
||||||
memory_status->dwTotalPhys = 1024 * SDL_GetSystemRAM();
|
|
||||||
}
|
|
||||||
|
|
||||||
HICON LoadIcon(HINSTANCE hInstance, LPCSTR lpIconName)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int lstrcmpi(LPCSTR lpString1, LPCSTR lpString2)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
HINSTANCE AfxFindResourceHandle(LPCTSTR lpszResourceName, int lpszResourceType)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
HMODULE LoadLibrary(const char* name)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int FreeLibrary(void* hModule)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
HMENU GetSystemMenu(HWND hWnd, bool bRevert)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
assert(false && "Needs implementation");
|
|
||||||
return reinterpret_cast<HMENU>(0x1234);
|
|
||||||
}
|
|
||||||
|
|
||||||
HWND WINAPI FindWindow(LPCSTR lpClassName, LPCSTR lpWindowName)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT SendMessage(UINT Msg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT SendMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL IsDlgButtonChecked(int nIDButton)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CWnd* GetDlgItem(int id)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return new CWnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CheckRadioButton(int nIDFirstButton, int nIDLastButton, int nIDCheckButton)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CheckDlgButton(int nIDButton, BOOL uCheck)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Enable3dControls()
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParseCommandLine(CCommandLineInfo& cmdInfo)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
}
|
|
||||||
@ -36,17 +36,18 @@ BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy,
|
|||||||
if (!hWnd) {
|
if (!hWnd) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
SDL_Window* sdlWindow = reinterpret_cast<SDL_Window*>(hWnd);
|
||||||
|
|
||||||
if (!(uFlags & SWP_NOACTIVATE)) {
|
if (!(uFlags & SWP_NOACTIVATE)) {
|
||||||
SDL_RaiseWindow(hWnd);
|
SDL_RaiseWindow(sdlWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(uFlags & SWP_NOSIZE)) {
|
if (!(uFlags & SWP_NOSIZE)) {
|
||||||
SDL_SetWindowSize(hWnd, cx, cy);
|
SDL_SetWindowSize(sdlWindow, cx, cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(uFlags & SWP_NOMOVE)) {
|
if (!(uFlags & SWP_NOMOVE)) {
|
||||||
SDL_SetWindowPosition(hWnd, X, Y);
|
SDL_SetWindowPosition(sdlWindow, X, Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -181,8 +182,9 @@ int StretchDIBits(
|
|||||||
|
|
||||||
LONG GetWindowLong(HWND hWnd, int nIndex)
|
LONG GetWindowLong(HWND hWnd, int nIndex)
|
||||||
{
|
{
|
||||||
|
SDL_Window* sdlWindow = reinterpret_cast<SDL_Window*>(hWnd);
|
||||||
if (nIndex == GWL_STYLE) {
|
if (nIndex == GWL_STYLE) {
|
||||||
Uint32 flags = SDL_GetWindowFlags(hWnd);
|
Uint32 flags = SDL_GetWindowFlags(sdlWindow);
|
||||||
LONG style = WS_POPUP;
|
LONG style = WS_POPUP;
|
||||||
if ((flags & SDL_WINDOW_BORDERLESS) == 0) {
|
if ((flags & SDL_WINDOW_BORDERLESS) == 0) {
|
||||||
style = WS_OVERLAPPED | WS_CAPTION;
|
style = WS_OVERLAPPED | WS_CAPTION;
|
||||||
@ -202,9 +204,10 @@ LONG GetWindowLong(HWND hWnd, int nIndex)
|
|||||||
|
|
||||||
LONG SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong)
|
LONG SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong)
|
||||||
{
|
{
|
||||||
|
SDL_Window* sdlWindow = reinterpret_cast<SDL_Window*>(hWnd);
|
||||||
if (nIndex == GWL_STYLE) {
|
if (nIndex == GWL_STYLE) {
|
||||||
SDL_SetWindowBordered(hWnd, (dwNewLong & WS_CAPTION) != 0);
|
SDL_SetWindowBordered(sdlWindow, (dwNewLong & WS_CAPTION) != 0);
|
||||||
SDL_SetWindowResizable(hWnd, (dwNewLong & WS_THICKFRAME) != 0);
|
SDL_SetWindowResizable(sdlWindow, (dwNewLong & WS_THICKFRAME) != 0);
|
||||||
|
|
||||||
return dwNewLong;
|
return dwNewLong;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user