1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/nativdlg.cpp
3 // Purpose: Native dialog loading code (part of wxWindow)
4 // Author: David Webster
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ===========================================================================
13 // ===========================================================================
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
27 #include "wx/os2/private.h"
28 #include "wx/spinbutt.h"
30 // ---------------------------------------------------------------------------
32 // ---------------------------------------------------------------------------
34 extern wxWindow
* wxWndHook
;
35 extern MRESULT EXPENTRY
wxDlgProc( HWND hWnd
41 // ===========================================================================
43 // ===========================================================================
45 bool wxWindow::LoadNativeDialog (
50 wxWindow
* pChild
= NULL
;
52 HWND hWndNext
= NULLHANDLE
;
56 hWndOwner
= GetHwndOf(pParent
);
58 hWndOwner
= HWND_DESKTOP
;
63 m_hWnd
= ::WinLoadDlg( HWND_DESKTOP
67 ,(ULONG
)131 // Caption dialog from the resource file
75 SubclassWin(GetHWND());
78 pParent
->AddChild(this);
80 wxTopLevelWindows
.Append(this);
83 // Enumerate the children
85 hEnum
= ::WinBeginEnumWindows(GetHwndOf(pParent
));
86 while ((hWndNext
= ::WinGetNextWindow(hEnum
)) != NULLHANDLE
)
87 pChild
= CreateWindowFromHWND( this
90 ::WinEndEnumWindows(hEnum
);
92 } // end of wxWindow::LoadNativeDialog
94 bool wxWindow::LoadNativeDialog (
96 , const wxString
& rsName
102 hWndOwner
= GetHwndOf(pParent
);
104 hWndOwner
= HWND_DESKTOP
;
108 m_hWnd
= ::WinLoadDlg( HWND_DESKTOP
112 ,(ULONG
)131 // Caption dialog from the resource file
120 SubclassWin(GetHWND());
123 pParent
->AddChild(this);
125 wxTopLevelWindows
.Append(this);
127 } // end of wxWindow::LoadNativeDialog
129 // ---------------------------------------------------------------------------
130 // look for child by id
131 // ---------------------------------------------------------------------------
132 wxWindow
* wxWindow::GetWindowChild1 (
136 if (m_windowId
== vId
)
139 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
143 wxWindow
* pChild
= node
->GetData();
144 wxWindow
* pWin
= pChild
->GetWindowChild1(vId
);
149 node
= node
->GetNext();
152 } // end of wxWindow::GetWindowChild1
154 wxWindow
* wxWindow::GetWindowChild (
158 wxWindow
* pWin
= GetWindowChild1(vId
);
162 HWND hWnd
= 0; // TODO: ::GetDlgItem((HWND) GetHWND(), id);
166 wxWindow
* pChild
= CreateWindowFromHWND( this
171 pChild
->AddChild(this);
177 } // end of wxWindow::GetWindowChild
179 // ---------------------------------------------------------------------------
180 // create wxWin window from a native HWND
181 // ---------------------------------------------------------------------------
183 wxWindow
* wxWindow::CreateWindowFromHWND (
188 wxString
sStr(wxGetWindowClass(hWnd
));
189 long lId
= wxGetWindowId(hWnd
);
190 long lStyle
= ::WinQueryWindowULong((HWND
)hWnd
193 wxWindow
* pWin
= NULL
;
199 if (sStr
== wxT("BUTTON"))
201 if (lStyle
== BS_AUTOCHECKBOX
)
203 pWin
= new wxCheckBox
;
205 else if (lStyle
== BS_AUTORADIOBUTTON
)
207 pWin
= new wxRadioButton
;
209 else if (lStyle
& BS_BITMAP
|| lStyle
== BS_USERBUTTON
)
211 pWin
= new wxBitmapButton
;
213 else if (lStyle
== BS_PUSHBUTTON
)
217 else if (lStyle
== SS_GROUPBOX
)
219 pWin
= new wxStaticBox
;
223 wxLogError(wxT("Don't know what kind of button this is: id = %ld"),
227 else if (sStr
== wxT("COMBOBOX"))
229 pWin
= new wxComboBox
;
231 else if (sStr
== wxT("EDIT"))
233 pWin
= new wxTextCtrl
;
235 else if (sStr
== wxT("LISTBOX"))
237 pWin
= new wxListBox
;
239 else if (sStr
== wxT("SCROLLBAR"))
241 pWin
= new wxScrollBar
;
243 else if (sStr
== wxT("MSCTLS_UPDOWN32"))
245 pWin
= new wxSpinButton
;
247 else if (sStr
== wxT("MSCTLS_TRACKBAR32"))
251 else if (sStr
== wxT("STATIC"))
253 if (lStyle
== SS_TEXT
)
254 pWin
= new wxStaticText
;
255 else if (lStyle
== SS_ICON
)
257 pWin
= new wxStaticBitmap
;
262 wxString
sMsg(wxT("Don't know how to convert from Windows class "));
269 pParent
->AddChild(pWin
);
270 pWin
->SetEventHandler(pWin
);
273 pWin
->SubclassWin(hWnd
);
274 pWin
->AdoptAttributesFromHWND();
275 pWin
->SetupColours();
280 } // end of wxWindow::CreateWindowFromHWND
283 // Make sure the window style (etc.) reflects the HWND style (roughly)
285 void wxWindow::AdoptAttributesFromHWND()
287 // Does nothing under OS/2
288 } // end of wxWindow::AdoptAttributesFromHWND