Rev 1 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 4 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | unit DXPlayFm; |
1 | unit DXPlayFm; |
2 | 2 | ||
3 | interface |
3 | interface |
4 | - | ||
- | 4 | {$INCLUDE DelphiXcfg.inc} |
|
5 | uses |
5 | uses |
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
7 | StdCtrls, ExtCtrls, DirectX, DXPlay, ActiveX, DXETable, DIB; |
7 | StdCtrls, ExtCtrls, DXPlay, ActiveX, DXETable, DIB, |
- | 8 | {$IfDef StandardDX} |
|
- | 9 | DirectDraw, DirectPlay; |
|
- | 10 | {$Else} |
|
- | 11 | DirectX; |
|
- | 12 | {$EndIf} |
|
8 | 13 | ||
9 | type |
14 | type |
10 | TDelphiXDXPlayForm = class(TForm) |
15 | TDelphiXDXPlayForm = class(TForm) |
11 | Notebook: TNotebook; |
16 | Notebook: TNotebook; |
12 | NextButton: TButton; |
17 | NextButton: TButton; |
Line 52... | Line 57... | ||
52 | procedure JoinGameGetPlayerListTimerTimer(Sender: TObject); |
57 | procedure JoinGameGetPlayerListTimerTimer(Sender: TObject); |
53 | procedure JoinGameSessionListClick(Sender: TObject); |
58 | procedure JoinGameSessionListClick(Sender: TObject); |
54 | private |
59 | private |
55 | FProviderGUID: TGUID; |
60 | FProviderGUID: TGUID; |
56 | public |
61 | public |
- | 62 | DPlay: //{$IfDef DX7} |
|
57 | DPlay: IDirectPlay4A; |
63 | IDirectPlay4A; |
- | 64 | //{$Else}IDirectPlay8Address{$EndIf}; |
|
58 | DXPlay: TCustomDXPlay; |
65 | DXPlay: TCustomDXPlay; |
59 | PlayerName: string; |
66 | PlayerName: string; |
60 | ProviderName: string; |
67 | ProviderName: string; |
61 | SessionName: string; |
68 | SessionName: string; |
62 | end; |
69 | end; |
Line 102... | Line 109... | ||
102 | 109 | ||
103 | procedure TDelphiXDXPlayForm.NextButtonClick(Sender: TObject); |
110 | procedure TDelphiXDXPlayForm.NextButtonClick(Sender: TObject); |
104 | 111 | ||
105 | procedure InitDirectPlay; |
112 | procedure InitDirectPlay; |
106 | var |
113 | var |
- | 114 | DPlay1: //{$IfDef DX7} |
|
107 | DPlay1: IDirectPlay; |
115 | IDirectPlay; |
- | 116 | //{$Else}IDirectPlay8Server{$EndIf}; |
|
108 | begin |
117 | begin |
109 | if DXDirectPlayCreate(FProviderGUID, DPlay1, nil)<>0 then |
118 | if DXDirectPlayCreate(FProviderGUID, DPlay1, nil)<>0 then |
110 | raise EDXPlayError.CreateFmt(SCannotInitialized, [SDirectPlay]); |
119 | raise EDXPlayError.CreateFmt(SCannotInitialized, [SDirectPlay]); |
111 | 120 | ||
112 | DPlay := DPlay1 as IDirectPlay4A; |
121 | DPlay := DPlay1 as //{$IfDef DX7} |
- | 122 | IDirectPlay4A//{$Else}IDirectPlay8Address{$EndIf} |
|
113 | end; |
123 | end; |
114 | 124 | ||
115 | function EnumSessionsCallback(const lpThisSD: TDPSessionDesc2; |
125 | function EnumSessionsCallback(const lpThisSD: TDPSessionDesc2; |
116 | var lpdwTimeOut: DWORD; dwFlags: DWORD; lpContext: Pointer): BOOL; stdcall; |
126 | var lpdwTimeOut: DWORD; dwFlags: DWORD; lpContext: Pointer): BOOL; stdcall; |
117 | var |
127 | var |
Line 123... | Line 133... | ||
123 | Exit; |
133 | Exit; |
124 | end; |
134 | end; |
125 | 135 | ||
126 | Guid := New(PGUID); |
136 | Guid := New(PGUID); |
127 | Move(lpThisSD.guidInstance, Guid^, SizeOf(TGUID)); |
137 | Move(lpThisSD.guidInstance, Guid^, SizeOf(TGUID)); |
- | 138 | {$IFDEF UNICODE} |
|
- | 139 | TDelphiXDXPlayForm(lpContext).JoinGameSessionList.Items.AddObject(lpThisSD.lpszSessionNameW, Pointer(Guid)); |
|
- | 140 | {$ELSE} |
|
128 | TDelphiXDXPlayForm(lpContext).JoinGameSessionList.Items.AddObject(lpThisSD.lpszSessionNameA, Pointer(Guid)); |
141 | TDelphiXDXPlayForm(lpContext).JoinGameSessionList.Items.AddObject(lpThisSD.lpszSessionNameA, Pointer(Guid)); |
129 | 142 | {$ENDIF} |
|
130 | Result := True; |
143 | Result := True; |
131 | end; |
144 | end; |
132 | 145 | ||
133 | var |
146 | var |
134 | dpDesc: TDPSessionDesc2; |
147 | dpDesc: TDPSessionDesc2; |
Line 230... | Line 243... | ||
230 | const lpName: TDPName; dwFlags: DWORD; lpContext: Pointer): BOOL; stdcall; |
243 | const lpName: TDPName; dwFlags: DWORD; lpContext: Pointer): BOOL; stdcall; |
231 | begin |
244 | begin |
232 | with lpName do |
245 | with lpName do |
233 | begin |
246 | begin |
234 | if lpszShortNameA<>nil then |
247 | if lpszShortNameA<>nil then |
- | 248 | {$IFDEF UNICODE} |
|
- | 249 | TDelphiXDXPlayForm(lpContext).JoinGamePlayerList.Items.Add(lpszShortNameW); |
|
- | 250 | {$ELSE} |
|
235 | TDelphiXDXPlayForm(lpContext).JoinGamePlayerList.Items.Add(lpszShortNameA); |
251 | TDelphiXDXPlayForm(lpContext).JoinGamePlayerList.Items.Add(lpszShortNameA); |
- | 252 | {$ENDIF} |
|
236 | end; |
253 | end; |
237 | 254 | ||
238 | Result := True; |
255 | Result := True; |
239 | end; |
256 | end; |
240 | 257 | ||
Line 262... | Line 279... | ||
262 | dpDesc.guidApplication := DXPlayStringToGUID(DXPlay.GUID); |
279 | dpDesc.guidApplication := DXPlayStringToGUID(DXPlay.GUID); |
263 | 280 | ||
264 | hr := TempDPlay.Open(dpDesc, DPOPEN_JOIN); |
281 | hr := TempDPlay.Open(dpDesc, DPOPEN_JOIN); |
265 | if hr<>0 then Exit; |
282 | if hr<>0 then Exit; |
266 | try |
283 | try |
267 | TempDPlay.EnumPlayers(PGUID(nil)^, @EnumPlayersCallback2, Self, DPENUMPLAYERS_REMOTE); |
284 | TempDPlay.EnumPlayers(PGUID(nil), @EnumPlayersCallback2, Self, DPENUMPLAYERS_REMOTE); |
268 | finally |
285 | finally |
269 | TempDPlay.Close; |
286 | TempDPlay.Close; |
270 | end; |
287 | end; |
271 | finally |
288 | finally |
272 | TempDPlay := nil; |
289 | TempDPlay := nil; |