Debian Codegraph @

plugins/wfx/samba/src/smbauthdlg.pas

raw
1 unit SmbAuthDlg;
2
3 {$mode objfpc}{$H+}
4
5 {$R smbauthdlg.lfm}
6
7 interface
8
9 uses
10 SysUtils, Extension;
11
12 function ShowSmbAuthDlg: Boolean;
13
14 implementation
15
16 uses
17 SmbFunc;
18
19 function DlgProc (pDlg: PtrUInt; DlgItemName: PAnsiChar; Msg, wParam, lParam: PtrInt): PtrInt; cdecl;
20 var
21 Data: PtrInt;
22 Text: String;
23 begin
24 Result:= 0;
25 with ExtensionStartupInfo do
26 begin
27 case Msg of
28 DN_INITDIALOG:
29 begin
30 Text:= PAnsiChar(SendDlgMsg(pDlg, 'lblMessage', DM_GETTEXT, 0, 0));
31 Data:= PtrInt(PAnsiChar(Format(Text, [Message])));
32 SendDlgMsg(pDlg, 'lblMessage', DM_SETTEXT, Data, 0);
33 Data:= PtrInt(PAnsiChar(UserName));
34 SendDlgMsg(pDlg, 'edtUserName', DM_SETTEXT, Data, 0);
35 Data:= PtrInt(PAnsiChar(WorkGroup));
36 SendDlgMsg(pDlg, 'edtDomain', DM_SETTEXT, Data, 0);
37 Data:= PtrInt(PAnsiChar(Password));
38 SendDlgMsg(pDlg, 'edtPassword', DM_SETTEXT, Data, 0);
39 end;
40 DN_CLICK:
41 if DlgItemName = 'btnOK' then
42 begin
43 Data:= SendDlgMsg(pDlg, 'edtUserName', DM_GETTEXT, 0, 0);
44 StrLCopy(UserName, PAnsiChar(Data), MAX_PATH);
45 Data:= SendDlgMsg(pDlg, 'edtDomain', DM_GETTEXT, 0, 0);
46 StrLCopy(WorkGroup, PAnsiChar(Data), MAX_PATH);
47 Data:= SendDlgMsg(pDlg, 'edtPassword', DM_GETTEXT, 0, 0);
48 StrLCopy(Password, PAnsiChar(Data), MAX_PATH);
49 // close dialog
50 SendDlgMsg(pDlg, DlgItemName, DM_CLOSE, ID_OK, 0);
51 end
52 else if DlgItemName = 'btnCancel' then
53 begin
54 // close dialog
55 SendDlgMsg(pDlg, DlgItemName, DM_CLOSE, ID_CANCEL, 0);
56 end;
57 end;// case
58 end; // with
59 end;
60
61 function ShowSmbAuthDlg: Boolean;
62 var
63 ResHandle: TFPResourceHandle = 0;
64 ResGlobal: TFPResourceHGLOBAL = 0;
65 ResData: Pointer = nil;
66 ResSize: LongWord;
67 begin
68 Result := False;
69 try
70 ResHandle := FindResource(HINSTANCE, PChar('TDIALOGBOX'), MAKEINTRESOURCE(10) {RT_RCDATA});
71 if ResHandle <> 0 then
72 begin
73 ResGlobal := LoadResource(HINSTANCE, ResHandle);
74 if ResGlobal <> 0 then
75 begin
76 ResData := LockResource(ResGlobal);
77 ResSize := SizeofResource(HINSTANCE, ResHandle);
78
79 with ExtensionStartupInfo do
80 begin
81 Result := DialogBoxLRS(ResData, ResSize, @DlgProc);
82 end;
83 end;
84 end;
85
86 finally
87 if ResGlobal <> 0 then
88 begin
89 UnlockResource(ResGlobal);
90 FreeResource(ResGlobal);
91 end;
92 end;
93 end;
94
95 end.