linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05866
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3001: make modeless dialogs usable
------------------------------------------------------------
revno: 3001
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Thu 2012-07-19 23:15:09 +0200
message:
make modeless dialogs usable
modified:
dwt/include/dwt/Application.h
dwt/include/dwt/widgets/ModelessDialog.h
dwt/src/Application.cpp
dwt/src/widgets/ModelessDialog.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dwt/include/dwt/Application.h'
--- dwt/include/dwt/Application.h 2012-01-13 20:55:20 +0000
+++ dwt/include/dwt/Application.h 2012-07-19 21:15:09 +0000
@@ -42,7 +42,6 @@
#include <functional>
#ifdef _MSC_VER
-#ifndef WINCE
#ifdef _DEBUG
// Enable memory leak detection with file/line tracing.
#define _CRTDBG_MAP_ALLOC
@@ -50,17 +49,12 @@
#include <crtdbg.h>
#endif
#endif
-#endif
namespace dwt {
// Forward declaration of friends
class Widget;
-namespace Policies {
-class ModelessDialog;
-}
-
/// Class declaration for the application class
/** Every application using SmartWin will get ONE and ONLY one Application object
* automatically. <br>
@@ -78,20 +72,9 @@
*/
class Application :public boost::noncopyable
{
-#ifdef WINCE
- friend int WINAPI ::WinMain( HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPTSTR lpCmdLine,
- int nCmdShow );
-#else
- friend int PASCAL ::WinMain( HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow );
-#endif
+ static int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
friend class Widget;
- friend class Policies::ModelessDialog;
public:
typedef std::function<void()> Callback;
=== modified file 'dwt/include/dwt/widgets/ModelessDialog.h'
--- dwt/include/dwt/widgets/ModelessDialog.h 2012-01-13 20:55:20 +0000
+++ dwt/include/dwt/widgets/ModelessDialog.h 2012-07-19 21:15:09 +0000
@@ -55,12 +55,12 @@
public aspects::Dialog<ModelessDialog>
{
typedef Frame BaseType;
+
+ friend class WidgetCreator<ModelessDialog>;
+
public:
- /// Class type
typedef ModelessDialog ThisType;
-
- /// Object type
- typedef ThisType * ObjectType;
+ typedef ThisType* ObjectType;
struct Seed : public BaseType::Seed {
typedef ThisType WidgetType;
@@ -71,24 +71,14 @@
void create(const Seed& cs = Seed());
protected:
- // Protected since this Widget we HAVE to inherit from
- explicit ModelessDialog( Widget * parent = 0 );
-
- virtual ~ModelessDialog()
- {}
+ explicit ModelessDialog(Widget* parent);
+ virtual ~ModelessDialog() { }
private:
friend class ChainingDispatcher;
static const TCHAR *windowClass;
};
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Implementation of class
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-inline ModelessDialog::ModelessDialog( Widget * parent )
- : BaseType(parent, ChainingDispatcher::superClass<ModelessDialog>())
-{}
-
}
#endif
=== modified file 'dwt/src/Application.cpp'
--- dwt/src/Application.cpp 2012-03-03 19:33:45 +0000
+++ dwt/src/Application.cpp 2012-07-19 21:15:09 +0000
@@ -45,16 +45,6 @@
namespace dwt {
-// link to Common Controls to relieve user of explicitly doing so
-#ifdef _MSC_VER
-#ifdef WINCE
-#pragma comment( lib, "commctrl.lib" )
-#else
-#pragma comment( lib, "comctl32.lib" )
-#endif //! WINCE
-#endif //! _MSC_VER
-// Friend functions to Application
-
Application* Application::itsInstance = 0;
HANDLE Application::itsMutex = 0;
@@ -273,8 +263,7 @@
} // namespace dwt
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
-{
+int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
dwt::Application::init(nCmdShow);
int ret = dwtMain(dwt::Application::instance()); // Call library user's startup function.
=== modified file 'dwt/src/widgets/ModelessDialog.cpp'
--- dwt/src/widgets/ModelessDialog.cpp 2012-01-13 20:55:20 +0000
+++ dwt/src/widgets/ModelessDialog.cpp 2012-07-19 21:15:09 +0000
@@ -36,11 +36,16 @@
const TCHAR *ModelessDialog::windowClass = WC_DIALOG;
ModelessDialog::Seed::Seed(const Point& size, DWORD styles_) :
-BaseType::Seed(tstring(), styles_ | DS_CONTROL | WS_CHILD, WS_EX_CONTROLPARENT)
+BaseType::Seed(tstring(), styles_ | WS_POPUP | WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_VISIBLE, WS_EX_CONTROLPARENT)
{
location.size = size;
}
+ModelessDialog::ModelessDialog(Widget* parent) :
+ BaseType(parent, ChainingDispatcher::superClass<ModelessDialog>())
+{
+}
+
void ModelessDialog::create(const Seed& cs) {
Seed cs2 = cs;
@@ -48,17 +53,12 @@
cs2.exStyle |= WS_EX_CONTEXTHELP;
}
- if((cs.style & DS_CONTROL) == DS_CONTROL) {
- cs2.style &= ~WS_CAPTION;
- cs2.style &= ~WS_SYSMENU;
- }
-
- cs2.style &= ~WS_VISIBLE;
-
BaseType::create(cs2);
SetWindowLongPtr(handle(), DWLP_DLGPROC, (LPARAM)dialogProc);
+ onClosing([this]() -> bool { ::DestroyWindow(handle()); return false; });
+
HWND hwndDefaultFocus = GetNextDlgTabItem(handle(), NULL, FALSE);
if (sendMessage(WM_INITDIALOG, (WPARAM)hwndDefaultFocus)) {
sendMessage(WM_NEXTDLGCTL, (WPARAM)hwndDefaultFocus, TRUE);