no message

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4086 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster 1999-10-20 22:41:35 +00:00
parent 2f073eb2e0
commit 10e5b9303b

View File

@ -46,7 +46,6 @@
#include <netcons.h> #include <netcons.h>
#include <netbios.h> #include <netbios.h>
// In the WIN.INI file
static const wxChar WX_SECTION[] = _T("wxWindows"); static const wxChar WX_SECTION[] = _T("wxWindows");
static const wxChar eHOSTNAME[] = _T("HostName"); static const wxChar eHOSTNAME[] = _T("HostName");
static const wxChar eUSERID[] = _T("UserId"); static const wxChar eUSERID[] = _T("UserId");
@ -58,87 +57,117 @@ static const wxChar eUSERNAME[] = _T("UserName");
// functions beyond those provided by WinSock // functions beyond those provided by WinSock
// Get full hostname (eg. DoDo.BSn-Germany.crg.de) // Get full hostname (eg. DoDo.BSn-Germany.crg.de)
bool wxGetHostName(wxChar *buf, int maxSize) bool wxGetHostName(
wxChar* zBuf
, int nMaxSize
)
{ {
#if wxUSE_NET_API #if wxUSE_NET_API
char server[256]; char zServer[256];
char computer[256]; char zComputer[256];
unsigned long ulLevel; unsigned long ulLevel;
unsigned char* pbBuffer; unsigned char* zBuffer;
unsigned long ulBuffer; unsigned long ulBuffer;
unsigned long* pulTotalAvail; unsigned long* pulTotalAvail;
NetBios32GetInfo( (const unsigned char*)server NetBios32GetInfo( (const unsigned char*)zServer
,(const unsigned char*)computer ,(const unsigned char*)zComputer
,ulLevel ,ulLevel
,pbBuffer ,zBuffer
,ulBuffer ,ulBuffer
,pulTotalAvail ,pulTotalAvail
); );
strcpy(buf, server); strcpy(zBuf, zServer);
#else #else
wxChar *sysname; wxChar* zSysname;
const wxChar *default_host = _T("noname"); const wxChar* zDefaultHost = _T("noname");
if ((sysname = wxGetenv(_T("SYSTEM_NAME"))) == NULL) if ((zSysname = wxGetenv(_T("SYSTEM_NAME"))) == NULL)
{ {
// GetProfileString(WX_SECTION, eHOSTNAME, default_host, buf, maxSize - 1); ULONG n = ::PrfQueryProfileString( HINI_PROFILE
,(PSZ)WX_SECTION
,(PSZ)eHOSTNAME
,(PSZ)zDefaultHost
,(void*)zBuf
,(ULONG)nMaxSize - 1
);
} }
else else
wxStrncpy(buf, sysname, maxSize - 1); wxStrncpy(zBuf, zSysname, nMaxSize - 1);
buf[maxSize] = _T('\0'); zBuf[nMaxSize] = _T('\0');
#endif #endif
return *buf ? TRUE : FALSE; return *zBuf ? TRUE : FALSE;
} }
// Get user ID e.g. jacs // Get user ID e.g. jacs
bool wxGetUserId(wxChar *buf, int maxSize) bool wxGetUserId(
wxChar* zBuf
, int nMaxSize
)
{ {
return(U32ELOCL((unsigned char*)buf, (unsigned long *)&maxSize)); return(U32ELOCL((unsigned char*)zBuf, (unsigned long *)&nMaxSize));
} }
bool wxGetUserName(wxChar *buf, int maxSize) bool wxGetUserName(
wxChar* zBuf
, int nMaxSize
)
{ {
#ifdef USE_NET_API #ifdef USE_NET_API
wxGetUserId(buf, maxSize); wxGetUserId( zBuf
,nMaxSize
);
#else #else
wxStrncpy(buf, _T("Unknown User"), maxSize); wxStrncpy(zBuf, _T("Unknown User"), nMaxSize);
#endif #endif
return TRUE; return TRUE;
} }
int wxKill(long pid, int sig) int wxKill(
long lPid
, int nSig
)
{ {
return 0; return((int)::DosKillProcess(0, (PID)lPid));
} }
// //
// Execute a program in an Interactive Shell // Execute a program in an Interactive Shell
// //
bool wxShell(const wxString& command) bool wxShell(
const wxString& rCommand
)
{ {
wxChar *shell; wxChar* zShell;
if ((shell = wxGetenv(_T("COMSPEC"))) == NULL)
shell = _T("\\CMD.EXE");
wxChar tmp[255]; if ((zShell = wxGetenv(_T("COMSPEC"))) == NULL)
if (command != "") zShell = _T("\\CMD.EXE");
wxSprintf(tmp, "%s /c %s", shell, WXSTRINGCAST command);
wxChar zTmp[255];
if (rCommand != "")
wxSprintf( zTmp
,"%s /c %s"
,zShell
,WXSTRINGCAST rCommand
);
else else
wxStrcpy(tmp, shell); wxStrcpy(zTmp, zShell);
return (wxExecute((wxChar *)tmp, FALSE) != 0); return (wxExecute((wxChar*)zTmp, FALSE) != 0);
} }
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
long wxGetFreeMemory(void *memptr) long wxGetFreeMemory(
void* pMemptr
)
{ {
ULONG lSize; ULONG lSize;
ULONG lMemFlags; ULONG lMemFlags;
APIRET rc; APIRET rc;
lMemFlags = PAG_FREE; lMemFlags = PAG_FREE;
rc = ::DosQueryMem(memptr, &lSize, &lMemFlags); rc = ::DosQueryMem(pMemptr, &lSize, &lMemFlags);
if (rc != 0) if (rc != 0)
return -1L; return -1L;
return (long)lSize; return (long)lSize;
@ -159,12 +188,16 @@ class wxSleepTimer: public wxTimer
static wxTimer* wxTheSleepTimer = NULL; static wxTimer* wxTheSleepTimer = NULL;
void wxUsleep(unsigned long milliseconds) void wxUsleep(
unsigned long ulMilliseconds
)
{ {
::DosSleep(milliseconds); ::DosSleep(ulMilliseconds);
} }
void wxSleep(int nSecs) void wxSleep(
int nSecs
)
{ {
::DosSleep(1000 * nSecs); ::DosSleep(1000 * nSecs);
} }
@ -176,29 +209,31 @@ void wxFlushEvents()
} }
// Output a debug mess., in a system dependent fashion. // Output a debug mess., in a system dependent fashion.
void wxDebugMsg(const wxChar *fmt ...) void wxDebugMsg(
const wxChar* zFmt ...
)
{ {
va_list ap; va_list vAp;
static wxChar buffer[512]; static wxChar zBuffer[512];
if (!wxTheApp->GetWantDebugOutput()) if (!wxTheApp->GetWantDebugOutput())
return ; return ;
va_start(vAp, zFmt);
va_start(ap, fmt); sprintf(zBuffer, zFmt, vAp) ;
va_end(vAp);
sprintf(buffer,fmt,ap) ;
va_end(ap);
} }
// Non-fatal error: pop up message box and (possibly) continue // Non-fatal error: pop up message box and (possibly) continue
void wxError(const wxString& msg, const wxString& title) void wxError(
const wxString& rMsg
, const wxString& rTitle
)
{ {
wxSprintf(wxBuffer, "%s\nContinue?", WXSTRINGCAST msg); wxSprintf(wxBuffer, "%s\nContinue?", WXSTRINGCAST rMsg);
if (::WinMessageBox( HWND_DESKTOP if (::WinMessageBox( HWND_DESKTOP
,NULL ,NULL
,(PSZ)wxBuffer ,(PSZ)wxBuffer
,(PSZ)WXSTRINGCAST title ,(PSZ)WXSTRINGCAST rTitle
,0 ,0
,MB_ICONEXCLAMATION | MB_YESNO ,MB_ICONEXCLAMATION | MB_YESNO
) == MBID_YES) ) == MBID_YES)
@ -206,18 +241,21 @@ void wxError(const wxString& msg, const wxString& title)
} }
// Fatal error: pop up message box and abort // Fatal error: pop up message box and abort
void wxFatalError(const wxString& rMsg, const wxString& rTitle) void wxFatalError(
const wxString& rMsg
, const wxString& rTitle
)
{ {
unsigned long rc; unsigned long ulRc;
rc = ::WinMessageBox( HWND_DESKTOP ulRc = ::WinMessageBox( HWND_DESKTOP
,NULL ,NULL
,WXSTRINGCAST rMsg ,WXSTRINGCAST rMsg
,WXSTRINGCAST rTitle ,WXSTRINGCAST rTitle
,0 ,0
,MB_NOICON | MB_OK ,MB_NOICON | MB_OK
); );
DosExit(EXIT_PROCESS, rc); DosExit(EXIT_PROCESS, ulRc);
} }
// Emit a beeeeeep // Emit a beeeeeep
@ -228,58 +266,74 @@ void wxBell()
// Chris Breeze 27/5/98: revised WIN32 code to // Chris Breeze 27/5/98: revised WIN32 code to
// detect WindowsNT correctly // detect WindowsNT correctly
int wxGetOsVersion(int *majorVsn, int *minorVsn) int wxGetOsVersion(
int* pMajorVsn
, int* pMinorVsn
)
{ {
ULONG aulSysInfo[QSV_MAX] = {0}; ULONG ulSysInfo[QSV_MAX] = {0};
if (DosQuerySysInfo( 1L if (::DosQuerySysInfo( 1L
,QSV_MAX ,QSV_MAX
,(PVOID)aulSysInfo ,(PVOID)ulSysInfo
,sizeof(ULONG) * QSV_MAX ,sizeof(ULONG) * QSV_MAX
)) ))
{ {
*majorVsn = aulSysInfo[QSV_VERSION_MAJOR]; *pMajorVsn = ulSysInfo[QSV_VERSION_MAJOR];
*minorVsn = aulSysInfo[QSV_VERSION_MINOR]; *pMinorVsn = ulSysInfo[QSV_VERSION_MINOR];
return wxWINDOWS_OS2; return wxWINDOWS_OS2;
} }
return wxWINDOWS; // error if we get here, return generic value return wxWINDOWS; // error if we get here, return generic value
} }
// Reading and writing resources (eg WIN.INI, .Xdefaults) // Reading and writing resources (eg WIN.INI, .Xdefaults)
// TODO: Ability to read and write to an INI file
#if wxUSE_RESOURCES #if wxUSE_RESOURCES
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file) bool wxWriteResource(
const wxString& rSection
, const wxString& rEntry
, const wxString& rValue
, const wxString& rFile
)
{ {
HAB hab; HAB hab;
HINI hIni; HINI hIni;
if (file != "") if (rFile != "")
{ {
hIni = ::PrfOpenProfile(hab, (PSZ)WXSTRINGCAST file); hIni = ::PrfOpenProfile(hab, (PSZ)WXSTRINGCAST rFile);
if (hIni != 0L) if (hIni != 0L)
{ {
return (::PrfWriteProfileString( hIni return (::PrfWriteProfileString( hIni
,(PSZ)WXSTRINGCAST section ,(PSZ)WXSTRINGCAST rSection
,(PSZ)WXSTRINGCAST entry ,(PSZ)WXSTRINGCAST rEntry
,(PSZ)WXSTRINGCAST value ,(PSZ)WXSTRINGCAST rValue
)); ));
} }
} }
else else
return (::PrfWriteProfileString( HINI_PROFILE return (::PrfWriteProfileString( HINI_PROFILE
,(PSZ)WXSTRINGCAST section ,(PSZ)WXSTRINGCAST rSection
,(PSZ)WXSTRINGCAST entry ,(PSZ)WXSTRINGCAST rEntry
,(PSZ)WXSTRINGCAST value ,(PSZ)WXSTRINGCAST rValue
)); ));
return FALSE; return FALSE;
} }
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file) bool wxWriteResource(
const wxString& rSection
, const wxString& rEntry
, float fValue
, const wxString& rFile
)
{ {
wxChar buf[50]; wxChar zBuf[50];
wxSprintf(buf, "%.4f", value);
return wxWriteResource(section, entry, buf, file); wxSprintf(zBuf, "%.4f", fValue);
return wxWriteResource( rSection
,rEntry
,zBuf
,rFile
);
} }
bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file) bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file)
@ -438,7 +492,7 @@ const wxChar* wxGetHomeDir(wxString *pstr)
return strDir.c_str(); return strDir.c_str();
} }
// Hack for MS-DOS // Hack for OS/2
wxChar *wxGetUserHome (const wxString& user) wxChar *wxGetUserHome (const wxString& user)
{ {
wxChar *home; wxChar *home;
@ -491,37 +545,6 @@ bool wxCheckForInterrupt(wxWindow *wnd)
} }
} }
wxChar *wxLoadUserResource(const wxString& resourceName, const wxString& resourceType)
{
wxChar *s = NULL;
/*
* How to in PM?
*
* #if !defined(__WIN32__) || defined(__TWIN32__)
* HRSRC hResource = ::FindResource(wxGetInstance(), WXSTRINGCAST resourceName, WXSTRINGCAST resourceType);
* #else
* #ifdef UNICODE
* HRSRC hResource = ::FindResourceW(wxGetInstance(), WXSTRINGCAST resourceName, WXSTRINGCAST resourceType);
* #else
* HRSRC hResource = ::FindResourceA(wxGetInstance(), WXSTRINGCAST resourceName, WXSTRINGCAST resourceType);
* #endif
* #endif
*
* if (hResource == 0)
* return NULL;
* HGLOBAL hData = ::LoadResource(wxGetInstance(), hResource);
* if (hData == 0)
* return NULL;
* wxChar *theText = (wxChar *)LockResource(hData);
* if (!theText)
* return NULL;
*
* s = copystring(theText);
*/
return s;
}
void wxGetMousePosition( int* x, int* y ) void wxGetMousePosition( int* x, int* y )
{ {
POINTL pt; POINTL pt;