2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
14 * The AFS Application Library is a collection of handy support code
15 * for UI-level applications written for Windows NT and Windows 95.
17 * The various components of the library provide common dialogs,
18 * error code translation, task threading, error dialogs, additional
19 * Windows dialog controls, and many other functions.
21 * The goal of this library is to shorten application development time
22 * by providing pre-packaged functions, while ensuring a common user
23 * interface for Transarc applications.
29 * DEFINITIONS ________________________________________________________________
36 #ifdef EXPORT_AFSAPPLIB
37 #define EXPORTED __declspec(dllexport)
39 #define EXPORTED __declspec(dllimport)
43 # define APP_HINST AfsAppLib_GetAppInstance()
46 # define APPLIB_HINST AfsAppLib_GetInstance()
50 # define THIS_HINST APPLIB_HINST
52 # define THIS_HINST APP_HINST
74 * INCLUSIONS _________________________________________________________________
78 // This library relies on the TaLocale suite to provide
79 // access to localized resources.
81 #include <WINNT/TaLocale.h>
83 // This library provides support for performing all operations
84 // through a remote administration server. If you want to use
85 // these capabilities AND you want to use the asc_* routines
86 // from TaAfsAdmSvrClient.lib directly, you must include
87 // <TaAfsAdmSvrClient.h> before including this header.
89 #ifdef TAAFSADMSVRCLIENT_H
90 #ifndef TAAFSADMSVRINTERNAL_H
91 #ifndef TAAFSADMSVRCLIENTINTERNAL_H
92 #include <WINNT/al_admsvr.h>
93 #endif // TAAFSADMSVRCLIENTINTERNAL_H
94 #endif // TAAFSADMSVRINTERNAL_H
95 #endif // TAAFSADMSVRCLIENT_H
97 // A few general-purpose AfsAppLib headers
99 #include <WINNT/al_resource.h>
100 #include <WINNT/al_messages.h>
102 // In addition to the prototypes you'll find in this header file,
103 // the following source files provide many useful features--
104 // take a few moments and examine their headers individually to
105 // see what they can do for your application.
107 // Each header is associated with one source file, and each pair
108 // can easily (well, hopefully easily) be copied off to other
111 #include <WINNT/hashlist.h> // general-purpose list management code
112 #include <WINNT/resize.h> // window resizing functions
113 #include <WINNT/subclass.h> // window subclass code
114 #include <WINNT/dialog.h> // general window control routines
115 #include <WINNT/ctl_spinner.h> // enhanced version of MSCTLS_UPDOWN
116 #include <WINNT/ctl_elapsed.h> // elapsed-time entry window control
117 #include <WINNT/ctl_time.h> // absolute-time entry window control
118 #include <WINNT/ctl_date.h> // absolute-date entry window control
119 #include <WINNT/ctl_sockaddr.h> // IP address entry window control
120 #include <WINNT/settings.h> // version-controlled settings
121 #include <WINNT/checklist.h> // checked-item listbox control
122 #include <WINNT/fastlist.h> // fast treeview/listview replacement
123 #include <WINNT/al_wizard.h> // easy wizard generation code
124 #include <WINNT/al_progress.h> // easy threaded progress-dialog code
125 #include <WINNT/regexp.h> // regular-expression pattern matching
129 * GENERAL ____________________________________________________________________
133 // AfsAppLib_SetAppName
134 // ...records the display name of your application, so AfsAppLib
135 // can add it to dialog boxes' titles.
137 EXPORTED
void AfsAppLib_SetAppName (LPTSTR pszName
);
138 EXPORTED
void AfsAppLib_GetAppName (LPTSTR pszName
);
140 // AfsAppLib_SetMainWindow
141 // ...specifies which window represents your application; the library
142 // subclasses this window and uses it to ensure some tasks are
143 // performed by the UI thread.
145 EXPORTED
void AfsAppLib_SetMainWindow (HWND hMain
);
146 EXPORTED HWND
AfsAppLib_GetMainWindow (void);
150 * REMOTE ADMINISTRATION ______________________________________________________
154 // AfsAppLib_OpenAdminServer
155 // AfsAppLib_CloseAdminServer
156 // ...enables the caller of the AfsAppLib library to indicate
157 // that AFS administrative functions should be performed by
158 // out-farming the actual operations onto an administrative
159 // server process, possibly running on another machine.
160 // By calling the OpenAdminServer() routine specifying a
161 // machine name or IP address, the AfsAppLib library will attempt
162 // to connect to an already-running administrative server on
163 // that machine; if successful, all further administrative
164 // tasks (until CloseAdminServer() is called) will be performed
165 // on that remote server. Similarly, by calling OpenAdminServer()
166 // but passing NULL as the address, the AfsAppLib library will
167 // use a separate administrative process running on the local
168 // computer, forking a new administrative server process if
169 // none is currently running now.
171 EXPORTED BOOL
AfsAppLib_OpenAdminServer (LPTSTR pszAddress
= NULL
, ULONG
*pStatus
= NULL
);
172 EXPORTED
void AfsAppLib_CloseAdminServer (void);
174 // AfsAppLib_GetAdminServerClientID
175 // ...every process which interacts with a remote administration
176 // server is assigned a client ID by that server, which the
177 // client process passes on each RPC to identify itself to the
178 // server. If AfsAppLib_OpenAdminServer() has previously been
179 // called, the AfsAppLib_GetAdminServerClientID() routine can
180 // be used to obtain the client id which the administrative
181 // server has assigned to this process.
183 EXPORTED UINT_PTR
AfsAppLib_GetAdminServerClientID (void);
187 * CELLLIST ___________________________________________________________________
191 // AfsAppLib_GetCellList
192 // ...obtains a list of cells:
193 // - if a registry path is supplied, that path is enumerated
194 // and the names of the keys below it returned as a cell list
195 // - if a registry path is not supplied, the list of cells
196 // contacted by the AFS client is returned.
197 // - if another cell list is supplied, that list is copied.
198 // The local cell will be in element 0. The AfsAppLib_FreeCellList
199 // routine should be called when the CELLLIST structure is no
202 typedef struct // CELLLIST
207 TCHAR szRegPath
[ MAX_PATH
];
208 } CELLLIST
, *LPCELLLIST
;
210 EXPORTED LPCELLLIST
AfsAppLib_GetCellList (HKEY hkBase
= NULL
, LPTSTR pszRegPath
= NULL
);
211 EXPORTED LPCELLLIST
AfsAppLib_GetCellList (LPCELLLIST lpcl
);
212 EXPORTED
void AfsAppLib_AddToCellList (LPCELLLIST lpcl
, LPTSTR pszCell
);
213 EXPORTED
void AfsAppLib_FreeCellList (LPCELLLIST lpcl
);
217 * BROWSE _____________________________________________________________________
221 // AfsAppLib_ShowBrowseDialog
222 // ...creates a modal dialog that lets the user select an AFS
235 HWND hParent
; // [in] Parent window for browse dialog
236 TCHAR szCell
[ cchNAME
]; // [inout] Cell name
237 TCHAR szNamed
[ cchNAME
]; // [inout] Selected principal
238 BROWSETYPE bt
; // [in] type of prinicipals to show
239 int idsTitle
; // [in] string ID for dialog title
240 int idsPrompt
; // [in] string ID for Edit prompt
241 int idsNone
; // [in] string ID for checkbox (or 0)
242 LPCELLLIST lpcl
; // [in] from AfsAppLib_GetCellList()
243 UINT_PTR hCreds
; // [in] credentials for enumeration
244 } BROWSEDLG_PARAMS
, *LPBROWSEDLG_PARAMS
;
246 EXPORTED BOOL
AfsAppLib_ShowBrowseDialog (LPBROWSEDLG_PARAMS lpp
);
249 // AfsAppLib_ShowBrowseFilesetDialog
250 // ...creates a modal dialog that lets the user select a fileset
254 HWND hParent
; // [in] parent window for browse dialog
255 TCHAR szCell
[ cchNAME
]; // [inout] cell name
256 TCHAR szFileset
[ cchNAME
]; // [inout] selected fileset
257 int idsTitle
; // [in] string ID for title (or 0)
258 int idsPrompt
; // [in] string ID for prompt (or 0)
259 LPCELLLIST lpcl
; // [in] NULL to disable cell selection
261 } BROWSESETDLG_PARAMS
, *LPBROWSESETDLG_PARAMS
;
263 EXPORTED BOOL
AfsAppLib_ShowBrowseFilesetDialog (LPBROWSESETDLG_PARAMS lpp
);
267 * COVER ______________________________________________________________________
271 // AfsAppLib_CoverClient
272 // AfsAppLib_CoverWindow
273 // ...hides the specified window (or just its client area), showing
274 // instead a simple etched rectangle filled with the descriptive
275 // text that you supply. An optional button can be shown in the
276 // lower-right corner; when pressed, the parent of the covered
277 // window receives a WM_COMMAND/IDC_COVERBUTTON message.
279 EXPORTED
void AfsAppLib_CoverClient (HWND hWnd
, LPTSTR pszDesc
, LPTSTR pszButton
= NULL
);
280 EXPORTED
void AfsAppLib_CoverWindow (HWND hWnd
, LPTSTR pszDesc
, LPTSTR pszButton
= NULL
);
283 // ...removes a cover (if any) from the specified window, re-showing
284 // the controls previously hidden underneath the cover.
286 EXPORTED
void AfsAppLib_Uncover (HWND hWnd
);
290 * CREDENTIALS ________________________________________________________________
294 // AfsAppLib_CrackCredentials
295 // ...obtains information about the specified credentials cookie.
296 // returns TRUE if the data could be successfully parsed.
298 EXPORTED BOOL
AfsAppLib_CrackCredentials (UINT_PTR hCreds
, LPTSTR pszCell
= NULL
, LPTSTR pszUser
= NULL
, LPSYSTEMTIME pst
= NULL
, ULONG
*pStatus
= NULL
);
300 // AfsAppLib_GetCredentials
301 // ...returns nonzero if the calling process has AFS credentials within
302 // the specified cell. Specify NULL as the cell ID to query
303 // credentials within the local cell. The return code is actually
304 // a token handle which can be supplied to the AFS administrative
307 EXPORTED UINT_PTR
AfsAppLib_GetCredentials (LPCTSTR pszCell
= NULL
, ULONG
*pStatus
= NULL
);
309 // AfsAppLib_SetCredentials
310 // ...obtains new credentials for the calling process; performs no UI.
311 // If successful, returns a nonzero token handle which can be
312 // supplied to the AFS administrative functions.
314 EXPORTED UINT_PTR
AfsAppLib_SetCredentials (LPCTSTR pszCell
, LPCTSTR pszUser
, LPCTSTR pszPassword
, ULONG
*pStatus
= NULL
);
316 // AfsAppLib_IsUserAdmin
317 // ...queries the KAS database for a particular cell to determine
318 // whether the specified identity has administrative privileges.
319 // The hCreds passed in should be for an admin, or for the user
322 EXPORTED BOOL
AfsAppLib_IsUserAdmin (UINT_PTR hCreds
, LPTSTR pszUser
);
324 // AfsAppLib_ShowOpenCellDialog
325 // ...presents a dialog which allows the user to select a cell,
326 // and optionally obtain new AFS credentials within that cell.
327 // the caller may optionally specify an alternate dialog template;
328 // if not, a default template will be used. the caller may also
329 // optionally supply a DLGPROC, which will be called to handle all
330 // dialog messages--if this hook returns FALSE, the default handler
331 // will be called; if it returns TRUE, no further processing for
332 // that message is performed.
336 int idd
; // [in] dialog template (or 0)
337 DLGPROC hookproc
; // [in] dialog procedure (or NULL)
338 HWND hParent
; // [in] parent window (or NULL)
339 int idsDesc
; // [in] string ID for description
340 BOOL
*pfShowWarningEver
; // [in] "don't ask again" checkbox
341 } BADCREDSDLG_PARAMS
, *LPBADCREDSDLG_PARAMS
;
345 int idd
; // [in] dialog template (or 0)
346 DLGPROC hookproc
; // [in] dialog procedure (or NULL)
347 HWND hParent
; // [in] parent window (or NULL)
348 int idsDesc
; // [in] string ID for dialog text
349 LPCELLLIST lpcl
; // [in] from AfsAppLib_GetCellList()
350 BADCREDSDLG_PARAMS bcdp
; // [in] params for bad creds dialog
351 TCHAR szCell
[ cchNAME
]; // [out] selected cell
352 UINT_PTR hCreds
; // [out] credentials in cell
353 } OPENCELLDLG_PARAMS
, *LPOPENCELLDLG_PARAMS
;
355 EXPORTED BOOL
AfsAppLib_ShowOpenCellDialog (LPOPENCELLDLG_PARAMS lpp
);
357 // AfsAppLib_ShowCredentialsDialog
358 // ...presents a dialog which displays the current AFS credentials
359 // and allows the user to obtain new credentials. An alternate
360 // dialog template and hook procedure can be specified.
364 int idd
; // [in] dialog template (or 0)
365 DLGPROC hookproc
; // [in] dialog procedure (or NULL)
366 HWND hParent
; // [in] parent window (or NULL)
367 TCHAR szCell
[ MAX_PATH
]; // [in out] current cell
368 BOOL fIgnoreBadCreds
; // [in] TRUE to skip bad creds dialog
369 BADCREDSDLG_PARAMS bcdp
; // [in] params for bad creds dialog
370 TCHAR szIdentity
[ cchNAME
]; // [out] current DCE identity in szCell
371 TCHAR szPassword
[ cchNAME
]; // [out] password entered (or "")
372 UINT_PTR hCreds
; // [in out] credentials in cell
373 } CREDENTIALSDLG_PARAMS
, *LPCREDENTIALSDLG_PARAMS
;
375 EXPORTED BOOL
AfsAppLib_ShowCredentialsDialog (LPCREDENTIALSDLG_PARAMS lpp
);
377 // AfsAppLib_CheckCredentials
378 // ...tests the current credentials to see if they represent
379 // a user with administrative access within the target cell.
383 UINT_PTR hCreds
; // [in] credentials to query
384 BOOL fShowWarning
; // [in] TRUE to present warning dialog
385 BADCREDSDLG_PARAMS bcdp
; // [in] params for bad creds dialog
386 } CHECKCREDS_PARAMS
, *LPCHECKCREDS_PARAMS
;
388 EXPORTED BOOL
AfsAppLib_CheckCredentials (LPCHECKCREDS_PARAMS lpp
);
390 // AfsAppLib_CheckForExpiredCredentials
391 // ...tests the user's credentials in the specified cell to see if
392 // they have expired; if so, calls AfsAppLib_CheckCredentials to
393 // display a warning dialog--if the user accepts the warning
394 // dialog, calls AfsAppLib_ShowCredentialsDialog. All that UI
395 // is modeless; this routine returns immediately.
397 EXPORTED
void AfsAppLib_CheckForExpiredCredentials (LPCREDENTIALSDLG_PARAMS lpp
);
401 * TASKING ____________________________________________________________________
407 int idTask
; // task ID requested
408 HWND hReply
; // window to which to reply
409 PVOID lpUser
; // parameter supplied by user
410 BOOL rc
; // TRUE if successful
411 ULONG status
; // if (rc == FALSE), error code
412 PVOID pReturn
; // allocated storage for return data
413 } TASKPACKET
, *LPTASKPACKET
;
415 // AfsAppLib_InitTaskQueue
416 // ...allows use of StartTask to perform background tasks.
417 // call this routine only once per application, and only
418 // if you want to use StartTask().
422 LPTASKPACKET (*fnCreateTaskPacket
)(int idTask
, HWND hReply
, PVOID lpUser
);
423 void (*fnPerformTask
)(LPTASKPACKET ptp
);
424 void (*fnFreeTaskPacket
)(LPTASKPACKET ptp
);
426 } TASKQUEUE_PARAMS
, *LPTASKQUEUE_PARAMS
;
428 EXPORTED
void AfsAppLib_InitTaskQueue (LPTASKQUEUE_PARAMS lpp
);
431 // ...pushes a request onto the task queue created by a previous
432 // call to AfsAppLib_InitTaskQueue. A background thread will
433 // be allocated to popping off the request and performing it,
434 // optionally posting a WM_ENDTASK message to the specified
435 // window upon completion.
437 EXPORTED
void StartTask (int idTask
, HWND hReply
= 0, PVOID lpUser
= 0);
441 * ERROR DIALOGS ______________________________________________________________
446 // ...creates a modeless error dialog containing the specified
447 // error text. if a non-zero status code is specified, the
448 // error dialog will also translate that error code and
449 // display its description. These routines create a modeless
450 // dialog, and can be called by any thread.
452 EXPORTED
void cdecl ErrorDialog (DWORD dwStatus
, LPTSTR pszError
, LPTSTR pszFmt
= NULL
, ...);
453 EXPORTED
void cdecl ErrorDialog (DWORD dwStatus
, int idsError
, LPTSTR pszFmt
= NULL
, ...);
456 // ...identical to ErrorDialog, except that PostQuitMessage()
457 // is performed after the error dialog is dismissed.
459 EXPORTED
void cdecl FatalErrorDialog (DWORD dwStatus
, LPTSTR pszError
, LPTSTR pszFmt
= NULL
, ...);
460 EXPORTED
void cdecl FatalErrorDialog (DWORD dwStatus
, int idsError
, LPTSTR pszFmt
= NULL
, ...);
462 // ImmediateErrorDialog
463 // ...identical to ErrorDialog, except that the error dialog
466 EXPORTED
void cdecl ImmediateErrorDialog (DWORD dwStatus
, LPTSTR pszError
, LPTSTR pszFmt
= NULL
, ...);
467 EXPORTED
void cdecl ImmediateErrorDialog (DWORD dwStatus
, int idsError
, LPTSTR pszFmt
= NULL
, ...);
471 * MODELESS DIALOGS ___________________________________________________________
473 * Modeless dialogs aren't treated as dialogs unless you call IsDialogMessage()
474 * for them in your pump--that is, tab won't work, nor will RETURN or ESC do
475 * what you expect, nor will hotkeys. The routines below allow you to specify
476 * that a given window should be treated as a modeless dialog--by calling one
477 * routine in your main pump, you can ensure all such modeless dialogs will
478 * have IsDialogMessage called for them:
481 * while (GetMessage (&msg, NULL, 0, 0))
483 * -> if (AfsAppLib_IsModelessDialogMessage (&msg))
486 * TranslateMessage (&msg);
487 * DispatchMessage (&msg);
490 * An equivalent technique is:
492 * AfsAppLib_MainPump();
494 * ...the MainPump() routine does exactly what the first example did.
498 // AfsAppLib_IsModelessDialogMessage
499 // ...called from your applications pump, this routine
500 // calls IsDialogMessage() for each window which
501 // has been registered by AfsAppLib_RegisterModelessDialog.
503 EXPORTED BOOL
AfsAppLib_IsModelessDialogMessage (MSG
*lpm
);
505 // AfsAppLib_RegisterModelessDialog
506 // ...ensures that AfsAppLib_IsModelessDialogMessage will
507 // call IsDialogMessage() for the specified window
509 EXPORTED
void AfsAppLib_RegisterModelessDialog (HWND hDlg
);
511 // AfsAppLib_SetPumpRoutine
512 // ...can be used to specify a routine which will be called for
513 // your application to process every message--if not done,
514 // AfsAppLib_MainPump and ModalDialog will instead simply
515 // call TranslateMessage/DispatchMessage.
517 EXPORTED
void AfsAppLib_SetPumpRoutine (void (*fnPump
)(MSG
*lpm
));
519 // AfsAppLib_MainPump
520 // ...Calls GetMessage() until the WM_QUIT message is received;
521 // for each message, calls AfsAppLib_IsModelessDialogMessage
522 // followed by the pump routine which was specified by
523 // AfsAppLib_SetPumpRoutine.
525 EXPORTED
void AfsAppLib_MainPump (void);
529 * WINDOW DATA ________________________________________________________________
531 * Ever been frustrated by Get/SetWindowLong's inability to dynamically
532 * grow the space associated with a window? Worse, how do you know
533 * that GetWindowLong(hWnd,3) isn't already used by some other routine?
535 * The routines below solve both problems: by specifying indices by a
536 * descriptive name rather than an integer index, collisions are eliminated.
537 * And as new fields are specified, they're dynamically added--the data-space
538 * associated with a window grows indefinitely as needed.
540 * Note that GetWindowData will return 0 unless SetWindowData
541 * has been used to explicitly change that field for that window.
547 // ...Alternatives to GetWindowLong and SetWindowLong; these
548 // routines use descriptive field indices rather than
549 // the integer indices used by the Get/SetWindowLong routines,
550 // and can grow windows' data-space as necessary.
552 EXPORTED UINT_PTR
GetWindowData (HWND hWnd
, LPTSTR pszField
);
553 EXPORTED UINT_PTR
SetWindowData (HWND hWnd
, LPTSTR pszField
, UINT_PTR dwNewData
);
557 * IMAGE LISTS ________________________________________________________________
561 // AfsAppLib_CreateImageList
562 // ...creates an initial IMAGELIST, containing several
563 // AFS-specific icons (which are included in this library's
564 // resources). fLarge indicates whether the imagelist should
565 // be composed of 32x32 or 16x16 icons; the highest visible
566 // color depth image will automatically be selected for each icon.
568 #define imageSERVER 0
569 #define imageSERVER_ALERT 1
570 #define imageSERVER_UNMON 2
571 #define imageSERVICE 3
572 #define imageSERVICE_ALERT 4
573 #define imageSERVICE_STOPPED 5
574 #define imageAGGREGATE 6
575 #define imageAGGREGATE_ALERT 7
576 #define imageFILESET 8
577 #define imageFILESET_ALERT 9
578 #define imageFILESET_LOCKED 10
579 #define imageBOSSERVICE 11
581 #define imageSERVERKEY 13
583 #define imageGROUP 15
585 #define imageNEXT 16 // next ID given by AfsAppLib_AddToImageList()
587 EXPORTED HIMAGELIST
AfsAppLib_CreateImageList (BOOL fLarge
);
589 // AfsAppLib_AddToImageList
590 // ...easy wrapper for adding additional icons to an image list.
592 EXPORTED
void AfsAppLib_AddToImageList (HIMAGELIST hil
, int idi
, BOOL fLarge
);
596 * HELP _______________________________________________________________________
598 * These routines make implementing context-sensitive help fairly easy.
599 * To use them, your application should contain the following code at startup
600 * for each dialog in your application:
602 * static DWORD IDH_MAIN_HELP_CTX[] = {
603 * IDC_BUTTON, IDH_BUTTON_HELP_ID,
604 * IDC_EDIT, IDH_EDIT_HELP_ID,
608 * AfsAppLib_RegisterHelp (IDD_MAIN, IDH_MAIN_HELP_CTX, IDH_MAIN_HELP_OVIEW);
610 * You'll also have to call one other routine, at least once:
612 * AfsAppLib_RegisterHelpFile (TEXT("myapp.hlp"));
614 * Within IDD_MAIN's dialog proc, call the following:
616 * BOOL CALLBACK IddMain_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
618 * if (AfsAppLib_HandleHelp (IDD_MAIN, hDlg, msg, wp, lp))
623 * That's it--context help will work for the dialog, and if you've attached
624 * a "Help" button (which should be IDHELP==9), it will conjure an overall
629 // AfsAppLib_RegisterHelpFile
630 // ...specifies the help file that the library should use to display
633 EXPORTED
void AfsAppLib_RegisterHelpFile (LPTSTR pszFilename
);
635 // AfsAppLib_RegisterHelp
636 // ...adds another dialog to the library's list of CSH-enabled
637 // dialogs. Dialogs are referenced by their resource ID--that's
638 // what the "idd" thing is.
640 EXPORTED
void AfsAppLib_RegisterHelp (int idd
, DWORD
*adwContext
, int idhOverview
);
642 // AfsAppLib_HandleHelp
643 // ...handles CSH messages and IDHELP button presses; returns TRUE
644 // if the given message has been handled and needs no further
647 EXPORTED BOOL
AfsAppLib_HandleHelp (int idd
, HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
);
651 * GENERAL ____________________________________________________________________
655 // AfsApplib_CreateFont
656 // ...loads a string resource and uses its content to create a
657 // font. The string resource should be of the form:
658 // "TypeFace,Size,Flags"--
660 // TypeFace is "MS Sans Serif", "Times New Roman", or other font
661 // Size is the point-size of the font (no decimals!)
662 // Flags is combination of B, I, U (bold, italicized, underlined)
664 // Some examples, then:
665 // IDS_BIG_FONT "Times New Roman,20,BU"
666 // IDS_LITTLE_FONT "Arial,8,I"
667 // IDS_NORMAL_FONT "MS Sans Serif,10"
669 // The returned font handle should be destroyed with DeleteObject()
670 // when no longer needed.
672 EXPORTED HFONT
AfsAppLib_CreateFont (int idsFont
);
674 // AfsAppLib_GetInstance
675 // ...returns the handle representing this library, for use in
676 // loading resources.
678 EXPORTED HINSTANCE
AfsAppLib_GetInstance (void);
680 // AfsAppLib_GetAppInstance
681 // ...returns the handle representing the application which
682 // loaded this library. If a .DLL loaded this library,
683 // you may need to call AfsAppLib_SetAppInstance().
685 EXPORTED HINSTANCE
AfsAppLib_GetAppInstance (void);
686 EXPORTED
void AfsAppLib_SetAppInstance (HINSTANCE hInst
);
688 // AfsAppLib_AnimateIcon
689 // ...used to animate the 8-frame spinning Transarc logo.
690 // specify NULL for piFrameLast to stop the spinning,
691 // otherwise, provide a pointer to an int that will be used
692 // to track the current frame.
694 EXPORTED
void AfsAppLib_AnimateIcon (HWND hIcon
, int *piFrameLast
= NULL
);
696 // AfsAppLib_StartAnimation
697 // AfsAppLib_StopAnimation
698 // ...an alternate technique for calling AfsAppLib_AnimateIcon;
699 // using these routines causes a timer to be created which will
700 // animate the Transarc logo within the specified window.
702 EXPORTED
void AfsAppLib_StartAnimation (HWND hIcon
, int fps
= 8);
703 EXPORTED
void AfsAppLib_StopAnimation (HWND hIcon
);
705 // AfsAppLib_IsTimeInFuture
706 // ...returns TRUE if the specified time (GMT) is in the
707 // future; handy for checking credentials' expiration dates.
709 EXPORTED BOOL
AfsAppLib_IsTimeInFuture (LPSYSTEMTIME pstTest
);
711 // AfsAppLib_UnixTimeToSystemTime
712 // ...translate a unix time DWORD into a SYSTEMTIME structure
714 EXPORTED
void AfsAppLib_UnixTimeToSystemTime (LPSYSTEMTIME pst
, ULONG ut
, BOOL fElapsed
= FALSE
);
716 // AfsAppLib_TranslateError
717 // ...obtains descriptive text for the given status code.
718 // This routine is just a wrapper around TaLocale's
719 // FormatError(); either routine produces identical output.
720 // Both routines call back into a hook installed by the
721 // AfsAppLib library to provide AFS-specific error translation..
722 // If successful, the resulting string will appear as:
723 // "Unable to create an RPC binding to host. (0x0E008001)"
724 // If unsuccessful, the resulting string will appear as:
727 EXPORTED BOOL
AfsAppLib_TranslateError (LPTSTR pszText
, ULONG status
, LANGID idLanguage
= 0);
729 // AfsAppLib_GetLocalCell
730 // ...returns the local cell into which this machine is configured.
732 EXPORTED BOOL
AfsAppLib_GetLocalCell (LPTSTR pszCell
, ULONG
*pStatus
= NULL
);
735 // ...general-purpose array reallocator:
736 // int *aInts = NULL;
738 // if (!REALLOC (aInts, cInts, 128, 16)) { ... }
739 // the code above ensures that there will be 128 ints available
740 // as iInts[0]..aInts[127]; the 16 indicates the minimum allocation
741 // granularity (i.e., asking for 129 ints will actually get you
742 // 144 of them). Reallocation only increases array size, and is
743 // only performed when necessary; newly-allocated space is zero-
744 // initialized, and old data is always retained across reallocation.
745 // Use GlobalFree((HGLOBAL)aInts) to free the array when done.
746 // Use it a few times, and you'll be hooked: amazingly useful.
749 #define REALLOC(_a,_c,_r,_i) AfsAppLib_ReallocFunction ((LPVOID*)&_a,sizeof(*_a),&_c,_r,_i)
750 EXPORTED BOOL
AfsAppLib_ReallocFunction (LPVOID
*ppTarget
, size_t cbElement
, size_t *pcTarget
, size_t cReq
, size_t cInc
);