+ return Window->Data;
+}
+
+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 {
+ switch( info->ID )
+ {
+ case WNDMSG_HOTKEY: {
+ const struct sWndMsg_Hotkey *mi = (void*)info->Data;
+ if( mi->ID >= MAX_HOTKEYS )
+ ; // TODO: Error when hotkey is out of range
+ else if( gAxWin3_Hotkeys[mi->ID] == 0 )
+ _SysDebug("--- Unmapped hotkey ID %i fired", mi->ID);
+ else
+ gAxWin3_Hotkeys[mi->ID]();
+ }break;
+ default:
+ _SysDebug("--- Unhandled SENDMSG %i", info->ID);
+ break;
+ }
+ }
+ break; }
+ default:
+ _SysDebug("Unknow message ID %i", Msg->ID);
+ break;
+ }
+}
+
+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);
+}
+
+void AxWin3_SendMessage(tHWND Window, tHWND Destination, int Message, int Length, void *Data)
+{
+ tAxWin_IPCMessage *msg;
+ tIPCMsg_SendMsg *info;
+
+ msg = AxWin3_int_AllocateIPCMessage(Window, IPCMSG_SENDMSG, 0, sizeof(*info)+Length);
+ info = (void*)msg->Data;
+ info->Remote = AxWin3_int_GetWindowID(Destination);
+ info->ID = Message;
+ info->Length = Length;
+ memcpy(info->Data, Data, Length);
+
+ AxWin3_int_SendIPCMessage(msg);
+ free(msg);
+}
+
+void *AxWin3_WaitMessage(tHWND Window, int MessageID, size_t *Length)
+{
+ tAxWin_IPCMessage *msg;
+
+ for( ;; )
+ {
+ msg = AxWin3_int_WaitIPCMessage(IPCMSG_SENDMSG);
+ if( msg->Window != AxWin3_int_GetWindowID(Window) ) {
+ AxWin3_int_HandleMessage(msg);
+ continue ;
+ }
+ tIPCMsg_SendMsg *info = (void*)msg->Data;
+ if( info->ID != MessageID ) {
+ AxWin3_int_HandleMessage(msg);
+ continue ;
+ }
+
+ *Length = info->Length;
+ void *ret = malloc(info->Length);
+ memcpy(ret, info->Data, info->Length);
+ free(msg);
+
+ return ret;
+ }
+}
+
+void AxWin3_FocusWindow(tHWND Window)
+{
+ tAxWin_IPCMessage *msg;
+
+ msg = AxWin3_int_AllocateIPCMessage(Window, IPCMSG_FOCUSWINDOW, 0, 0);
+
+ AxWin3_int_SendIPCMessage(msg);
+ free(msg);