1. wxGetFullHostName() does return the full host name now under MSW

2. wxGetEmailAddress() doesn't always return empty string...
3. status bar created under MSW is of type wxStatusBar, hence wxWin RTTI
   works for it
4. carsh in IPC sample fixed


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6810 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2000-03-17 23:00:10 +00:00
parent 8759d4d519
commit 1f0500b3ee
5 changed files with 67 additions and 29 deletions

View File

@ -409,7 +409,7 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
{
wxSocketBase *sock = event.GetSocket();
wxSocketNotify evt = event.GetSocketEvent();
wxTCPConnection *connection = (wxTCPConnection *)(event.GetClientData());
wxTCPConnection *connection = (wxTCPConnection *)(sock->GetClientData());
// This socket is being deleted; skip this event
if (!connection)

View File

@ -1242,7 +1242,7 @@ class WXDLLEXPORT wxSocketModule : public wxModule
DECLARE_DYNAMIC_CLASS(wxSocketModule)
public:
bool OnInit() { return GSocket_Init(); }
bool OnInit() { return GSocket_Init() != 0; }
void OnExit() { GSocket_Cleanup(); }
};

View File

@ -1091,14 +1091,13 @@ wxString wxGetEmailAddress()
{
wxString email;
wxString host = wxGetHostName();
wxString host = wxGetFullHostName();
if ( !!host )
{
wxString user = wxGetUserId();
if ( !!user )
{
wxString email(user);
email << wxT('@') << host;
email << user << wxT('@') << host;
}
}

View File

@ -360,31 +360,29 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number,
wxStatusBar *statusBar = NULL;
#if wxUSE_NATIVE_STATUSBAR
if ( UsesNativeStatusBar() )
if ( !UsesNativeStatusBar() )
{
statusBar = (wxStatusBar *)new wxStatusBar95(this, id, style);
statusBar->SetFieldsCount(number);
statusBar = (wxStatusBar *)new wxStatusBarGeneric(this, id, style);
}
else
#endif
{
statusBar = (wxStatusBar *)new wxStatusBarGeneric(this, id, style, name);
// Set the height according to the font and the border size
wxClientDC dc(statusBar);
dc.SetFont(statusBar->GetFont());
wxCoord y;
dc.GetTextExtent(_T("X"), NULL, &y );
int height = (int)( (11*y)/10 + 2*statusBar->GetBorderY());
statusBar->SetSize(-1, -1, -1, height);
statusBar->SetFieldsCount(number);
statusBar = new wxStatusBar(this, id, style, name);
}
// Set the height according to the font and the border size
wxClientDC dc(statusBar);
dc.SetFont(statusBar->GetFont());
wxCoord y;
dc.GetTextExtent(_T("X"), NULL, &y );
int height = (int)( (11*y)/10 + 2*statusBar->GetBorderY());
statusBar->SetSize(-1, -1, -1, height);
statusBar->SetFieldsCount(number);
return statusBar;
}

View File

@ -32,12 +32,13 @@
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/cursor.h"
#include "wx/intl.h"
#include "wx/log.h"
#endif //WX_PRECOMP
#include "wx/msw/private.h" // includes <windows.h>
#include "wx/timer.h"
#include "wx/intl.h"
#include <ctype.h>
@ -54,14 +55,16 @@
#include <sys/stat.h>
#endif //GNUWIN32
#include "wx/log.h"
#ifdef __BORLANDC__ // Please someone tell me which version of Borland needs
// this (3.1 I believe) and how to test for it.
// If this works for Borland 4.0 as well, then no worries.
#include <dir.h>
#endif
#if defined(__WIN32__) && !defined(__TWIN32__)
#include <winsock.h> // we use socket functions in wxGetFullHostName()
#endif
// VZ: there is some code using NetXXX() functions to get the full user name:
// I don't think it's a good idea because they don't work under Win95 and
// seem to return the same as wxGetUserId() under NT. If you really want
@ -146,12 +149,10 @@ static const wxChar eUSERID[] = wxT("UserId");
// get host name and related
// ----------------------------------------------------------------------------
// Get full hostname (eg. DoDo.BSn-Germany.crg.de)
// Get hostname only (without domain name)
bool wxGetHostName(wxChar *buf, int maxSize)
{
#if defined(__WIN32__) && !defined(__TWIN32__)
// TODO should use GetComputerNameEx() when available
DWORD nSize = maxSize;
if ( !::GetComputerName(buf, &nSize) )
{
@ -174,8 +175,48 @@ bool wxGetHostName(wxChar *buf, int maxSize)
#endif
}
// get full hostname (with domain name if possible)
bool wxGetFullHostName(wxChar *buf, int maxSize)
{
#if defined(__WIN32__) && !defined(__TWIN32__)
// TODO should use GetComputerNameEx() when available
WSADATA wsa;
if ( WSAStartup(MAKEWORD(1, 1), &wsa) == 0 )
{
wxString host;
char bufA[256];
if ( gethostname(bufA, WXSIZEOF(bufA)) == 0 )
{
// gethostname() won't usually include the DNS domain name, for
// this we need to work a bit more
if ( !strchr(bufA, '.') )
{
struct hostent *pHostEnt = gethostbyname(bufA);
if ( pHostEnt )
{
// Windows will use DNS internally now
pHostEnt = gethostbyaddr(pHostEnt->h_addr, 4, PF_INET);
}
if ( pHostEnt )
{
host = pHostEnt->h_name;
}
}
}
WSACleanup();
if ( !!host )
{
wxStrncpy(buf, host, maxSize);
return TRUE;
}
}
#endif // Win32
return wxGetHostName(buf, maxSize);
}