# error "wxLibrary can't be compiled on this platform, sorry."
#endif // OS
-// defined in windows.h
-// This breaks app.cpp if RICHEDIT is included.
-#if 0
-#ifdef LoadLibrary
-# undef LoadLibrary
-#endif
+// LoadLibrary is defined in windows.h as LoadLibraryA, but wxDllLoader method
+// should be called LoadLibrary, not LoadLibraryA or LoadLibraryW!
+#if defined(__WIN32__) && defined(LoadLibrary)
+# include "wx/msw/winundef.h"
#endif
// ----------------------------------------------------------------------------
@param success Must point to a bool variable which will be set to TRUE or FALSE.
@return A handle to the loaded DLL. Use success parameter to test if it is valid.
*/
- static wxDllType LoadLibrary(const wxString & libname, bool *success);
+ static wxDllType LoadLibrary(const wxString & libname, bool *success = NULL);
/** This function unloads the shared library. */
static void UnloadLibrary(wxDllType dll);
/** This function returns a valid handle for the main program
const wxEventType wxEVT_INIT_DIALOG = wxEVT_FIRST + 437;
const wxEventType wxEVT_IDLE = wxEVT_FIRST + 438;
const wxEventType wxEVT_UPDATE_UI = wxEVT_FIRST + 439;
+
/* System misc. */
const wxEventType wxEVT_END_PROCESS = wxEVT_FIRST + 440;
+ /* Dial up events */
+const wxEventType wxEVT_DIALUP_CONNECTED = wxEVT_FIRST + 450;
+const wxEventType wxEVT_DIALUP_DISCONNECTED = wxEVT_FIRST + 451;
+
/* Generic command events */
/* Note: a click is a higher-level event than button down/up */
const wxEventType wxEVT_COMMAND_LEFT_CLICK = wxEVT_FIRST + 500;
#define _WX_WINUNDEF_H_
*/
-// windows.h #defines the following identifiers which are also used in wxWin
+// ----------------------------------------------------------------------------
+// windows.h #defines the following identifiers which are also used in wxWin so
+// we replace these symbols with the corresponding inline functions and
+// undefine the macro.
+//
+// This looks quite ugly here but allows us to write clear (and correct!) code
+// elsewhere because the functions, unlike the macros, respect the scope.
+// ----------------------------------------------------------------------------
// GetCharWidth
}
#endif
+// GetMessage
#ifdef GetMessage
#undef GetMessage
}
#endif
+// LoadLibrary
+
+#ifdef LoadLibrary
+ #undef LoadLibrary
+ inline HINSTANCE LoadLibrary(LPCTSTR lpLibFileName)
+ {
+ #ifdef _UNICODE
+ return LoadLibraryW(lpLibFileName);
+ #else
+ return LoadLibraryA(lpLibFileName);
+ #endif
+ }
+#endif
+
// For WINE
#if defined(GetWindowStyle) || defined(__WXWINE__)
// closes the file and frees memory, losing all changes
bool Close();
// is file currently opened?
- bool IsOpened() const { return m_file.IsOpened(); }
+ bool IsOpened() const { return m_isOpened; }
// accessors
// get the number of lines in the file
size_t m_nCurLine; // number of current line in the file
+ bool m_isOpened; // was the file successfully opened the last time?
+
wxString m_strFile; // name of the file
};
wxFAIL_MSG(_("This method is not implemented under Windows"));
return 0;
-#endif
+#endif
}
-
/* static */
wxDllType
-wxDllLoader::LoadLibrary(const wxString & lib_name, bool *success)
+wxDllLoader::LoadLibrary(const wxString & libname, bool *success)
{
- wxASSERT(success);
-
- wxDllType handle;
+ wxDllType handle;
#if defined(__WXMAC__)
- FSSpec myFSSpec ;
- Ptr myMainAddr ;
- Str255 myErrName ;
-
- wxMacPathToFSSpec( lib_name , &myFSSpec ) ;
- if (GetDiskFragment( &myFSSpec , 0 , kCFragGoesToEOF , "\p" , kPrivateCFragCopy , &handle , &myMainAddr ,
- myErrName ) != noErr )
- {
- p2cstr( myErrName ) ;
- wxASSERT_MSG( 1 , (char*)myErrName ) ;
- return NULL ;
- }
+ FSSpec myFSSpec ;
+ Ptr myMainAddr ;
+ Str255 myErrName ;
+
+ wxMacPathToFSSpec( libname , &myFSSpec ) ;
+ if (GetDiskFragment( &myFSSpec , 0 , kCFragGoesToEOF , "\p" , kPrivateCFragCopy , &handle , &myMainAddr ,
+ myErrName ) != noErr )
+ {
+ p2cstr( myErrName ) ;
+ wxASSERT_MSG( 1 , (char*)myErrName ) ;
+ return NULL ;
+ }
#else // !Mac
- handle = wxDllOpen(lib_name);
+ handle = wxDllOpen(libname);
#endif // OS
- if ( !handle )
- {
- wxLogSysError(_("Failed to load shared library '%s'"),
- lib_name.c_str());
- *success = FALSE;
- return NULL;
- }
- *success = TRUE;
- return handle;
+ if ( !handle )
+ {
+ wxLogSysError(_("Failed to load shared library '%s'"), libname.c_str());
+ }
+
+ if ( success )
+ {
+ *success = handle != 0;
+ }
+
+ return handle;
}
void *
wxDllLoader::GetSymbol(wxDllType dllHandle, const wxString &name)
{
- void *symbol = NULL; // return value
+ void *symbol = NULL; // return value
#if defined( __WXMAC__ )
- Ptr symAddress ;
- CFragSymbolClass symClass ;
- Str255 symName ;
-
- strcpy( (char*) symName , name ) ;
- c2pstr( (char*) symName ) ;
-
- if ( FindSymbol( dllHandle , symName , &symAddress , &symClass ) == noErr )
- symbol = (void *)symAddress ;
+ Ptr symAddress ;
+ CFragSymbolClass symClass ;
+ Str255 symName ;
+
+ strcpy( (char*) symName , name ) ;
+ c2pstr( (char*) symName ) ;
+
+ if ( FindSymbol( dllHandle , symName , &symAddress , &symClass ) == noErr )
+ symbol = (void *)symAddress ;
#else
symbol = wxDllGetSymbol(dllHandle, name);
#endif
if ( !symbol )
{
- wxLogSysError(_("Couldn't find symbol '%s' in a dynamic library"),
- name.c_str());
+ wxLogSysError(_("Couldn't find symbol '%s' in a dynamic library"),
+ name.c_str());
}
return symbol;
}
old_sm_first = wxClassInfo::sm_first;
wxClassInfo::sm_first = NULL;
- wxString lib_name = ConstructLibraryName(name);
+ wxString libname = ConstructLibraryName(name);
/*
Unix automatically builds that library name, at least for dlopen()
{
wxString fullname(tokenizer.NextToken());
- fullname << '/' << lib_name;
+ fullname << '/' << libname;
if ( wxFileExists(fullname) )
{
- lib_name = fullname;
+ libname = fullname;
// found the library
break;
#endif
bool success = FALSE;
- wxDllType handle = wxDllLoader::LoadLibrary(lib_name, &success);
+ wxDllType handle = wxDllLoader::LoadLibrary(libname, &success);
if(success)
{
lib = new wxLibrary(handle);
wxTextFile::wxTextFile(const wxString& strFile) : m_strFile(strFile)
{
+ m_nCurLine = 0;
+ m_isOpened = FALSE;
}
wxTextFile::~wxTextFile()
return FALSE;
// read file into memory
- bool bRet = Read();
+ m_isOpened = Read();
m_file.Close();
- return bRet;
+ return m_isOpened;
}
// analyse some lines of the file trying to guess it's type.
nRead = m_file.Read(buf, WXSIZEOF(buf));
if ( nRead == wxInvalidOffset ) {
// read error (error message already given in wxFile::Read)
- m_file.Close();
return FALSE;
}
m_aTypes.Clear();
m_aLines.Clear();
m_nCurLine = 0;
+ m_isOpened = FALSE;
return TRUE;
}
}
}
- } // END: if ( success )
+ }
+ else
+ {
+ // common dialog failed - why?
+#ifdef __WXDEBUG__
+ DWORD dwErr = CommDlgExtendedError();
+ if ( dwErr != 0 )
+ {
+ // this msg is only for developers
+ wxLogError(_T("Common dialog failed with error code %0lx."),
+ dwErr);
+ }
+ //else: it was just cancelled
+#endif
+ }
- return (success ? wxID_OK : wxID_CANCEL) ;
+ return success ? wxID_OK : wxID_CANCEL;
}
LV_ITEM item;
wxConvertToMSWListItem(this, info, item);
item.cchTextMax = 0;
- return (ListView_SetItem(GetHwnd(), &item) != 0);
+ bool ok = ListView_SetItem(GetHwnd(), &item) != 0;
+ if ( ok && (info.m_mask & wxLIST_MASK_IMAGE) )
+ {
+ // make the change visible
+ ListView_Update(GetHwnd(), item.iItem);
+ }
+
+ return ok;
}
long wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId)