|
From: andrew7 <bd...@us...> - 2007-01-07 18:43:11
|
Update of /cvsroot/smartwin/SmartWin/tests/swDll In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv4421/tests/swDll Modified Files: swDll.cpp swDllMain.cpp swdll.h Added Files: swDll.rc Log Message: Add example of using a resource based dialog in a DLL --- NEW FILE: swDll.rc --- // Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE BEGIN "resource.h\0" END 2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_HEXDIALOG DIALOGEX 0, 0, 200, 100 STYLE DS_SETFONT | DS_FIXEDSYS | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE CAPTION "WidgetDialog from a DLL" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "OK",IDOK,128,36,50,14 PUSHBUTTON "Cancel",IDCANCEL,7,36,50,14 EDITTEXT IDC_HEXEDIT,7,7,171,17,ES_AUTOHSCROLL END ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN IDD_HEXDIALOG, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 178 TOPMARGIN, 7 BOTTOMMARGIN, 50 END END #endif // APSTUDIO_INVOKED #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED Index: swdll.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/swDll/swdll.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- swdll.h 5 May 2006 17:14:40 -0000 1.2 +++ swdll.h 7 Jan 2007 18:43:05 -0000 1.3 @@ -12,3 +12,6 @@ __declspec( DLLMODE ) bool guiGetNumberAndString( int * numb, char str[] ); + +__declspec( DLLMODE ) +bool dialogGetNumberAndString( int * numb, char str[] ); Index: swDll.cpp =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/swDll/swDll.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- swDll.cpp 5 May 2006 17:21:47 -0000 1.4 +++ swDll.cpp 7 Jan 2007 18:43:05 -0000 1.5 @@ -15,16 +15,17 @@ #define DLLMODE dllexport #include "swdll.h" #include "helloDll.h" +#include "ResourceDialogClass.h" // Called -BOOL APIENTRY DllMain( HANDLE hModule, +BOOL APIENTRY DllMain( HINSTANCE hInstance, DWORD ul_reason_for_call, LPVOID lpReserved ) { if ( DLL_PROCESS_ATTACH == ul_reason_for_call ) { - Application::neededSmartWinInit(); // Prepare for SmartWin++ + Application::neededSmartWinInit( hInstance, SW_SHOW, "" ); // Prepare for SmartWin++ } if ( DLL_PROCESS_DETACH == ul_reason_for_call ) @@ -65,6 +66,22 @@ return true; } + +// The DLL function that invokes a resource based SmartWin++ dialog. +// +__declspec( dllexport ) +bool dialogGetNumberAndString( int * numb, char str[] ) +{ + *numb= 33; + ResourceDialogClass * rdc = new ResourceDialogClass( str ); + Application::instance().run(); // Stops when window closes. + return true; +} + + + + + // Just so "SmartWinMain" is not undefined when we link the DLL. // Since WinMain is not called in a DLL, this function is never called. int SmartWinMain( Application & app ) Index: swDllMain.cpp =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/swDll/swDllMain.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- swDllMain.cpp 5 May 2006 17:21:47 -0000 1.3 +++ swDllMain.cpp 7 Jan 2007 18:43:05 -0000 1.4 @@ -22,5 +22,12 @@ std::cout << numb << " " << str << std::endl; } + // Same thing but this time the DLL does it with a dialog. + if ( dialogGetNumberAndString( & numb, ( char * ) & str ) ) + { + std::cout << numb << " " << str << std::endl; + } + + return 0; } |