| |
 |
SWAPI_EnumContinentCountries
This function enumerates all countries of the given continent by passing the country ID for each country one by one to an application-defined callback function. Function continues until all the continent countries are enumerated or the callback function returns FALSE.
Syntax
| Microsoft Visual C++ |
BOOL __stdcall SWAPI_EnumContinentCountries( UCHAR ContinentID, WORD CodeStatus, EnumCountriesProc EnumProc, DWORD UserData ); |
|
| Borland Delphi |
function SWAPI_EnumContinentCountries( const ContinentID: Byte; const CodeStatus: WORD; const EnumProc: TEnumCountriesProc; const UserData: DWORD ): BOOL; stdcall; |
|
| Microsoft Visual Basic |
Declare Function SWAPI_EnumContinentCountries Lib "swapimap.dll" ( ByVal ContinentID As Byte, ByVal CodeStatus As Integer, ByVal EnumProc As Long, ByVal UserData As Long ) As Boolean |
|
Parameters
| ContinentID |
[in] Continent ID for which the countries are being enumerated. Must be within the range returned by SWAPI_GetMinContinentID and SWAPI_GetMaxContinentID, otherwise the function will fail. |
| CodeStatus |
[in] Only those countries will be enumerated for which the ISO 3166-1 code status matches the status in this parameter. A single or combination of several statuses returned by SWAPI_GetCountryCodeStatus are allowed. The default value is CODE_STATUS_ISO_OFFICIALLY_ASSIGNED. |
| EnumProc |
[in] Pointer to an application-defined callback function. For more information, see EnumCountriesProc. |
| UserData |
| [in] Specifies an application-defined value to be passed to the callback function. |
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Remarks
Countries are enumerated in ascending order.
Sample Code
| Microsoft Visual C++ |
BOOL __stdcall FillCountriesProc(WORD CountryID, DWORD UserData) { CListBox *lb = (CListBox *)UserData; lb->AddString(CountryIDToCountryName(CountryID)); return TRUE; }
void CMainDlg::ListCountries(UCHAR ContinentID) { m_cCountryList.ResetContent(); SWAPI_EnumContinentCountries(ContinentID, CODE_STATUS_ISO_OFFICIALLY_ASSIGNED, &FillCountriesProc, (DWORD)&m_cCountryList); m_cCountryList.UpdateWindow(); } |
|
| Borland Delphi |
function EnumCountriesProc(const CountryID: WORD; const UserData: DWORD): BOOL; stdcall; begin Result := True; TMemo(UserData).Lines.Add(CountryIDToCountryName(CountryID)); end;
procedure TMainForm.ListCountries(const ContinentID: Byte); begin Memo1.Lines.BeginUpdate; try Memo1.Clear; SWAPI_EnumContinentCountries(ContinentID, CODE_STATUS_ISO_OFFICIALLY_ASSIGNED, EnumCountriesProc, DWORD(Memo1)); finally Memo1.Lines.EndUpdate; end; end; |
|
| Microsoft Visual Basic |
' Module Public Function EnumCountriesProc(ByVal CountryID As Integer, ByRef lb As ListBox) As Boolean EnumCountriesProc = True lb.AddItem CountryIDToCountryName(CountryID) End Function
' Form Private Sub ListCountries(ContinentID As Byte) List1.Clear SWAPI_EnumContinentCountries ContinentID, _ CODE_STATUS_ISO_OFFICIALLY_ASSIGNED, AddressOf EnumCountriesProc, List1 End Sub |
|
Defined In
| Microsoft Visual C++ |
| SWAPIMap.h, SWAPIMap.cpp |
|
| Borland Delphi |
| SWAPIMap.pas |
|
| Microsoft Visual Basic |
| SWAPIMap.bas |
|
See Also
Functions for Obtaining the Continent ID EnumCountriesProc SWAPI_GetCountryCodeStatus
Copyright © 2006-2008, TamoSoft
|