| 1 | /* $Id: oslibmsg.cpp,v 1.2 1999-07-20 07:42:35 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Window message translation functions for OS/2
|
|---|
| 4 | *
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 7 | *
|
|---|
| 8 | *
|
|---|
| 9 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 10 | *
|
|---|
| 11 | * TODO: Simply copy for now. Need to make a real translation
|
|---|
| 12 | *
|
|---|
| 13 | */
|
|---|
| 14 | #define INCL_WIN
|
|---|
| 15 | #define INCL_PM
|
|---|
| 16 | #define INCL_DOSPROCESS
|
|---|
| 17 | #include <os2.h>
|
|---|
| 18 | #include <os2wrap.h>
|
|---|
| 19 | #include <string.h>
|
|---|
| 20 | #include <misc.h>
|
|---|
| 21 | #include "oslibmsg.h"
|
|---|
| 22 | #include <win32wnd.h>
|
|---|
| 23 | #include "oslibutil.h"
|
|---|
| 24 |
|
|---|
| 25 | QMSG *MsgThreadPtr = 0;
|
|---|
| 26 |
|
|---|
| 27 | //******************************************************************************
|
|---|
| 28 | //******************************************************************************
|
|---|
| 29 | BOOL OSLibInitMsgQueue()
|
|---|
| 30 | {
|
|---|
| 31 | if(DosAllocThreadLocalMemory(sizeof(QMSG)/sizeof(ULONG), (PULONG *)&MsgThreadPtr) != 0)
|
|---|
| 32 | {
|
|---|
| 33 | dprintf(("OSLibInitMsgQueue: local thread memory alloc failed!!"));
|
|---|
| 34 | DebugInt3();
|
|---|
| 35 | return FALSE;
|
|---|
| 36 | }
|
|---|
| 37 | return TRUE;
|
|---|
| 38 | }
|
|---|
| 39 | //******************************************************************************
|
|---|
| 40 | //******************************************************************************
|
|---|
| 41 | void WinToOS2MsgTranslate(MSG *winMsg, QMSG *os2Msg, BOOL isUnicode)
|
|---|
| 42 | {
|
|---|
| 43 | memcpy(os2Msg, winMsg, sizeof(MSG));
|
|---|
| 44 | os2Msg->reserved = 0;
|
|---|
| 45 | }
|
|---|
| 46 | //******************************************************************************
|
|---|
| 47 | //******************************************************************************
|
|---|
| 48 | void OS2ToWinMsgTranslate(QMSG *os2Msg, MSG *winMsg, BOOL isUnicode)
|
|---|
| 49 | {
|
|---|
| 50 | memcpy(winMsg, os2Msg, sizeof(MSG));
|
|---|
| 51 | winMsg->hwnd = Win32Window::OS2ToWin32Handle(os2Msg->hwnd);
|
|---|
| 52 | }
|
|---|
| 53 | //******************************************************************************
|
|---|
| 54 | //TODO!!!
|
|---|
| 55 | //******************************************************************************
|
|---|
| 56 | ULONG TranslateWinMsg(ULONG msg)
|
|---|
| 57 | {
|
|---|
| 58 | return 0;
|
|---|
| 59 | }
|
|---|
| 60 | //******************************************************************************
|
|---|
| 61 | //******************************************************************************
|
|---|
| 62 | void OSLibWinPostQuitMessage(ULONG nExitCode)
|
|---|
| 63 | {
|
|---|
| 64 | WinPostQueueMsg(GetThreadMessageQueue(), WM_QUIT, (MPARAM)nExitCode, 0);
|
|---|
| 65 | }
|
|---|
| 66 | //******************************************************************************
|
|---|
| 67 | //******************************************************************************
|
|---|
| 68 | LONG OSLibWinDispatchMsg(MSG *msg, BOOL isUnicode)
|
|---|
| 69 | {
|
|---|
| 70 | //TODO: What to do if app changed msg? (translate)
|
|---|
| 71 | // WinToOS2MsgTranslate(msg, &qmsg, isUnicode);
|
|---|
| 72 |
|
|---|
| 73 | return (LONG)WinDispatchMsg(GetThreadHAB(), MsgThreadPtr);
|
|---|
| 74 | }
|
|---|
| 75 | //******************************************************************************
|
|---|
| 76 | //******************************************************************************
|
|---|
| 77 | BOOL OSLibWinGetMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax, BOOL isUnicode)
|
|---|
| 78 | {
|
|---|
| 79 | BOOL rc;
|
|---|
| 80 |
|
|---|
| 81 | rc = WinGetMsg(GetThreadHAB(), MsgThreadPtr, TranslateWinMsg(uMsgFilterMin), TranslateWinMsg(uMsgFilterMax), 0);
|
|---|
| 82 | OS2ToWinMsgTranslate(MsgThreadPtr, pMsg, isUnicode);
|
|---|
| 83 | return rc;
|
|---|
| 84 | }
|
|---|
| 85 | //******************************************************************************
|
|---|
| 86 | //******************************************************************************
|
|---|