/******************************************************************************
*
*
* Notepad2
*
* Helpers.h
*   Definitions for general helper functions and macros
*
* See Readme.txt for more information about this source code.
* Please send me your comments to this work.
*
* Distributed under the terms of the GNU General Public License,
* see License.txt for details.
*
*                                              (c) Florian Balmer 1996-2004
*                                                       textview@bluewin.ch
*                                               http://www.flos-freeware.ch
*
*
******************************************************************************/



extern HINSTANCE g_hInstance;


#define COUNTOF(ar) (sizeof(ar)/sizeof(ar[0]))


void BeginWaitCursor();
void EndWaitCursor();


//void KeepWindowsAlive();


BOOL IsWindowsNT();
BOOL PrivateIsAppThemed();


BOOL SetWindowTitle(HWND,UINT,UINT,LPCSTR,BOOL,BOOL,UINT,BOOL);
void SetWindowTransparentMode(HWND,BOOL);


void CenterDlgInParent(HWND);
void MakeBitmapButton(HWND,int,HINSTANCE,UINT);


#define StatusSetSimple(hwnd,b) SendMessage(hwnd,SB_SIMPLE,(WPARAM)b,0)
BOOL StatusSetText(HWND,UINT,LPCSTR);
BOOL StatusSetTextID(HWND,UINT,UINT);
int  StatusCalcPaneWidth(HWND,LPCSTR);

void Toolbar_SetButtonImage(HWND,int,int);

LRESULT SendWMSize(HWND);

#define EnableCmd(hmenu,id,b) EnableMenuItem(hmenu,id,(b)\
                               ?MF_BYCOMMAND|MF_ENABLED:MF_BYCOMMAND|MF_GRAYED)

#define CheckCmd(hmenu,id,b)  CheckMenuItem(hmenu,id,(b)\
                               ?MF_BYCOMMAND|MF_CHECKED:MF_BYCOMMAND|MF_UNCHECKED)

BOOL IsCmdEnabled(HWND, UINT);


#define GetString(id,pb,cb) LoadString(g_hInstance,id,pb,cb)

#define StrEnd(pStart) (pStart + lstrlen(pStart))

int FormatString(LPSTR,int,UINT,...);
void FormatBytes(LPSTR,int,DWORD);


BOOL PathIsLnkFile(LPCSTR);
BOOL PathGetLnkPath(LPCSTR,LPSTR,int);
BOOL PathIsLnkToDirectory(LPCSTR,LPSTR,int);
BOOL PathCreateDeskLnk(LPCSTR);
BOOL PathCreateFavLnk(LPCSTR,LPCSTR,LPCSTR);


BOOL TrimString(LPSTR);
BOOL ExtractFirstArgument(LPCSTR, LPSTR, LPSTR);

void PrepareFilterStr(LPSTR);

void StrTab2Space(LPSTR);


void  ExpandEnvironmentStringsEx(LPSTR,DWORD);
void  PathCanonicalizeEx(LPSTR);
DWORD GetLongPathNameEx(LPCSTR,LPSTR,DWORD);
DWORD_PTR SHGetFileInfo2(LPCTSTR,DWORD,SHFILEINFO*,UINT,UINT);


int  FormatNumberStr(LPSTR);
BOOL SetDlgItemIntEx(HWND,int,UINT);


#define MBCSToWChar(c,a,w,i) MultiByteToWideChar(c,0,a,-1,w,i)
#define WCharToMBCS(c,w,a,i) WideCharToMultiByte(c,0,w,-1,a,i,NULL,NULL)

UINT    GetDlgItemTextA2W(UINT,HWND,int,LPSTR,int);
UINT    SetDlgItemTextA2W(UINT,HWND,int,LPSTR);
LRESULT ComboBox_AddStringA2W(UINT,HWND,LPCSTR);


UINT CodePageFromCharSet(UINT);


void GetDefaultFavoritesDir(LPSTR,int);
void GetDefaultOpenWithDir(LPSTR,int);


//==== XPM Functions ==========================================================
LPSTR LoadXPM(HINSTANCE,UINT);


//==== MRU Functions ==========================================================
typedef struct {
  DWORD   cbSize;
  DWORD   nMaxItems;
  DWORD   dwFlags;
  HKEY    hKey;
  LPCSTR  lpszSubKey;
  PROC    lpfnCompare;
} CREATEMRULIST;

#define COMCTL32FN(ord) GetProcAddress(GetModuleHandle("Comctl32"),(LPCSTR)MAKELONG(ord,0))

#define CreateMRUList(pcl)     (HANDLE)COMCTL32FN(151)(pcl)
#define FreeMRUList(h)         (void)  COMCTL32FN(152)(h)
#define AddMRUString(h,psz)    (int)   COMCTL32FN(153)(h,psz)
#define DelMRUString(h,i)      (BOOL)  COMCTL32FN(156)(h,i)
#define EnumMRUList(h,i,psz,n) (int)   COMCTL32FN(154)(h,i,psz,n)


//==== MinimizeToTray Functions - see comments in Helpers.c ===================
VOID MinimizeWndToTray(HWND hWnd);
VOID RestoreWndFromTray(HWND hWnd);



///   End of Helpers.h   \\\
