#if defined(__WIN32__)
+#undef WINVER
#define WINVER 0x0500
-#define _WIN32_WINNT 0x0500
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0501
#undef JOY_BUTTON1
#undef JOY_BUTTON2
#define Method _Method
#define byte _byte
#define int64 _int64
+#define String _String
+#define Mutex _Mutex
+#define Platform _Platform
#include <windows.h>
+#include <wincon.h>
#include <shellapi.h>
#undef Method
#undef byte
#undef int64
+#undef String
+#undef Mutex
+#undef Platform
import "Window"
'D','F','G','H','J','K','L',VK_SEMI,VK_QUOTE,VK_TILDE,VK_SHIFT,VK_BACK_SLASH,'Z','X','C','V',
'B','N','M',VK_COMMA,VK_PERIOD,VK_DIVIDE,VK_SHIFT,VK_MULTIPLY,VK_LMENU,VK_SPACE,VK_CAPITAL,VK_F1,VK_F2,VK_F3,VK_F4,VK_F5,
VK_F6,VK_F7,VK_F8,VK_F9,VK_F10,VK_NUMLOCK,VK_SCROLL,VK_NUMPAD7,VK_NUMPAD8,VK_NUMPAD9,VK_SUBTRACT,VK_NUMPAD4,VK_NUMPAD5,VK_NUMPAD6,VK_ADD,VK_NUMPAD1,
- VK_NUMPAD2,VK_NUMPAD3,VK_NUMPAD0,VK_DELETE,0,0,0,0,0,0,0,0,0,0,0,0,
+ VK_NUMPAD2,VK_NUMPAD3,VK_NUMPAD0,VK_DELETE,0,0,0,VK_F11,VK_F12,0,0,0,0,0,0,0,
0,0,0,0,0,0,VK_HOME,VK_UP,VK_PRIOR,VK_LEFT,VK_RIGHT,VK_END,VK_DOWN,VK_NEXT,VK_INSERT,VK_DELETE,
0,0,0,VK_SHIFT,VK_MENU,VK_CONTROL
};
if(time - lastAutoHideCheck > 1)
{
APPBARDATA appBarData = { 0 };
- newTaskBarState = SHAppBarMessage(ABM_GETSTATE, &appBarData);
+ newTaskBarState = (int)SHAppBarMessage(ABM_GETSTATE, &appBarData);
lastAutoHideCheck = time;
}
code = key;
}
- if(key != leftShift && key != rightShift && ::GetKeyState(VK_SHIFT) & 0x80000)
- code.shift = true;
- if(key != leftControl && key != rightControl && ::GetKeyState(VK_CONTROL) & 0x80000 && !frenchShift)
- code.ctrl = true;
- if(key != leftAlt && key != rightAlt && ::GetKeyState(VK_MENU) & 0x80000 && !frenchShift)
- code.alt = true;
-
if(msg == WM_MOUSEWHEEL)
{
+ if(::GetAsyncKeyState(VK_SHIFT) & 0x80000)
+ code.ctrl = true;
+ if(::GetAsyncKeyState(VK_CONTROL) & 0x80000)
+ code.ctrl = true;
+ if(::GetAsyncKeyState(VK_MENU) & 0x80000)
+ code.alt = true;
+
result = window.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit, code, 0);
}
else
{
+ if(key != leftShift && key != rightShift && ::GetKeyState(VK_SHIFT) & 0x80000)
+ code.shift = true;
+ if(key != leftControl && key != rightControl && ::GetKeyState(VK_CONTROL) & 0x80000 && !frenchShift)
+ code.ctrl = true;
+ if(key != leftAlt && key != rightAlt && ::GetKeyState(VK_MENU) & 0x80000 && !frenchShift)
+ code.alt = true;
/*
byte ch = Interface::TranslateKeykey, code.shift);
if(::GetKeyState(VK_CAPITAL))
// --- Window procedure ---
DWORD CALLBACK ::ApplicationWindow(HWND windowHandle, UINT msg, WPARAM wParam, LPARAM lParam)
{
+#ifdef _WIN64
+ Window window = (Window)GetWindowLongPtr(windowHandle, GWLP_USERDATA);
+#else
Window window = (Window)GetWindowLong(windowHandle, GWL_USERDATA);
+#endif
static Point lastPos;
if(window)
{
{
HWND foreground;
DWORD id;
- uint windowLong;
+ void * windowLong;
foreground = GetForegroundWindow();
if(foreground == windowHandle && lParam)
foreground = (HWND)lParam;
GetWindowThreadProcessId(foreground, &id);
- windowLong = GetWindowLong(foreground, GWL_WNDPROC);
+#ifdef _WIN64
+ windowLong = (void*)GetWindowLongPtr(foreground, GWLP_WNDPROC);
+#else
+ windowLong = (void*)GetWindowLong(foreground, GWL_WNDPROC);
+#endif
#if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
// The != ApplicationWindow check is for not recognizing the Console window as an Ecere Window
// That check causes a problem with the OpenGL driver which seems to popup a window of a different class
if(window.displaySystem && window.displaySystem.driver == class(OpenGLDisplayDriver))
- windowLong = (uint)ApplicationWindow;
+ windowLong = (void *)ApplicationWindow;
#endif
- if(id != GetCurrentProcessId() || windowLong != (LPARAM)ApplicationWindow)
+ if(id != GetCurrentProcessId() || windowLong != (void *)ApplicationWindow)
window.ExternalActivate(false, true, window, null);
// DefWindowProc for WM_NCACTIVATE draws the decorations, make sure it's drawn in the right state
return (uint)DefWindowProc(windowHandle, msg, window.active, lParam);
SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOSIZE); //|SWP_NOREDRAW);
*/
}
- guiApp.SetAppFocus(wParam);
+ guiApp.SetAppFocus((bool)wParam);
}
}
else
- guiApp.SetAppFocus(wParam);
+ guiApp.SetAppFocus((bool)wParam);
break;
case WM_PAINT:
{
static int lastRes = 0;
if(lastBits != wParam || lastRes != lParam)
{
- lastBits = wParam;
- lastRes = lParam;
+ lastBits = (int)wParam;
+ lastRes = (int)lParam;
externalDisplayChange = true;
if(guiApp.desktop.DisplayModeChanged())
incref window;
if(msg == WM_CHAR || msg == WM_DEADCHAR || PeekMessage(&charMsg, windowHandle, min, max, PM_REMOVE))
{
- ch = (msg == WM_CHAR || msg == WM_DEADCHAR) ? wParam : (unichar)charMsg.wParam;
+ ch = (msg == WM_CHAR || msg == WM_DEADCHAR) ? (unichar)wParam : (unichar)charMsg.wParam;
+ // TOCHECK: What is this for again? Fixing some obscure activation status?
+ // -- I believe this was somehow allowing 'unmaximizing', but was causing problems
+ // as there was no way to prevent AltEnter from doing so (e.g. when it is used for a node property)
+ // Worked around by fixing ProcessHotKeys to properly check for sysButtons in parent.parent when sys buttons
+ // are placed inside a menu bar for a document
+ /*
if(msg == WM_SYSKEYDOWN && ch == 13)
{
- ShowWindow(window.windowHandle, SW_SHOWNORMAL);
+ ShowWindow(window.windowHandle, window.state == maximized ? SW_MAXIMIZE : SW_SHOWNORMAL);
+ // This last line been commented out for a long time:
// window.ExternalActivate(true, true, window, null);
}
+ */
if(msg == WM_SYSKEYUP || msg == WM_KEYUP)
{
if(!ProcessKeyMessage(window, WM_KEYDOWN, 0x40000000, 0, ch))
font.lfOutPrecision = OUT_DEFAULT_PRECIS;
font.lfClipPrecision = CLIP_DEFAULT_PRECIS;
font.lfQuality = DEFAULT_QUALITY;
- font.lfPitchAndFamily = (byte)DEFAULT_PITCH|FF_DONTCARE; // TODO: Fix compiler 0 | 0 to produce byte, not int
+ font.lfPitchAndFamily = (byte)(DEFAULT_PITCH|FF_DONTCARE); // TODO: Fix compiler 0 | 0 to produce byte, not int
UTF8toUTF16Buffer(res.faceName, font.lfFaceName, LF_FACESIZE);
ImmSetCompositionFont(ctx, &font);
//case WM_NCLBUTTONDOWN:
case WM_LBUTTONDOWN:
window.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown,x,y,&code, false,
- (msg == WM_LBUTTONDBLCLK) ? false: true);
+ /*(msg == WM_LBUTTONDBLCLK) ? false: */true);
break;
//case WM_NCLBUTTONUP:
case WM_LBUTTONUP: window.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp, x,y,&code, false, false);break;
/// DRIVER IMPLEMENTATION /////////////
****************************************************************************/
+#ifdef _WIN64
+ void CALLBACK ::TimerProc(UINT uTimerID, UINT uMsg, uint64 dwUser, uint64 dw1, uint64 dw2)
+#else
void CALLBACK ::TimerProc(UINT uTimerID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
+#endif
{
guiApp.SignalEvent();
}
null,
className
};
+ AttachConsole(-1);
wcl.hInstance = hInstance = GetModuleHandle(null);
RegisterClass(&wcl);
if(window.style.stayOnTop)
exStyle |= WS_EX_TOPMOST;
- if(rootWindow && (window.style.modal || window.style.interim))
+ if(rootWindow && (window._isModal || window.style.interim))
parentWindow = rootWindow.is3D ? rootWindow.parent.windowHandle : rootWindow.windowHandle;
if(window.alphaBlend)
}
}
delete text;
+#ifdef _WIN64
+ SetWindowLongPtr(windowHandle, GWLP_USERDATA, (int64)window);
+#else
SetWindowLong(windowHandle, GWL_USERDATA, (DWORD)window);
+#endif
return windowHandle;
}
void DestroyRootWindow(Window window)
{
- HICON oldIcon = (HICON)SendMessage(window.windowHandle, WM_GETICON, ICON_BIG, 0);
+ HICON oldIcon;
+ int c, lockCount = guiApp.lockMutex.lockCount;
+ for(c = 0; c < lockCount; c++)
+ guiApp.lockMutex.Release();
+
+ oldIcon = (HICON)SendMessage(window.windowHandle, WM_GETICON, ICON_BIG, 0);
+#ifdef _WIN64
+ if(oldIcon && oldIcon != (HICON)GetClassLongPtr(window.windowHandle, GCLP_HICON))
+#else
if(oldIcon && oldIcon != (HICON)GetClassLong(window.windowHandle, GCL_HICON))
- {
+#endif
DestroyIcon(oldIcon);
- }
- // TO FIX LOCK UP PROBLEMS... WOULD NEED TO UNLOCK ALL RECURSIONS ((GuiApplication)__thisModule.application).Unlock();
ShowWindow(window.windowHandle, SW_HIDE);
- // TO FIX LOCK UP PROBLEMS... WOULD NEED TO LOCK ALL RECURSIONS((GuiApplication)__thisModule.application).Lock();
+#ifdef _WIN64
+ SetWindowLongPtr(window.windowHandle, GWLP_USERDATA, (int64)null);
+#else
SetWindowLong(window.windowHandle, GWL_USERDATA, 0);
+#endif
DestroyWindow(window.windowHandle);
+
+ for(c = 0; c < lockCount; c++)
+ guiApp.lockMutex.Wait();
+
window.windowHandle = null;
}
void SetRootWindowCaption(Window window, char * name)
{
uint16 * text = UTF8toUTF16(name, null);
+ guiApp.Unlock();
SetWindowText(window.windowHandle, text);
+ guiApp.Lock();
delete text;
}
flashInfo.hwnd = window.windowHandle;
flashInfo.uCount = 1;
flashInfo.dwFlags = FLASHW_TRAY; // FLASHW_ALL;
+ guiApp.Unlock();
FlashWindowEx((void *)&flashInfo);
+ guiApp.Lock();
}
// --- Mouse-based window movement ---
}
}
+#ifdef _WIN64
+ if(oldIcon && oldIcon != (HICON)GetClassLongPtr(window.windowHandle, GCLP_HICON))
+#else
if(oldIcon && oldIcon != (HICON)GetClassLong(window.windowHandle, GCL_HICON))
+#endif
{
DestroyIcon(oldIcon);
}