文字列のアトムテーブル追加と取得 <TOP>
AddAtom
文字列をローカルアトムテーブルに追加し、その文字列を識別する一意の値(アトム)を返す
GetAtomName 指定されたローカルアトムに関連付けられている文字列のコピーを取得
'================================================================ '= 文字列のアトムテーブル追加と取得 '= (AddAtom.bas) '================================================================ #include "Windows.bi" ' 文字列をローカルアトムテーブルに追加し、その文字列を識別する一意の値(アトム)を返す Declare Function Api_AddAtom% Lib "kernel32" Alias "AddAtomA" (ByVal lpString$) ' 指定されたローカルアトムに関連付けられている文字列のコピーを取得 Declare Function Api_GetAtomName& Lib "kernel32" Alias "GetAtomNameA" (ByVal nAtom%, ByVal lpBuffer$, ByVal nSize&) #define MAX_ATOM 255 Var Shared Text1 As Object var shared List1 As Object Text1.Attach GetDlgItem("Text1") : Text1.SetFontSize 14 List1.Attach GetDlgItem("List1") : List1.SetFontSize 14 Var Shared iAtom(11) As Integer '================================================================ '= '================================================================ Declare Sub MainForm_Start edecl () Sub MainForm_Start() Var i As Integer Var mm(11) As String List1.ResetContent For i = 0 To 11 Read mm(i) iAtom(i) = Api_AddAtom(mm(i) & Chr$(0)) List1.AddString Right$(Hex$(iAtom(i)), 4) Next i data "January" data "February" data "March" data "April" data "May" data "June" data "July" data "August" data "September" data "October" data "November" data "December" End Sub '================================================================ '= '================================================================ Declare Sub List1_Click edecl () Sub List1_Click() Var i As Integer Var txt As String Var Ret As Long txt = Space$(MAX_ATOM) i = List1.GetCursel Ret = Api_GetAtomName(iAtom(i), txt, Len(txt)) Text1.SetWindowtext Left$(txt, Ret) End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End