source: trunk/src/ole32/new/apartment.cpp@ 5280

Last change on this file since 5280 was 3456, checked in by davidr, 25 years ago

OLE32/NEW: Work-in-progress on adding apartment handling

File size: 3.1 KB
Line 
1/* $Id: apartment.cpp,v 1.1 2000-04-27 22:18:14 davidr Exp $ */
2/*
3 *
4 * Project Odin Software License can be found in LICENSE.TXT
5 *
6 */
7/*
8 * COM Apartment handling
9 *
10 * 22/04/2000
11 *
12 * Copyright 2000 David J. Raison
13 *
14 */
15
16#include "ole32.h"
17#include "oString.h"
18#include "oTls.h"
19#include "apartment.h"
20#include "rpcdce.h"
21
22CHAR ComMessagePumpWndClass[] = "OleMainThreadWndClass";
23CHAR ComMessagePumpWndName[] = "OleMainThreadWndName";
24
25// ======================================================================
26// OleMainThreadWndProc
27// ======================================================================
28LRESULT CALLBACK ComMessagePumpWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
29{
30 switch (msg)
31 {
32 case WM_USER:
33
34 // Dispatch method call...
35
36 break;
37
38 default:
39 return DefWindowProcA(hWnd, msg, wParam, lParam);
40 }
41
42 return 0;
43}
44
45// ======================================================================
46// Apartment
47// ======================================================================
48
49// ----------------------------------------------------------------------
50// Apartment::Apartment
51// ----------------------------------------------------------------------
52Apartment::Apartment(enAptType aptType)
53{
54 WNDCLASSEXA wcex;
55
56 m_AptType = aptType;
57
58 UuidCreate(&m_Guid);
59
60 m_pDefaultContext = new ObjectContext;
61 m_pDefaultContext->SetApt(this);
62
63 if (IsMessageBased())
64 {
65 // First STA shall always be MAIN...
66 if (m_AptType == APT_MAIN)
67 {
68 // Register our window class...
69 ZeroMemory( &wcex, sizeof(WNDCLASSEXA));
70 wcex.cbSize = sizeof(WNDCLASSEXA);
71 wcex.style = CS_GLOBALCLASS;
72 wcex.lpfnWndProc = (WNDPROC)ComMessagePumpWndProc;
73 wcex.hInstance = 0;
74 wcex.lpszClassName = ComMessagePumpWndClass;
75
76 RegisterClassExA(&wcex);
77 }
78
79 // Initialise message pump window...
80 m_hwndPump = CreateWindowA(ComMessagePumpWndClass,
81 ComMessagePumpWndName,
82 WS_POPUP | WS_CLIPSIBLINGS | WS_OVERLAPPED,
83 CW_USEDEFAULT, CW_USEDEFAULT,
84 CW_USEDEFAULT, CW_USEDEFAULT,
85 0,
86 0,
87 0,
88 0);
89 }
90}
91
92// ----------------------------------------------------------------------
93// Apartment::~Apartment
94// ----------------------------------------------------------------------
95Apartment::~Apartment()
96{
97 if (IsMessageBased())
98 DestroyWindow(m_hwndPump);
99
100 delete m_pDefaultContext;
101}
102
103// ----------------------------------------------------------------------
104// Apartment::IsCompatible
105// ----------------------------------------------------------------------
106BOOL Apartment::IsCompatible(Attributes * const pTarget) const
107{
108 switch (pTarget->GetThreadingModel())
109 {
110 case THM_BOTH:
111 return TRUE;
112
113 case THM_FREE:
114 return m_AptType == APT_MT;
115
116 case THM_NEUTRAL:
117 return m_AptType == APT_TN;
118
119 case THM_UNDEFINED:
120 return m_AptType == APT_MAIN;
121
122 case THM_APARTMENT:
123 return IsMessageBased();
124
125 default:
126 // drop thru to warning msg.
127 break;
128 }
129
130 dprintf(("Apartment::IsCompatible() - Invalid Threading model (%d)",
131 pTarget->GetThreadingModel()));
132
133 return FALSE;
134}
Note: See TracBrowser for help on using the repository browser.