source: trunk/src/user32/oslibmsg.cpp@ 1066

Last change on this file since 1066 was 1066, checked in by dengert, 26 years ago

SetTimer/KillTimer implemented

File size: 3.8 KB
Line 
1/* $Id: oslibmsg.cpp,v 1.2 1999-09-26 16:09:04 dengert 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#include "timer.h"
25
26QMSG *MsgThreadPtr = 0;
27
28//******************************************************************************
29//******************************************************************************
30BOOL OSLibInitMsgQueue()
31{
32 if(DosAllocThreadLocalMemory(sizeof(QMSG)/sizeof(ULONG), (PULONG *)&MsgThreadPtr) != 0)
33 {
34 dprintf(("OSLibInitMsgQueue: local thread memory alloc failed!!"));
35 DebugInt3();
36 return FALSE;
37 }
38 return TRUE;
39}
40//******************************************************************************
41//******************************************************************************
42void WinToOS2MsgTranslate(MSG *winMsg, QMSG *os2Msg, BOOL isUnicode)
43{
44 memcpy(os2Msg, winMsg, sizeof(MSG));
45 os2Msg->reserved = 0;
46}
47//******************************************************************************
48//******************************************************************************
49void OS2ToWinMsgTranslate(QMSG *os2Msg, MSG *winMsg, BOOL isUnicode)
50{
51 memcpy(winMsg, os2Msg, sizeof(MSG));
52 winMsg->hwnd = Win32Window::OS2ToWin32Handle(os2Msg->hwnd);
53}
54//******************************************************************************
55//TODO!!!
56//******************************************************************************
57ULONG TranslateWinMsg(ULONG msg)
58{
59 return 0;
60}
61//******************************************************************************
62//******************************************************************************
63void OSLibWinPostQuitMessage(ULONG nExitCode)
64{
65 WinPostQueueMsg(NULLHANDLE, WM_QUIT, (MPARAM)nExitCode, 0);
66}
67//******************************************************************************
68//******************************************************************************
69LONG OSLibWinDispatchMsg(MSG *msg, BOOL isUnicode)
70{
71//TODO: What to do if app changed msg? (translate)
72// WinToOS2MsgTranslate(msg, &qmsg, isUnicode);
73
74 return (LONG)WinDispatchMsg(GetThreadHAB(), MsgThreadPtr);
75}
76//******************************************************************************
77//******************************************************************************
78BOOL OSLibWinGetMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
79 BOOL isUnicode)
80{
81 BOOL rc, eaten;
82
83 do {
84 eaten = FALSE;
85 rc = WinGetMsg(GetThreadHAB(), MsgThreadPtr, TranslateWinMsg(uMsgFilterMin), TranslateWinMsg(uMsgFilterMax), 0);
86 if (MsgThreadPtr->msg == WM_TIMER)
87 eaten = TIMER_HandleTimer (MsgThreadPtr);
88 } while (eaten);
89
90 OS2ToWinMsgTranslate(MsgThreadPtr, pMsg, isUnicode);
91 return rc;
92}
93//******************************************************************************
94//******************************************************************************
95BOOL OSLibWinPeekMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
96 BOOL fRemove, BOOL isUnicode)
97{
98 BOOL rc;
99
100 rc = WinPeekMsg(GetThreadHAB(), MsgThreadPtr, hwnd, TranslateWinMsg(uMsgFilterMin),
101 TranslateWinMsg(uMsgFilterMax), (fRemove == MSG_REMOVE) ? PM_REMOVE : PM_NOREMOVE);
102 OS2ToWinMsgTranslate(MsgThreadPtr, pMsg, isUnicode);
103 return rc;
104}
105//******************************************************************************
106//******************************************************************************
Note: See TracBrowser for help on using the repository browser.