OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
oledialg.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectComponents
3// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Implementation of class TOleDialog. This defines the basic behavior of all
7/// Ole dialogs.
8//----------------------------------------------------------------------------
9#include <ocf/pch.h>
10
11#include <ocf/oledialg.h>
12
13namespace ocf {
14
15using namespace owl;
16
18
22
23//
24/// Creates a TOleDialog object. Registers an OCX window class for the application
25/// by calling TRegisterOcxWnd. Sets the wfAutoCreate flag for the object.
26//
28 :TOleWindow(parent, module), TDialog(parent, resId, module)
29{
30 // Register OCX class
31 //
32 static TRegisterOcxWnd regWnd(GetApplication()->GetHandle());
33
34 // Override TDialog's desire to not be autocreated
35 //
36 SetFlag(wfAutoCreate);
37}
38
39//
40/// Destroys the TOleDialog object.
41//
46
47//
48/// Calls the SetupWindow functions of the TOleWindow and TDialog base classes. Then
49/// calls CheckChild on the dialog box handle and child window handles, destroying
50/// any corresponding OCX windows. (The dummy OCX windows are replaced by OCX
51/// controls.)
52//
53void
55{
56 // Call parents setup
57 //
60
62 if (hWnd) {
63 // Check if it is a control class and if so, load it
64 //
66
67 // Loop through all the children and look for 'stub' windows
68 // that should be replaced with an OCX control...
69 //
70 while ((hWnd = ::GetWindow(hWnd, GW_HWNDNEXT)) != 0) {
71 if (hWndControl)
74 }
75
76 if (hWndControl)
78 }
79}
80
81//
82/// Called when no messages are waiting to be processed. Calls the IdleAction
83/// functions of the TOleWindow and TDialog base classes.
84//
85bool
91
92/// Called before a Windows message (stored in msg) is dispatched. Calls the
93/// PreProcessMsg functions of the TOleWindow and TDialog base classes.
94bool
96{
98 return true;
99 return false;
100}
101
102//
103/// Handles OC_VIEWSITERECT messages. Calls the EvOcViewSetSiteRect function of the
104/// TOleWindow base class. Then returns false, forcing OCX controls to keep the
105/// sizes and positions defined in their resource scripts.
106///
107/// Overrides SetSiteRect from TOleWindow since we want to force
108/// our OCX Controls to keep the size and position defined in
109/// the resource file. This is done by simply returning false
110//
111bool
117
118//
119/// Checks to see if a window handle (HWND) corresponds to an OCX window. If so,
120/// CheckChild calls LoadControl on the HWND and returns the HWND. (The HWND should
121/// be used by the calling procedure to destroy the window, which has been replaced
122/// by an OCX control.) Otherwise, CheckChild returns 0.
123/// The CheckChild function is used by the TOleDialog::SetupWindow function.
124//
125HWND
127{
128 TCHAR className [50];
129 if (::GetClassName(hWndChild, className, 50)) {
130 if (_tcscmp(className, OCX_STUB_CLASS) == 0) {
132 return hWndChild;
133 }
134 }
135 return 0;
136}
137
138//
139/// Determines the ProgId and position of the window corresponding to hControl. Then
140/// creates a TOcControl object that is initialized with the control's class
141/// (calculated from ProgId) and position.
142//
143void
145{
146 // Get stub control's location
147 //
150 TPoint TopLeft(ControlRect.left, ControlRect.top);
151 ::ScreenToClient(GetHandle(), &TopLeft);
152 TPoint BottomRight(ControlRect.right, ControlRect.bottom);
153 ::ScreenToClient(GetHandle(), &BottomRight);
154 ControlRect.Set(TopLeft.x, TopLeft.y, BottomRight.x, BottomRight.y);
155
156 // Get ProgId
157 //
158 TCHAR progId [80];
160
161 // Create control with specified progid at location
162 //
164}
165
166//
167/// Registers an OCX window for the specified instance of the application.
168//
170 :HAppInst(hInst)
171{
172 // Registration for OCX window
173 //
175
176 wndClass.style = CS_GLOBALCLASS; // Global registration
177 wndClass.lpfnWndProc = ::DefWindowProc;
178 wndClass.cbClsExtra = 0;
179 wndClass.cbWndExtra = 0;
180 wndClass.hInstance = HAppInst;
181 wndClass.hIcon = 0;
182 wndClass.hCursor = 0;
183 wndClass.hbrBackground = 0;
184 wndClass.lpszMenuName = 0;
185 wndClass.lpszClassName = OCX_STUB_CLASS;
186
187 RegisterClass(&wndClass);
188}
189
190//
191/// Unregister OCX stub-window class
192//
194{
195 UnregisterClass(_T("OCX"), HAppInst);
196}
197
198
199} // OCF namespace
200
201//==============================================================================
202
203
Provides OLE support to dialog boxes.
Definition oledialg.h:45
bool EvOcViewSetSiteRect(owl::TRect *rect)
Handles OC_VIEWSITERECT messages.
Definition oledialg.cpp:112
~TOleDialog()
Destroys the TOleDialog object.
Definition oledialg.cpp:42
void LoadControl(HWND hControl)
Determines the ProgId and position of the window corresponding to hControl.
Definition oledialg.cpp:144
HWND CheckChild(HWND)
Checks to see if a window handle (HWND) corresponds to an OCX window.
Definition oledialg.cpp:126
auto IdleAction(long idleCount) -> bool override
Called when no messages are waiting to be processed.
Definition oledialg.cpp:86
auto PreProcessMsg(MSG &) -> bool override
Called before a Windows message (stored in msg) is dispatched.
Definition oledialg.cpp:95
void SetupWindow() override
Calls the SetupWindow functions of the TOleWindow and TDialog base classes.
Definition oledialg.cpp:54
The generic OLE2 window. Use as a client of a frame window.
Definition olewindo.h:91
void SetupWindow() override
Establishes a connection between the TOcView object and the view's HWND so the view can send notifica...
Definition olewindo.cpp:286
bool EvOcViewSetSiteRect(owl::TRect *rect)
Converts the rect to logical units.
TOcControl * InsertControl(TOcInitInfo &initInfo, owl::TRect *pos=0, int id=0)
Definition olewindo.cpp:508
Registers an OCX window for a subsequent call to the TOleDialog::SetupWindow function.
Definition oledialg.h:75
TRegisterOcxWnd(HINSTANCE)
Registers an OCX window for the specified instance of the application.
Definition oledialg.cpp:169
HINSTANCE HAppInst
The application instance for which the OCX window is registered.
Definition oledialg.h:82
~TRegisterOcxWnd()
Unregister OCX stub-window class.
Definition oledialg.cpp:193
Typically used to obtain information from a user, a dialog box is a window inside of which other cont...
Definition dialog.h:85
auto PreProcessMsg(MSG &) -> bool override
Preprocess posted messages to provide various accelerator translations.
Definition dialog.cpp:217
void SetupWindow() override
Overrides the virtual function defined in TWindow.
Definition dialog.cpp:825
void Destroy(int retValue=IDCANCEL) override
Destroys the interface element associated with the TDialog object.
Definition dialog.cpp:887
auto IdleAction(long idleCount) -> bool override
Handle enabling and disabling of child controls.
Definition dialog.cpp:995
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
Reference to reference counted string object TUString Lightweight reference object consisting of a po...
Definition string.h:67
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
tstring GetWindowText() const
String-aware overload.
Definition window.cpp:4415
virtual bool PreProcessMsg(MSG &msg)
Called from TApplication::ProcessAppMsg() to give the window an opportunity to perform preprocessing ...
Definition window.cpp:644
HWND GetWindow(uint cmd) const
Returns the handle of the window that has the indicated relationship to this window.
Definition window.h:2784
TRect GetWindowRect() const
Gets the screen coordinates of the window's rectangle.
Definition window.h:2257
long GetWindowLong(int index) const
Retrieves information about the window depending on the value stored in index.
Definition window.h:2388
virtual bool IdleAction(long idleCount)
Called when no messages are waiting to be processed, IdleAction performs idle processing as long as t...
Definition window.cpp:671
void ScreenToClient(TPoint &point) const
Uses the screen coordinates specified in point to calculate the client window's coordinates and then ...
Definition window.h:2192
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
#define _tcscmp
Definition cygwin.h:75
#define _T(x)
Definition cygwin.h:51
#define DEFINE_RESPONSE_TABLE2(cls, base1, base2)
Macro to define a response table for a class with two bases.
Definition eventhan.h:506
@ wfAutoCreate
Create the HWND when our parent is created.
Definition window.h:60
Include for OC, gets common headers when precompiled headers are enabled.
Object Component Framework (COM encapsulation)
Definition appdesc.h:22
EV_OC_VIEWSETSITERECT
Definition oledialg.cpp:20
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
OWL_DIAGINFO
Definition animctrl.cpp:14
END_RESPONSE_TABLE
Definition button.cpp:26
Definition of class TOleDialog, a TDialog that can host OLE controls.