+int AxWin3_int_DefaultMessageHandler(tWindow *Win, int ID, size_t Len, const void *Data)
+{
+ switch(ID)
+ {
+ case WNDMSG_HOTKEY: {
+ const struct sWndMsg_Hotkey *mi = Data;
+ if( Len < sizeof(*mi) )
+ return -1;
+
+ if( mi->ID >= MAX_HOTKEYS )
+ _SysDebug("--- Out of range hotkey %i fired", mi->ID);
+ else if( gAxWin3_Hotkeys[mi->ID] == 0 )
+ _SysDebug("--- Unmapped hotkey ID %i fired", mi->ID);
+ else
+ gAxWin3_Hotkeys[mi->ID]();
+ }
+ return 1;
+ // Honour a close message by default
+ case WNDMSG_CLOSE:
+ AxWin3_DestroyWindow(Win);
+ return 1;
+ // Zero fucks given?
+ case WNDMSG_DESTROY:
+ _SysDebug("TODO: Check that WNDMSG_DESTROY was from us calling _DestroyWindow");
+ // TODO: Finalise cleanup of window, this will be the last message sent to this window
+ AxWin3_int_DelWindowByID(Win->ServerID);
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+void AxWin3_int_HandleMessage(tAxWin_IPCMessage *Msg)
+{
+ tWindow *dest;
+
+ dest = AxWin3_int_GetWindowFromID(Msg->Window);
+
+ switch(Msg->ID)
+ {
+ case IPCMSG_SENDMSG: {
+ tIPCMsg_SendMsg *info = (void*)Msg->Data;
+ if(Msg->Size < sizeof(*info) || Msg->Size < sizeof(*info) + info->Length) {
+ _SysDebug("Message is undersized (%i < %i + %i)",
+ Msg->Size < sizeof(*info), info->Length);
+ return ;
+ }
+ if(!dest || !dest->Handler) {
+ _SysDebug("No handler for destination %p", dest);
+ return ;
+ }
+ _SysDebug("IPC Message 0x%x - %i bytes", info->ID, info->Length);
+
+ if( dest->Handler(dest, info->ID, info->Length, info->Data) )
+ ;
+ else if( AxWin3_int_DefaultMessageHandler(dest, info->ID, info->Length, info->Data) )
+ ;
+ else
+ _SysDebug("--- Unhandled SENDMSG 0x%x win %i", info->ID, Msg->Window);
+ break; }
+ case IPCMSG_DESTROYWIN:
+ // Clean up resources associated with this window
+ break;
+ default:
+ _SysDebug("Unknow message ID %i", Msg->ID);
+ break;
+ }
+
+ free(Msg);
+}
+
+void AxWin3_SetWindowTitle(tHWND Window, const char *Title)
+{
+ tAxWin_IPCMessage *msg;
+ int len = strlen(Title);
+
+ msg = AxWin3_int_AllocateIPCMessage(Window, IPCMSG_SETWINTITLE, 0, len+1);
+ strcpy(msg->Data, Title);
+
+ AxWin3_int_SendIPCMessage(msg);
+
+ free(msg);
+}
+