c pw safe app c pw safe app tcscpy g pfontnamenormal t ms serif tcscpy g pfontnamesymbol t symbol cpwsafeapp cpwsafeapp _tcscpy g_pfontnamenormal _t _tcscpy g_pfontnamesymbol _t bool c pw safe app register shell association long l hkey h base h shell h temp h temp2 tchar tsz temp max path 2 tchar tsz me max path 2 dword dw verify get module file name null tsz me max path 2 2 0 hkey classes root kdb l reg create key hkey classes root t kdb h base if l error success return false tcscpy tsz temp t kdbfile dw tcslen tsz temp 1 sizeof tchar l reg set value ex h base t 0 reg sz const byte tsz temp dw assert l error success if l error success reg close key h base return false reg close key h base hkey classes root kdbfile l reg create key hkey classes root t kdbfile h base assert l error success if l error success return false tcscpy tsz temp trl kee pass password database dw tcslen tsz temp 1 sizeof tchar l reg set value ex h base t 0 reg sz const byte tsz temp dw assert l error success if l error success reg close key h base return false tcscpy tsz temp t dw tcslen tsz temp 1 sizeof tchar l reg set value ex h base t always show ext 0 reg sz const byte tsz temp dw assert l error success if l error success reg close key h base return false l reg create key h base t default icon h temp assert l error success if l error success return false tcscpy tsz temp tsz me tcscat tsz temp t 0 dw tcslen tsz temp 1 sizeof tchar l reg set value ex h temp t 0 reg sz const byte tsz temp dw assert l error success if l error success reg close key h temp reg close key h base return false reg close key h temp hkey classes root kdbfile shell l reg create key h base t shell h shell assert l error success if l error success return false hkey classes root kdbfile shell open l reg create key h shell t open h temp tcscpy tsz temp trl open with kee pass dw tcslen tsz temp 1 sizeof tchar l reg set value ex h temp t 0 reg sz const byte tsz temp dw assert l error success if l error success reg close key h temp reg close key h shell reg close key h base return false l reg create key h temp t command h temp2 assert l error success if l error success return false tcscpy tsz temp t tcscat tsz temp tsz me tcscat tsz temp t 1 dw tcslen tsz temp 1 sizeof tchar l reg set value ex h temp2 t 0 reg sz const byte tsz temp dw assert l error success if l error success reg close key h temp reg close key h shell reg close key h base return false verify reg close key h temp2 error success verify reg close key h temp error success verify reg close key h shell error success verify reg close key h base error success return true cpwsafeapp registershellassociation hbase hshell htemp htemp2 tsztemp max_path tszme max_path getmodulefilename tszme max_path hkey_classes_root regcreatekey hkey_classes_root _t hbase error_success _tcscpy tsztemp _t _tcslen tsztemp regsetvalueex hbase _t reg_sz tsztemp error_success error_success regclosekey hbase regclosekey hbase hkey_classes_root regcreatekey hkey_classes_root _t hbase error_success error_success _tcscpy tsztemp keepass _tcslen tsztemp regsetvalueex hbase _t reg_sz tsztemp error_success error_success regclosekey hbase _tcscpy tsztemp _t _tcslen tsztemp regsetvalueex hbase _t alwaysshowext reg_sz tsztemp error_success error_success regclosekey hbase regcreatekey hbase _t defaulticon htemp error_success error_success _tcscpy tsztemp tszme _tcscat tsztemp _t _tcslen tsztemp regsetvalueex htemp _t reg_sz tsztemp error_success error_success regclosekey htemp regclosekey hbase regclosekey htemp hkey_classes_root regcreatekey hbase _t hshell error_success error_success hkey_classes_root regcreatekey hshell _t htemp _tcscpy tsztemp keepass _tcslen tsztemp regsetvalueex htemp _t reg_sz tsztemp error_success error_success regclosekey htemp regclosekey hshell regclosekey hbase regcreatekey htemp _t htemp2 error_success error_success _tcscpy tsztemp _t _tcscat tsztemp tszme _tcscat tsztemp _t _tcslen tsztemp regsetvalueex htemp2 _t reg_sz tsztemp error_success error_success regclosekey htemp regclosekey hshell regclosekey hbase regclosekey htemp2 error_success regclosekey htemp error_success regclosekey hshell error_success regclosekey hbase error_success bool c pw safe app unregister shell association hkey h base h shell h open h command long l l reg open key ex hkey classes root t kdb 0 key write h base if l error success return false reg delete value h base t verify reg close key h base error success verify reg delete key hkey classes root t kdb error success l reg open key ex hkey classes root t kdbfile 0 key write h base if l error success return false l reg open key ex h base t shell 0 key write h shell if l error success return false l reg open key ex h shell t open 0 key write h open if l error success return false l reg open key ex h open t command 0 key write h command if l error success return false reg delete value h command t verify reg close key h command error success reg delete value h open t verify reg close key h open error success reg delete value h shell t verify reg close key h shell error success reg delete value h base t reg delete value h base t always show ext verify reg close key h base error success return true cpwsafeapp unregistershellassociation hbase hshell hopen hcommand regopenkeyex hkey_classes_root _t key_write hbase error_success regdeletevalue hbase _t regclosekey hbase error_success regdeletekey hkey_classes_root _t error_success regopenkeyex hkey_classes_root _t key_write hbase error_success regopenkeyex hbase _t key_write hshell error_success regopenkeyex hshell _t key_write hopen error_success regopenkeyex hopen _t key_write hcommand error_success regdeletevalue hcommand _t regclosekey hcommand error_success regdeletevalue hopen _t regclosekey hopen error_success regdeletevalue hshell _t regclosekey hshell error_success regdeletevalue hbase _t regdeletevalue hbase _t alwaysshowext regclosekey hbase error_success bool c pw safe app get start with windows hkey h null long l tchar tsz buf 512 dword dw size 510 l reg open key ex hkey current user t software microsoft windows current version run 0 key query value h if l error success return false dword dw type reg sz if reg query value ex h t kee pass password safe null dw type lpbyte tsz buf dw size error success reg close key h h null return false reg close key h h null if tcslen tsz buf 0 tsz buf 0 t return true return false cpwsafeapp getstartwithwindows tszbuf dwsize regopenkeyex hkey_current_user _t currentversion key_query_value error_success dwtype reg_sz regqueryvalueex _t keepass dwtype tszbuf dwsize error_success regclosekey regclosekey _tcslen tszbuf tszbuf _t bool c pw safe app set start with windows bool b auto start hkey h null tchar tsz buf 512 long l l reg open key ex hkey current user t software microsoft windows current version run 0 key write h if l error success return false if b auto start true get module file name null tsz buf 510 dword dw size tcslen tsz buf 1 sizeof tchar l reg set value ex h t kee pass password safe 0 reg sz lpbyte tsz buf dw size if l error success reg close key h h null return false else b auto start false l reg delete value h t kee pass password safe if l error success reg close key h h null return false reg close key h h null return true cpwsafeapp setstartwithwindows bautostart tszbuf regopenkeyex hkey_current_user _t currentversion key_write error_success bautostart getmodulefilename tszbuf dwsize _tcslen tszbuf regsetvalueex _t keepass reg_sz tszbuf dwsize error_success regclosekey bautostart regdeletevalue _t keepass error_success regclosekey regclosekey bool c pw safe app parse current command line c string ps file lpctstr lp password lpctstr lp key file lpctstr lp pre select path long i bool b first true assert ps file null if ps file null return false ps file empty assert lp password null if lp password null return false lp password null assert lp key file null if lp key file null return false lp key file null assert lp pre select path null if lp pre select path null return false lp pre select path null if argc 1 return false for i 1 i long argc i if tcsnicmp targv i t pw 4 0 tcslen targv i 4 lp password targv i 4 else if tcsnicmp targv i t pw 4 0 tcslen targv i 4 lp password targv i 4 else if tcsnicmp targv i t keyfile 9 0 tcslen targv i 9 lp key file targv i 9 else if tcsnicmp targv i t keyfile 9 0 tcslen targv i 9 lp key file targv i 9 else if tcsnicmp targv i t preselect 11 0 tcslen targv i 11 lp pre select path targv i 11 else if tcsnicmp targv i t preselect 11 0 tcslen targv i 11 lp pre select path targv i 11 else if tcsnicmp targv i t ext 5 0 tcslen targv i 5 ignore this parameter else if tcsnicmp targv i t ext 5 0 tcslen targv i 5 ignore this parameter else if b first true ps file t ps file targv i b first false ps file trim left ps file trim right if ps file get length 0 return false if ps file left 1 t ps file ps file right ps file get length 1 if ps file get length 0 return false ps file trim left ps file trim right if ps file get length 0 return false if ps file right 1 t ps file ps file left ps file get length 1 if ps file get length 0 return false ps file trim left ps file trim right if ps file get length 0 return false return true cpwsafeapp parsecurrentcommandline cstring psfile lppassword lpkeyfile lppreselectpath bfirst psfile psfile psfile lppassword lppassword lppassword lpkeyfile lpkeyfile lpkeyfile lppreselectpath lppreselectpath lppreselectpath __argc __argc _tcsnicmp __targv _t _tcslen __targv lppassword __targv _tcsnicmp __targv _t _tcslen __targv lppassword __targv _tcsnicmp __targv _t _tcslen __targv lpkeyfile __targv _tcsnicmp __targv _t _tcslen __targv lpkeyfile __targv _tcsnicmp __targv _t _tcslen __targv lppreselectpath __targv _tcsnicmp __targv _t _tcslen __targv lppreselectpath __targv _tcsnicmp __targv _t _tcslen __targv _tcsnicmp __targv _t _tcslen __targv bfirst psfile _t psfile __targv bfirst psfile trimleft psfile trimright psfile getlength psfile _t psfile psfile psfile getlength psfile getlength psfile trimleft psfile trimright psfile getlength psfile _t psfile psfile psfile getlength psfile getlength psfile trimleft psfile trimright psfile getlength void c pw safe app create hi color image list c image list p image list word w resourceid int cz size assert p image list null if p image list null return c bitmap bmp images verify bmp images load bitmap makeintresource w resourceid verify p image list create cz size cz size ilc color24 ilc mask bmp images get bitmap dimension cx cz size 0 p image list add bmp images rgb 255 0 255 bmp images delete object cpwsafeapp createhicolorimagelist cimagelist pimagelist wresourceid czsize pimagelist pimagelist cbitmap bmpimages bmpimages loadbitmap wresourceid pimagelist czsize czsize ilc_color24 ilc_mask bmpimages getbitmapdimension czsize pimagelist bmpimages bmpimages deleteobject bool c pw safe app ismb threadacp if g uthreadacp 932 g uthreadacp 936 g uthreadacp 950 return true return false cpwsafeapp ismbthreadacp g_uthreadacp g_uthreadacp g_uthreadacp tchar c pw safe app get password character if ismb threadacp true g bforcesimpleasterisks true return t return tchar 0xb7 cpwsafeapp getpasswordcharacter ismbthreadacp g_bforcesimpleasterisks _t lpctstr c pw safe app get password font if ismb threadacp true g bforcesimpleasterisks true return g pfontnamenormal return tchar g pfontnamesymbol cpwsafeapp getpasswordfont ismbthreadacp g_bforcesimpleasterisks g_pfontnamenormal g_pfontnamesymbol bool c pw safe app init instance if mfc ver 0x0500 ifdef afxdll enable3d controls else enable3d controls static endif endif create application s mutex object to make our presence public m pappmutex new c mutex false t kee pass application mutex null if m pappmutex null assert false verify afx ole init afx enable control container ifndef unicode afx init rich edit else afx init rich edit ex endif init common controls set dialog bk color newgui getbgcolor cr front setup the new dialog look assert true 1 assert false 0 g uthreadacp getacp osversioninfo osvi zero memory osvi sizeof osversioninfo osvi dwos version info size sizeof osversioninfo get version ex osvi if osvi dw major version 5 osvi dw minor version 0 g bforcesimpleasterisks true c pw safe dlg dlg m pmainwnd dlg c private config pc new c private config false if pc null dlg m bcheckforinstance pc get bool pwmkey singleinstance false delete pc pc null if dlg m bcheckforinstance true dlg m instancechecker activate checker if dlg m instancechecker previous instance running c string str file lpctstr lp password null lpctstr lp key file null lpctstr lp pre select path null dword dw data 0 parse current command line str file lp password lp key file lp pre select path if str file get length 0 if lp password null dw data dword tcslen lp password 16 str file c string lp password str file if lp key file null dw data dword tcslen lp key file str file c string lp key file str file dlg m instancechecker activate previous instance lpctstr str file dw data else dlg m instancechecker activate previous instance t 0xf0fffff0 m pmainwnd null return false int n response dlg do modal if n response idok else if n response idcancel return false cpwsafeapp initinstance _mfc_ver _afxdll enable3dcontrols enable3dcontrolsstatic m_pappmutex cmutex _t keepassapplicationmutex m_pappmutex afxoleinit afxenablecontrolcontainer _unicode afxinitrichedit afxinitricheditex initcommoncontrols setdialogbkcolor newgui_getbgcolor cr_front g_uthreadacp zeromemory dwosversioninfosize getversionex dwmajorversion dwminorversion g_bforcesimpleasterisks cpwsafedlg m_pmainwnd cprivateconfig cprivateconfig m_bcheckforinstance getbool pwmkey_singleinstance m_bcheckforinstance m_instancechecker activatechecker m_instancechecker previousinstancerunning cstring strfile lppassword lpkeyfile lppreselectpath dwdata parsecurrentcommandline strfile lppassword lpkeyfile lppreselectpath strfile getlength lppassword dwdata _tcslen lppassword strfile cstring lppassword strfile lpkeyfile dwdata _tcslen lpkeyfile strfile cstring lpkeyfile strfile m_instancechecker activatepreviousinstance strfile dwdata m_instancechecker activatepreviousinstance _t m_pmainwnd nresponse domodal nresponse nresponse int c pw safe app exit instance release application s mutex object if m pappmutex null m pappmutex unlock delete m pappmutex m pappmutex null return c win app exit instance cpwsafeapp exitinstance m_pappmutex m_pappmutex m_pappmutex m_pappmutex cwinapp exitinstance c wnd util lpctstr lpsz class name m strclassname lpsz class name cwndutil lpszclassname m_strclassname lpszclassname virtual c wnd util cwndutil virtual bool register wnd class wndclass wnd hinstance h inst afx get instance handle if get class info h inst m strclassname wnd wnd style cs dblclks cs hredraw cs vredraw wnd lpfn wnd proc def window proc wnd cb cls extra wnd cb wnd extra 0 wnd h instance h inst wnd h icon null wnd h cursor afx get app load standard cursor idc arrow wnd hbr background null wnd lpsz menu name null wnd lpsz class name m strclassname if afx register class wnd afx throw resource exception return false return true registerwndclass hinst afxgetinstancehandle getclassinfo hinst m_strclassname cs_dblclks cs_hredraw cs_vredraw lpfnwndproc defwindowproc cbclsextra cbwndextra hinstance hinst hicon hcursor afxgetapp loadstandardcursor idc_arrow hbrbackground lpszmenuname lpszclassname m_strclassname afxregisterclass afxthrowresourceexception c wnd util lpctstr lpsz class name m strclassname lpsz class name cwndutil lpszclassname m_strclassname lpszclassname virtual c wnd util cwndutil virtual bool register wnd class wndclass wnd hinstance h inst afx get instance handle if get class info h inst m strclassname wnd wnd style cs dblclks cs hredraw cs vredraw wnd lpfn wnd proc def window proc wnd cb cls extra wnd cb wnd extra 0 wnd h instance h inst wnd h icon null wnd h cursor afx get app load standard cursor idc arrow wnd hbr background null wnd lpsz menu name null wnd lpsz class name m strclassname if afx register class wnd afx throw resource exception return false return true registerwndclass hinst afxgetinstancehandle getclassinfo hinst m_strclassname cs_dblclks cs_hredraw cs_vredraw lpfnwndproc defwindowproc cbclsextra cbwndextra hinstance hinst hicon hcursor afxgetapp loadstandardcursor idc_arrow hbrbackground lpszmenuname lpszclassname m_strclassname afxregisterclass afxthrowresourceexception wchar t m szmenutext public bc menu data menu icon normal 1 xoffset 1 bitmap null p context null n flags 0 nid 0 syncflag 0 m szmenutext null global offset 1 wchar_t m_szmenutext bcmenudata menuiconnormal pcontext nflags m_szmenutext global_offset wchar t m szmenutext public bc menu data menu icon normal 1 xoffset 1 bitmap null p context null n flags 0 nid 0 syncflag 0 m szmenutext null global offset 1 wchar_t m_szmenutext bcmenudata menuiconnormal pcontext nflags m_szmenutext global_offset void bc menu data set ansi string lpcstr sz ansi string uses conversion set wide string a2w sz ansi string sk see mfc tech note 059 bcmenudata setansistring szansistring uses_conversion setwidestring szansistring void bc menu data set wide string const wchar t sz wide string delete m szmenutext need not check for null because ansi x3j16 allows delete null if sz wide string m szmenutext new wchar t sizeof wchar t wcslen sz wide string 1 if m szmenutext wcscpy m szmenutext sz wide string else m szmenutext null set to null so we need not bother about dangling non null ptrs bcmenudata setwidestring wchar_t szwidestring m_szmenutext szwidestring m_szmenutext wchar_t wchar_t szwidestring m_szmenutext m_szmenutext szwidestring m_szmenutext bc menu data bc menu data if bitmap delete bitmap delete m szmenutext need not check for null because ansi x3j16 allows delete null bcmenudata bcmenudata m_szmenutext depending on the mfc version we are using c string str text if m szmenutext ifdef unicode str text m szmenutext else uses conversion str text w2a m szmenutext sk see mfc tech note 059 endif return str text cstring strtext m_szmenutext strtext m_szmenutext uses_conversion strtext m_szmenutext strtext function to set how menu is drawn either original or xp style static void set menu draw mode uint mode bc menu original drawmode mode bc menu xp drawmode mode setmenudrawmode bcmenu original_drawmode bcmenu xp_drawmode function to set how disabled items are drawn mode false means they are not drawn selected static void set select disable mode bool mode bc menu original select disabled mode bc menu xp select disabled mode setselectdisablemode bcmenu original_select_disabled bcmenu xp_select_disabled how the bitmaps are drawn in xp luna mode static void setxp bitmap3d bool val bc menu xp draw 3d bitmaps val setxpbitmap3d bcmenu xp_draw_3d_bitmaps function to set how menu is drawn either original or xp style static void set menu draw mode uint mode bc menu original drawmode mode bc menu xp drawmode mode setmenudrawmode bcmenu original_drawmode bcmenu xp_drawmode function to set how disabled items are drawn mode false means they are not drawn selected static void set select disable mode bool mode bc menu original select disabled mode bc menu xp select disabled mode setselectdisablemode bcmenu original_select_disabled bcmenu xp_select_disabled how the bitmaps are drawn in xp luna mode static void setxp bitmap3d bool val bc menu xp draw 3d bitmaps val setxpbitmap3d bcmenu xp_draw_3d_bitmaps bc menu bc menu m bdynicons false o s no dynamic icons by default disable old style false m selectcheck 1 m unselectcheck 1 checkmaps null checkmapsshare false set the color used for the transparent background in all bitmaps m bitmapbackground rgb 192 192 192 gray m bitmapbackgroundflag false getcp info getacp cp info modified by dominik reichl changed cp acp to getacp m loadmenu false bcmenu bcmenu m_bdynicons disable_old_style m_selectcheck m_unselectcheck m_bitmapbackground m_bitmapbackgroundflag getcpinfo cpinfo cp_acp m_loadmenu bc menu bc menu destroy menu bcmenu bcmenu destroymenu bool bc menu load menu lpctstr lpsz resource name assert valid this assert lpsz resource name null find the menu resource hinstance h inst afx find resource handle lpsz resource name rt menu hrsrc h rsrc find resource h inst lpsz resource name rt menu if h rsrc null h inst null h rsrc find resource h inst lpsz resource name rt menu if h rsrc null return false load the menu resource hglobal h global load resource h inst h rsrc if h global null return false first destroy the menu if we re trying to loadmenu again destroy menu attempt to create us as a menu if c menu create menu return false get item template header and calculate offset of menuitemtemplates menuitemtemplateheader p tp hdr menuitemtemplateheader lock resource h global byte p tp byte p tp hdr sizeof menuitemtemplateheader p tp hdr offset variables needed during processing of menu item templates int j 0 word dw flags 0 flags of the menu item word dwid 0 id of the menu item uint u flags actual flags wchar t sz caption null int n len 0 length of caption c typed ptr array c ptr array bc menu m stack popup menu stack c array bool bool m stackend popup menu stack m stack add this add it to this m stackend add false do obtain flags and if necessary the id memcpy dw flags p tp sizeof word p tp sizeof word obtain flags if dw flags mf popup memcpy dwid p tp sizeof word obtain id p tp sizeof word else dwid 0 u flags uint dw flags remove mf end from the flags that will if u flags mf end be passed to the append od menu functions u flags mf end obtain caption and length n len 0 sz caption new wchar t wcslen wchar t p tp 1 wcscpy sz caption wchar t p tp p tp p tp wcslen wchar t p tp 1 sizeof wchar t modified sk handle popup menus first wide char to multi byte if dw flags mf popup if dw flags mf end m stackend set at m stack get upper bound true bc menu p sub menu new bc menu p sub menu m unselectcheck m unselectcheck p sub menu m selectcheck m selectcheck p sub menu checkmaps checkmaps p sub menu checkmapsshare true p sub menu create popup menu append it to the top of the stack m stack m stack get upper bound appendod menuw sz caption u flags uint p sub menu m hmenu 1 m stack add p sub menu m stackend add false else m stack m stack get upper bound appendod menuw sz caption u flags dwid 1 if dw flags mf end m stackend set at m stack get upper bound true j m stack get upper bound while j 0 m stackend get at j m stack m stack get upper bound insert spaces m stack remove at j m stackend remove at j j delete sz caption while m stack get upper bound 1 for int i 0 i int get menu item count i c string str m menulist i get string if get sub menu i m menulist i n flags mf popup mf byposition modify menu i mf popup mf byposition uint get sub menu i m hmenu str else m menulist i n flags mf string mf byposition modify menu i mf string mf byposition m menulist i nid str m loadmenu true return true bcmenu loadmenu lpszresourcename assert_valid lpszresourcename hinst afxfindresourcehandle lpszresourcename rt_menu hrsrc findresource hinst lpszresourcename rt_menu hrsrc hinst hrsrc findresource hinst lpszresourcename rt_menu hrsrc hglobal loadresource hinst hrsrc hglobal destroymenu cmenu createmenu ptphdr lockresource hglobal ptp ptphdr ptphdr dwflags uflags wchar_t szcaption nlen ctypedptrarray cptrarray bcmenu m_stack carray m_stackend m_stack m_stackend dwflags ptp ptp dwflags mf_popup ptp ptp uflags dwflags mf_end uflags mf_end uflags mf_end nlen szcaption wchar_t wchar_t ptp szcaption wchar_t ptp ptp ptp wchar_t ptp wchar_t widechartomultibyte dwflags mf_popup dwflags mf_end m_stackend setat m_stack getupperbound bcmenu psubmenu bcmenu psubmenu m_unselectcheck m_unselectcheck psubmenu m_selectcheck m_selectcheck psubmenu psubmenu psubmenu createpopupmenu m_stack m_stack getupperbound appendodmenuw szcaption uflags psubmenu m_hmenu m_stack psubmenu m_stackend m_stack m_stack getupperbound appendodmenuw szcaption uflags dwflags mf_end m_stackend setat m_stack getupperbound m_stack getupperbound m_stackend getat m_stack m_stack getupperbound insertspaces m_stack removeat m_stackend removeat szcaption m_stack getupperbound getmenuitemcount cstring m_menulist getstring getsubmenu m_menulist nflags mf_popup mf_byposition modifymenu mf_popup mf_byposition getsubmenu m_hmenu m_menulist nflags mf_string mf_byposition modifymenu mf_string mf_byposition m_menulist m_loadmenu bool bc menu load menu int n resource return bc menu load menu makeintresource n resource bcmenu loadmenu nresource bcmenu loadmenu nresource bool bc menu load toolbar uint n tool bar uint n bitmap uint nid n style bool returnflag false c tool bar bar int xoffset 1 xset c wnd p wnd afx get main wnd if p wnd null p wnd c wnd get desktop window bar create p wnd if bar load tool bar n tool bar c image list imglist imglist create m iconx m icony ilc colorddb ilc mask 1 1 if add bitmap to image list imglist n bitmap returnflag true for int i 0 i bar get count i nid bar get itemid i if nid get menu state nid mf bycommand 0xffffffff xoffset bar command to index nid if xoffset 0 bar get button info xoffset nid n style xset if xset 0 xoffset xset modifyod menu null nid imglist xoffset return returnflag bcmenu loadtoolbar ntoolbar nbitmap nstyle ctoolbar cwnd pwnd afxgetmainwnd pwnd pwnd cwnd getdesktopwindow pwnd loadtoolbar ntoolbar cimagelist m_iconx m_icony ilc_colorddb ilc_mask addbitmaptoimagelist nbitmap getcount getitemid getmenustate mf_bycommand commandtoindex getbuttoninfo nstyle modifyodmenu bool bc menu load toolbars const uint arid int n assert arid bool returnflag true for int i 0 i n i if load toolbar arid i arid i returnflag false return returnflag bcmenu loadtoolbars loadtoolbar void bc menu add from tool bar c tool bar p tool bar int n resourceid for int i 0 i p tool bar get count i uint nid p tool bar get itemid i see if this toolbar option appears as a command on this menu or is a separator if nid 0 get menu state nid mf bycommand 0xffffffff continue item doesn t exist uint n style int n image get the toolbar button info p tool bar get button info i nid n style n image ok we have the command id of the toolbar option and the tollbar bitmap offset int n loc bc menu data p data bc menu p sub menu find menu option nid n loc if p sub menu n loc 0 p data p sub menu m menulist n loc else create a new bc menu data structure p data new bc menu data m menulist add p data set some default structure members p data menu icon normal n resourceid p data nid nid p data n flags mf bycommand mf ownerdraw p data xoffset n image if p data bitmap p data bitmap delete image list else p data bitmap new c image list p data bitmap create m iconx m icony ilc colorddb ilc mask 1 1 if add bitmap to image list p data bitmap n resourceid p data bitmap delete image list delete p data bitmap p data bitmap null p data menu icon normal 1 p data xoffset 1 modify our menu modify menu nid p data n flags nid lpctstr p data bcmenu addfromtoolbar ctoolbar ptoolbar nresourceid ptoolbar getcount ptoolbar getitemid getmenustate mf_bycommand nstyle nimage ptoolbar getbuttoninfo nstyle nimage nloc bcmenudata pdata bcmenu psubmenu findmenuoption nloc psubmenu nloc pdata psubmenu m_menulist nloc bcmenudata pdata bcmenudata m_menulist pdata pdata menuiconnormal nresourceid pdata pdata nflags mf_bycommand mf_ownerdraw pdata nimage pdata pdata deleteimagelist pdata cimagelist pdata m_iconx m_icony ilc_colorddb ilc_mask addbitmaptoimagelist pdata nresourceid pdata deleteimagelist pdata pdata pdata menuiconnormal pdata modifymenu pdata nflags pdata bool bc menu load from tool bar uint nid uint n tool bar int xoffset int xset offset uint n style bool returnflag false c tool bar bar c wnd p wnd afx get main wnd if p wnd null p wnd c wnd get desktop window bar create p wnd if bar load tool bar n tool bar offset bar command to index nid if offset 0 bar get button info offset nid n style xset if xset 0 xoffset xset returnflag true return returnflag bcmenu loadfromtoolbar ntoolbar nstyle ctoolbar cwnd pwnd afxgetmainwnd pwnd pwnd cwnd getdesktopwindow pwnd loadtoolbar ntoolbar commandtoindex getbuttoninfo nstyle bool bc menu add bitmap to image list c image list bmplist uint n resourceid bool b return false o s if m bdynicons bmplist add hicon n resourceid b return true else hbitmap hbmp load sys color bitmap n resourceid if hbmp c bitmap bmp bmp attach hbmp if m bitmapbackgroundflag if bmplist add bmp m bitmapbackground 0 b return true else if bmplist add bmp get sys color color 3dface 0 b return true bmp detach delete object hbmp else a hicolor bitmap c bitmap mybmp if mybmp load bitmap n resourceid hicolor bitmaps true get transparent bitmap mybmp if m bitmapbackgroundflag if bmplist add mybmp m bitmapbackground 0 b return true else assert false if bmplist add mybmp get sys color color 3dface 0 b return true if b return is luna menu style xp draw 3d bitmaps c wnd p wnd afx get main wnd get main window if p wnd null p wnd c wnd get desktop window cdc pdc p wnd getdc get device context c bitmap bmp bmp2 bmp3 get bitmap from image list pdc bmplist 0 bmp get faded bitmap bmp bmplist add bmp get sys color color 3dface get bitmap from image list pdc bmplist 0 bmp2 get shadow bitmap bmp2 bmplist add bmp2 get sys color color 3dface get bitmap from image list pdc bmplist 0 bmp3 get disabled bitmap bmp3 bmplist add bmp3 get sys color color 3dface p wnd releasedc pdc release the dc return b return bcmenu addbitmaptoimagelist cimagelist nresourceid breturn m_bdynicons nresourceid breturn loadsyscolorbitmap nresourceid cbitmap m_bitmapbackgroundflag m_bitmapbackground breturn getsyscolor color_3dface breturn deleteobject cbitmap loadbitmap nresourceid hicolor_bitmaps gettransparentbitmap m_bitmapbackgroundflag m_bitmapbackground breturn getsyscolor color_3dface breturn breturn islunamenustyle xp_draw_3d_bitmaps cwnd pwnd afxgetmainwnd pwnd pwnd cwnd getdesktopwindow pwnd cbitmap getbitmapfromimagelist getfadedbitmap getsyscolor color_3dface getbitmapfromimagelist getshadowbitmap getsyscolor color_3dface getbitmapfromimagelist getdisabledbitmap getsyscolor color_3dface pwnd breturn hbitmap bc menu load sys color bitmap int n resource id hinstance h inst afx find resource handle makeintresource n resource id rt bitmap hrsrc h rsrc find resource h inst makeintresource n resource id rt bitmap if h rsrc null h inst null h rsrc find resource h inst makeintresource n resource id rt bitmap if h rsrc null return null determine how many colors in the bitmap hglobal hglb if hglb load resource h inst h rsrc null return null lpbitmapinfoheader lp bitmap lpbitmapinfoheader lock resource hglb if lp bitmap null return null word numcol num bitmap colors lp bitmap free resource hglb if numcol 16 return null return afx load sys color bitmap h inst h rsrc false bcmenu loadsyscolorbitmap nresourceid hinst afxfindresourcehandle nresourceid rt_bitmap hrsrc findresource hinst nresourceid rt_bitmap hrsrc hinst hrsrc findresource hinst nresourceid rt_bitmap hrsrc loadresource hinst hrsrc lpbitmap lockresource lpbitmap numbitmapcolors lpbitmap freeresource afxloadsyscolorbitmap hinst hrsrc void bc menu load checkmark bitmap int unselect int select if unselect 0 select 0 m selectcheck select m unselectcheck unselect if checkmaps checkmaps delete image list else checkmaps new c image list checkmaps create m iconx m icony ilc mask 2 1 bool flag1 add bitmap to image list checkmaps unselect bool flag2 add bitmap to image list checkmaps select if flag1 flag2 checkmaps delete image list delete checkmaps checkmaps null bcmenu loadcheckmarkbitmap m_selectcheck m_unselectcheck deleteimagelist cimagelist m_iconx m_icony ilc_mask addbitmaptoimagelist addbitmaptoimagelist deleteimagelist bool bc menu append menua uint n flags uint nid new item const char lpsz new item int n icon normal uses conversion return append menuw n flags nid new item a2w lpsz new item n icon normal bcmenu appendmenua nflags nidnewitem lpsznewitem niconnormal uses_conversion appendmenuw nflags nidnewitem lpsznewitem niconnormal bool bc menu append menua uint n flags uint nid new item const char lpsz new item c image list il int xoffset uses conversion return append menuw n flags nid new item a2w lpsz new item il xoffset bcmenu appendmenua nflags nidnewitem lpsznewitem cimagelist uses_conversion appendmenuw nflags nidnewitem lpsznewitem bool bc menu append menua uint n flags uint nid new item const char lpsz new item c bitmap bmp uses conversion return append menuw n flags nid new item a2w lpsz new item bmp bcmenu appendmenua nflags nidnewitem lpsznewitem cbitmap uses_conversion appendmenuw nflags nidnewitem lpsznewitem bool bc menu append menuw uint n flags uint nid new item wchar t lpsz new item int n icon normal return appendod menuw lpsz new item n flags nid new item n icon normal bcmenu appendmenuw nflags nidnewitem wchar_t lpsznewitem niconnormal appendodmenuw lpsznewitem nflags nidnewitem niconnormal bool bc menu append menuw uint n flags uint nid new item wchar t lpsz new item c image list il int xoffset return appendod menuw lpsz new item n flags nid new item il xoffset bcmenu appendmenuw nflags nidnewitem wchar_t lpsznewitem cimagelist appendodmenuw lpsznewitem nflags nidnewitem bool bc menu append menuw uint n flags uint nid new item wchar t lpsz new item c bitmap bmp if bmp c image list temp temp create m iconx m icony ilc colorddb ilc mask 1 1 if m bitmapbackgroundflag temp add bmp m bitmapbackground else temp add bmp get sys color color 3dface return appendod menuw lpsz new item n flags nid new item temp 0 return appendod menuw lpsz new item n flags nid new item null 0 bcmenu appendmenuw nflags nidnewitem wchar_t lpsznewitem cbitmap cimagelist m_iconx m_icony ilc_colorddb ilc_mask m_bitmapbackgroundflag m_bitmapbackground getsyscolor color_3dface appendodmenuw lpsznewitem nflags nidnewitem appendodmenuw lpsznewitem nflags nidnewitem int n icon normal uses conversion return appendod menuw a2w lpstr text n flags nid n icon normal sk see mfc tech note 059 niconnormal uses_conversion appendodmenuw lpstrtext nflags niconnormal int n icon normal add the mf ownerdraw flag if not specified if nid if n flags mf byposition n flags mf separator mf ownerdraw mf byposition else n flags mf separator mf ownerdraw else if n flags mf ownerdraw n flags mf ownerdraw if n flags mf popup m allsubmenus add hmenu nid m submenus add hmenu nid bc menu data mdata new bc menu data m menulist add mdata mdata set wide string lpstr text sk modified for dynamic allocation mdata menu icon normal 1 mdata xoffset 1 if n icon normal 0 c image list bitmap int xoffset 0 load from tool bar nid n icon normal xoffset if mdata bitmap mdata bitmap delete image list mdata bitmap null bitmap create m iconx m icony ilc colorddb ilc mask 1 1 if add bitmap to image list bitmap n icon normal mdata global offset add to global image list bitmap xoffset nid else mdata global offset global image list offset nid mdata n flags n flags mdata nid nid bool returnflag c menu append menu n flags nid lpctstr mdata if m loadmenu remove top level owner draw return returnflag niconnormal mf_ownerdraw nflags mf_byposition nflags mf_separator mf_ownerdraw mf_byposition nflags mf_separator mf_ownerdraw nflags mf_ownerdraw nflags mf_ownerdraw nflags mf_popup m_allsubmenus m_submenus bcmenudata bcmenudata m_menulist setwidestring lpstrtext menuiconnormal niconnormal cimagelist loadfromtoolbar niconnormal deleteimagelist m_iconx m_icony ilc_colorddb ilc_mask addbitmaptoimagelist niconnormal global_offset addtoglobalimagelist global_offset globalimagelistoffset nflags nflags cmenu appendmenu nflags m_loadmenu removetoplevelownerdraw c image list il int xoffset uses conversion return appendod menuw a2w lpstr text n flags nid il xoffset cimagelist uses_conversion appendodmenuw lpstrtext nflags c image list il int xoffset add the mf ownerdraw flag if not specified if nid if n flags mf byposition n flags mf separator mf ownerdraw mf byposition else n flags mf separator mf ownerdraw else if n flags mf ownerdraw n flags mf ownerdraw if n flags mf popup m allsubmenus add hmenu nid m submenus add hmenu nid bc menu data mdata new bc menu data m menulist add mdata mdata set wide string lpstr text sk modified for dynamic allocation if il mdata menu icon normal 0 mdata xoffset 0 if mdata bitmap mdata bitmap delete image list else mdata bitmap new c image list image list duplicate il xoffset mdata bitmap else mdata menu icon normal 1 mdata xoffset 1 mdata n flags n flags mdata nid nid return c menu append menu n flags nid lpctstr mdata cimagelist mf_ownerdraw nflags mf_byposition nflags mf_separator mf_ownerdraw mf_byposition nflags mf_separator mf_ownerdraw nflags mf_ownerdraw nflags mf_ownerdraw nflags mf_popup m_allsubmenus m_submenus bcmenudata bcmenudata m_menulist setwidestring lpstrtext menuiconnormal deleteimagelist cimagelist imagelistduplicate menuiconnormal nflags nflags cmenu appendmenu nflags bc menu bc menu appendod popup menua lpcstr lpstr text uses conversion return appendod popup menuw a2w lpstr text bcmenu bcmenu appendodpopupmenua lpstrtext uses_conversion appendodpopupmenuw lpstrtext bc menu bc menu appendod popup menuw wchar t lpstr text bc menu p sub menu new bc menu p sub menu m unselectcheck m unselectcheck p sub menu m selectcheck m selectcheck p sub menu checkmaps checkmaps p sub menu checkmapsshare true p sub menu create popup menu appendod menuw lpstr text mf popup uint p sub menu m hmenu 1 return p sub menu bcmenu bcmenu appendodpopupmenuw wchar_t lpstrtext bcmenu psubmenu bcmenu psubmenu m_unselectcheck m_unselectcheck psubmenu m_selectcheck m_selectcheck psubmenu psubmenu psubmenu createpopupmenu appendodmenuw lpstrtext mf_popup psubmenu m_hmenu psubmenu bool bc menu insert menua uint n position uint n flags uint nid new item const char lpsz new item int n icon normal uses conversion return insert menuw n position n flags nid new item a2w lpsz new item n icon normal bcmenu insertmenua nposition nflags nidnewitem lpsznewitem niconnormal uses_conversion insertmenuw nposition nflags nidnewitem lpsznewitem niconnormal bool bc menu insert menua uint n position uint n flags uint nid new item const char lpsz new item c image list il int xoffset uses conversion return insert menuw n position n flags nid new item a2w lpsz new item il xoffset bcmenu insertmenua nposition nflags nidnewitem lpsznewitem cimagelist uses_conversion insertmenuw nposition nflags nidnewitem lpsznewitem bool bc menu insert menua uint n position uint n flags uint nid new item const char lpsz new item c bitmap bmp uses conversion return insert menuw n position n flags nid new item a2w lpsz new item bmp bcmenu insertmenua nposition nflags nidnewitem lpsznewitem cbitmap uses_conversion insertmenuw nposition nflags nidnewitem lpsznewitem bool bc menu insert menuw uint n position uint n flags uint nid new item wchar t lpsz new item int n icon normal return insertod menuw n position lpsz new item n flags nid new item n icon normal bcmenu insertmenuw nposition nflags nidnewitem wchar_t lpsznewitem niconnormal insertodmenuw nposition lpsznewitem nflags nidnewitem niconnormal bool bc menu insert menuw uint n position uint n flags uint nid new item wchar t lpsz new item c image list il int xoffset return insertod menuw n position lpsz new item n flags nid new item il xoffset bcmenu insertmenuw nposition nflags nidnewitem wchar_t lpsznewitem cimagelist insertodmenuw nposition lpsznewitem nflags nidnewitem bool bc menu insert menuw uint n position uint n flags uint nid new item wchar t lpsz new item c bitmap bmp if bmp c image list temp temp create m iconx m icony ilc colorddb ilc mask 1 1 if m bitmapbackgroundflag temp add bmp m bitmapbackground else temp add bmp get sys color color 3dface return insertod menuw n position lpsz new item n flags nid new item temp 0 return insertod menuw n position lpsz new item n flags nid new item null 0 bcmenu insertmenuw nposition nflags nidnewitem wchar_t lpsznewitem cbitmap cimagelist m_iconx m_icony ilc_colorddb ilc_mask m_bitmapbackgroundflag m_bitmapbackground getsyscolor color_3dface insertodmenuw nposition lpsznewitem nflags nidnewitem insertodmenuw nposition lpsznewitem nflags nidnewitem int n icon normal uses conversion return insertod menuw n position a2w lpstr text n flags nid n icon normal niconnormal uses_conversion insertodmenuw nposition lpstrtext nflags niconnormal int n icon normal if n flags mf byposition int i position 0 bc menu p menu find menu option n position i position if p menu return p menu insertod menuw i position lpstr text n flags mf byposition nid n icon normal else return false if nid n flags mf separator mf ownerdraw mf byposition else if n flags mf ownerdraw n flags mf ownerdraw int menustart 0 if n flags mf popup if m loadmenu menustart get menu start if n position uint menustart menustart 0 m allsubmenus add hmenu nid m submenus add hmenu nid stephane clog suggested adding this believe it or not it s in the help if n position uint 1 n position get menu item count bc menu data mdata new bc menu data m menulist insert at n position menustart mdata mdata set wide string lpstr text sk modified for dynamic allocation mdata menu icon normal n icon normal mdata xoffset 1 if n icon normal 0 c image list bitmap int xoffset 0 load from tool bar nid n icon normal xoffset if mdata bitmap mdata bitmap delete image list mdata bitmap null bitmap create m iconx m icony ilc colorddb ilc mask 1 1 if add bitmap to image list bitmap n icon normal mdata global offset add to global image list bitmap xoffset nid else mdata global offset global image list offset nid mdata n flags n flags mdata nid nid bool returnflag c menu insert menu n position n flags nid lpctstr mdata if m loadmenu remove top level owner draw return returnflag niconnormal nflags mf_byposition iposition bcmenu pmenu findmenuoption nposition iposition pmenu pmenu insertodmenuw iposition lpstrtext nflags mf_byposition niconnormal nflags mf_separator mf_ownerdraw mf_byposition nflags mf_ownerdraw nflags mf_ownerdraw nflags mf_popup m_loadmenu getmenustart nposition m_allsubmenus m_submenus nposition nposition getmenuitemcount bcmenudata bcmenudata m_menulist insertat nposition setwidestring lpstrtext menuiconnormal niconnormal niconnormal cimagelist loadfromtoolbar niconnormal deleteimagelist m_iconx m_icony ilc_colorddb ilc_mask addbitmaptoimagelist niconnormal global_offset addtoglobalimagelist global_offset globalimagelistoffset nflags nflags cmenu insertmenu nposition nflags m_loadmenu removetoplevelownerdraw c image list il int xoffset uses conversion return insertod menuw n position a2w lpstr text n flags nid il xoffset cimagelist uses_conversion insertodmenuw nposition lpstrtext nflags c image list il int xoffset if n flags mf byposition int i position 0 bc menu p menu find menu option n position i position if p menu return p menu insertod menuw i position lpstr text n flags mf byposition nid il xoffset else return false if nid n flags mf separator mf ownerdraw mf byposition else if n flags mf ownerdraw n flags mf ownerdraw if n flags mf popup m allsubmenus add hmenu nid m submenus add hmenu nid stephane clog suggested adding this believe it or not it s in the help if n position uint 1 n position get menu item count bc menu data mdata new bc menu data m menulist insert at n position mdata mdata set wide string lpstr text sk modified for dynamic allocation mdata menu icon normal 1 mdata xoffset 1 if il if mdata bitmap mdata bitmap delete image list mdata bitmap null mdata global offset add to global image list il xoffset nid mdata n flags n flags mdata nid nid return c menu insert menu n position n flags nid lpctstr mdata cimagelist nflags mf_byposition iposition bcmenu pmenu findmenuoption nposition iposition pmenu pmenu insertodmenuw iposition lpstrtext nflags mf_byposition nflags mf_separator mf_ownerdraw mf_byposition nflags mf_ownerdraw nflags mf_ownerdraw nflags mf_popup m_allsubmenus m_submenus nposition nposition getmenuitemcount bcmenudata bcmenudata m_menulist insertat nposition setwidestring lpstrtext menuiconnormal deleteimagelist global_offset addtoglobalimagelist nflags nflags cmenu insertmenu nposition nflags bool bc menu modifyod menua const char lpstr text uint nid int n icon normal uses conversion return modifyod menuw a2w lpstr text nid n icon normal sk see mfc tech note 059 bcmenu modifyodmenua lpstrtext niconnormal uses_conversion modifyodmenuw lpstrtext niconnormal bool bc menu modifyod menua const char lpstr text uint nid c image list il int xoffset uses conversion return modifyod menuw a2w lpstr text nid il xoffset bcmenu modifyodmenua lpstrtext cimagelist uses_conversion modifyodmenuw lpstrtext bool bc menu modifyod menua const char lpstr text uint nid c bitmap bmp uses conversion return modifyod menuw a2w lpstr text nid bmp bcmenu modifyodmenua lpstrtext cbitmap uses_conversion modifyodmenuw lpstrtext int n icon normal uses conversion return modifyod menuw a2w lpstr text a2w option text n icon normal sk see mfc tech note 059 niconnormal uses_conversion modifyodmenuw lpstrtext optiontext niconnormal bool bc menu modifyod menuw wchar t lpstr text uint nid int n icon normal int n loc bc menu data mdata c array bc menu bc menu bcsubs c array int int bclocs find the old bc menu data structure bc menu psubmenu find menu option nid n loc do if psubmenu n loc 0 mdata psubmenu m menulist n loc else create a new bc menu data structure mdata new bc menu data m menulist add mdata assert mdata if lpstr text mdata set wide string lpstr text sk modified for dynamic allocation mdata menu icon normal 1 mdata xoffset 1 if n icon normal 0 c image list bitmap int xoffset 0 load from tool bar nid n icon normal xoffset if mdata bitmap mdata bitmap delete image list mdata bitmap null bitmap create m iconx m icony ilc colorddb ilc mask 1 1 if add bitmap to image list bitmap n icon normal mdata global offset add to global image list bitmap xoffset nid else mdata global offset global image list offset nid mdata n flags mf byposition mdata n flags mf ownerdraw mdata nid nid bcsubs add psubmenu bclocs add n loc if psubmenu n loc 0 psubmenu find another menu option nid n loc bcsubs bclocs else psubmenu null while psubmenu return c menu modify menu nid mdata n flags nid lpctstr mdata bcmenu modifyodmenuw wchar_t lpstrtext niconnormal nloc bcmenudata carray bcmenu bcmenu carray bcmenudata bcmenu findmenuoption nloc nloc m_menulist nloc bcmenudata bcmenudata m_menulist lpstrtext setwidestring lpstrtext menuiconnormal niconnormal cimagelist loadfromtoolbar niconnormal deleteimagelist m_iconx m_icony ilc_colorddb ilc_mask addbitmaptoimagelist niconnormal global_offset addtoglobalimagelist global_offset globalimagelistoffset nflags mf_byposition nflags mf_ownerdraw nloc nloc findanothermenuoption nloc cmenu modifymenu nflags bool bc menu modifyod menuw wchar t lpstr text uint nid c image list il int xoffset int n loc bc menu data mdata c array bc menu bc menu bcsubs c array int int bclocs find the old bc menu data structure bc menu psubmenu find menu option nid n loc do if psubmenu n loc 0 mdata psubmenu m menulist n loc else create a new bc menu data structure mdata new bc menu data m menulist add mdata assert mdata if lpstr text mdata set wide string lpstr text sk modified for dynamic allocation mdata menu icon normal 1 mdata xoffset 1 if il if mdata bitmap mdata bitmap delete image list mdata bitmap null mdata global offset add to global image list il xoffset nid mdata n flags mf byposition mdata n flags mf ownerdraw mdata nid nid bcsubs add psubmenu bclocs add n loc if psubmenu n loc 0 psubmenu find another menu option nid n loc bcsubs bclocs else psubmenu null while psubmenu return c menu modify menu nid mdata n flags nid lpctstr mdata bcmenu modifyodmenuw wchar_t lpstrtext cimagelist nloc bcmenudata carray bcmenu bcmenu carray bcmenudata bcmenu findmenuoption nloc nloc m_menulist nloc bcmenudata bcmenudata m_menulist lpstrtext setwidestring lpstrtext menuiconnormal deleteimagelist global_offset addtoglobalimagelist nflags mf_byposition nflags mf_ownerdraw nloc nloc findanothermenuoption nloc cmenu modifymenu nflags bool bc menu modifyod menuw wchar t lpstr text uint nid c bitmap bmp if bmp c image list temp temp create m iconx m icony ilc colorddb ilc mask 1 1 if m bitmapbackgroundflag temp add bmp m bitmapbackground else temp add bmp get sys color color 3dface return modifyod menuw lpstr text nid temp 0 return modifyod menuw lpstr text nid null 0 bcmenu modifyodmenuw wchar_t lpstrtext cbitmap cimagelist m_iconx m_icony ilc_colorddb ilc_mask m_bitmapbackgroundflag m_bitmapbackground getsyscolor color_3dface modifyodmenuw lpstrtext modifyodmenuw lpstrtext int n icon normal bc menu data mdata find the old bc menu data structure mdata find menu option option text if mdata if lpstr text mdata set wide string lpstr text sk modified for dynamic allocation mdata menu icon normal n icon normal mdata xoffset 1 if n icon normal 0 mdata xoffset 0 if mdata bitmap mdata bitmap delete image list else mdata bitmap new c image list mdata bitmap create m iconx m icony ilc colorddb ilc mask 1 1 if add bitmap to image list mdata bitmap n icon normal mdata bitmap delete image list delete mdata bitmap mdata bitmap null mdata menu icon normal n icon normal 1 mdata xoffset 1 return true return false niconnormal bcmenudata bcmenudata findmenuoption optiontext lpstrtext setwidestring lpstrtext menuiconnormal niconnormal niconnormal deleteimagelist cimagelist m_iconx m_icony ilc_colorddb ilc_mask addbitmaptoimagelist niconnormal deleteimagelist menuiconnormal niconnormal bool bc menu set image for popup from toolbara const char str pop up text uint toolbarid uint command id to extract icon from uses conversion return set image for popup from toolbarw a2w str pop up text toolbarid command id to extract icon from bcmenu setimageforpopupfromtoolbara strpopuptext command_id_to_extract_icon_from uses_conversion setimageforpopupfromtoolbarw strpopuptext command_id_to_extract_icon_from bool bc menu set image for popup from toolbarw wchar t str pop up text uint toolbarid uint command id to extract icon from c wnd p wnd afx get main wnd if p wnd null p wnd c wnd get desktop window c tool bar bar bar create p wnd if bar load tool bar toolbarid bc menu data mdata find menu option str pop up text if mdata null if mdata bitmap null mdata bitmap delete image list delete mdata bitmap mdata bitmap null c image list imglist imglist create m iconx m icony ilc colorddb ilc mask 1 1 if add bitmap to image list imglist toolbarid int ind bar command to index command id to extract icon from if ind 0 return false uint dummyid dummy style int image index bar get button info ind dummyid dummy style image index assert dummyid command id to extract icon from mdata bitmap new c image list mdata bitmap create m iconx m icony ilc colorddb ilc mask 0 1 mdata bitmap add imglist extract icon image index mdata menu icon normal toolbarid mdata xoffset 0 return true else mdata menu icon normal 1 mdata xoffset 1 return false bcmenu setimageforpopupfromtoolbarw wchar_t strpopuptext command_id_to_extract_icon_from cwnd pwnd afxgetmainwnd pwnd pwnd cwnd getdesktopwindow ctoolbar pwnd loadtoolbar bcmenudata findmenuoption strpopuptext deleteimagelist cimagelist m_iconx m_icony ilc_colorddb ilc_mask addbitmaptoimagelist commandtoindex command_id_to_extract_icon_from dummystyle image_index getbuttoninfo dummystyle image_index command_id_to_extract_icon_from cimagelist m_iconx m_icony ilc_colorddb ilc_mask extracticon image_index menuiconnormal menuiconnormal bool bc menu modifyod menua const char lpstr text uint nid colorref fill colorref border int hatchstyle c size p size uses conversion return modifyod menuw a2w lpstr text nid fill border hatchstyle p size bcmenu modifyodmenua lpstrtext csize psize uses_conversion modifyodmenuw lpstrtext psize bool bc menu modifyod menuw wchar t lpstr text uint nid colorref fill colorref border int hatchstyle c size p size c wnd p wnd afx get main wnd get main window cdc pdc p wnd getdc get device context size sz if p size sz cx m iconx sz cy m icony else sz cx p size cx sz cy p size cy c size bitmap size sz c size icon size m iconx m icony c bitmap bmp color bitmap pdc bmp bitmap size icon size fill border hatchstyle p wnd releasedc pdc return modifyod menuw lpstr text nid bmp bcmenu modifyodmenuw wchar_t lpstrtext csize psize cwnd pwnd afxgetmainwnd pwnd psize m_iconx m_icony psize psize csize bitmap_size csize icon_size m_iconx m_icony cbitmap colorbitmap bitmap_size icon_size pwnd modifyodmenuw lpstrtext bool bc menu remove menu uint ui id uint n flags if mf byposition n flags uint uint get menu state ui id mf byposition if uint mf separator uint mf popup delete m menulist get at ui id m menulist remove at ui id else bc menu p sub menu bc menu get sub menu ui id if null p sub menu uint ui command id get menu itemid ui id for int i 0 i m menulist get size i if m menulist i nid ui command id delete m menulist get at i m menulist remove at i break else int num sub menus m submenus get upper bound for int m num sub menus m 0 m if m submenus m p sub menu m hmenu int num all sub menus m allsubmenus get upper bound for int n num all sub menus n 0 n if m allsubmenus n m submenus m m allsubmenus remove at n m submenus remove at m int num p sub menu get menu item count i for i num 1 i 0 i p sub menu remove menu i mf byposition for i m menulist get upper bound i 0 i if m menulist i nid uint p sub menu m hmenu delete m menulist get at i m menulist remove at i break delete p sub menu else int i position 0 bc menu p menu find menu option ui id i position bug fix ria 14th september 2000 failed to return correct value on call to remove menu as the item was removed twice the second time its not found so a value of 0 was being returned if p menu return p menu remove menu i position mf byposition added return return c menu remove menu ui id n flags bcmenu removemenu uiid nflags mf_byposition nflags getmenustate uiid mf_byposition mf_separator mf_popup m_menulist getat uiid m_menulist removeat uiid bcmenu psubmenu bcmenu getsubmenu uiid psubmenu uicommandid getmenuitemid uiid m_menulist getsize m_menulist uicommandid m_menulist getat m_menulist removeat numsubmenus m_submenus getupperbound numsubmenus m_submenus psubmenu m_hmenu numallsubmenus m_allsubmenus getupperbound numallsubmenus m_allsubmenus m_submenus m_allsubmenus removeat m_submenus removeat psubmenu getmenuitemcount psubmenu removemenu mf_byposition m_menulist getupperbound m_menulist psubmenu m_hmenu m_menulist getat m_menulist removeat psubmenu iposition bcmenu pmenu findmenuoption uiid iposition pmenu pmenu removemenu iposition mf_byposition cmenu removemenu uiid nflags bool bc menu delete menu uint ui id uint n flags if mf byposition n flags uint uint get menu state ui id mf byposition if uint mf separator uint mf popup make sure it s a separator int menulistsize m menulist get size if ui id uint menulistsize c string str m menulist ui id get string if str delete m menulist get at ui id m menulist remove at ui id else bc menu p sub menu bc menu get sub menu ui id if null p sub menu uint ui command id get menu itemid ui id for int i 0 i m menulist get size i if m menulist i nid ui command id delete m menulist get at i m menulist remove at i break else int num sub menus m submenus get upper bound for int m num sub menus m 0 m if m submenus m p sub menu m hmenu int num all sub menus m allsubmenus get upper bound for int n num all sub menus n 0 n if m allsubmenus n m submenus m m allsubmenus remove at n m submenus remove at m int num p sub menu get menu item count i for i num 1 i 0 i p sub menu delete menu i mf byposition for i m menulist get upper bound i 0 i if m menulist i nid uint p sub menu m hmenu delete m menulist get at i m menulist remove at i break delete p sub menu else int i position 0 bc menu p menu find menu option ui id i position if p menu return p menu delete menu i position mf byposition return c menu delete menu ui id n flags bcmenu deletemenu uiid nflags mf_byposition nflags getmenustate uiid mf_byposition mf_separator mf_popup m_menulist getsize uiid cstring m_menulist uiid getstring m_menulist getat uiid m_menulist removeat uiid bcmenu psubmenu bcmenu getsubmenu uiid psubmenu uicommandid getmenuitemid uiid m_menulist getsize m_menulist uicommandid m_menulist getat m_menulist removeat numsubmenus m_submenus getupperbound numsubmenus m_submenus psubmenu m_hmenu numallsubmenus m_allsubmenus getupperbound numallsubmenus m_allsubmenus m_submenus m_allsubmenus removeat m_submenus removeat psubmenu getmenuitemcount psubmenu deletemenu mf_byposition m_menulist getupperbound m_menulist psubmenu m_hmenu m_menulist getat m_menulist removeat psubmenu iposition bcmenu pmenu findmenuoption uiid iposition pmenu pmenu deletemenu iposition mf_byposition cmenu deletemenu uiid nflags int bc menu remove menu char p text bc seperator s pos uses conversion return remove menu a2w p text s pos bcmenu removemenu ptext bc_seperator spos uses_conversion removemenu ptext spos int bc menu remove menu wchar t p text bc seperator s pos int n pos get menu position p text if n pos 1 remove menu n pos mf byposition if s pos bcmenu head assert n pos 1 0 remove menu n pos 1 mf byposition else if s pos bcmenu tail remove menu n pos 1 mf byposition else if s pos bcmenu both remove the end first remove menu n pos 1 mf byposition remove the head assert n pos 1 0 remove menu n pos 1 mf byposition return n pos bcmenu removemenu wchar_t ptext bc_seperator spos npos getmenuposition ptext npos removemenu npos mf_byposition spos bcmenu_head npos removemenu npos mf_byposition spos bcmenu_tail removemenu npos mf_byposition spos bcmenu_both removemenu npos mf_byposition npos removemenu npos mf_byposition npos int bc menu delete menu char p text bc seperator s pos uses conversion return delete menu a2w p text s pos bcmenu deletemenu ptext bc_seperator spos uses_conversion deletemenu ptext spos int bc menu delete menu wchar t p text bc seperator s pos int n pos get menu position p text if n pos 1 delete menu n pos mf byposition if s pos bcmenu head assert n pos 1 0 delete menu n pos 1 mf byposition else if s pos bcmenu tail delete menu n pos 1 mf byposition else if s pos bcmenu both remove the end first delete menu n pos 1 mf byposition remove the head assert n pos 1 0 delete menu n pos 1 mf byposition return n pos bcmenu deletemenu wchar_t ptext bc_seperator spos npos getmenuposition ptext npos deletemenu npos mf_byposition spos bcmenu_head npos deletemenu npos mf_byposition spos bcmenu_tail deletemenu npos mf_byposition spos bcmenu_both deletemenu npos mf_byposition npos deletemenu npos mf_byposition npos bool bc menu destroy menu destroy sub menus int m n int num all sub menus m allsubmenus get upper bound for n num all sub menus n 0 n if m allsubmenus n this m hmenu m allsubmenus remove at n int num sub menus m submenus get upper bound for m num sub menus m 0 m num all sub menus m allsubmenus get upper bound for n num all sub menus n 0 n if m allsubmenus n m submenus m m allsubmenus remove at n c menu ptr from handle m submenus m if ptr bool flag ptr is kind of runtime class bc menu if flag delete bc menu ptr m submenus remove all destroy menu data int num items m menulist get upper bound for m 0 m num items m delete m menulist m m menulist remove all if checkmaps checkmapsshare delete checkmaps checkmaps null call base class implementation last return c menu destroy menu bcmenu destroymenu numallsubmenus m_allsubmenus getupperbound numallsubmenus m_allsubmenus m_hmenu m_allsubmenus removeat numsubmenus m_submenus getupperbound numsubmenus numallsubmenus m_allsubmenus getupperbound numallsubmenus m_allsubmenus m_submenus m_allsubmenus removeat cmenu fromhandle m_submenus iskindof runtime_class bcmenu bcmenu m_submenus removeall numitems m_menulist getupperbound numitems m_menulist m_menulist removeall cmenu destroymenu bool bc menu get menu text uint id c string string uint n flags mf byposition bool returnflag false if mf byposition n flags uint num menu items m menulist get upper bound if id num menu items string m menulist id get string returnflag true else int ui loc bc menu p menu find menu option id ui loc if null p menu returnflag p menu get menu text ui loc string return returnflag bcmenu getmenutext cstring nflags mf_byposition mf_byposition nflags nummenuitems m_menulist getupperbound nummenuitems m_menulist getstring uiloc bcmenu pmenu findmenuoption uiloc pmenu pmenu getmenutext uiloc bool bc menu set menu text uint id c string string uint n flags mf byposition bool returnflag false if mf byposition n flags uint num menu items m menulist get upper bound if id num menu items ifdef unicode m menulist id set wide string lpctstr string else m menulist id set ansi string string endif returnflag true else int ui loc bc menu p menu find menu option id ui loc if null p menu returnflag p menu set menu text ui loc string return returnflag bcmenu setmenutext cstring nflags mf_byposition mf_byposition nflags nummenuitems m_menulist getupperbound nummenuitems m_menulist setwidestring m_menulist setansistring uiloc bcmenu pmenu findmenuoption uiloc pmenu pmenu setmenutext uiloc bc menu bc menu get subbc menu char p text uses conversion return get subbc menu a2w p text bcmenu bcmenu getsubbcmenu ptext uses_conversion getsubbcmenu ptext bc menu bc menu get subbc menu wchar t lpsz sub menu name bc menu data mdata mdata find menu option lpsz sub menu name if mdata hmenu bchmenu hmenu mdata nid c menu ptr from handle bchmenu if ptr bool flag ptr is kind of runtime class bc menu if flag return bc menu ptr return null bcmenu bcmenu getsubbcmenu wchar_t lpszsubmenuname bcmenudata findmenuoption lpszsubmenuname cmenu fromhandle iskindof runtime_class bcmenu bcmenu c menu bc menu get sub menu lpctstr lpsz sub menu name int num get menu item count c string name for int i 0 i num i get menu string i name mf byposition if name compare lpsz sub menu name 0 return c menu get sub menu i return null cmenu bcmenu getsubmenu lpszsubmenuname getmenuitemcount cstring getmenustring mf_byposition lpszsubmenuname cmenu getsubmenu c menu bc menu get sub menu int n pos return c menu get sub menu n pos cmenu bcmenu getsubmenu npos cmenu getsubmenu npos int bc menu get menu position char p text uses conversion return get menu position a2w p text bcmenu getmenuposition ptext uses_conversion getmenuposition ptext int bc menu get menu position wchar t p text int i j bc menu psubmenu for i 0 i int get menu item count i psubmenu bc menu get sub menu i if psubmenu const wchar t sz wide sk we use const to prevent misuse of this ptr for j 0 j m menulist get upper bound j sz wide m menulist j get wide string if sz wide wcscmp p text sz wide sk modified for dynamic allocation return j means no found return 1 bcmenu getmenuposition wchar_t ptext bcmenu getmenuitemcount bcmenu getsubmenu wchar_t szwide m_menulist getupperbound szwide m_menulist getwidestring szwide ptext szwide void bc menu draw item lpdrawitemstruct lpdis assert lpdis null cdc pdc cdc from handle lpdis hdc if pdc get device caps rastercaps rc palette drawitem win9xnt2000 lpdis else if is winxp luna if xp drawmode bcmenu drawmode xp drawitem winxp lpdis else drawitem win9xnt2000 lpdis else if original drawmode bcmenu drawmode xp drawitem winxp lpdis else drawitem win9xnt2000 lpdis bcmenu drawitem fromhandle getdevicecaps rc_palette drawitem_win9xnt2000 iswinxpluna xp_drawmode bcmenu_drawmode_xp drawitem_winxp drawitem_win9xnt2000 original_drawmode bcmenu_drawmode_xp drawitem_winxp drawitem_win9xnt2000 void bc menu measure item lpmeasureitemstruct lpmis uint state bc menu data lpmis item data n flags int bcmenu pad 4 if is luna menu style xp draw 3d bitmaps bcmenu pad 7 if state mf separator lpmis item width 0 int temp get system metrics sm cymenu 1 if is luna menu style lpmis item height 3 else lpmis item height temp m icony bcmenu pad 2 temp m icony bcmenu pad 2 else c font m fontmenu logfont m lf zero memory pvoid m lf sizeof logfont nonclientmetrics nm nm cb size sizeof nonclientmetrics verify system parameters info spi getnonclientmetrics nm cb size nm 0 m lf nm lf menu font m fontmenu create font indirect m lf obtain the width of the text c wnd p wnd afx get main wnd get main window if p wnd null p wnd c wnd get desktop window cdc pdc p wnd getdc get device context c font p font null select menu font in if is new shell p font pdc select object m fontmenu select menu font in get pointer to text sk const wchar t lpstr text bc menu data lpmis item data get wide string sk we use const to prevent misuse size size size cx size cy 0 if win32s g shell verify get text extent point32w pdc m hdc lpstr text wcslen lpstr text size sk should also work on 95 ifndef unicode can t be unicode for win32s else it s win32suckx rect rect rect left rect top 0 size cy draw text pdc m hdc lpctstr lpstr text wcslen lpstr text rect dt singleline dt left dt vcenter dt calcrect 3 makes at least three pixels space to the menu border size cx rect right rect left 3 size cx 3 size cx wcslen lpstr text endif c size t c size size if is new shell pdc select object p font select old font in p wnd releasedc pdc release the dc set width and height if is luna menu style lpmis item width m iconx bcmenu pad 8 t cx else lpmis item width m iconx t cx m iconx bcmenu gap int temp get system metrics sm cymenu lpmis item height temp m icony bcmenu pad temp m icony bcmenu pad m fontmenu delete object bcmenu measureitem bcmenudata itemdata nflags bcmenu_pad islunamenustyle xp_draw_3d_bitmaps bcmenu_pad mf_separator itemwidth getsystemmetrics sm_cymenu islunamenustyle itemheight itemheight m_icony bcmenu_pad m_icony bcmenu_pad cfont m_fontmenu m_lf zeromemory m_lf cbsize systemparametersinfo spi_getnonclientmetrics cbsize m_lf lfmenufont m_fontmenu createfontindirect m_lf cwnd pwnd afxgetmainwnd pwnd pwnd cwnd getdesktopwindow pwnd cfont pfont isnewshell pfont selectobject m_fontmenu wchar_t lpstrtext bcmenudata itemdata getwidestring g_shell gettextextentpoint32w m_hdc lpstrtext lpstrtext drawtext m_hdc lpstrtext lpstrtext dt_singleline dt_left dt_vcenter dt_calcrect lpstrtext csize csize isnewshell selectobject pfont pwnd islunamenustyle itemwidth m_iconx bcmenu_pad itemwidth m_iconx m_iconx bcmenu_gap getsystemmetrics sm_cymenu itemheight m_icony bcmenu_pad m_icony bcmenu_pad m_fontmenu deleteobject void bc menu update menu c menu pmenu ifdef cpprtti bc menu psubmenu dynamic cast bc menu pmenu else bc menu psubmenu bc menu pmenu endif if psubmenu psubmenu synchronize menu bcmenu updatemenu cmenu _cpprtti bcmenu dynamic_cast bcmenu bcmenu bcmenu synchronizemenu bool bc menu is menu c menu submenu int m int num sub menus m allsubmenus get upper bound for m 0 m num sub menus m if submenu m hmenu m allsubmenus m return true return false bcmenu ismenu cmenu numsubmenus m_allsubmenus getupperbound numsubmenus m_hmenu m_allsubmenus bool bc menu is menu hmenu submenu int m int num sub menus m allsubmenus get upper bound for m 0 m num sub menus m if submenu m allsubmenus m return true return false bcmenu ismenu numsubmenus m_allsubmenus getupperbound numsubmenus m_allsubmenus c menu p menu ifdef cpprtti bc menu pbc menu dynamic cast bc menu p menu else bc menu pbc menu bc menu p menu endif if pbc menu n flags mf popup c string key t 2 sk modified for unicode correctness key set at 1 tchar n char key make lower c string menutext int menusize int pbc menu get menu item count if menusize pbc menu m menulist get upper bound 1 pbc menu synchronize menu for int i 0 i menusize i if pbc menu get menu text i menutext menutext make lower if menutext find key 0 return makelresult i 2 return 0 cmenu pmenu _cpprtti bcmenu pbcmenu dynamic_cast bcmenu pmenu bcmenu pbcmenu bcmenu pmenu pbcmenu nflags mf_popup cstring _t setat nchar makelower cstring pbcmenu getmenuitemcount pbcmenu m_menulist getupperbound pbcmenu synchronizemenu pbcmenu getmenutext makelower int bc menu get menu draw mode void if is winxp luna return xp drawmode return original drawmode bcmenu getmenudrawmode iswinxpluna xp_drawmode original_drawmode bool bc menu get select disable mode void if is luna menu style return xp select disabled return original select disabled bcmenu getselectdisablemode islunamenustyle xp_select_disabled original_select_disabled void bc menu set icon size int width int height m iconx width m icony height bcmenu seticonsize m_iconx m_icony void bc menu set bitmap background colorref color m bitmapbackground color m bitmapbackgroundflag true bcmenu setbitmapbackground m_bitmapbackground m_bitmapbackgroundflag void bc menu un set bitmap background void m bitmapbackgroundflag false bcmenu unsetbitmapbackground m_bitmapbackgroundflag bool bc menu get disable old style void return disable old style bcmenu getdisableoldstyle disable_old_style void bc menu set disable old style void disable old style true bcmenu setdisableoldstyle disable_old_style void bc menu un set disable old style void disable old style false bcmenu unsetdisableoldstyle disable_old_style colorref bc menu lighten color colorref col double factor if factor 0 0 factor 1 0 byte red green blue lightred lightgreen lightblue red getr value col green getg value col blue getb value col lightred byte factor 255 red red lightgreen byte factor 255 green green lightblue byte factor 255 blue blue col rgb lightred lightgreen lightblue return col bcmenu lightencolor getrvalue getgvalue getbvalue colorref bc menu darken color colorref col double factor if factor 0 0 factor 1 0 byte red green blue lightred lightgreen lightblue red getr value col green getg value col blue getb value col lightred byte red factor red lightgreen byte green factor green lightblue byte blue factor blue col rgb lightred lightgreen lightblue return col bcmenu darkencolor getrvalue getgvalue getbvalue bool bc menu is windows classic theme void tchar buf max path 10 hkey h key dword size type long l ret code static bool xptheme returnflag false static bool xptheme checkflag false if xptheme checkflag return xptheme returnflag xptheme checkflag true l ret code reg open key ex hkey current user t software microsoft plus themes current 0 key read h key if l ret code error success size max path type reg sz l ret code reg query value ex h key null null type unsigned char buf size if l ret code error success tchar sz classic theme t windows classic theme int len lstrlen buf if len lstrlen sz classic theme if lstrcmpi buf len lstrlen sz classic theme sz classic theme xptheme returnflag true reg close key h key return xptheme returnflag bcmenu iswindowsclassictheme _max_path hkey lretcode xptheme_returnflag xptheme_checkflag xptheme_checkflag xptheme_returnflag xptheme_checkflag lretcode regopenkeyex hkey_current_user _t key_read hkey lretcode error_success _max_path reg_sz lretcode regqueryvalueex hkey lretcode error_success szclassictheme _t szclassictheme szclassictheme szclassictheme xptheme_returnflag regclosekey hkey xptheme_returnflag bc menu data bc menu find menu item uint nid bc menu data p data null int i for i 0 i m menulist get upper bound i if m menulist i nid nid p data m menulist i break if p data int loc bc menu p menu find menu option nid loc assert p menu this if loc 0 return p menu find menu item nid return p data bcmenudata bcmenu findmenuitem bcmenudata pdata m_menulist getupperbound m_menulist pdata m_menulist pdata bcmenu pmenu findmenuoption pmenu pmenu findmenuitem pdata bc menu bc menu find menu option int n id int n loc int i bc menu psubmenu pgoodmenu for i 0 i int get menu item count i ifdef cpprtti psubmenu dynamic cast bc menu get sub menu i else psubmenu bc menu get sub menu i endif if psubmenu pgoodmenu psubmenu find menu option n id n loc if pgoodmenu return pgoodmenu else if n id int get menu itemid i n loc i return this n loc 1 return null bcmenu bcmenu findmenuoption nid nloc bcmenu getmenuitemcount _cpprtti dynamic_cast bcmenu getsubmenu bcmenu getsubmenu findmenuoption nid nloc nid getmenuitemid nloc nloc c array int int bclocs int i numsubs j bc menu psubmenu pgoodmenu bool foundflag for i 0 i int get menu item count i ifdef cpprtti psubmenu dynamic cast bc menu get sub menu i else psubmenu bc menu get sub menu i endif if psubmenu pgoodmenu psubmenu find another menu option n id n loc bcsubs bclocs if pgoodmenu return pgoodmenu else if n id int get menu itemid i numsubs bcsubs get size foundflag true for j 0 j numsubs j if bcsubs j this bclocs j i foundflag false break if foundflag n loc i return this n loc 1 return null carray bcmenu getmenuitemcount _cpprtti dynamic_cast bcmenu getsubmenu bcmenu getsubmenu findanothermenuoption nid nloc nid getmenuitemid getsize nloc nloc bc menu data bc menu find menu option wchar t lpstr text int i j bc menu psubmenu bc menu data pmenulist for i 0 i int get menu item count i ifdef cpprtti psubmenu dynamic cast bc menu get sub menu i else psubmenu bc menu get sub menu i endif if psubmenu pmenulist psubmenu find menu option lpstr text if pmenulist return pmenulist else const wchar t sz wide sk we use const to prevent misuse of this ptr for j 0 j m menulist get upper bound j sz wide m menulist j get wide string if sz wide wcscmp lpstr text sz wide sk modified for dynamic allocation return m menulist j return null bcmenudata bcmenu findmenuoption wchar_t lpstrtext bcmenu bcmenudata getmenuitemcount _cpprtti dynamic_cast bcmenu getsubmenu bcmenu getsubmenu findmenuoption lpstrtext wchar_t szwide m_menulist getupperbound szwide m_menulist getwidestring szwide lpstrtext szwide m_menulist void bc menu insert spaces void if is luna menu style if xp space accelerators return else if original space accelerators return int i j numitems maxlength c string string newstring c size t c font m fontmenu logfont m lf zero memory pvoid m lf sizeof logfont nonclientmetrics nm nm cb size sizeof nonclientmetrics verify system parameters info spi getnonclientmetrics nm cb size nm 0 m lf nm lf menu font m fontmenu create font indirect m lf c wnd p wnd afx get main wnd if p wnd null p wnd c wnd get desktop window cdc pdc p wnd getdc c font p font pdc select object m fontmenu numitems get menu item count maxlength 1 for i 0 i numitems i string m menulist i get string j string find char 9 newstring empty if j 1 newstring string left j else newstring string newstring t sk modified for unicode correctness lpctstr lpstr text lpctstr newstring t pdc get text extent lpstr text tcslen lpstr text if t cx maxlength maxlength t cx for i 0 i numitems i string m menulist i get string j string find char 9 if j 1 newstring empty newstring string left j lpctstr lpstr text lpctstr newstring t pdc get text extent lpstr text tcslen lpstr text while t cx maxlength newstring t sk modified for unicode correctness lpctstr lpstr text lpctstr newstring t pdc get text extent lpstr text tcslen lpstr text newstring string mid j ifdef unicode m menulist i set wide string newstring sk modified for dynamic allocation else m menulist i set ansi string newstring endif pdc select object p font select old font in p wnd releasedc pdc release the dc m fontmenu delete object bcmenu insertspaces islunamenustyle xp_space_accelerators original_space_accelerators cstring csize cfont m_fontmenu m_lf zeromemory m_lf cbsize systemparametersinfo spi_getnonclientmetrics cbsize m_lf lfmenufont m_fontmenu createfontindirect m_lf cwnd pwnd afxgetmainwnd pwnd pwnd cwnd getdesktopwindow pwnd cfont pfont selectobject m_fontmenu getmenuitemcount m_menulist getstring _t lpstrtext gettextextent lpstrtext _tcslen lpstrtext m_menulist getstring lpstrtext gettextextent lpstrtext _tcslen lpstrtext _t lpstrtext gettextextent lpstrtext _tcslen lpstrtext m_menulist setwidestring m_menulist setansistring selectobject pfont pwnd m_fontmenu deleteobject void bc menu draw check mark cdc pdc int x int y colorref color bool narrowflag int dp 0 c pen m penback m penback create pen ps solid 0 color c pen p old pen pdc select object m penback if narrowflag dp 1 pdc move to x y 2 pdc line to x y 5 dp pdc move to x 1 y 3 pdc line to x 1 y 6 dp pdc move to x 2 y 4 pdc line to x 2 y 7 dp pdc move to x 3 y 3 pdc line to x 3 y 6 dp pdc move to x 4 y 2 pdc line to x 4 y 5 dp pdc move to x 5 y 1 pdc line to x 5 y 4 dp pdc move to x 6 y pdc line to x 6 y 3 dp pdc select object p old pen m penback delete object bcmenu drawcheckmark cpen m_penback m_penback createpen ps_solid cpen poldpen selectobject m_penback moveto lineto moveto lineto moveto lineto moveto lineto moveto lineto moveto lineto moveto lineto selectobject poldpen m_penback deleteobject void bc menu draw radio dot cdc pdc int x int y colorref color c rect rc dot x y x 6 y 6 c brush brush c pen pen brush create solid brush color pen create pen ps solid 0 color c brush p old brush pdc select object brush c pen p old pen pdc select object pen pdc ellipse rc dot pdc select object p old brush pdc select object p old pen pen delete object brush delete object bcmenu drawradiodot crect rcdot cbrush cpen createsolidbrush createpen ps_solid cbrush poldbrush selectobject cpen poldpen selectobject rcdot selectobject poldbrush selectobject poldpen deleteobject deleteobject bc menu data bc menu newod menu uint pos uint n flags uint nid c string string bc menu data mdata mdata new bc menu data mdata menu icon normal 1 mdata xoffset 1 ifdef unicode mdata set wide string lpctstr string sk modified for dynamic allocation else mdata set ansi string string endif mdata n flags n flags mdata nid nid if n flags mf popup m allsubmenus add hmenu nid if n flags mf ownerdraw assert n flags mf string modify menu pos n flags nid lpctstr mdata else if n flags mf string assert n flags mf ownerdraw modify menu pos n flags nid mdata get string else assert n flags mf separator modify menu pos n flags nid return mdata bcmenudata bcmenu newodmenu nflags cstring bcmenudata bcmenudata menuiconnormal setwidestring setansistring nflags nflags nflags mf_popup m_allsubmenus nflags mf_ownerdraw nflags mf_string modifymenu nflags nflags mf_string nflags mf_ownerdraw modifymenu nflags getstring nflags mf_separator modifymenu nflags void bc menu synchronize menu void c typed ptr array c ptr array bc menu data temp bc menu data mdata c string string uint submenu nid 0 state j initialize menu list 0 for j 0 j get menu item count j mdata null state get menu state j mf byposition if state mf popup submenu uint get sub menu j m hmenu mdata find menu list submenu get menu string j string mf byposition if mdata mdata newod menu j state 0xff mf byposition mf popup mf ownerdraw submenu string else if string get length 0 ifdef unicode mdata set wide string string sk modified for dynamic allocation else mdata set ansi string string endif else if state mf separator mdata find menu list 0 if mdata mdata newod menu j state mf byposition mf separator mf ownerdraw 0 t sk modified for unicode correctness else modify menu j mdata n flags nid lpctstr mdata else nid get menu itemid j mdata find menu list nid get menu string j string mf byposition if mdata mdata newod menu j state mf byposition mf ownerdraw nid string else mdata n flags state mf byposition mf ownerdraw if string get length 0 ifdef unicode mdata set wide string string sk modified for dynamic allocation else mdata set ansi string string endif modify menu j mdata n flags nid lpctstr mdata if mdata temp add mdata delete menu list m menulist remove all m menulist append temp temp remove all bcmenu synchronizemenu ctypedptrarray cptrarray bcmenudata bcmenudata cstring initializemenulist getmenuitemcount getmenustate mf_byposition mf_popup getsubmenu m_hmenu findmenulist getmenustring mf_byposition newodmenu mf_byposition mf_popup mf_ownerdraw getlength setwidestring setansistring mf_separator findmenulist newodmenu mf_byposition mf_separator mf_ownerdraw _t modifymenu nflags getmenuitemid findmenulist getmenustring mf_byposition newodmenu mf_byposition mf_ownerdraw nflags mf_byposition mf_ownerdraw getlength setwidestring setansistring modifymenu nflags deletemenulist m_menulist removeall m_menulist removeall void bc menu initialize menu list int value for int i 0 i m menulist get upper bound i m menulist i syncflag value bcmenu initializemenulist m_menulist getupperbound m_menulist void bc menu delete menu list void for int i 0 i m menulist get upper bound i if m menulist i syncflag delete m menulist i bcmenu deletemenulist m_menulist getupperbound m_menulist m_menulist bc menu data bc menu find menu list uint nid for int i 0 i m menulist get upper bound i if m menulist i nid nid m menulist i syncflag m menulist i syncflag 1 return m menulist i return null bcmenudata bcmenu findmenulist m_menulist getupperbound m_menulist m_menulist m_menulist m_menulist void bc menu drawitem win9xnt2000 lpdrawitemstruct lpdis assert lpdis null cdc pdc cdc from handle lpdis hdc c rect rect uint state bc menu data lpdis item data n flags c brush m brbackground colorref m clrback if is winxp luna m clrback get sys color color 3dface else m clrback get sys color color menu m brbackground create solid brush m clrback remove the selected bit if it s grayed out if lpdis item state ods grayed original select disabled if lpdis item state ods selected lpdis item state lpdis item state ods selected if state mf separator rect copy rect lpdis rc item pdc fill rect rect m brbackground rect top rect height 1 pdc draw edge rect edge etched bf top else c rect rect2 bool standardflag false selectedflag false disableflag false bool checkflag false colorref cr text get sys color color menutext c brush m brselect c pen m penback int x0 y0 dy int n icon normal 1 xoffset 1 global offset 1 c image list bitmap null set some colors m penback create pen ps solid 0 m clrback m brselect create solid brush get sys color color highlight draw the colored rectangle portion rect copy rect lpdis rc item rect2 rect draw the up down focused disabled state uint state lpdis item state c string str text if lpdis item data null n icon normal bc menu data lpdis item data menu icon normal xoffset bc menu data lpdis item data xoffset global offset bc menu data lpdis item data global offset bitmap bc menu data lpdis item data bitmap str text bc menu data lpdis item data get string if n icon normal 0 global offset 0 xoffset global offset n icon normal 0 bitmap m allimages if state ods checked n icon normal 0 if state ods selected m selectcheck 0 checkflag true else if m unselectcheck 0 checkflag true else if n icon normal 1 standardflag true if state ods selected state ods grayed selectedflag true else if state ods grayed disableflag true else str text empty if state ods selected draw the down edges c pen p old pen pdc select object m penback you need only text highlight and thats what you get if checkflag standardflag selectedflag disableflag state ods checked rect2 set rect rect left m iconx 4 bcmenu gap rect top rect right rect bottom pdc fill rect rect2 m brselect pdc select object p old pen cr text get sys color color highlighttext else c pen p old pen pdc select object m penback pdc fill rect rect m brbackground pdc select object p old pen draw the up edges pdc draw3d rect rect m clrback m clrback draw the text if there is any we have to paint the text only if the image is nonexistant dy rect height 4 m icony 2 dy dy 0 0 dy if checkflag standardflag selectedflag disableflag rect2 set rect rect left 1 rect top 1 dy rect left m iconx 3 rect top m icony 3 dy pdc draw3d rect rect2 m clrback m clrback if checkflag checkmaps pdc fill rect rect2 m brbackground rect2 set rect rect left rect top dy rect left m iconx 4 rect top m icony 4 dy pdc draw3d rect rect2 m clrback m clrback c point pt image rect left 2 rect top 2 dy if state ods selected checkmaps draw pdc 1 pt image ild transparent else checkmaps draw pdc 0 pt image ild transparent else if disableflag if selectedflag c bitmap bitmapstandard get bitmap from image list pdc bitmap xoffset bitmapstandard rect2 set rect rect left rect top dy rect left m iconx 4 rect top m icony 4 dy pdc draw3d rect rect2 m clrback m clrback if disable old style dither blt lpdis hdc rect left 2 rect top 2 dy m iconx m icony hbitmap bitmapstandard 0 0 m clrback else if hicolor bitmaps dither blt3 pdc rect left 2 rect top 2 dy m iconx m icony bitmapstandard m clrback else dither blt2 pdc rect left 2 rect top 2 dy m iconx m icony bitmapstandard 0 0 m clrback bitmapstandard delete object else if selectedflag pdc fill rect rect2 m brbackground rect2 set rect rect left rect top dy rect left m iconx 4 rect top m icony 4 dy if is new shell if state ods checked pdc draw3d rect rect2 get sys color color 3dshadow get sys color color 3dhilight else pdc draw3d rect rect2 get sys color color 3dhilight get sys color color 3dshadow c point pt image rect left 2 rect top 2 dy if bitmap bitmap draw pdc xoffset pt image ild transparent else if state ods checked c brush brush colorref col m clrback col lighten color col 0 6 brush create solid brush col pdc fill rect rect2 brush brush delete object rect2 set rect rect left rect top dy rect left m iconx 4 rect top m icony 4 dy if is new shell pdc draw3d rect rect2 get sys color color 3dshadow get sys color color 3dhilight else pdc fill rect rect2 m brbackground rect2 set rect rect left rect top dy rect left m iconx 4 rect top m icony 4 dy pdc draw3d rect rect2 m clrback m clrback c point pt image rect left 2 rect top 2 dy if bitmap bitmap draw pdc xoffset pt image ild transparent if n icon normal 0 state ods checked checkflag rect2 set rect rect left 1 rect top 2 dy rect left m iconx 1 rect top m icony 2 dy c menu item info info info f mask miim checkmarks get menu item info hmenu lpdis hwnd item lpdis itemid mf bycommand info if state ods checked info hbmp unchecked draw3d checkmark pdc rect2 state ods selected state ods checked info hbmp checked info hbmp unchecked this is needed always so that we can have the space for check marks x0 rect left y0 rect top rect left rect left m iconx 8 bcmenu gap if str text is empty c rect rectt rect left rect top 1 rect right rect bottom 1 find tabs c string left str right str left str empty right str empty int tablocr str text reverse find t t if tablocr 1 right str str text mid tablocr 1 left str str text left str text find t t rectt right m iconx else left str str text int i old mode pdc get bk mode pdc set bk mode transparent draw the text in the correct colour uint n format dt left dt singleline dt vcenter uint n formatr dt right dt singleline dt vcenter if lpdis item state ods grayed pdc set text color cr text pdc draw text left str rectt n format if tablocr 1 pdc draw text right str rectt n formatr else draw the disabled text if state ods selected rect offset rectt offset left 1 offset right 1 offset top 1 offset bottom 1 pdc set text color get sys color color btnhilight pdc draw text left str offset n format if tablocr 1 pdc draw text right str offset n formatr pdc set text color get sys color color graytext pdc draw text left str rectt n format if tablocr 1 pdc draw text right str rectt n formatr else and the standard grey text pdc set text color m clrback pdc draw text left str rectt n format if tablocr 1 pdc draw text right str rectt n formatr pdc set bk mode i old mode m penback delete object m brselect delete object m brbackground delete object bcmenu drawitem_win9xnt2000 fromhandle crect bcmenudata itemdata nflags cbrush m_brbackground m_clrback iswinxpluna m_clrback getsyscolor color_3dface m_clrback getsyscolor color_menu m_brbackground createsolidbrush m_clrback itemstate ods_grayed original_select_disabled itemstate ods_selected itemstate itemstate ods_selected mf_separator copyrect rcitem fillrect m_brbackground drawedge edge_etched bf_top crect crtext getsyscolor color_menutext cbrush m_brselect cpen m_penback niconnormal global_offset cimagelist m_penback createpen ps_solid m_clrback m_brselect createsolidbrush getsyscolor color_highlight copyrect rcitem itemstate cstring strtext itemdata niconnormal bcmenudata itemdata menuiconnormal bcmenudata itemdata global_offset bcmenudata itemdata global_offset bcmenudata itemdata strtext bcmenudata itemdata getstring niconnormal global_offset global_offset niconnormal m_allimages ods_checked niconnormal ods_selected m_selectcheck m_unselectcheck niconnormal ods_selected ods_grayed ods_grayed strtext ods_selected cpen poldpen selectobject m_penback ods_checked setrect m_iconx bcmenu_gap fillrect m_brselect selectobject poldpen crtext getsyscolor color_highlighttext cpen poldpen selectobject m_penback fillrect m_brbackground selectobject poldpen draw3drect m_clrback m_clrback m_icony setrect m_iconx m_icony draw3drect m_clrback m_clrback fillrect m_brbackground setrect m_iconx m_icony draw3drect m_clrback m_clrback cpoint ptimage ods_selected ptimage ild_transparent ptimage ild_transparent cbitmap getbitmapfromimagelist setrect m_iconx m_icony draw3drect m_clrback m_clrback disable_old_style ditherblt m_iconx m_icony m_clrback hicolor_bitmaps ditherblt3 m_iconx m_icony m_clrback ditherblt2 m_iconx m_icony m_clrback deleteobject fillrect m_brbackground setrect m_iconx m_icony isnewshell ods_checked draw3drect getsyscolor color_3dshadow getsyscolor color_3dhilight draw3drect getsyscolor color_3dhilight getsyscolor color_3dshadow cpoint ptimage ptimage ild_transparent ods_checked cbrush m_clrback lightencolor createsolidbrush fillrect deleteobject setrect m_iconx m_icony isnewshell draw3drect getsyscolor color_3dshadow getsyscolor color_3dhilight fillrect m_brbackground setrect m_iconx m_icony draw3drect m_clrback m_clrback cpoint ptimage ptimage ild_transparent niconnormal ods_checked setrect m_iconx m_icony cmenuiteminfo fmask miim_checkmarks getmenuiteminfo hwnditem mf_bycommand ods_checked hbmpunchecked draw3dcheckmark ods_selected ods_checked hbmpchecked hbmpunchecked m_iconx bcmenu_gap strtext isempty crect cstring leftstr rightstr leftstr rightstr strtext reversefind _t rightstr strtext leftstr strtext strtext _t m_iconx leftstr strtext ioldmode getbkmode setbkmode nformat dt_left dt_singleline dt_vcenter nformatr dt_right dt_singleline dt_vcenter itemstate ods_grayed settextcolor crtext drawtext leftstr nformat drawtext rightstr nformatr ods_selected settextcolor getsyscolor color_btnhilight drawtext leftstr nformat drawtext rightstr nformatr settextcolor getsyscolor color_graytext drawtext leftstr nformat drawtext rightstr nformatr settextcolor m_clrback drawtext leftstr nformat drawtext rightstr nformatr setbkmode ioldmode m_penback deleteobject m_brselect deleteobject m_brbackground deleteobject void bc menu drawitem winxp lpdrawitemstruct lpdis assert lpdis null cdc pdc cdc from handle lpdis hdc ifdef bcmenu use memdc bc menu memdc p memdc null endif c rect rect rect2 uint state bc menu data lpdis item data n flags colorref m newclrback get sys color color 3dface colorref m clrback get sys color color window m clrback darken color m clrback 0 02 c font m fontmenu p font null logfont m lf if is winxp luna m newclrback lighten color m newclrback 0 25 c brush m newbrbackground m brbackground m brbackground create solid brush m clrback m newbrbackground create solid brush m newclrback int bcmenu pad 4 if xp draw 3d bitmaps bcmenu pad 7 int barwidth m iconx bcmenu pad remove the selected bit if it s grayed out if lpdis item state ods grayed xp select disabled if lpdis item state ods selected lpdis item state lpdis item state ods selected ifdef bcmenu use memdc p memdc new bc menu memdc pdc lpdis rc item pdc p memdc zero memory pvoid m lf sizeof logfont nonclientmetrics nm nm cb size sizeof nonclientmetrics verify system parameters info spi getnonclientmetrics nm cb size nm 0 m lf nm lf menu font m fontmenu create font indirect m lf p font pdc select object m fontmenu endif if state mf separator rect copy rect lpdis rc item pdc fill rect rect m brbackground rect2 set rect rect left rect top rect left barwidth rect bottom rect top rect height 1 rect left rect2 right bcmenu pad pdc draw edge rect edge etched bf top pdc fill rect rect2 m newbrbackground pdc draw3d rect rect2 m newclrback m newclrback else bool standardflag false selectedflag false disableflag false bool checkflag false colorref cr text get sys color color menutext colorref cr select get sys color color highlight colorref cr select fill if is winxp luna cr select fill lighten color cr select 0 85 else cr select fill lighten color cr select 0 7 c brush m brselect c pen m penback int x0 y0 dx dy int n icon normal 1 xoffset 1 global offset 1 int faded offset 1 shadow offset 2 disabled offset 3 c image list bitmap null bool can draw3d false set some colors m penback create pen ps solid 0 m clrback m brselect create solid brush cr select fill draw the colored rectangle portion rect copy rect lpdis rc item rect2 rect draw the up down focused disabled state uint state lpdis item state c string str text if lpdis item data null n icon normal bc menu data lpdis item data menu icon normal xoffset bc menu data lpdis item data xoffset bitmap bc menu data lpdis item data bitmap str text bc menu data lpdis item data get string global offset bc menu data lpdis item data global offset if xoffset 0 xp draw 3d bitmaps bitmap bitmap get image count 2 can draw3d true if n icon normal 0 xoffset 0 global offset 0 xoffset global offset n icon normal 0 bitmap m allimages if xp draw 3d bitmaps can draw3d image list global offset can draw3d true faded offset global offset 1 shadow offset global offset 2 disabled offset global offset 3 if state ods checked n icon normal 0 if state ods selected m selectcheck 0 checkflag true else if m unselectcheck 0 checkflag true else if n icon normal 1 standardflag true if state ods selected state ods grayed selectedflag true else if state ods grayed disableflag true else str text empty if state ods selected draw the down edges c pen p old pen pdc select object m penback pdc fill rect rect m brselect pdc draw3d rect rect cr select cr select pdc select object p old pen else rect2 set rect rect left rect top rect left barwidth rect bottom c pen p old pen pdc select object m penback pdc fill rect rect m brbackground pdc fill rect rect2 m newbrbackground pdc select object p old pen draw the up edges pdc draw3d rect rect m clrback m clrback pdc draw3d rect rect2 m newclrback m newclrback draw the text if there is any we have to paint the text only if the image is nonexistant dy int 0 5 rect height m icony 2 0 dy dy 0 0 dy dx int 0 5 barwidth m iconx 2 0 dx dx 0 0 dx rect2 set rect rect left 1 rect top 1 rect left barwidth 2 rect bottom 1 if checkflag standardflag selectedflag disableflag if checkflag checkmaps pdc fill rect rect2 m newbrbackground c point pt image rect left dx rect top dy if state ods selected checkmaps draw pdc 1 pt image ild transparent else checkmaps draw pdc 0 pt image ild transparent else if disableflag if selectedflag if can draw3d c point pt image rect left dx rect top dy bitmap draw pdc disabled offset pt image ild transparent else c bitmap bitmapstandard get bitmap from image list pdc bitmap xoffset bitmapstandard colorref transparentcol m newclrback if state ods selected transparentcol cr select fill if disable old style dither blt lpdis hdc rect left dx rect top dy m iconx m icony hbitmap bitmapstandard 0 0 transparentcol else dither blt2 pdc rect left dx rect top dy m iconx m icony bitmapstandard 0 0 transparentcol if state ods selected pdc draw3d rect rect cr select cr select bitmapstandard delete object else if selectedflag c point pt image rect left dx rect top dy if state ods checked c brush brushin brushin create solid brush lighten color cr select 0 55 pdc fill rect rect2 brushin brushin delete object pdc draw3d rect rect2 cr select cr select pt image x 1 pt image y 1 else pdc fill rect rect2 m brselect if bitmap if can draw3d state ods checked c point pt image1 pt image x 1 pt image y 1 c point pt image2 pt image x 1 pt image y 1 bitmap draw pdc shadow offset pt image1 ild transparent bitmap draw pdc xoffset pt image2 ild transparent else bitmap draw pdc xoffset pt image ild transparent else if state ods checked c brush brushin brushin create solid brush lighten color cr select 0 85 pdc fill rect rect2 brushin brushin delete object pdc draw3d rect rect2 cr select cr select c point pt image rect left dx 1 rect top dy 1 if bitmap bitmap draw pdc xoffset pt image ild transparent else pdc fill rect rect2 m newbrbackground pdc draw3d rect rect2 m newclrback m newclrback c point pt image rect left dx rect top dy if bitmap if can draw3d bitmap draw pdc faded offset pt image ild transparent else bitmap draw pdc xoffset pt image ild transparent if n icon normal 0 state ods checked checkflag c menu item info info info f mask miim checkmarks get menu item info hmenu lpdis hwnd item lpdis itemid mf bycommand info if state ods checked info hbmp unchecked drawxp checkmark pdc rect2 state ods checked info hbmp checked info hbmp unchecked cr select state ods selected this is needed always so that we can have the space for check marks x0 rect left y0 rect top rect left rect left barwidth 8 if str text is empty c rect rectt rect left rect top 1 rect right rect bottom 1 find tabs c string left str right str left str empty right str empty int tablocr str text reverse find t t if tablocr 1 right str str text mid tablocr 1 left str str text left str text find t t rectt right m iconx else left str str text int i old mode pdc get bk mode pdc set bk mode transparent draw the text in the correct colour uint n format dt left dt singleline dt vcenter uint n formatr dt right dt singleline dt vcenter if lpdis item state ods grayed pdc set text color cr text pdc draw text left str rectt n format if tablocr 1 pdc draw text right str rectt n formatr else rect offset rectt offset left 1 offset right 1 offset top 1 offset bottom 1 if is winxp luna colorref graycol get sys color color graytext if state ods selected graycol lighten color graycol 0 4 pdc set text color graycol else pdc set text color get sys color color graytext pdc draw text left str rectt n format if tablocr 1 pdc draw text right str rectt n formatr pdc set bk mode i old mode m penback delete object m brselect delete object m brbackground delete object m newbrbackground delete object ifdef bcmenu use memdc if p font pdc select object p font set it to the old font m fontmenu delete object if p memdc delete p memdc endif bcmenu drawitem_winxp fromhandle bcmenu_use_memdc bcmenumemdc pmemdc crect bcmenudata itemdata nflags m_newclrback getsyscolor color_3dface m_clrback getsyscolor color_window m_clrback darkencolor m_clrback cfont m_fontmenu pfont m_lf iswinxpluna m_newclrback lightencolor m_newclrback cbrush m_newbrbackground m_brbackground m_brbackground createsolidbrush m_clrback m_newbrbackground createsolidbrush m_newclrback bcmenu_pad xp_draw_3d_bitmaps bcmenu_pad m_iconx bcmenu_pad itemstate ods_grayed xp_select_disabled itemstate ods_selected itemstate itemstate ods_selected bcmenu_use_memdc pmemdc bcmenumemdc rcitem pmemdc zeromemory m_lf cbsize systemparametersinfo spi_getnonclientmetrics cbsize m_lf lfmenufont m_fontmenu createfontindirect m_lf pfont selectobject m_fontmenu mf_separator copyrect rcitem fillrect m_brbackground setrect bcmenu_pad drawedge edge_etched bf_top fillrect m_newbrbackground draw3drect m_newclrback m_newclrback crtext getsyscolor color_menutext crselect getsyscolor color_highlight crselectfill iswinxpluna crselectfill lightencolor crselect crselectfill lightencolor crselect cbrush m_brselect cpen m_penback niconnormal global_offset faded_offset shadow_offset disabled_offset cimagelist candraw3d m_penback createpen ps_solid m_clrback m_brselect createsolidbrush crselectfill copyrect rcitem itemstate cstring strtext itemdata niconnormal bcmenudata itemdata menuiconnormal bcmenudata itemdata bcmenudata itemdata strtext bcmenudata itemdata getstring global_offset bcmenudata itemdata global_offset xp_draw_3d_bitmaps getimagecount candraw3d niconnormal global_offset global_offset niconnormal m_allimages xp_draw_3d_bitmaps candraw3dimagelist global_offset candraw3d faded_offset global_offset shadow_offset global_offset disabled_offset global_offset ods_checked niconnormal ods_selected m_selectcheck m_unselectcheck niconnormal ods_selected ods_grayed ods_grayed strtext ods_selected cpen poldpen selectobject m_penback fillrect m_brselect draw3drect crselect crselect selectobject poldpen setrect cpen poldpen selectobject m_penback fillrect m_brbackground fillrect m_newbrbackground selectobject poldpen draw3drect m_clrback m_clrback draw3drect m_newclrback m_newclrback m_icony m_iconx setrect fillrect m_newbrbackground cpoint ptimage ods_selected ptimage ild_transparent ptimage ild_transparent candraw3d cpoint ptimage disabled_offset ptimage ild_transparent cbitmap getbitmapfromimagelist m_newclrback ods_selected crselectfill disable_old_style ditherblt m_iconx m_icony ditherblt2 m_iconx m_icony ods_selected draw3drect crselect crselect deleteobject cpoint ptimage ods_checked cbrush createsolidbrush lightencolor crselect fillrect deleteobject draw3drect crselect crselect ptimage ptimage fillrect m_brselect candraw3d ods_checked cpoint ptimage1 ptimage ptimage cpoint ptimage2 ptimage ptimage shadow_offset ptimage1 ild_transparent ptimage2 ild_transparent ptimage ild_transparent ods_checked cbrush createsolidbrush lightencolor crselect fillrect deleteobject draw3drect crselect crselect cpoint ptimage ptimage ild_transparent fillrect m_newbrbackground draw3drect m_newclrback m_newclrback cpoint ptimage candraw3d faded_offset ptimage ild_transparent ptimage ild_transparent niconnormal ods_checked cmenuiteminfo fmask miim_checkmarks getmenuiteminfo hwnditem mf_bycommand ods_checked hbmpunchecked drawxpcheckmark ods_checked hbmpchecked hbmpunchecked crselect ods_selected strtext isempty crect cstring leftstr rightstr leftstr rightstr strtext reversefind _t rightstr strtext leftstr strtext strtext _t m_iconx leftstr strtext ioldmode getbkmode setbkmode nformat dt_left dt_singleline dt_vcenter nformatr dt_right dt_singleline dt_vcenter itemstate ods_grayed settextcolor crtext drawtext leftstr nformat drawtext rightstr nformatr iswinxpluna getsyscolor color_graytext ods_selected lightencolor settextcolor settextcolor getsyscolor color_graytext drawtext leftstr nformat drawtext rightstr nformatr setbkmode ioldmode m_penback deleteobject m_brselect deleteobject m_brbackground deleteobject m_newbrbackground deleteobject bcmenu_use_memdc pfont selectobject pfont m_fontmenu deleteobject pmemdc pmemdc bool b selected hbitmap hbm check c rect rc dest rc c brush brush colorref col if is winxp luna col get sys color color 3dface else col get sys color color menu if b selected col lighten color col 0 6 brush create solid brush col dc fill rect rc dest brush brush delete object if is new shell sk looks better on the old shell dc draw edge rc dest bdr sunkenouter bf rect if hbm check draw check mark dc rc left 4 rc top 4 get sys color color menutext else draw radio dot dc rc left 5 rc top 4 get sys color color menutext return true bselected hbmcheck crect rcdest cbrush iswinxpluna getsyscolor color_3dface getsyscolor color_menu bselected lightencolor createsolidbrush fillrect rcdest deleteobject isnewshell drawedge rcdest bdr_sunkenouter bf_rect hbmcheck drawcheckmark getsyscolor color_menutext drawradiodot getsyscolor color_menutext bool bc menu drawxp checkmark cdc dc const c rect rc hbitmap hbm check colorref colorout bool selected c brush brushin colorref col int dx dy dy rc height 1 3 dy dy 0 0 dy dx rc width 1 3 dx dx 0 0 dx if selected col lighten color colorout 0 55 else col lighten color colorout 0 85 brushin create solid brush col dc fill rect rc brushin brushin delete object dc draw3d rect rc colorout colorout if hbm check draw check mark dc rc left dx rc top dy get sys color color menutext true else draw radio dot dc rc left dx rc top dy get sys color color menutext return true bcmenu drawxpcheckmark crect hbmcheck cbrush lightencolor lightencolor createsolidbrush fillrect deleteobject draw3drect hbmcheck drawcheckmark getsyscolor color_menutext drawradiodot getsyscolor color_menutext colorref bgcolor assert hdc dest hbm assert n width 0 n height 0 create a generic dc for all bit blts hdc hdc create compatibledc hdc dest assert hdc if hdc create a dc for the monochrome dib section hdc bwdc create compatibledc hdc assert bwdc if bwdc create the monochrome dib section with a black and white palette struct bitmapinfoheader bmi header rgbquad bmi colors 2 rgbbwbitmapinfo a bitmapinfoheader sizeof bitmapinfoheader bi size n width bi width n height bi height 1 bi planes 1 bi bit count bi rgb bi compression 0 bi size image 0 bix pels per meter 0 biy pels per meter 0 bi clr used 0 bi clr important 0x00 0x00 0x00 0x00 0xff 0xff 0xff 0x00 void pbitsbw hbitmap hbmbw createdib section bwdc lpbitmapinfo rgbbwbitmapinfo dib rgb colors pbitsbw null 0 assert hbmbw if hbmbw attach the monochrome dib section and the bitmap to the d cs hbitmap olddib hbitmap select object bwdc hbmbw hbitmap hdcolddib hbitmap select object hdc hbm bit blt the bitmap into the monochrome dib section bit blt bwdc 0 0 n width n height hdc nx src ny src srccopy paint the destination rectangle in gray fill rect hdc dest c rect nx dest ny dest nx dest n width ny dest n height get sys color brush bgcolor sk looks better on the old shell bit blt the black bits in the monochrome bitmap into color 3dhilight bits in the destination dc the magic rop comes from the charles petzold s book hbrush hb create solid brush get sys color color 3dhilight hbrush old brush hbrush select object hdc dest hb bit blt hdc dest nx dest 1 ny dest 1 n width n height bwdc 0 0 0xb8074a bit blt the black bits in the monochrome bitmap into color 3dshadow bits in the destination dc hb create solid brush get sys color color 3dshadow delete object select object hdc dest hb bit blt hdc dest nx dest ny dest n width n height bwdc 0 0 0xb8074a delete object select object hdc dest old brush verify delete object select object bwdc olddib select object hdc hdcolddib verify deletedc bwdc verify deletedc hdc hdcdest nwidth nheight bitblts createcompatibledc hdcdest createcompatibledc bmiheader bmicolors bisize nwidth biwidth nheight biheight biplanes bibitcount bi_rgb bicompression bisizeimage bixpelspermeter biypelspermeter biclrused biclrimportant createdibsection dib_rgb_colors dcs selectobject selectobject bitblt bitblt nwidth nheight nxsrc nysrc fillrect hdcdest crect nxdest nydest nxdest nwidth nydest nheight getsyscolorbrush bitblt color_3dhilight createsolidbrush getsyscolor color_3dhilight oldbrush selectobject hdcdest bitblt hdcdest nxdest nydest nwidth nheight bitblt color_3dshadow createsolidbrush getsyscolor color_3dshadow deleteobject selectobject hdcdest bitblt hdcdest nxdest nydest nwidth nheight deleteobject selectobject hdcdest oldbrush deleteobject selectobject selectobject colorref bgcolor create a monochrome memory dc cdc ddc ddc create compatibledc 0 c bitmap bwbmp bwbmp create compatible bitmap ddc n width n height c bitmap pddc old bmp ddc select object bwbmp cdc dc dc create compatibledc 0 c bitmap pdc old bmp dc select object bmp build a mask ddc pat blt 0 0 n width n height whiteness dc set bk color get sys color color btnface ddc bit blt 0 0 n width n height dc nx src ny src srccopy dc set bk color get sys color color btnhilight ddc bit blt 0 0 n width n height dc nx src ny src srcpaint copy the image from the toolbar into the memory dc and draw it grayed back into the toolbar dc fill solid rect 0 0 n width n height bgcolor sk looks better on the old shell dc set bk color rgb 0 0 0 dc set text color rgb 255 255 255 c brush br shadow br hilight br hilight create solid brush get sys color color btnhilight br shadow create solid brush get sys color color btnshadow c brush p old brush dc select object br hilight dc bit blt 0 0 n width n height ddc 0 0 0x00e20746l drawdc bit blt nx dest 1 ny dest 1 n width n height dc 0 0 srccopy dc bit blt 1 1 n width n height ddc 0 0 0x00e20746l dc select object br shadow dc bit blt 0 0 n width n height ddc 0 0 0x00e20746l drawdc bit blt nx dest ny dest n width n height dc 0 0 srccopy reset d cs ddc select object pddc old bmp ddc deletedc dc select object p old brush dc select object pdc old bmp dc deletedc br shadow delete object br hilight delete object bwbmp delete object createcompatibledc cbitmap createcompatiblebitmap nwidth nheight cbitmap pddcoldbmp selectobject createcompatibledc cbitmap pdcoldbmp selectobject patblt nwidth nheight setbkcolor getsyscolor color_btnface bitblt nwidth nheight nxsrc nysrc setbkcolor getsyscolor color_btnhilight bitblt nwidth nheight nxsrc nysrc fillsolidrect nwidth nheight setbkcolor settextcolor cbrush brshadow brhilight brhilight createsolidbrush getsyscolor color_btnhilight brshadow createsolidbrush getsyscolor color_btnshadow cbrush poldbrush selectobject brhilight bitblt nwidth nheight bitblt nxdest nydest nwidth nheight bitblt nwidth nheight selectobject brshadow bitblt nwidth nheight bitblt nxdest nydest nwidth nheight dcs selectobject pddcoldbmp selectobject poldbrush selectobject pdcoldbmp brshadow deleteobject brhilight deleteobject deleteobject int n height c bitmap bmp colorref bgcolor get disabled bitmap bmp bgcolor cdc dc dc create compatibledc null c bitmap pdc old bmp dc select object bmp drawdc bit blt nx dest ny dest n width n height dc 0 0 srccopy reset d cs dc select object pdc old bmp dc deletedc nheight cbitmap getdisabledbitmap createcompatibledc cbitmap pdcoldbmp selectobject bitblt nxdest nydest nwidth nheight dcs selectobject pdcoldbmp bool bc menu get bitmap from image list cdc pdc c image list imglist int n index c bitmap bmp hicon h icon imglist extract icon n index cdc dc dc create compatibledc pdc bmp create compatible bitmap pdc m iconx m icony c bitmap p old bmp dc select object bmp c brush brush colorref m newclrback m newclrback get sys color color 3dface brush create solid brush m newclrback draw icon ex dc get safe hdc 0 0 h icon m iconx m icony 0 hbrush brush di normal dc select object p old bmp dc deletedc the icon is not longer needed destroy icon h icon return true bcmenu getbitmapfromimagelist cimagelist nindex cbitmap hicon extracticon nindex createcompatibledc createcompatiblebitmap m_iconx m_icony cbitmap poldbmp selectobject cbrush m_newclrback m_newclrback getsyscolor color_3dface createsolidbrush m_newclrback drawiconex getsafehdc hicon m_iconx m_icony di_normal selectobject poldbmp destroyicon hicon bool bc menu image list duplicate c image list il int xoffset c image list newlist if il null newlist null xoffset 0 return false hicon h icon il extract icon xoffset int cx cy imagelist geticonsize il m himagelist cx cy newlist create cx cy ilc colorddb ilc mask 1 1 newlist add h icon destroy icon h icon if is luna menu style xp draw 3d bitmaps c wnd p wnd afx get main wnd get main window if p wnd null p wnd c wnd get desktop window cdc pdc p wnd getdc get device context c bitmap bmp bmp2 bmp3 get bitmap from image list pdc newlist 0 bmp get faded bitmap bmp newlist add bmp get sys color color 3dface get bitmap from image list pdc newlist 0 bmp2 get shadow bitmap bmp2 newlist add bmp2 get sys color color 3dface get bitmap from image list pdc newlist 0 bmp3 get disabled bitmap bmp3 newlist add bmp3 get sys color color 3dface p wnd releasedc pdc release the dc return true bcmenu imagelistduplicate cimagelist cimagelist hicon extracticon imagelist_geticonsize m_himagelist ilc_colorddb ilc_mask hicon destroyicon hicon islunamenustyle xp_draw_3d_bitmaps cwnd pwnd afxgetmainwnd pwnd pwnd cwnd getdesktopwindow pwnd cbitmap getbitmapfromimagelist getfadedbitmap getsyscolor color_3dface getbitmapfromimagelist getshadowbitmap getsyscolor color_3dface getbitmapfromimagelist getdisabledbitmap getsyscolor color_3dface pwnd word bc menu num bitmap colors lpbitmapinfoheader lp bitmap word returnval 0 if lp bitmap bi clr used 0 returnval word lp bitmap bi clr used else switch lp bitmap bi bit count case 1 returnval 2 break case 4 returnval 16 break case 8 returnval 256 break default returnval 0 break return returnval bcmenu numbitmapcolors lpbitmap lpbitmap biclrused lpbitmap biclrused lpbitmap bibitcount void bc menu color bitmap cdc pdc c bitmap bmp c size bitmap size c size icon size colorref fill colorref border int hatchstyle cdc bmpdc colorref m newclrback int x1 0 y1 0 x2 bitmap size cx y2 bitmap size cy if is winxp luna m newclrback get sys color color 3dface else m newclrback get sys color color menu bmpdc create compatibledc pdc bmp create compatible bitmap pdc icon size cx icon size cy c bitmap p old bitmap bmpdc select object bmp if bitmap size icon size c brush background brush background brush create solid brush m newclrback c rect rect 0 0 icon size cx icon size cy bmpdc fill rect rect background brush x1 icon size cx bitmap size cx 2 y1 icon size cy bitmap size cy 2 x2 x1 bitmap size cx y2 y1 bitmap size cy background brush delete object c pen border pen ps solid 1 border c brush fill brush if hatchstyle 1 fill brush create hatch brush hatchstyle fill else fill brush create solid brush fill c pen p old pen bmpdc select object border pen c brush p old brush bmpdc select object fill brush bmpdc rectangle x1 y1 x2 y2 if null p old brush bmpdc select object p old brush if null p old pen bmpdc select object p old pen if null p old bitmap bmpdc select object p old bitmap bcmenu colorbitmap cbitmap csize bitmap_size csize icon_size m_newclrback bitmap_size bitmap_size iswinxpluna m_newclrback getsyscolor color_3dface m_newclrback getsyscolor color_menu createcompatibledc createcompatiblebitmap icon_size icon_size cbitmap poldbitmap selectobject bitmap_size icon_size cbrush background_brush background_brush createsolidbrush m_newclrback crect icon_size icon_size fillrect background_brush icon_size bitmap_size icon_size bitmap_size bitmap_size bitmap_size background_brush deleteobject cpen border_pen ps_solid cbrush fill_brush fill_brush createhatchbrush fill_brush createsolidbrush cpen poldpen selectobject border_pen cbrush poldbrush selectobject fill_brush poldbrush selectobject poldbrush poldpen selectobject poldpen poldbitmap selectobject poldbitmap void bc menu remove top level owner draw void c string str int i 0 j 0 int nummenulist m menulist get size menustart menustart get menu start for i menustart j 0 i int get menu item count i j if j nummenulist str m menulist j get string if get sub menu i m menulist j n flags mf popup mf byposition modify menu i mf popup mf byposition uint get sub menu i m hmenu str bcmenu removetoplevelownerdraw cstring m_menulist getsize getmenustart getmenuitemcount m_menulist getstring getsubmenu m_menulist nflags mf_popup mf_byposition modifymenu mf_popup mf_byposition getsubmenu m_hmenu int bc menu get menu start void if m loadmenu return 0 c string name str int menuloc 1 listloc 1 menustart 0 i 0 j 0 int nummenulist m menulist get size int nummenu int get menu item count while i nummenu menuloc 1 get menu string i name mf byposition if name get length 0 for j 0 j nummenulist j str m menulist j get string if name str menuloc i listloc j break i if menuloc 0 listloc 0 menuloc listloc menustart menuloc listloc return menustart bcmenu getmenustart m_loadmenu cstring m_menulist getsize getmenuitemcount getmenustring mf_byposition getlength m_menulist getstring void bc menu get disabled bitmap c bitmap bmp colorref background cdc ddc colorref bgcol col discol bitmap bit map bmp get bitmap bit map ddc create compatibledc null c bitmap pddc old bmp ddc select object bmp use this to get the background color takes into account color shifting cdc ddc2 c brush brush c bitmap bmp2 ddc2 create compatibledc null bmp2 create compatible bitmap ddc bit map bm width bit map bm height col get sys color color 3dface brush create solid brush col c bitmap pddc old bmp2 ddc2 select object bmp2 c rect rect 0 0 bit map bm width bit map bm height ddc2 fill rect rect brush bgcol ddc2 get pixel 1 1 brush delete object ddc2 select object pddc old bmp2 discol get sys color color btnshadow for int i 0 i bit map bm width i for int j 0 j bit map bm height j col ddc get pixel i j if col bgcol byte r getr value col byte g getg value col byte b getb value col int avgcol r g b 3 double factor avgcol 255 0 ddc set pixel i j lighten color discol factor else if background ddc set pixel i j background ddc select object pddc old bmp bcmenu getdisabledbitmap cbitmap bitmap getbitmap bitmap createcompatibledc cbitmap pddcoldbmp selectobject cbrush cbitmap createcompatibledc createcompatiblebitmap bitmap bmwidth bitmap bmheight getsyscolor color_3dface createsolidbrush cbitmap pddcoldbmp2 selectobject crect bitmap bmwidth bitmap bmheight fillrect getpixel deleteobject selectobject pddcoldbmp2 getsyscolor color_btnshadow bitmap bmwidth bitmap bmheight getpixel getrvalue getgvalue getbvalue setpixel lightencolor setpixel selectobject pddcoldbmp void bc menu get shadow bitmap c bitmap bmp cdc ddc colorref bgcol col shadowcol get sys color color btnshadow bitmap bit map if is winxp luna shadowcol lighten color shadowcol 0 49 bmp get bitmap bit map ddc create compatibledc null c bitmap pddc old bmp ddc select object bmp use this to get the background color takes into account color shifting cdc ddc2 c brush brush c bitmap bmp2 ddc2 create compatibledc null bmp2 create compatible bitmap ddc bit map bm width bit map bm height col get sys color color 3dface brush create solid brush col c bitmap pddc old bmp2 ddc2 select object bmp2 c rect rect 0 0 bit map bm width bit map bm height ddc2 fill rect rect brush bgcol ddc2 get pixel 1 1 brush delete object ddc2 select object pddc old bmp2 for int i 0 i bit map bm width i for int j 0 j bit map bm height j col ddc get pixel i j if col bgcol ddc set pixel i j shadowcol ddc select object pddc old bmp bcmenu getshadowbitmap cbitmap getsyscolor color_btnshadow bitmap iswinxpluna lightencolor getbitmap bitmap createcompatibledc cbitmap pddcoldbmp selectobject cbrush cbitmap createcompatibledc createcompatiblebitmap bitmap bmwidth bitmap bmheight getsyscolor color_3dface createsolidbrush cbitmap pddcoldbmp2 selectobject crect bitmap bmwidth bitmap bmheight fillrect getpixel deleteobject selectobject pddcoldbmp2 bitmap bmwidth bitmap bmheight getpixel setpixel selectobject pddcoldbmp int bc menu add to global image list c image list il int xoffset int nid int loc 1 himagelist h image list m allimages m himagelist if h image list m allimages create m iconx m icony ilc colorddb ilc mask 1 1 hicon h icon il extract icon xoffset if h icon c bitmap bmp bmp2 bmp3 if is luna menu style xp draw 3d bitmaps c wnd p wnd afx get main wnd get main window if p wnd null p wnd c wnd get desktop window cdc pdc p wnd getdc get device context get bitmap from image list pdc il xoffset bmp get faded bitmap bmp get bitmap from image list pdc il xoffset bmp2 get shadow bitmap bmp2 get bitmap from image list pdc il xoffset bmp3 get disabled bitmap bmp3 p wnd releasedc pdc release the dc int numcurrent m allimagesid get size int existsloc 1 for int i 0 i numcurrent i if m allimagesid i nid existsloc i break if existsloc 0 m allimages replace existsloc h icon loc existsloc if is luna menu style xp draw 3d bitmaps if existsloc 1 numcurrent m allimagesid existsloc 1 nid if existsloc 2 numcurrent m allimagesid existsloc 2 nid c image list il2 il2 create m iconx m icony ilc colorddb ilc mask 1 1 il2 add bmp get sys color color 3dface hicon h icon2 il2 extract icon 0 m allimages replace existsloc 1 h icon2 il2 add bmp2 get sys color color 3dface hicon h icon3 il2 extract icon 1 m allimages replace existsloc 2 h icon3 il2 add bmp3 get sys color color 3dface hicon h icon4 il2 extract icon 2 m allimages replace existsloc 3 h icon4 destroy icon h icon2 destroy icon h icon3 destroy icon h icon4 else m allimages add h icon m allimagesid add nid loc numcurrent if is luna menu style xp draw 3d bitmaps m allimages add bmp get sys color color 3dface m allimages add bmp2 get sys color color 3dface m allimages add bmp3 get sys color color 3dface m allimagesid add nid m allimagesid add nid m allimagesid add nid destroy icon h icon return loc bcmenu addtoglobalimagelist cimagelist himagelist m_allimages m_himagelist himagelist m_allimages m_iconx m_icony ilc_colorddb ilc_mask hicon extracticon hicon cbitmap islunamenustyle xp_draw_3d_bitmaps cwnd pwnd afxgetmainwnd pwnd pwnd cwnd getdesktopwindow pwnd getbitmapfromimagelist getfadedbitmap getbitmapfromimagelist getshadowbitmap getbitmapfromimagelist getdisabledbitmap pwnd m_allimagesid getsize m_allimagesid m_allimages hicon islunamenustyle xp_draw_3d_bitmaps m_allimagesid m_allimagesid cimagelist m_iconx m_icony ilc_colorddb ilc_mask getsyscolor color_3dface hicon2 extracticon m_allimages hicon2 getsyscolor color_3dface hicon3 extracticon m_allimages hicon3 getsyscolor color_3dface hicon4 extracticon m_allimages hicon4 destroyicon hicon2 destroyicon hicon3 destroyicon hicon4 m_allimages hicon m_allimagesid islunamenustyle xp_draw_3d_bitmaps m_allimages getsyscolor color_3dface m_allimages getsyscolor color_3dface m_allimages getsyscolor color_3dface m_allimagesid m_allimagesid m_allimagesid destroyicon hicon int bc menu global image list offset int nid int numcurrent m allimagesid get size int existsloc 1 for int i 0 i numcurrent i if m allimagesid i nid existsloc i break return existsloc bcmenu globalimagelistoffset m_allimagesid getsize m_allimagesid bool bc menu can draw3d image list int offset bool retflag false int numcurrent m allimagesid get size if offset 1 numcurrent offset 2 numcurrent int nid m allimagesid offset if m allimagesid offset 1 nid m allimagesid offset 2 nid retflag true return retflag bcmenu candraw3dimagelist m_allimagesid getsize m_allimagesid m_allimagesid m_allimagesid bc menu memdc cdc pdc lpcrect lp src rect cdc assert pdc null m rect copy rect lp src rect m pdc pdc m poldbitmap null m bmemdc pdc is printing if m bmemdc create a memory dc create compatibledc pdc m bitmap create compatible bitmap pdc m rect width m rect height m poldbitmap select object m bitmap set window org m rect left m rect top else make a copy of the relevent parts of the current dc for printing m bprinting pdc m bprinting m hdc pdc m hdc m hattribdc pdc m hattribdc bcmenumemdc lpsrcrect m_rect copyrect lpsrcrect m_pdc m_poldbitmap m_bmemdc isprinting m_bmemdc createcompatibledc m_bitmap createcompatiblebitmap m_rect m_rect m_poldbitmap selectobject m_bitmap setwindoworg m_rect m_rect m_bprinting m_bprinting m_hdc m_hdc m_hattribdc m_hattribdc bc menu memdc if m bmemdc copy the offscreen bitmap onto the screen m pdc bit blt m rect left m rect top m rect width m rect height this m rect left m rect top srccopy swap back the original bitmap select object m poldbitmap else all we need to do is replace the dc with an illegal value this keeps us from accidently deleting the handles associated with the cdc that was passed to the constructor m hdc m hattribdc null bcmenumemdc m_bmemdc m_pdc bitblt m_rect m_rect m_rect m_rect m_rect m_rect selectobject m_poldbitmap m_hdc m_hattribdc bc menu memdc cdc pdc lpcrect lp src rect cdc assert pdc null m rect copy rect lp src rect m pdc pdc m poldbitmap null m bmemdc pdc is printing if m bmemdc create a memory dc create compatibledc pdc m bitmap create compatible bitmap pdc m rect width m rect height m poldbitmap select object m bitmap set window org m rect left m rect top else make a copy of the relevent parts of the current dc for printing m bprinting pdc m bprinting m hdc pdc m hdc m hattribdc pdc m hattribdc bcmenumemdc lpsrcrect m_rect copyrect lpsrcrect m_pdc m_poldbitmap m_bmemdc isprinting m_bmemdc createcompatibledc m_bitmap createcompatiblebitmap m_rect m_rect m_poldbitmap selectobject m_bitmap setwindoworg m_rect m_rect m_bprinting m_bprinting m_hdc m_hdc m_hattribdc m_hattribdc bc menu memdc if m bmemdc copy the offscreen bitmap onto the screen m pdc bit blt m rect left m rect top m rect width m rect height this m rect left m rect top srccopy swap back the original bitmap select object m poldbitmap else all we need to do is replace the dc with an illegal value this keeps us from accidently deleting the handles associated with the cdc that was passed to the constructor m hdc m hattribdc null bcmenumemdc m_bmemdc m_pdc bitblt m_rect m_rect m_rect m_rect m_rect m_rect selectobject m_poldbitmap m_hdc m_hattribdc void list restoreview restore the previous password list view int n item count m clist get item count if n item count 0 return m clist ensure visible n item count 1 false if m nsaveview n item count m clist ensure visible m nsaveview false _list_restoreview nitemcount m_clist getitemcount nitemcount m_clist ensurevisible nitemcount m_nsaveview nitemcount m_clist ensurevisible m_nsaveview void groups saveview bool b save selection true htreeitem h top m cgroups get first visible item if h top null m dwgroupssavefirstvisible m cgroups get item data h top else m dwgroupssavefirstvisible dword max m dwgroupssaveselected dword max if b save selection true htreeitem h m cgroups get selected item if h null m dwgroupssaveselected m cgroups get item data h _groups_saveview bsaveselection htop m_cgroups getfirstvisibleitem htop m_dwgroupssavefirstvisible m_cgroups getitemdata htop m_dwgroupssavefirstvisible dword_max m_dwgroupssaveselected dword_max bsaveselection m_cgroups getselecteditem m_dwgroupssaveselected m_cgroups getitemdata void groups restoreview htreeitem h if m dwgroupssavefirstvisible dword max h groupidtohtreeitem m dwgroupssavefirstvisible if h null m cgroups select set first visible h if m dwgroupssaveselected dword max h groupidtohtreeitem m dwgroupssaveselected if h null m cgroups select item h _groups_restoreview m_dwgroupssavefirstvisible dword_max _groupidtohtreeitem m_dwgroupssavefirstvisible m_cgroups selectsetfirstvisible m_dwgroupssaveselected dword_max _groupidtohtreeitem m_dwgroupssaveselected m_cgroups selectitem c dialog c pw safe dlg idd p parent m instancechecker t kee pass instance afx data init c pw safe dlg m strquickfind t afx data init m hicon afx get app load icon idr mainframe m bexiting false m bcheckforinstance false m brestorehotkeyregistered false m hlastselectedgroup 0 m dwlastnumselecteditems 0 m dwlastfirstselecteditem 0 m nclipboardstate 0 m hwndnextviewer null m ppwlistmenu m pgrouplistmenu m pentryviewmenu null m ppwlisttrackablemenu m pgrouplisttrackablemenu m pentryviewtrackablemenu null m mgr init primary instance cdialog cpwsafedlg pparent m_instancechecker _t keepass afx_data_init cpwsafedlg m_strquickfind _t afx_data_init m_hicon afxgetapp loadicon idr_mainframe m_bexiting m_bcheckforinstance m_brestorehotkeyregistered m_hlastselectedgroup m_dwlastnumselecteditems m_dwlastfirstselecteditem m_nclipboardstate m_hwndnextviewer m_ppwlistmenu m_pgrouplistmenu m_pentryviewmenu m_ppwlisttrackablemenu m_pgrouplisttrackablemenu m_pentryviewtrackablemenu m_mgr initprimaryinstance void c pw safe dlg on update flush c menu p menu assert p menu null check the enabled state of various menu items c cmdui state state m pmenu p menu assert state m pother null assert state m pparentmenu null determine if menu is popup in top level menu and set m pother to it if so m pparentmenu null indicates that it is secondary popup hmenu h parent menu if afx get thread state m htrackingmenu p menu m hmenu state m pparentmenu p menu parent child for tracking popup else if h parent menu get menu m hwnd null c wnd p parent get top level parent child windows don t have menus need to go to the top if p parent null h parent menu get menu p parent m hwnd null int n index max get menu item count h parent menu for int n index 0 n index n index max n index if get sub menu h parent menu n index p menu m hmenu when popup is found m pparentmenu is containing menu state m pparentmenu c menu from handle h parent menu break state m nindexmax p menu get menu item count for state m nindex 0 state m nindex state m nindexmax state m nindex state m nid p menu get menu itemid state m nindex if state m nid 0 continue menu separator or invalid cmd ignore it assert state m pother null assert state m pmenu null if state m nid uint 1 possibly a popup menu route to first item of that popup state m psubmenu p menu get sub menu state m nindex if state m psubmenu null state m nid state m psubmenu get menu itemid 0 0 state m nid uint 1 continue first item of popup can t be routed to state do update this false popups are never auto disabled else normal menu item auto enable disable if frame window has m bautomenuenable set and command is not a system command state m psubmenu null state do update this state m nid 0xf000 adjust for menu deletions and additions uint n count p menu get menu item count if n count state m nindexmax state m nindex state m nindexmax n count while state m nindex n count p menu get menu itemid state m nindex state m nid state m nindex state m nindexmax n count cpwsafedlg onupdateflush cmenu pmenu pmenu ccmdui m_pmenu pmenu m_pother m_pparentmenu m_pother m_pparentmenu hparentmenu afxgetthreadstate m_htrackingmenu pmenu m_hmenu m_pparentmenu pmenu hparentmenu getmenu m_hwnd cwnd pparent gettoplevelparent pparent hparentmenu getmenu pparent m_hwnd nindexmax getmenuitemcount hparentmenu nindex nindex nindexmax nindex getsubmenu hparentmenu nindex pmenu m_hmenu m_pparentmenu m_pparentmenu cmenu fromhandle hparentmenu m_nindexmax pmenu getmenuitemcount m_nindex m_nindex m_nindexmax m_nindex m_nid pmenu getmenuitemid m_nindex m_nid m_pother m_pmenu m_nid m_psubmenu pmenu getsubmenu m_nindex m_psubmenu m_nid m_psubmenu getmenuitemid m_nid doupdate m_bautomenuenable _not_ m_psubmenu doupdate m_nid ncount pmenu getmenuitemcount ncount m_nindexmax m_nindex m_nindexmax ncount m_nindex ncount pmenu getmenuitemid m_nindex m_nid m_nindex m_nindexmax ncount void c pw safe dlg translatemenu bc menu pbc menu bool b append suffix bool p flags c string str item str new uint n item 0 bc menu p next const tchar p suffix t bool b default flag false assert pbc menu null if pbc menu null return if p flags null p flags b default flag while 1 if pbc menu get menu text uint n item str item mf byposition false break if b append suffix true p suffix getcmdaccelext str item if str item t export to str item t import from str item t show columns str item t rearrange str item t auto sort password list str item t tan view options p next pbc menu get subbc menu tchar lpctstr str item if p next null translatemenu p next true p flags replace url menu item if required p flags 0 must be a pointer to m bcopyurls if p flags true if str item t open url s str item t copy url to clipboard if str item get length 0 str new trl var str item else str new t if tcslen p suffix 0 str new t t str new p suffix if pbc menu set menu text n item str new mf byposition false assert false n item cpwsafedlg _translatemenu bcmenu pbcmenu bappendsuffix pflags cstring stritem strnew nitem bcmenu pnext psuffix _t bdefaultflag pbcmenu pbcmenu pflags pflags bdefaultflag pbcmenu getmenutext nitem stritem mf_byposition bappendsuffix psuffix _getcmdaccelext stritem stritem _t stritem _t stritem _t stritem _t stritem _t stritem _t pnext pbcmenu getsubbcmenu stritem pnext _translatemenu pnext pflags pflags m_bcopyurls pflags stritem _t stritem _t stritem getlength strnew trl_var stritem strnew _t _tcslen psuffix strnew _t strnew psuffix pbcmenu setmenutext nitem strnew mf_byposition nitem const tchar c pw safe dlg getcmdaccelext const tchar psz static const tchar p empty t assert psz null if psz null return p empty if tcsicmp psz t new database 0 return t ctrl n if tcsicmp psz t open database 0 return t ctrl o if tcsicmp psz t save database 0 return t ctrl s if tcsicmp psz t close database 0 return t ctrl w if tcsicmp psz t print 0 return t ctrl p if tcsicmp psz t database settings 0 return t ctrl i if tcsicmp psz t lock workspace 0 return t ctrl l if tcsicmp psz t e xit 0 return t ctrl x if tcsicmp psz t add entry 0 return t ctrl y if tcsicmp psz t edit view entry 0 return t ctrl e if tcsicmp psz t delete entry 0 return t ctrl d if tcsicmp psz t se lect all 0 return t ctrl a if tcsicmp psz t find in database 0 return t ctrl f if tcsicmp psz t add password group 0 return t ctrl g if tcsicmp psz t open url s 0 return t ctrl u if tcsicmp psz t copy password to clipboard 0 return t ctrl c if tcsicmp psz t copy user name to clipboard 0 return t ctrl b if tcsicmp psz t dupli cate entry 0 return t ctrl k if tcsicmp psz t options 0 return t ctrl m if tcsicmp psz t perform auto type 0 return t ctrl v if tcsicmp psz t password generator 0 return t ctrl z if tcsicmp psz t hide user names behind asterisks 0 return t ctrl j if tcsicmp psz t hide passwords behind asterisks 0 return t ctrl h if tcsicmp psz t move entry to top 0 return t alt home if tcsicmp psz t move entry one up 0 return t alt up if tcsicmp psz t mo ve entry one down 0 return t alt down if tcsicmp psz t move entry to bottom 0 return t alt end if tcsicmp psz t move group to top 0 return t alt home if tcsicmp psz t move group one up 0 return t alt up if tcsicmp psz t move group one down 0 return t alt down if tcsicmp psz t move group to bottom 0 return t alt end if tcsicmp psz t move group one left 0 return t alt left if tcsicmp psz t move group one right 0 return t alt right return p empty cpwsafedlg _getcmdaccelext pempty _t pempty _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t _tcsicmp _t _t pempty void c pw safe dlg restart application tchar sz file 1024 get module file name null sz file 1024 if t win exec sz file 0 31 c string str str trl application cannot be restarted automatically str t r n r n str trl please restart kee pass manually message box str trl loading error mb ok mb iconwarning cpwsafedlg restartapplication szfile getmodulefilename szfile twinexec szfile cstring _t keepass messagebox mb_ok mb_iconwarning c string c pw safe dlg getsecureedittiptext const tchar tsz base c string str assert tsz base null if tsz base null return c string t str trl var tsz base str trim right t str t r n str trl press shift home or shift end to clear this edit control str t return str cstring cpwsafedlg _getsecureedittiptext tszbase cstring tszbase tszbase cstring _t trl_var tszbase trimright _t _t _t void c pw safe dlg rebuild context menus delete context menus m ppwlistmenu new bc menu m ppwlistmenu load menu idr pwlist menu m ppwlistmenu set menu draw mode bcmenu drawmode xp bcmenu drawmode original m ppwlistmenu set select disable mode false m ppwlistmenu setxp bitmap3d true m ppwlistmenu set bitmap background rgb 255 0 255 m ppwlistmenu set icon size 16 16 m ppwlistmenu load toolbar idr infoicons idb infoicons ex m ppwlisttrackablemenu bc menu m ppwlistmenu get sub menu 0 translatemenu m ppwlisttrackablemenu true m bcopyurls m pgrouplistmenu new bc menu m pgrouplistmenu load menu idr grouplist menu m pgrouplistmenu set menu draw mode bcmenu drawmode xp bcmenu drawmode original m pgrouplistmenu set select disable mode false m pgrouplistmenu setxp bitmap3d true m pgrouplistmenu set bitmap background rgb 255 0 255 m pgrouplistmenu set icon size 16 16 m pgrouplistmenu load toolbar idr infoicons idb infoicons ex m pgrouplisttrackablemenu bc menu m pgrouplistmenu get sub menu 0 translatemenu m pgrouplisttrackablemenu true null m pentryviewmenu new bc menu m pentryviewmenu load menu idr rectx menu m pentryviewmenu set menu draw mode bcmenu drawmode xp bcmenu drawmode original m pentryviewmenu set select disable mode false m pentryviewmenu setxp bitmap3d true m pentryviewmenu set bitmap background rgb 255 0 255 m pentryviewmenu set icon size 16 16 m pentryviewmenu load toolbar idr infoicons idb infoicons ex m pentryviewtrackablemenu bc menu m pentryviewmenu get sub menu 0 translatemenu m pentryviewtrackablemenu true null cpwsafedlg rebuildcontextmenus deletecontextmenus m_ppwlistmenu bcmenu m_ppwlistmenu loadmenu idr_pwlist_menu m_ppwlistmenu setmenudrawmode bcmenu_drawmode_xp bcmenu_drawmode_original m_ppwlistmenu setselectdisablemode m_ppwlistmenu setxpbitmap3d m_ppwlistmenu setbitmapbackground m_ppwlistmenu seticonsize m_ppwlistmenu loadtoolbar idr_infoicons idb_infoicons_ex m_ppwlisttrackablemenu bcmenu m_ppwlistmenu getsubmenu _translatemenu m_ppwlisttrackablemenu m_bcopyurls m_pgrouplistmenu bcmenu m_pgrouplistmenu loadmenu idr_grouplist_menu m_pgrouplistmenu setmenudrawmode bcmenu_drawmode_xp bcmenu_drawmode_original m_pgrouplistmenu setselectdisablemode m_pgrouplistmenu setxpbitmap3d m_pgrouplistmenu setbitmapbackground m_pgrouplistmenu seticonsize m_pgrouplistmenu loadtoolbar idr_infoicons idb_infoicons_ex m_pgrouplisttrackablemenu bcmenu m_pgrouplistmenu getsubmenu _translatemenu m_pgrouplisttrackablemenu m_pentryviewmenu bcmenu m_pentryviewmenu loadmenu idr_rectx_menu m_pentryviewmenu setmenudrawmode bcmenu_drawmode_xp bcmenu_drawmode_original m_pentryviewmenu setselectdisablemode m_pentryviewmenu setxpbitmap3d m_pentryviewmenu setbitmapbackground m_pentryviewmenu seticonsize m_pentryviewmenu loadtoolbar idr_infoicons idb_infoicons_ex m_pentryviewtrackablemenu bcmenu m_pentryviewmenu getsubmenu _translatemenu m_pentryviewtrackablemenu void c pw safe dlg delete context menus if m ppwlistmenu null m ppwlistmenu destroy menu delete m ppwlistmenu m ppwlistmenu null m ppwlisttrackablemenu null if m pgrouplistmenu null m pgrouplistmenu destroy menu delete m pgrouplistmenu m pgrouplistmenu null m pgrouplisttrackablemenu null if m pentryviewmenu null m pentryviewmenu destroy menu delete m pentryviewmenu m pentryviewmenu null m pentryviewtrackablemenu null cpwsafedlg deletecontextmenus m_ppwlistmenu m_ppwlistmenu destroymenu m_ppwlistmenu m_ppwlistmenu m_ppwlisttrackablemenu m_pgrouplistmenu m_pgrouplistmenu destroymenu m_pgrouplistmenu m_pgrouplistmenu m_pgrouplisttrackablemenu m_pentryviewmenu m_pentryviewmenu destroymenu m_pentryviewmenu m_pentryviewmenu m_pentryviewtrackablemenu void c pw safe dlg process resize notify user activity rect rect client rect rect list int cy menu get system metrics sm cymenu long n add top rect rect tb int tb height 23 if is window m btntbabout m hwnd if m bshowtoolbar true m btntbabout get window rect rect tb tb height rect tb bottom rect tb top if m bshowtoolbar true n add top tb height else n add top 0 get client rect rect client rect rect window get window rect rect window bool b window valid true if rect window right rect window left 314 32 b window valid false if rect window bottom rect window top 207 32 b window valid false if m bminimized false m bshowwindow true b window valid true range check and correction for splitter windows if m lsplitterposhoriz 1 m lsplitterposhoriz 1 if m lsplitterposhoriz rect client right 10 m lsplitterposhoriz rect client right 10 if m lsplitterposvert 26 m lsplitterposvert 26 if rect client bottom m lsplitterposvert 76 n add top m lsplitterposvert rect client bottom 76 n add top long n entry view height rect client bottom rect client top m lsplitterposvert if m bentryview false n entry view height 1 if is window m cgroups m hwnd resize group box rect list top gui spacer n add top rect list bottom rect client bottom gui spacer 1 cy menu n entry view height 1 rect list left 0 rect list right gui spacer m lsplitterposhoriz 1 m cgroups move window rect list true int n column width rect list right rect list left get system metrics sm cxvscroll 8 m cgroups set column width 0 n column width if is window m clist m hwnd resize password list view rect list top gui spacer n add top rect list bottom rect client bottom gui spacer 1 cy menu n entry view height 1 rect list left gui spacer m lsplitterposhoriz 2 rect list right rect client right m clist move window rect list true if m bcolautosize true calccolumnsizes setcolumnwidths if is window m reentryview m hwnd rect list top rect client bottom gui spacer 1 cy menu n entry view height gui spacer 1 rect list bottom rect client bottom gui spacer 1 cy menu rect list left 0 rect list right rect client right rect client left m reentryview move window rect list true if is window m stcmenuline m hwnd resize menu line rect list top 0 rect list bottom 2 rect list left 0 rect list right rect client right rect client left m stcmenuline move window rect list true if is window m sbstatus m hwnd resize status bar rect rectsb m sbstatus get client rect rectsb rectsb top rect client bottom rect client top rectsb bottom rectsb top rectsb bottom rect client bottom rect client top rectsb left 0 rectsb right rect client right rect client left m sbstatus move window rectsb true m sbstatus redraw window null cpwsafedlg processresize notifyuseractivity rectclient rectlist cymenu getsystemmetrics sm_cymenu naddtop recttb tbheight iswindow m_btntbabout m_hwnd m_bshowtoolbar m_btntbabout getwindowrect recttb tbheight recttb recttb m_bshowtoolbar naddtop tbheight naddtop getclientrect rectclient rectwindow getwindowrect rectwindow bwindowvalid rectwindow rectwindow bwindowvalid rectwindow rectwindow bwindowvalid m_bminimized m_bshowwindow bwindowvalid m_lsplitterposhoriz m_lsplitterposhoriz m_lsplitterposhoriz rectclient m_lsplitterposhoriz rectclient m_lsplitterposvert m_lsplitterposvert rectclient m_lsplitterposvert naddtop m_lsplitterposvert rectclient naddtop nentryviewheight rectclient rectclient m_lsplitterposvert m_bentryview nentryviewheight iswindow m_cgroups m_hwnd rectlist gui_spacer naddtop rectlist rectclient gui_spacer cymenu nentryviewheight rectlist rectlist gui_spacer m_lsplitterposhoriz m_cgroups movewindow rectlist ncolumnwidth rectlist rectlist getsystemmetrics sm_cxvscroll m_cgroups setcolumnwidth ncolumnwidth iswindow m_clist m_hwnd rectlist gui_spacer naddtop rectlist rectclient gui_spacer cymenu nentryviewheight rectlist gui_spacer m_lsplitterposhoriz rectlist rectclient m_clist movewindow rectlist m_bcolautosize _calccolumnsizes _setcolumnwidths iswindow m_reentryview m_hwnd rectlist rectclient gui_spacer cymenu nentryviewheight gui_spacer rectlist rectclient gui_spacer cymenu rectlist rectlist rectclient rectclient m_reentryview movewindow rectlist iswindow m_stcmenuline m_hwnd rectlist rectlist rectlist rectlist rectclient rectclient m_stcmenuline movewindow rectlist iswindow m_sbstatus m_hwnd m_sbstatus getclientrect rectclient rectclient rectclient rectclient rectclient rectclient m_sbstatus movewindow m_sbstatus redrawwindow void c pw safe dlg clean up if m btimer true kill timer appwnd timer id m btimer false if m dwathotkey 0 unregister hot key this m hwnd hotkeyid autotype if m brestorehotkeyregistered false unregister hot key this m hwnd hotkeyid restore m pimgr unload all plugins if m bmenu true auto destroyed in bc menu destructor m menu destroy menu m bmenu false delete context menus if m nclipboardcountdown 0 clear clipboard if owner this clears the clipboard if we own it m nclipboardcountdown 1 disable clipboard clear countdown deletetemporaryfiles free current translation table save options hicon h releaser load get all icons and release them safely h releaser afx get app load icon makeintresource idi iconpic destroy icon h releaser h releaser afx get app load icon makeintresource idi key destroy icon h releaser h releaser afx get app load icon makeintresource idi options destroy icon h releaser h releaser afx get app load icon makeintresource idi search destroy icon h releaser h releaser afx get app load icon makeintresource idi world destroy icon h releaser h releaser afx get app load icon makeintresource idr mainframe destroy icon h releaser m mgr new database m clist delete all items m cgroups delete all items m ilicons delete image list safe delete m pthemehelper if m brestartapplication true restart application cpwsafedlg cleanup m_btimer killtimer appwnd_timer_id m_btimer m_dwathotkey unregisterhotkey m_hwnd hotkeyid_autotype m_brestorehotkeyregistered unregisterhotkey m_hwnd hotkeyid_restore m_pimgr unloadallplugins m_bmenu bcmenu m_menu destroymenu m_bmenu deletecontextmenus m_nclipboardcountdown clearclipboardifowner m_nclipboardcountdown _deletetemporaryfiles freecurrenttranslationtable saveoptions hreleaser hreleaser afxgetapp loadicon idi_iconpic destroyicon hreleaser hreleaser afxgetapp loadicon idi_key destroyicon hreleaser hreleaser afxgetapp loadicon idi_options destroyicon hreleaser hreleaser afxgetapp loadicon idi_search destroyicon hreleaser hreleaser afxgetapp loadicon idi_world destroyicon hreleaser hreleaser afxgetapp loadicon idr_mainframe destroyicon hreleaser m_mgr newdatabase m_clist deleteallitems m_cgroups deleteallitems m_ilicons deleteimagelist safe_delete m_pthemehelper m_brestartapplication restartapplication void c pw safe dlg save options c private config pcfg true tchar sz temp 1024 c string str temp save clipboard auto clear time ultot m dwclipboardsecs sz temp 10 pcfg set pwmkey clipsecs sz temp itot m nclipboardmethod sz temp 10 pcfg set pwmkey clipboardmethod sz temp get current directory 1024 sz temp if tcslen sz temp 0 pcfg set pwmkey lastdir sz temp ultot m dwathotkey sz temp 10 pcfg set pwmkey autotypehotkey sz temp save newline sequence if m bwindowsnewline true tcscpy sz temp t windows else tcscpy sz temp t unix pcfg set pwmkey newline sz temp pcfg set bool pwmkey useputtyforurls m buseputtyforurls itot m nautosort sz temp 10 pcfg set pwmkey autosort sz temp pcfg set bool pwmkey saveonlatmod m bsaveonlatmod pcfg set bool pwmkey openlastb m bopenlastdb pcfg set bool pwmkey autosaveb m bautosavedb pcfg set bool pwmkey rememberlast m brememberlast pcfg set bool pwmkey singleinstance m bcheckforinstance if m brememberlast true tchar tsz temp si regsize get module file name null tsz temp si regsize 2 pcfg set pwmkey lastdb make relative path ex tsz temp m strlastdb else pcfg set pwmkey lastdb t pcfg set bool pwmkey startminimized m bstartminimized pcfg set bool pwmkey disableunsafe m bdisableunsafe pcfg set bool pwmkey imgbtns m bimgbuttons pcfg set bool pwmkey entrygrid m bentrygrid pcfg set bool pwmkey autoshowexpired m bautoshowexpired pcfg set bool pwmkey autoshowexpireds m bautoshowexpiredsoon pcfg set bool pwmkey backupentries m bbackupentries pcfg set bool pwmkey secureedits m bsecureedits pcfg set bool pwmkey singleclicktray m bsingleclicktrayicon pcfg set bool pwmkey autopwgen m bautopwgen pcfg set bool pwmkey quickfindincbk m bquickfindincbackup pcfg set bool pwmkey deletebkonsave m bdeletebackupsonsave pcfg set bool pwmkey disableautotype m bdisableautotype pcfg set bool pwmkey copyurls m bcopyurls pcfg set bool pwmkey exitinsteadlock m bexitinsteadoflockat pcfg set bool pwmkey showtitle m bshowtitle pcfg set bool pwmkey showuser m bshowusername pcfg set bool pwmkey showurl m bshowurl pcfg set bool pwmkey showpass m bshowpassword pcfg set bool pwmkey shownotes m bshownotes pcfg set bool pwmkey showcreation m bshowcreation pcfg set bool pwmkey showlastmod m bshowlastmod pcfg set bool pwmkey showlastaccess m bshowlastaccess pcfg set bool pwmkey showexpire m bshowexpire pcfg set bool pwmkey showuuid m bshowuuid pcfg set bool pwmkey showattach m bshowattach pcfg set bool pwmkey entryview m bentryview pcfg set bool pwmkey hidestars m bpasswordstars pcfg set bool pwmkey hideusers m buserstars pcfg set bool pwmkey alwaystop m balwaysontop pcfg set bool pwmkey lockmin m blockonminimize pcfg set bool pwmkey mintray m bminimizetotray pcfg set bool pwmkey closemin m bcloseminimizes pcfg set bool pwmkey showtoolbar m bshowtoolbar pcfg set bool pwmkey colautosize m bcolautosize pcfg set bool pwmkey showfullpath m bshowfullpath pcfg set bool pwmkey simpletanview m bsimpletanview pcfg set bool pwmkey showtanindices m bshowtanindices newgui getheaderorder m clist m hwnd m aheaderorder 11 ar2str sz temp m aheaderorder 11 pcfg set pwmkey headerorder sz temp c string str options str char set uint n chars c pw generator dlg get options str options str char set n chars pcfg set pwmkey pwgen options str options pcfg set pwmkey pwgen chars str char set itot int n chars sz temp 10 pcfg set pwmkey pwgen numchars sz temp itot m nautotypemethod sz temp 10 pcfg set pwmkey autotypemethod sz temp pcfg set pwmkey listfont m strfontspec if m bminimized false m bmaximized false rect rect get window rect rect itot rect left sz temp 10 pcfg set pwmkey windowpx sz temp itot rect top sz temp 10 pcfg set pwmkey windowpy sz temp itot rect right rect left sz temp 10 pcfg set pwmkey windowdx sz temp itot rect bottom rect top sz temp 10 pcfg set pwmkey windowdy sz temp save all column widths itot m ncolumnwidths 0 sz temp 10 pcfg set pwmkey colwidth0 sz temp itot m ncolumnwidths 1 sz temp 10 pcfg set pwmkey colwidth1 sz temp itot m ncolumnwidths 2 sz temp 10 pcfg set pwmkey colwidth2 sz temp itot m ncolumnwidths 3 sz temp 10 pcfg set pwmkey colwidth3 sz temp itot m ncolumnwidths 4 sz temp 10 pcfg set pwmkey colwidth4 sz temp itot m ncolumnwidths 5 sz temp 10 pcfg set pwmkey colwidth5 sz temp itot m ncolumnwidths 6 sz temp 10 pcfg set pwmkey colwidth6 sz temp itot m ncolumnwidths 7 sz temp 10 pcfg set pwmkey colwidth7 sz temp itot m ncolumnwidths 8 sz temp 10 pcfg set pwmkey colwidth8 sz temp itot m ncolumnwidths 9 sz temp 10 pcfg set pwmkey colwidth9 sz temp itot m ncolumnwidths 10 sz temp 10 pcfg set pwmkey colwidth10 sz temp ltot m lsplitterposhoriz sz temp 10 pcfg set pwmkey splitterx sz temp ltot m lsplitterposvert sz temp 10 pcfg set pwmkey splittery sz temp pcfg set bool pwmkey winstate max m bmaximized ltot long m clist get row color ex sz temp 10 pcfg set pwmkey rowcolor sz temp ltot m nlocktimedef sz temp 10 pcfg set pwmkey locktimer sz temp ltot long m dwdefaultexpire sz temp 10 pcfg set pwmkey defaultexpire sz temp int jj c string str file strt for jj 0 jj int m pimgr m plugins size jj str temp format t keeplugin d jj if m pimgr m plugins jj b enabled true str file t else str file t strt m pimgr m plugins jj tsz file str file cs file only strt pcfg set str temp str file str temp format t keeplugin d jj verify pcfg set str temp t 0 cpwsafedlg saveoptions cprivateconfig sztemp cstring strtemp _ultot m_dwclipboardsecs sztemp pwmkey_clipsecs sztemp _itot m_nclipboardmethod sztemp pwmkey_clipboardmethod sztemp getcurrentdirectory sztemp _tcslen sztemp pwmkey_lastdir sztemp _ultot m_dwathotkey sztemp pwmkey_autotypehotkey sztemp m_bwindowsnewline _tcscpy sztemp _t _tcscpy sztemp _t pwmkey_newline sztemp setbool pwmkey_useputtyforurls m_buseputtyforurls _itot m_nautosort sztemp pwmkey_autosort sztemp setbool pwmkey_saveonlatmod m_bsaveonlatmod setbool pwmkey_openlastb m_bopenlastdb setbool pwmkey_autosaveb m_bautosavedb setbool pwmkey_rememberlast m_brememberlast setbool pwmkey_singleinstance m_bcheckforinstance m_brememberlast tsztemp si_regsize getmodulefilename tsztemp si_regsize pwmkey_lastdb makerelativepathex tsztemp m_strlastdb pwmkey_lastdb _t setbool pwmkey_startminimized m_bstartminimized setbool pwmkey_disableunsafe m_bdisableunsafe setbool pwmkey_imgbtns m_bimgbuttons setbool pwmkey_entrygrid m_bentrygrid setbool pwmkey_autoshowexpired m_bautoshowexpired setbool pwmkey_autoshowexpireds m_bautoshowexpiredsoon setbool pwmkey_backupentries m_bbackupentries setbool pwmkey_secureedits m_bsecureedits setbool pwmkey_singleclicktray m_bsingleclicktrayicon setbool pwmkey_autopwgen m_bautopwgen setbool pwmkey_quickfindincbk m_bquickfindincbackup setbool pwmkey_deletebkonsave m_bdeletebackupsonsave setbool pwmkey_disableautotype m_bdisableautotype setbool pwmkey_copyurls m_bcopyurls setbool pwmkey_exitinsteadlock m_bexitinsteadoflockat setbool pwmkey_showtitle m_bshowtitle setbool pwmkey_showuser m_bshowusername setbool pwmkey_showurl m_bshowurl setbool pwmkey_showpass m_bshowpassword setbool pwmkey_shownotes m_bshownotes setbool pwmkey_showcreation m_bshowcreation setbool pwmkey_showlastmod m_bshowlastmod setbool pwmkey_showlastaccess m_bshowlastaccess setbool pwmkey_showexpire m_bshowexpire setbool pwmkey_showuuid m_bshowuuid setbool pwmkey_showattach m_bshowattach setbool pwmkey_entryview m_bentryview setbool pwmkey_hidestars m_bpasswordstars setbool pwmkey_hideusers m_buserstars setbool pwmkey_alwaystop m_balwaysontop setbool pwmkey_lockmin m_blockonminimize setbool pwmkey_mintray m_bminimizetotray setbool pwmkey_closemin m_bcloseminimizes setbool pwmkey_showtoolbar m_bshowtoolbar setbool pwmkey_colautosize m_bcolautosize setbool pwmkey_showfullpath m_bshowfullpath setbool pwmkey_simpletanview m_bsimpletanview setbool pwmkey_showtanindices m_bshowtanindices newgui_getheaderorder m_clist m_hwnd m_aheaderorder sztemp m_aheaderorder pwmkey_headerorder sztemp cstring stroptions strcharset nchars cpwgeneratordlg getoptions stroptions strcharset nchars pwmkey_pwgen_options stroptions pwmkey_pwgen_chars strcharset _itot nchars sztemp pwmkey_pwgen_numchars sztemp _itot m_nautotypemethod sztemp pwmkey_autotypemethod sztemp pwmkey_listfont m_strfontspec m_bminimized m_bmaximized getwindowrect _itot sztemp pwmkey_windowpx sztemp _itot sztemp pwmkey_windowpy sztemp _itot sztemp pwmkey_windowdx sztemp _itot sztemp pwmkey_windowdy sztemp _itot m_ncolumnwidths sztemp pwmkey_colwidth0 sztemp _itot m_ncolumnwidths sztemp pwmkey_colwidth1 sztemp _itot m_ncolumnwidths sztemp pwmkey_colwidth2 sztemp _itot m_ncolumnwidths sztemp pwmkey_colwidth3 sztemp _itot m_ncolumnwidths sztemp pwmkey_colwidth4 sztemp _itot m_ncolumnwidths sztemp pwmkey_colwidth5 sztemp _itot m_ncolumnwidths sztemp pwmkey_colwidth6 sztemp _itot m_ncolumnwidths sztemp pwmkey_colwidth7 sztemp _itot m_ncolumnwidths sztemp pwmkey_colwidth8 sztemp _itot m_ncolumnwidths sztemp pwmkey_colwidth9 sztemp _itot m_ncolumnwidths sztemp pwmkey_colwidth10 sztemp _ltot m_lsplitterposhoriz sztemp pwmkey_splitterx sztemp _ltot m_lsplitterposvert sztemp pwmkey_splittery sztemp setbool pwmkey_winstate_max m_bmaximized _ltot m_clist getrowcolorex sztemp pwmkey_rowcolor sztemp _ltot m_nlocktimedef sztemp pwmkey_locktimer sztemp _ltot m_dwdefaultexpire sztemp pwmkey_defaultexpire sztemp cstring strfile m_pimgr m_plugins strtemp _t keeplugin_ m_pimgr m_plugins benabled strfile _t strfile _t m_pimgr m_plugins tszfile strfile csfileonly strtemp strfile strtemp _t keeplugin_ strtemp _t void c pw safe dlg set status text ex lpctstr lp status text int n pane if n pane 1 n pane 2 assert n pane 3 m sbstatus set text lp status text n pane 0 cpwsafedlg setstatustextex lpstatustext npane npane npane npane m_sbstatus settext lpstatustext npane inline void c pw safe dlg notify user activity m nlockcountdown m nlocktimedef cpwsafedlg notifyuseractivity m_nlockcountdown m_nlocktimedef void c pw safe dlg update auto sort menu items int i uint u cmdid id view autosort nosort for i 0 i 10 i switch i case 0 u cmdid id view autosort nosort break case 1 u cmdid id view autosort title break case 2 u cmdid id view autosort user break case 3 u cmdid id view autosort url break case 4 u cmdid id view autosort password break case 5 u cmdid id view autosort notes break case 6 u cmdid id view autosort creation break case 7 u cmdid id view autosort lastmodify break case 8 u cmdid id view autosort lastaccess break case 9 u cmdid id view autosort expire break default assert false break if i m nautosort m menu check menu item u cmdid mf bycommand mf checked else m menu check menu item u cmdid mf bycommand mf unchecked cpwsafedlg updateautosortmenuitems ucmdid id_view_autosort_nosort ucmdid id_view_autosort_nosort ucmdid id_view_autosort_title ucmdid id_view_autosort_user ucmdid id_view_autosort_url ucmdid id_view_autosort_password ucmdid id_view_autosort_notes ucmdid id_view_autosort_creation ucmdid id_view_autosort_lastmodify ucmdid id_view_autosort_lastaccess ucmdid id_view_autosort_expire m_nautosort m_menu checkmenuitem ucmdid mf_bycommand mf_checked m_menu checkmenuitem ucmdid mf_bycommand mf_unchecked void c pw safe dlg build plugin menu unsigned int i j kp menu item p uint u flags std vector bc menu ptrs bc menu psub bc menu m menu get sub menu tchar trl tools c string str item bool b make separator true assert psub null if psub null return ptrs push back psub for i 0 i unsigned int m pimgr m plugins size i if m pimgr m plugins i hinstdll null m pimgr m plugins i b enabled false continue for j 0 j unsigned int m pimgr m plugins i info dw num commands j psub ptrs ptrs size 1 p m pimgr m plugins i info p menu items j u flags mf string mf ownerdraw if tcslen p lp command string 0 u flags mf separator u flags mf string else if p dw flags kpmif checkbox 0 if p dw state kpmis checked 0 u flags mf checked else u flags mf unchecked else if p dw flags kpmif disabled 0 u flags mf grayed else u flags mf enabled if p dw flags kpmif popup start 0 u flags mf popup psub append menu u flags p dw commandid p lp command string if p dw flags kpmif popup start 0 if b make separator true psub appendod menu t mf ownerdraw mf separator b make separator false psub psub appendod popup menu p lp command string if psub null ptrs push back psub else if p dw flags kpmif popup end 0 if ptrs size 2 ptrs pop back else if b make separator true psub appendod menu t mf ownerdraw mf separator b make separator false if p dw icon 0 psub appendod menu p lp command string u flags int p dw commandid m ilicons int p dw icon 1 else psub appendod menu p lp command string u flags int p dw commandid b make separator true ptrs clear cpwsafedlg buildpluginmenu kp_menu_item uflags bcmenu bcmenu bcmenu m_menu getsubmenu cstring stritem bmakeseparator push_back m_pimgr m_plugins m_pimgr m_plugins m_pimgr m_plugins benabled m_pimgr m_plugins dwnumcommands m_pimgr m_plugins pmenuitems uflags mf_string mf_ownerdraw _tcslen lpcommandstring uflags mf_separator uflags mf_string dwflags kpmif_checkbox dwstate kpmis_checked uflags mf_checked uflags mf_unchecked dwflags kpmif_disabled uflags mf_grayed uflags mf_enabled dwflags kpmif_popup_start uflags mf_popup appendmenu uflags dwcommandid lpcommandstring dwflags kpmif_popup_start bmakeseparator appendodmenu _t mf_ownerdraw mf_separator bmakeseparator appendodpopupmenu lpcommandstring push_back dwflags kpmif_popup_end pop_back bmakeseparator appendodmenu _t mf_ownerdraw mf_separator bmakeseparator dwicon appendodmenu lpcommandstring uflags dwcommandid m_ilicons dwicon appendodmenu lpcommandstring uflags dwcommandid bmakeseparator bool c pw safe dlg register global hot key int n hot keyid dword dw hot key bool b release previous bool b message box on fail uint u modifiers 0 bool b if dw hot key 16 hotkeyf alt 0 u modifiers mod alt if dw hot key 16 hotkeyf shift 0 u modifiers mod shift if dw hot key 16 hotkeyf control 0 u modifiers mod control if b release previous true unregister hot key this m hwnd n hot keyid if dw hot key 0 return true nothing to register b register hot key this m hwnd n hot keyid u modifiers uint dw hot key 0x0000ffff if b false c string str str trl cannot register the global hot key if b message box on fail true str t r n r n str trl most probably another application has reserved this hot key already str t r n r n str trl you can choose an other hot key combination in edit options setup show a global warning window message box get desktop window str t kee pass mb ok mb iconwarning else set status text ex str return b cpwsafedlg registerglobalhotkey nhotkeyid dwhotkey breleaseprevious bmessageboxonfail umodifiers dwhotkey hotkeyf_alt umodifiers mod_alt dwhotkey hotkeyf_shift umodifiers mod_shift dwhotkey hotkeyf_control umodifiers mod_control breleaseprevious unregisterhotkey m_hwnd nhotkeyid dwhotkey registerhotkey m_hwnd nhotkeyid umodifiers dwhotkey cstring bmessageboxonfail _t _t messagebox getdesktopwindow _t keepass mb_ok mb_iconwarning setstatustextex void c pw safe dlg adjust pw list mode dword dw style m clist get style don t use set redraw and invalidate in this function if m btansonly true m bsimpletanview true if dw style lvs report 0 is in report display mode m dwpwlistmode lvsx changing for int i 1 i 11 i m clist set column width i 0 m clist set column width 0 100 lvscw autosize m clist modify style lvs report lvs smallicon m clist set column width 1 lvscw autosize m dwpwlistmode lvs smallicon setcolumnwidths return else m btansonly false if dw style lvs list 0 m dwpwlistmode lvsx changing m clist modify style lvs smallicon lvs report m dwpwlistmode lvs report setcolumnwidths return cpwsafedlg adjustpwlistmode dwstyle m_clist getstyle setredraw m_btansonly m_bsimpletanview dwstyle lvs_report m_dwpwlistmode lvsx_changing m_clist setcolumnwidth m_clist setcolumnwidth lvscw_autosize m_clist modifystyle lvs_report lvs_smallicon m_clist setcolumnwidth lvscw_autosize m_dwpwlistmode lvs_smallicon _setcolumnwidths m_btansonly dwstyle lvs_list m_dwpwlistmode lvsx_changing m_clist modifystyle lvs_smallicon lvs_report m_dwpwlistmode lvs_report _setcolumnwidths void c pw safe dlg adjust column widths assert m dwpwlistmode lvsx changing if m dwpwlistmode lvs smallicon return int n n max width 0 for int i 0 i m clist get item count i n m clist get string width m clist get item text i 0 if n n max width n max width n n max width 26 if m clist get column width 1 n max width m clist set column width 1 n max width cpwsafedlg adjustcolumnwidths m_dwpwlistmode lvsx_changing m_dwpwlistmode lvs_smallicon nmaxwidth m_clist getitemcount m_clist getstringwidth m_clist getitemtext nmaxwidth nmaxwidth nmaxwidth m_clist getcolumnwidth nmaxwidth m_clist setcolumnwidth nmaxwidth void c pw safe dlg parse and openurl with entry info lpctstr lpurl pw entry p entry if p entry null lpurl null c string strurl lpurl bool b parse two times false if strurl get length 0 c string str override str override extract parameter from string p entry psz additional t url override 0 if str override get length 0 strurl str override b parse two times true else if m strurloverride get length 0 if isunsafeallowed true bool b is specialurl false if strurl get length 6 c string str temp strurl left 6 str temp make lower if str temp t cmd b is specialurl true if b is specialurl false strurl m strurloverride b parse two times true m mgr unlock entry password p entry parseurl strurl p entry false if b parse two times true parseurl strurl p entry false m mgr lock entry password p entry fixurl strurl if strurl get length 0 if m buseputtyforurls true if open url using putty strurl p entry psz user name false open url ex strurl else open url ex strurl cpwsafedlg parseandopenurlwithentryinfo pw_entry pentry pentry cstring bparsetwotimes getlength cstring stroverride stroverride extractparameterfromstring pentry pszadditional _t stroverride getlength stroverride bparsetwotimes m_strurloverride getlength _isunsafeallowed bisspecialurl getlength cstring strtemp strtemp makelower strtemp _t bisspecialurl bisspecialurl m_strurloverride bparsetwotimes m_mgr unlockentrypassword pentry pentry bparsetwotimes pentry m_mgr lockentrypassword pentry getlength m_buseputtyforurls openurlusingputty pentry pszusername openurlex openurlex void c pw safe dlg autotype pw entry p entry bool b lose focus c string str assert entry p entry if p entry null return if m bdisableautotype true return block input true str extract parameter from string p entry psz additional t auto type 0 if str get length 0 if tcscmp p entry psz title pws tan entry 0 is it a tan entry str t password getcurrentpwtime p entry t expire m bmodified true else str t username tab password enter m mgr unlock entry password p entry parseurl str p entry true m mgr lock entry password p entry if b lose focus true if m nautotypemethod atm dropback hwnd h wnd get window this m hwnd gw hwndfirst long l style windowplacement wp zero memory wp sizeof windowplacement wp length sizeof windowplacement while 1 if h wnd this m hwnd l style get window long h wnd gwl style get window placement h wnd wp if l style ws visible ws visible wp show cmd sw showminimized tchar tsz window buf 256 get window text h wnd tsz window buf 255 if tsz window buf 0 0 break if get window text length h wnd 0 break h wnd get window h wnd gw hwndnext if h wnd null break set window pos c wnd wnd bottom 0 0 0 0 swp noactivate swp nomove swp nosize if h wnd null set foreground window h wnd else m nautotypemethod atm minimize hwnd h me get foreground window set window pos c wnd wnd bottom 0 0 0 0 swp noactivate swp nomove swp nosize if m bminimized false if m bminimizetotray false show window sw minimize m bminimized true else if m bshowwindow true show window sw minimize view hide handler hwnd h dword dw start time time get time while 1 h get foreground window if h h me break if time get time dw start time 750 break sleep 50 c send keys sk bool b toggle caps lock false sk set delay 10 sk send keys t false release all modifier keys sk send key up vk lshift sk send key up vk rshift sk send key up vk shift sk send key up vk lcontrol sk send key up vk rcontrol sk send key up vk control sk send key up vk lmenu sk send key up vk rmenu sk send key up vk menu sk send key up vk lwin sk send key up vk rwin if get key state vk capital 1 0 b toggle caps lock true sk send keys t capslock true msg msg clear wait while peek message msg clear wait 0 wm keyfirst wm keylast pm remove translate message msg clear wait dispatch message msg clear wait sk send keys str true if b toggle caps lock true sk send keys t capslock true block input false if b lose focus true m balwaysontop true set window pos c wnd wnd top most 0 0 0 0 swp noactivate swp nomove swp nosize erasec string str cpwsafedlg _autotype pw_entry pentry blosefocus cstring assert_entry pentry pentry m_bdisableautotype blockinput extractparameterfromstring pentry pszadditional _t getlength _tcscmp pentry psztitle pws_tan_entry _t _getcurrentpwtime pentry texpire m_bmodified _t m_mgr unlockentrypassword pentry pentry m_mgr lockentrypassword pentry blosefocus m_nautotypemethod atm_dropback hwnd getwindow m_hwnd gw_hwndfirst lstyle zeromemory hwnd m_hwnd lstyle getwindowlong hwnd gwl_style getwindowplacement hwnd lstyle ws_visible ws_visible showcmd sw_showminimized tszwindowbuf getwindowtext hwnd tszwindowbuf tszwindowbuf getwindowtextlength hwnd hwnd getwindow hwnd gw_hwndnext hwnd setwindowpos cwnd wndbottom swp_noactivate swp_nomove swp_nosize hwnd setforegroundwindow hwnd m_nautotypemethod atm_minimize hme getforegroundwindow setwindowpos cwnd wndbottom swp_noactivate swp_nomove swp_nosize m_bminimized m_bminimizetotray showwindow sw_minimize m_bminimized m_bshowwindow showwindow sw_minimize viewhidehandler dwstarttime timegettime getforegroundwindow hme timegettime dwstarttime csendkeys btogglecapslock setdelay sendkeys _t sendkeyup vk_lshift sendkeyup vk_rshift sendkeyup vk_shift sendkeyup vk_lcontrol sendkeyup vk_rcontrol sendkeyup vk_control sendkeyup vk_lmenu sendkeyup vk_rmenu sendkeyup vk_menu sendkeyup vk_lwin sendkeyup vk_rwin getkeystate vk_capital btogglecapslock sendkeys _t msgclearwait peekmessage msgclearwait wm_keyfirst wm_keylast pm_remove translatemessage msgclearwait dispatchmessage msgclearwait sendkeys btogglecapslock sendkeys _t blockinput blosefocus m_balwaysontop setwindowpos cwnd wndtopmost swp_noactivate swp_nomove swp_nosize erasecstring void c pw safe dlg update group list notify user activity dword i tvinsertstruct tvis pw group pgrp htreeitem h parent tvi root htreeitem h last item tvi root dword us level 0 m cgroups set redraw false group sync states true synchronize expanded flag from gui to list manager m cgroups select item null m cgroups delete all items if m bfileopen false m cgroups set redraw true return m cgroups set redraw false zero memory tvis sizeof tvinsertstruct tvis h insert after tvi last tvis item mask tvif image tvif text tvif param tvif state tvif selectedimage for i 0 i m mgr get number of groups i pgrp m mgr get group i assert pgrp null if pgrp null continue assert pgrp psz group name null while 1 if us level pgrp us level break else if us level ushort pgrp us level 1 h parent h last item us level else if us level pgrp us level assert false h parent tvi root break else if us level pgrp us level if h parent tvi root break h parent m cgroups get parent item h parent us level tvis h parent h parent tvis item psz text pgrp psz group name tvis item i selected image tvis item i image int pgrp u image id tvis item l param pgrp u group id tvis item state mask tvis expanded tvis item state pgrp dw flags pwgf expanded tvis expanded 0 h last item m cgroups insert item tvis m cgroups set redraw true m cgroups invalidate group sync states false expand all tree items that were open before if i 0 m cgroups select item m cgroups get root item cpwsafedlg updategrouplist notifyuseractivity pw_group hparent tvi_root hlastitem tvi_root uslevel m_cgroups setredraw groupsyncstates m_cgroups selectitem m_cgroups deleteallitems m_bfileopen m_cgroups setredraw m_cgroups setredraw zeromemory hinsertafter tvi_last tvif_image tvif_text tvif_param tvif_state tvif_selectedimage m_mgr getnumberofgroups m_mgr getgroup pszgroupname uslevel uslevel uslevel uslevel hparent hlastitem uslevel uslevel uslevel hparent tvi_root uslevel uslevel hparent tvi_root hparent m_cgroups getparentitem hparent uslevel hparent hparent psztext pszgroupname iselectedimage iimage uimageid lparam ugroupid statemask tvis_expanded dwflags pwgf_expanded tvis_expanded hlastitem m_cgroups insertitem m_cgroups setredraw m_cgroups groupsyncstates m_cgroups selectitem m_cgroups getrootitem void c pw safe dlg update password list notify user activity dword i j 0 dword dw group id pw entry pwe pw time t now if m bfileopen false return dw group id get selected group id if dw group id dword max return if m bblockpwlistupdate true return m bblockpwlistupdate true sortlistifautosort m bblockpwlistupdate false m clist set redraw false m clist delete all items m btansonly true getcurrentpwtime t now for i 0 i m mgr get number of entries i pwe m mgr get entry i assert entry pwe if pwe null if pwe u group id dw group id list setentry j pwe true t now j if j 0 m btansonly false use report list view adjust pw list mode if j 0 m btansonly true now set it to the correct value adjust column widths m clist set redraw true m clist invalidate show entry details null cpwsafedlg updatepasswordlist notifyuseractivity dwgroupid pw_entry pw_time tnow m_bfileopen dwgroupid getselectedgroupid dwgroupid dword_max m_bblockpwlistupdate m_bblockpwlistupdate _sortlistifautosort m_bblockpwlistupdate m_clist setredraw m_clist deleteallitems m_btansonly _getcurrentpwtime tnow m_mgr getnumberofentries m_mgr getentry assert_entry ugroupid dwgroupid _list_setentry tnow m_btansonly adjustpwlistmode m_btansonly adjustcolumnwidths m_clist setredraw m_clist showentrydetails void c pw safe dlg refresh password list notify user activity dword i j 0 pw entry pwe lv item lvi tchar sz temp 1024 byte a uuid 16 c string str temp pw time t now if m bfileopen false return getcurrentpwtime t now m clist set redraw false for i 0 i dword m clist get item count i zero memory lvi sizeof lv item lvi i item int i lvi i sub item 9 lvi mask lvif text lvi cch text max 1024 lvi psz text sz temp m clist get item lvi str temp lvi psz text stringtouuid str temp a uuid pwe m mgr get entry by uuid a uuid assert entry pwe if pwe null list setentry j pwe false t now j sortlistifautosort adjust pw list mode adjust column widths m clist set redraw true m clist invalidate cpwsafedlg refreshpasswordlist notifyuseractivity pw_entry lv_item sztemp auuid cstring strtemp pw_time tnow m_bfileopen _getcurrentpwtime tnow m_clist setredraw m_clist getitemcount zeromemory lv_item iitem isubitem lvif_text cchtextmax psztext sztemp m_clist getitem strtemp psztext _stringtouuid strtemp auuid m_mgr getentrybyuuid auuid assert_entry _list_setentry tnow _sortlistifautosort adjustpwlistmode adjustcolumnwidths m_clist setredraw m_clist dword c pw safe dlg get selected entry notify user activity dword i uint u state if m bfileopen false return dword max lvis focused is not enough here it must be lvis selected for i 0 i dword m clist get item count i u state m clist get item state int i lvis selected if u state lvis selected return i position pos first item m clist get first selected item position if pos first item null return dword max return dword m clist get next selected item pos first item cpwsafedlg getselectedentry notifyuseractivity ustate m_bfileopen dword_max lvis_focused lvis_selected m_clist getitemcount ustate m_clist getitemstate lvis_selected ustate lvis_selected posfirstitem m_clist getfirstselecteditemposition posfirstitem dword_max m_clist getnextselecteditem posfirstitem dword c pw safe dlg get selected entries count notify user activity dword i u selected items 0 uint u state if m bfileopen false return dword max for i 0 i dword m clist get item count i u state m clist get item state int i lvis selected if u state lvis selected u selected items return u selected items return dword m clist get selected count cpwsafedlg getselectedentriescount notifyuseractivity uselecteditems ustate m_bfileopen dword_max m_clist getitemcount ustate m_clist getitemstate lvis_selected ustate lvis_selected uselecteditems uselecteditems m_clist getselectedcount dword c pw safe dlg get selected group id htreeitem h m cgroups get selected item if h null return dword max return m cgroups get item data h cpwsafedlg getselectedgroupid m_cgroups getselecteditem dword_max m_cgroups getitemdata bool c pw safe dlg get export options pwexport options p options c pw export p pw export notify user activity assert p options null if p options null return false assert p pw export null if p pw export null return false m bdisplaydialog true p options p pw export m adefaults p pw export m nformat c check options dlg dlg chkopt param pa lcl chkopt param count zero memory pa sizeof chkopt param lcl chkopt param count dword n dword max pa n lp string trl options pa n n icon 9 pa n lp string trl encode replace newline characters by n pa n pb value p options b encode newlines pa n lp string trl export backup entries entries in the backup group pa n pb value p options b export backups pa n lp string t pa n n icon 0 pa n lp string trl fields to export pa n n icon 8 pa n lp string trl password groups pa n pb value p options b group pa n lp string trl group tree pa n pb value p options b group tree pa n lp string trl title pa n pb value p options b title pa n lp string trl user name pa n pb value p options b user name pa n lp string trl url pa n pb value p options burl pa n lp string trl password pa n pb value p options b password pa n lp string trl notes pa n pb value p options b notes pa n lp string trl creation time pa n pb value p options b creation time pa n lp string trl last access pa n pb value p options b last acc time pa n lp string trl last modification pa n pb value p options b last mod time pa n lp string trl expires pa n pb value p options b expire time pa n lp string trl icon pa n pb value p options b image pa n lp string trl uuid pa n pb value p options buuid pa n lp string trl attachment pa n pb value p options b attachment assert n lcl chkopt param count 1 dlg m strtitle trl export options dlg m strdescription trl here you can customize the exported files dlg m dwnumparams lcl chkopt param count dlg m pparams chkopt param pa if dlg do modal idok m bdisplaydialog false return true m bdisplaydialog false return false cpwsafedlg getexportoptions pwexport_options poptions cpwexport ppwexport notifyuseractivity poptions poptions ppwexport ppwexport m_bdisplaydialog poptions ppwexport m_adefaults ppwexport m_nformat ccheckoptionsdlg chkopt_param lcl_chkopt_param_count zeromemory chkopt_param lcl_chkopt_param_count dword_max lpstring nicon lpstring pbvalue poptions bencodenewlines lpstring pbvalue poptions bexportbackups lpstring _t nicon lpstring nicon lpstring pbvalue poptions bgroup lpstring pbvalue poptions bgrouptree lpstring pbvalue poptions btitle lpstring pbvalue poptions busername lpstring pbvalue poptions lpstring pbvalue poptions bpassword lpstring pbvalue poptions bnotes lpstring pbvalue poptions bcreationtime lpstring pbvalue poptions blastacctime lpstring pbvalue poptions blastmodtime lpstring pbvalue poptions bexpiretime lpstring pbvalue poptions bimage lpstring pbvalue poptions lpstring pbvalue poptions battachment lcl_chkopt_param_count m_strtitle m_strdescription m_dwnumparams lcl_chkopt_param_count m_pparams chkopt_param domodal m_bdisplaydialog m_bdisplaydialog c string c pw safe dlg get export file int n format lpctstr lp base file name bool b fix file name dword dw flags lptstr lp t exp c string str sample c string str filter if m bfileopen false return c string m bdisplaydialog true if n format pwexp txt lp t txt else if n format pwexp html lp t html else if n format pwexp xml lp t xml else if n format pwexp csv lp t csv else if n format pwexp keepass lp t kdb else assert false if lp base file name null str sample t export else str sample lp base file name if b fix file name true str sample replace t t str sample replace t t str sample replace t t str sample replace t t str sample replace t t str sample replace t t str sample replace t t str sample replace t t str sample replace t t str sample replace t t str sample replace t t str sample t str sample lp str filter trl all files str filter t dw flags ofn longnames ofn hidereadonly ofn overwriteprompt dw flags ofn extensiondifferent ofn explorer 0x00080000 ofn enablesizing 0x00800000 dw flags 0x00080000 0x00800000 ofn noreadonlyreturn c file dialog dlg false lp str sample dw flags str filter this if dlg do modal idok m bdisplaydialog false return dlg get path name str sample empty m bdisplaydialog false return str sample cstring cpwsafedlg getexportfile nformat lpbasefilename bfixfilename dwflags _t cstring strsample cstring strfilter m_bfileopen cstring m_bdisplaydialog nformat pwexp_txt _t nformat pwexp_html _t nformat pwexp_xml _t nformat pwexp_csv _t nformat pwexp_keepass _t lpbasefilename strsample _t strsample lpbasefilename bfixfilename strsample _t _t strsample _t _t strsample _t _t strsample _t _t strsample _t _t strsample _t _t strsample _t _t strsample _t _t strsample _t _t strsample _t _t strsample _t _t strsample _t strsample strfilter strfilter _t dwflags ofn_longnames ofn_hidereadonly ofn_overwriteprompt dwflags ofn_extensiondifferent ofn_explorer ofn_enablesizing dwflags ofn_noreadonlyreturn cfiledialog strsample dwflags strfilter domodal m_bdisplaydialog getpathname strsample m_bdisplaydialog strsample void c pw safe dlg export selected group int n format c pw export c exp pwexport options pwo c string str file dword dw selected group get selected group id assert dw selected group dword max if dw selected group dword max return if isunsafeallowed false return c exp set manager m mgr c exp set new line seq m bwindowsnewline c exp set format n format str file get export file n format m mgr get group by id dw selected group psz group name true if str file get length 0 if get export options pwo c exp true c exp export group str file dw selected group pwo null cpwsafedlg exportselectedgroup nformat cpwexport cexp pwexport_options cstring strfile dwselectedgroup getselectedgroupid dwselectedgroup dword_max dwselectedgroup dword_max _isunsafeallowed cexp setmanager m_mgr cexp setnewlineseq m_bwindowsnewline cexp setformat nformat strfile getexportfile nformat m_mgr getgroupbyid dwselectedgroup pszgroupname strfile getlength getexportoptions cexp cexp exportgroup strfile dwselectedgroup void c pw safe dlg export group to kee pass dword dw group id c pw manager pw temp mgr c pw export c exp notify user activity if isunsafeallowed false return c exp set manager m mgr c exp set new line seq m bwindowsnewline c exp set format pwexp keepass c string str file if dw group id dword max str file get export file pwexp keepass m mgr get group by id dw group id psz group name true else str file get export file pwexp keepass cs file only m strfile true if str file get length 0 return c string str text trl please choose if kee pass should use the key of the currently opened database or ask you to define a new key to encrypt the exported file str text t r n r n str text trl click yes to use the same key as the currently opened database str text t r n str text trl click no to set a new key for the exported file str text t r n r n str text trl reuse the current key password int n use message box str text trl password safe mb iconquestion mb yesno if n use idno if changemasterkey pw temp mgr true true return else byte a master key 32 copy the master key m mgr get raw master key a master key pw temp mgr set raw master key a master key if dw group id dword max clone manager properties when exporting all groups and entries pw temp mgr m dwlastselectedgroupid m mgr m dwlastselectedgroupid pw temp mgr m dwlasttopvisiblegroupid m mgr m dwlasttopvisiblegroupid memcpy pw temp mgr m alastselectedentryuuid m mgr m alastselectedentryuuid 16 memcpy pw temp mgr m alasttopvisibleentryuuid m mgr m alasttopvisibleentryuuid 16 c exp export group str file dw group id null pw temp mgr pw temp mgr set raw master key null cpwsafedlg exportgrouptokeepass dwgroupid cpwmanager pwtempmgr cpwexport cexp notifyuseractivity _isunsafeallowed cexp setmanager m_mgr cexp setnewlineseq m_bwindowsnewline cexp setformat pwexp_keepass cstring strfile dwgroupid dword_max strfile getexportfile pwexp_keepass m_mgr getgroupbyid dwgroupid pszgroupname strfile getexportfile pwexp_keepass csfileonly m_strfile strfile getlength cstring strtext keepass strtext _t strtext strtext _t strtext strtext _t strtext nuse messagebox strtext mb_iconquestion mb_yesno nuse _changemasterkey pwtempmgr amasterkey m_mgr getrawmasterkey amasterkey pwtempmgr setrawmasterkey amasterkey dwgroupid dword_max pwtempmgr m_dwlastselectedgroupid m_mgr m_dwlastselectedgroupid pwtempmgr m_dwlasttopvisiblegroupid m_mgr m_dwlasttopvisiblegroupid pwtempmgr m_alastselectedentryuuid m_mgr m_alastselectedentryuuid pwtempmgr m_alasttopvisibleentryuuid m_mgr m_alasttopvisibleentryuuid cexp exportgroup strfile dwgroupid pwtempmgr pwtempmgr setrawmasterkey c string c pw safe dlg makertfstring lpctstr lpt string c string str str2 int i tchar tch str empty assert lpt string null if lpt string null return str for i 0 i int tcslen lpt string i tch lpt string i if tch t str t else if tch t r else if tch t str t else if tch t str t else if tch t n str t par ifndef unicode else str tch else else if tch 128 tch 32 str tch else str2 format t u d tch str str2 endif else if tch 128 tch 32 str tch else str2 format t 02x byte tch 0xff str t str str2 return str cstring cpwsafedlg _makertfstring lptstring cstring lptstring lptstring _tcslen lptstring lptstring _t _t _t _t _t _t _t _t _t _unicode _t _t _t void c pw safe dlg show entry details pw entry p c string str c string str2 ppw group pg if p null assert entry p if m bentryview false return if p null if p null just clear the view ifndef unicode m reentryview setrtf c string t sf text else m reentryview setrtf c string t sf text sf unicode endif return m mgr unlock entry password p begin entry view rtf assembly c string str temp str t rtf1 ansi ansicpg str temp format t u m uacp str str temp str t deff0 fonttbl f0 fswiss ms sans serif f1 froman fcharset2 symbol f2 fswiss str m strlistfontface str t f3 fswiss arial str t colortbl red0 green0 blue0 str t deflang1031 pard plain f2 cf0 str temp format t d m nlistfontsize 2 str t fs str str temp str t b str trl group str t b0 pg m mgr get group by id p u group id assert pg null if pg null str makertfstring pg psz group name str t b str trl title str t b0 str makertfstring p psz title str t b str trl user name str t b0 if m buserstars false str makertfstring p psz user name else str t str t b str trl url str t b0 str makertfstring p pszurl str t b str trl password str t b0 c string str temp password makertfstring p psz password if m bpasswordstars false str str temp password else str t erasec string str temp password str t b str trl creation time str t b0 pwtimetostring p t creation str2 str makertfstring str2 str t b str trl last modification str t b0 pwtimetostring p t last mod str2 str makertfstring str2 str t b str trl last access str t b0 pwtimetostring p t last access str2 str makertfstring str2 if memcmp p t expire g tneverexpire sizeof pw time 0 str t b str trl expires str t b0 pwtimetostring p t expire str2 str makertfstring str2 if tcslen p psz binary desc 0 str t b str trl attachment str t b0 str makertfstring lpctstr p psz binary desc if p psz additional null if tcslen p psz additional 0 str t par par str2 makertfstring p psz additional str2 replace t b t b str2 replace t b t b0 str2 replace t i t i str2 replace t i t i0 str2 replace t u t ul str2 replace t u t ul0 str2 replace t center t qc str2 replace t center t ql str str2 str t pard end entry view rtf assembly m mgr lock entry password p ifndef unicode m reentryview setrtf str sf rtf else m reentryview setrtf str sf rtf sf unicode endif if tcslen p pszurl 0 make the url clickable charrange crurl charformat cfurl crurl cp min tcslen trl group tcslen trl title tcslen trl user name tcslen trl url 11 crurl cp min tcslen pg psz group name tcslen p psz title if m buserstars false crurl cp min tcslen p psz user name else crurl cp min 8 crurl cp max crurl cp min tcslen p pszurl zero memory cfurl sizeof charformat cfurl cb size sizeof charformat cfurl dw mask cfm link cfm color cfm underline cfurl dw effects cfe link cfe underline cfurl cr text color rgb 0 0 255 m reentryview set sel crurl m reentryview set selection char format cfurl m reentryview set sel 0 0 erasec string str cpwsafedlg showentrydetails pw_entry cstring cstring ppw_group assert_entry m_bentryview _unicode m_reentryview cstring _t sf_text m_reentryview cstring _t sf_text sf_unicode m_mgr unlockentrypassword cstring strtemp _t strtemp _t m_uacp strtemp _t m_strlistfontface _t _t _t strtemp _t m_nlistfontsize _t strtemp _t _t m_mgr getgroupbyid ugroupid _makertfstring pszgroupname _t _t _makertfstring psztitle _t _t m_buserstars _makertfstring pszusername _t _t _t _makertfstring _t _t cstring strtemppassword _makertfstring pszpassword m_bpasswordstars strtemppassword _t erasecstring strtemppassword _t _t _pwtimetostring tcreation _makertfstring _t _t _pwtimetostring tlastmod _makertfstring _t _t _pwtimetostring tlastaccess _makertfstring texpire g_tneverexpire pw_time _t _t _pwtimetostring texpire _makertfstring _tcslen pszbinarydesc _t _t _makertfstring pszbinarydesc pszadditional _tcslen pszadditional _t _makertfstring pszadditional _t _t _t _t _t _t _t _t _t _t _t _t _t _t _t _t _t m_mgr lockentrypassword _unicode m_reentryview sf_rtf m_reentryview sf_rtf sf_unicode _tcslen cpmin _tcslen _tcslen _tcslen _tcslen cpmin _tcslen pszgroupname _tcslen psztitle m_buserstars cpmin _tcslen pszusername cpmin cpmax cpmin _tcslen zeromemory cbsize dwmask cfm_link cfm_color cfm_underline dweffects cfe_link cfe_underline crtextcolor m_reentryview setsel m_reentryview setselectioncharformat m_reentryview setsel erasecstring htreeitem c pw safe dlg getlastgroupitem c tree ctrl p tree htreeitem h prev null h h p tree get first visible item while h null h prev h h p tree get next visible item h return h prev cpwsafedlg _getlastgroupitem ctreectrl ptree hprev ptree getfirstvisibleitem hprev ptree getnextvisibleitem hprev void c pw safe dlg group sync states bool b gui to mgr if m bfileopen false return if m cgroups get count 0 return syncsubtree m cgroups m cgroups get root item b gui to mgr cpwsafedlg groupsyncstates bguitomgr m_bfileopen m_cgroups getcount _syncsubtree m_cgroups m_cgroups getrootitem bguitomgr htreeitem c pw safe dlg groupidtohtreeitem dword dw group id return findselectintree m cgroups m cgroups get root item dw group id cpwsafedlg _groupidtohtreeitem dwgroupid _findselectintree m_cgroups m_cgroups getrootitem dwgroupid void c pw safe dlg processgroupkey uint n char uint n flags notify user activity if n flags 0x2000 0 if n char vk up on group move up else if n char vk down on group move down else if n char vk home on group move top else if n char vk end on group move bottom else if n char vk left on group move left else if n char vk right on group move right else if n char vk up n char vk down n char vk home n char vk end n char vk prior n char vk next n char vk left n char vk right m bcachedpwlistupdate true else m bcachedpwlistupdate false cpwsafedlg _processgroupkey nchar nflags notifyuseractivity nflags nchar vk_up ongroupmoveup nchar vk_down ongroupmovedown nchar vk_home ongroupmovetop nchar vk_end ongroupmovebottom nchar vk_left ongroupmoveleft nchar vk_right ongroupmoveright nchar vk_up nchar vk_down nchar vk_home nchar vk_end nchar vk_prior nchar vk_next nchar vk_left nchar vk_right m_bcachedpwlistupdate m_bcachedpwlistupdate void c pw safe dlg processlistkey uint n char bool b alt notify user activity if b alt true if n char vk up on pwlist move up else if n char vk down on pwlist move down else if n char vk home on pwlist move top else if n char vk end on pwlist move bottom else if n char vk delete on pwlist delete cpwsafedlg _processlistkey nchar balt notifyuseractivity balt nchar vk_up onpwlistmoveup nchar vk_down onpwlistmovedown nchar vk_home onpwlistmovetop nchar vk_end onpwlistmovebottom nchar vk_delete onpwlistdelete void c pw safe dlg cb onpwlistcolumnwidthchange int i column int i size assert i column 0 i column 11 if m dwpwlistmode lvs report return if i column 0 i column 11 if m bshowcolumn i column true m ncolumnwidths i column i size cpwsafedlg cb_onpwlistcolumnwidthchange icolumn isize icolumn icolumn m_dwpwlistmode lvs_report icolumn icolumn m_bshowcolumn icolumn m_ncolumnwidths icolumn isize void c pw safe dlg sortlistifautosort if m nautosort 0 return sortlist dword m nautosort 1 true cpwsafedlg _sortlistifautosort m_nautosort _sortlist m_nautosort void c pw safe dlg view hide handler notify user activity if m bminimized true bool b was maximized m bwasmaximized m systray maximise from tray this on sys command sc restore 0 send message wm syscommand sc restore 0 if b was maximized true show window sw maximize if m balwaysontop true set window pos c wnd wnd top most 0 0 0 0 swp noactivate swp nomove swp nosize return if m bshowwindow true m bshowwindow false if m bminimizetotray false m systray minimise to tray this else on sys command sc minimize 0 if m blockonminimize true m blocked false on file lock else m bshowwindow true if m bminimizetotray false m systray maximise from tray this else on sys command sc restore 0 if m bwasmaximized true show window sw maximize if m blocked true on file lock cpwsafedlg viewhidehandler notifyuseractivity m_bminimized bwasmaximized m_bwasmaximized m_systray maximisefromtray onsyscommand sc_restore sendmessage wm_syscommand sc_restore bwasmaximized showwindow sw_maximize m_balwaysontop setwindowpos cwnd wndtopmost swp_noactivate swp_nomove swp_nosize m_bshowwindow m_bshowwindow m_bminimizetotray m_systray minimisetotray onsyscommand sc_minimize m_blockonminimize m_blocked onfilelock m_bshowwindow m_bminimizetotray m_systray maximisefromtray onsyscommand sc_restore m_bwasmaximized showwindow sw_maximize m_blocked onfilelock void c pw safe dlg handleentrydrop dword dw drop type htreeitem h tree item dword dw to group id pw entry pwt pw entry p dword i uint u state dword dw index c string str password copy pw time t now dw to group id m cgroups get item data h tree item assert m mgr get group by id dw to group id null if m mgr get group by id dw to group id null return if dw drop type dropeffect move dw drop type dropeffect copy assert false return c string str group test pw group p group test m mgr get group by id dw to group id if c pw manager is allowed store group p group test psz group name pws searchgroup false message box trl the group you selected cannot store entries please select an other group trl stop mb iconwarning mb ok return getcurrentpwtime t now for i 0 i dword m clist get item count i u state m clist get item state int i lvis selected if u state lvis selected 0 dw index listseltoentryindex i uses uuid to get the entry assert dw index dword max if dw index dword max continue p m mgr get entry dw index assert p null if p null continue if dw drop type dropeffect move p t last access t now p t last mod t now p u group id dw to group id else if dw drop type dropeffect copy m mgr unlock entry password p str password copy p psz password m mgr lock entry password p memcpy pwt p sizeof pw entry copy entry zero memory pwt uuid 16 sizeof byte create new uuid pwt u group id dw to group id set group id pwt psz password tchar lpctstr str password copy pwt t last access t now pwt t last mod t now m mgr add entry pwt add as new entry erasec string str password copy else assert false m cgroups m drop set drag accept false full gui update groups saveview true list saveview update group list groups restoreview list restoreview update password list m bmodified true cpwsafedlg _handleentrydrop dwdroptype htreeitem dwtogroupid pw_entry pw_entry ustate dwindex cstring strpasswordcopy pw_time tnow dwtogroupid m_cgroups getitemdata htreeitem m_mgr getgroupbyid dwtogroupid m_mgr getgroupbyid dwtogroupid dwdroptype dropeffect_move dwdroptype dropeffect_copy cstring strgrouptest pw_group pgrouptest m_mgr getgroupbyid dwtogroupid cpwmanager isallowedstoregroup pgrouptest pszgroupname pws_searchgroup messagebox mb_iconwarning mb_ok _getcurrentpwtime tnow m_clist getitemcount ustate m_clist getitemstate lvis_selected ustate lvis_selected dwindex _listseltoentryindex dwindex dword_max dwindex dword_max m_mgr getentry dwindex dwdroptype dropeffect_move tlastaccess tnow tlastmod tnow ugroupid dwtogroupid dwdroptype dropeffect_copy m_mgr unlockentrypassword strpasswordcopy pszpassword m_mgr lockentrypassword pw_entry zeromemory ugroupid dwtogroupid pszpassword strpasswordcopy tlastaccess tnow tlastmod tnow m_mgr addentry erasecstring strpasswordcopy m_cgroups m_drop setdragaccept _groups_saveview _list_saveview updategrouplist _groups_restoreview _list_restoreview updatepasswordlist m_bmodified void c pw safe dlg calccolumnsizes rect rect int n column width n columns 0 i for i 0 i 11 i count active columns and reset all widths if m bshowcolumn i true n columns m ncolumnwidths i 0 if n columns 0 return m clist get client rect rect calculate and set new widths n column width rect right 9 n columns get system metrics sm cxvscroll n columns for i 0 i 11 i if m bshowcolumn i true m ncolumnwidths i n column width cpwsafedlg _calccolumnsizes ncolumnwidth ncolumns m_bshowcolumn ncolumns m_ncolumnwidths ncolumns m_clist getclientrect ncolumnwidth ncolumns getsystemmetrics sm_cxvscroll ncolumns m_bshowcolumn m_ncolumnwidths ncolumnwidth void c pw safe dlg setcolumnwidths if m dwpwlistmode lvs report for int i 0 i 11 i if m clist get column width i m ncolumnwidths i m clist set column width i m ncolumnwidths i else if m dwpwlistmode lvs smallicon adjust column widths do nothing if m dwpwlistmode lvsx changing cpwsafedlg _setcolumnwidths m_dwpwlistmode lvs_report m_clist getcolumnwidth m_ncolumnwidths m_clist setcolumnwidth m_ncolumnwidths m_dwpwlistmode lvs_smallicon adjustcolumnwidths m_dwpwlistmode lvsx_changing void c pw safe dlg setlistparameters lparam dw dw lvs ex si report lvs ex fullrowselect lvs ex oneclickactivate lvs ex underlinehot dw lvs ex headerdragdrop lvs ex infotip if m bentrygrid true dw lvs ex gridlines if m dwoldlistparameters dw m clist post message lvm setextendedlistviewstyle 0 dw m dwoldlistparameters dw cpwsafedlg _setlistparameters lvs_ex_si_report lvs_ex_fullrowselect lvs_ex_oneclickactivate lvs_ex_underlinehot lvs_ex_headerdragdrop lvs_ex_infotip m_bentrygrid lvs_ex_gridlines m_dwoldlistparameters m_clist postmessage lvm_setextendedlistviewstyle m_dwoldlistparameters bool c pw safe dlg removesearchgroup dword dw search group id m mgr get group id pws searchgroup if dw search group id dword max dword dw search items count m mgr get number of items in groupn dw search group id if dw search items count 0 delete only if the group is empty m mgr delete group by id dw search group id remove from password manager update group list show entry details null return true return false cpwsafedlg _removesearchgroup dwsearchgroupid m_mgr getgroupid pws_searchgroup dwsearchgroupid dword_max dwsearchitemscount m_mgr getnumberofitemsingroupn dwsearchgroupid dwsearchitemscount m_mgr deletegroupbyid dwsearchgroupid updategrouplist showentrydetails void c pw safe dlg deletebackupentries dword id group bool b upd false id group m mgr get group id pws backupgroup if id group 0 id group dword max verify m mgr delete group by id id group b upd true id group m mgr get group id pws backupgroup src if id group 0 id group dword max verify m mgr delete group by id id group b upd true if b upd true update group list show entry details null cpwsafedlg _deletebackupentries idgroup bupd idgroup m_mgr getgroupid pws_backupgroup idgroup idgroup dword_max m_mgr deletegroupbyid idgroup bupd idgroup m_mgr getgroupid pws_backupgroup_src idgroup idgroup dword_max m_mgr deletegroupbyid idgroup bupd bupd updategrouplist showentrydetails void c pw safe dlg selchangeview uint uid uint u state bool b checked bool p flag b checked just to avoid null pointer uint u index 0 rect rect u state m menu get menu state uid mf bycommand assert u state 0xffffffff if uid id view title p flag m bshowtitle u index 0 else if uid id view username p flag m bshowusername u index 1 else if uid id view url p flag m bshowurl u index 2 else if uid id view password p flag m bshowpassword u index 3 else if uid id view notes p flag m bshownotes u index 4 else if uid id view creation p flag m bshowcreation u index 5 else if uid id view lastmod p flag m bshowlastmod u index 6 else if uid id view lastaccess p flag m bshowlastaccess u index 7 else if uid id view expire p flag m bshowexpire u index 8 else if uid id view uuid p flag m bshowuuid u index 9 else if uid id view attach p flag m bshowattach u index 10 else assert false return if u state mf checked b checked true else b checked false if b checked true u state mf unchecked toggle p flag false else u state mf checked toggle p flag true m menu check menu item uid mf bycommand u state get client rect rect int n column width rect right rect left get system metrics sm cxvscroll n column width 8 n column width 3 m bshowcolumn u index p flag if p flag true m ncolumnwidths u index n column width else m ncolumnwidths u index 0 refresh password list process resize cpwsafedlg _selchangeview ustate bchecked pflag bchecked uindex ustate m_menu getmenustate mf_bycommand ustate id_view_title pflag m_bshowtitle uindex id_view_username pflag m_bshowusername uindex id_view_url pflag m_bshowurl uindex id_view_password pflag m_bshowpassword uindex id_view_notes pflag m_bshownotes uindex id_view_creation pflag m_bshowcreation uindex id_view_lastmod pflag m_bshowlastmod uindex id_view_lastaccess pflag m_bshowlastaccess uindex id_view_expire pflag m_bshowexpire uindex id_view_uuid pflag m_bshowuuid uindex id_view_attach pflag m_bshowattach uindex ustate mf_checked bchecked bchecked bchecked ustate mf_unchecked pflag ustate mf_checked pflag m_menu checkmenuitem mf_bycommand ustate getclientrect ncolumnwidth getsystemmetrics sm_cxvscroll ncolumnwidth ncolumnwidth m_bshowcolumn uindex pflag pflag m_ncolumnwidths uindex ncolumnwidth m_ncolumnwidths uindex refreshpasswordlist processresize void c pw safe dlg list setentry dword dw insert pos pw entry pwe bool b is new entry pw time pt now lv item lvi dword i t c string str temp dword u image id if dw insert pos dword max b is new entry true dw insert pos dword m clist get item count bool b istan tcscmp pwe psz title pws tan entry 0 false true bool b validtan index true tchar tch if b istan false m btansonly false zero memory lvi sizeof lv item lvi i item int dw insert pos lvi i sub item 0 set expired image if necessary if pwtimecmp pwe t expire pt now 0 u image id 45 else u image id pwe u image id lvi mask lvif text lvif image if m bshowtitle true b istan true if b istan false m bshowtanindices false lvi psz text pwe psz title else str temp pwe psz title if pwe psz additional 0 0 i 0 while 1 tch pwe psz additional i if tch 0 break else if tch t 0 tch t 9 b validtan index false break i if b validtan index true str temp t str temp pwe psz additional str temp t lvi psz text lptstr lpctstr str temp else lvi psz text g pnullstring lvi i image u image id if b is new entry true m clist insert item lvi add else m clist set item lvi set lvi mask lvif text lvi i sub item 1 if m bshowusername true hide usernames behind if the user has selected this option if m buserstars true lvi psz text pwm password string m clist set item lvi else don t hide display them lvi psz text pwe psz user name m clist set item lvi else lvi psz text g pnullstring m clist set item lvi lvi i sub item 2 if m bshowurl true lvi psz text pwe pszurl else lvi psz text g pnullstring m clist set item lvi lvi i sub item 3 if m bshowpassword true hide passwords behind if the user has selected this option if m bpasswordstars true lvi psz text pwm password string m clist set item lvi else don t hide display them m mgr unlock entry password pwe lvi psz text pwe psz password m clist set item lvi m mgr lock entry password pwe else hide passwords completely lvi psz text g pnullstring m clist set item lvi lvi i sub item 4 if m bshownotes true remove newline and break character for better display str temp pwe psz additional for t 0 t dword str temp get length t if str temp get at t t r str temp get at t t n str temp set at t t lvi psz text lptstr lpctstr str temp else lvi psz text g pnullstring m clist set item lvi lvi i sub item 5 if m bshowcreation true pwtimetostring pwe t creation str temp lvi psz text lptstr lpctstr str temp else lvi psz text g pnullstring m clist set item lvi lvi i sub item 6 if m bshowlastmod true pwtimetostring pwe t last mod str temp lvi psz text lptstr lpctstr str temp else lvi psz text g pnullstring m clist set item lvi lvi i sub item 7 if m bshowlastaccess true pwtimetostring pwe t last access str temp lvi psz text lptstr lpctstr str temp else lvi psz text g pnullstring m clist set item lvi lvi i sub item 8 if m bshowexpire true if memcmp pwe t expire g tneverexpire sizeof pw time 0 lvi psz text tchar g psztneverexpires else pwtimetostring pwe t expire str temp the c ole date time class seems to be really slow any better ideas c ole date time dt int pwe t expire sh year int pwe t expire bt month int pwe t expire bt day int pwe t expire bt hour int pwe t expire bt minute int pwe t expire bt second str temp dt format locale nouseroverride lang user default lvi psz text lptstr lpctstr str temp else lvi psz text g pnullstring m clist set item lvi ignore m bshowuuid the uuid field is needed in all cases lvi i sub item 9 uuidtostring pwe uuid str temp lvi psz text lptstr lpctstr str temp m clist set item lvi lvi i sub item 10 if m bshowattach true lvi psz text pwe psz binary desc else lvi psz text g pnullstring m clist set item lvi cpwsafedlg _list_setentry dwinsertpos pw_entry bisnewentry pw_time ptnow lv_item cstring strtemp uimageid dwinsertpos dword_max bisnewentry dwinsertpos m_clist getitemcount bistan _tcscmp psztitle pws_tan_entry bvalidtanindex bistan m_btansonly zeromemory lv_item iitem dwinsertpos isubitem _pwtimecmp texpire ptnow uimageid uimageid uimageid lvif_text lvif_image m_bshowtitle bistan bistan m_bshowtanindices psztext psztitle strtemp psztitle pszadditional pszadditional _t _t bvalidtanindex bvalidtanindex strtemp _t strtemp pszadditional strtemp _t psztext strtemp psztext g_pnullstring iimage uimageid bisnewentry m_clist insertitem m_clist setitem lvif_text isubitem m_bshowusername m_buserstars psztext pwm_password_string m_clist setitem psztext pszusername m_clist setitem psztext g_pnullstring m_clist setitem isubitem m_bshowurl psztext psztext g_pnullstring m_clist setitem isubitem m_bshowpassword m_bpasswordstars psztext pwm_password_string m_clist setitem m_mgr unlockentrypassword psztext pszpassword m_clist setitem m_mgr lockentrypassword psztext g_pnullstring m_clist setitem isubitem m_bshownotes strtemp pszadditional strtemp getlength strtemp getat _t strtemp getat _t strtemp setat _t psztext strtemp psztext g_pnullstring m_clist setitem isubitem m_bshowcreation _pwtimetostring tcreation strtemp psztext strtemp psztext g_pnullstring m_clist setitem isubitem m_bshowlastmod _pwtimetostring tlastmod strtemp psztext strtemp psztext g_pnullstring m_clist setitem isubitem m_bshowlastaccess _pwtimetostring tlastaccess strtemp psztext strtemp psztext g_pnullstring m_clist setitem isubitem m_bshowexpire texpire g_tneverexpire pw_time psztext g_psztneverexpires _pwtimetostring texpire strtemp coledatetime coledatetime texpire shyear texpire btmonth texpire btday texpire bthour texpire btminute texpire btsecond strtemp locale_nouseroverride lang_user_default psztext strtemp psztext g_pnullstring m_clist setitem m_bshowuuid isubitem _uuidtostring strtemp psztext strtemp m_clist setitem isubitem m_bshowattach psztext pszbinarydesc psztext g_pnullstring m_clist setitem dword c pw safe dlg listseltoentryindex dword dw selected lv item lvi dword dw sel tchar tsz temp 40 c string str temp byte a uuid 16 if dw selected dword max dw sel get selected entry else dw sel dw selected if dw sel dword max return dword max zero memory lvi sizeof lv item lvi i item int dw sel lvi i sub item 9 lvi mask lvif text lvi psz text tsz temp lvi cch text max 40 if m clist get item lvi false return dword max str temp lvi psz text stringtouuid str temp a uuid erasec string str temp dw sel m mgr get entry by uuidn a uuid assert dw sel dword max return dw sel cpwsafedlg _listseltoentryindex dwselected lv_item dwsel tsztemp cstring strtemp auuid dwselected dword_max dwsel getselectedentry dwsel dwselected dwsel dword_max dword_max zeromemory lv_item iitem dwsel isubitem lvif_text psztext tsztemp cchtextmax m_clist getitem dword_max strtemp psztext _stringtouuid strtemp auuid erasecstring strtemp dwsel m_mgr getentrybyuuidn auuid dwsel dword_max dwsel dword c pw safe dlg entryuuidtolistpos byte p uuid int i lv item lvi tchar sz temp 66 byte a uuid 16 zero memory lvi sizeof lv item lvi i sub item 9 lvi cch text max 65 lvi psz text sz temp lvi mask lvif text for i 0 i m clist get item count i lvi i item i lvi psz text sz temp m clist get item lvi stringtouuid lvi psz text a uuid if memcmp a uuid p uuid 16 0 return dword i return dword max cpwsafedlg _entryuuidtolistpos puuid lv_item sztemp auuid zeromemory lv_item isubitem cchtextmax psztext sztemp lvif_text m_clist getitemcount iitem psztext sztemp m_clist getitem _stringtouuid psztext auuid auuid puuid dword_max void c pw safe dlg deletetemporaryfiles if callplugins kpm delete temp files pre 0 0 false return if m strtempfile is empty false if secure delete file m strtempfile true m strtempfile empty cpwsafedlg _deletetemporaryfiles _callplugins kpm_delete_temp_files_pre m_strtempfile isempty securedeletefile m_strtempfile m_strtempfile void c pw safe dlg updatetoolbar bool b force update updatetitlebar if m bminimized true m bshowwindow false return c wnd p focus wnd get focus bool b need set focus false dword dw selected entry get selected entry dword dw num selected entries get selected entries count dword dw number of groups m mgr get number of groups dword dw number of entries m mgr get number of entries ulonglong ull list params ull list params ulonglong dw selected entry 0x0000ffff 48 ulonglong dw num selected entries 0x000000ff 40 ulonglong dw number of groups 0x000000ff 32 ulonglong dw number of entries 0x0000ffff 16 ulonglong m blocked 0x00000001 15 ulonglong m bmodified 0x00000001 14 ulonglong m bminimized 0x00000001 13 ull list params ulonglong dw selected entry 34 ulonglong dw num selected entries 2 m blocked 1 m bmodified ulonglong dw number of entries 14 update the rest toolbar entry view only if needed if ull list params m ulllastlistparams b force update false return m ulllastlistparams ull list params c string str status str status format trl total u groups u entries dw number of groups dw number of entries set status text ex str status 0 str status format trl u of u selected dw num selected entries dword max 0 dw num selected entries m bfileopen true m clist get item count 0 set status text ex str status 1 dword dw first entry index listseltoentryindex dw selected entry pw entry p null if dw first entry index dword max p m mgr get entry dw first entry index if p null show entry details p if m bfileopen true utb ensure enabled state m btntbaddentry true utb ensure enabled state m cquickfind true if m bfilereadonly false utb ensure enabled state m btntbsave true else utb ensure enabled state m btntbsave false else utb ensure enabled state m btntbaddentry false utb ensure enabled state m cquickfind false utb ensure enabled state m btntbsave false if m blocked false utb ensure enabled state m btntbnew true utb ensure enabled state m btntbopen true else utb ensure enabled state m btntbnew false utb ensure enabled state m btntbopen false if dw selected entry dword max dw num selected entries 1 utb ensure enabled state m btntbcopyuser true utb ensure enabled state m btntbcopypw true utb ensure enabled state m btntbeditentry true else utb ensure enabled state m btntbcopyuser false utb ensure enabled state m btntbcopypw false utb ensure enabled state m btntbeditentry false if dw selected entry dword max dw num selected entries 1 utb ensure enabled state m btntbdeleteentry true else utb ensure enabled state m btntbdeleteentry false if m bfileopen dw number of entries 0 utb ensure enabled state m btntbfind true else utb ensure enabled state m btntbfind false if m bfileopen m blocked utb ensure enabled state m btntblock true else utb ensure enabled state m btntblock false if p focus wnd null b need set focus true p focus wnd set focus restore the focus cpwsafedlg _updatetoolbar bforceupdate _updatetitlebar m_bminimized m_bshowwindow cwnd pfocuswnd getfocus bneedsetfocus dwselectedentry getselectedentry dwnumselectedentries getselectedentriescount dwnumberofgroups m_mgr getnumberofgroups dwnumberofentries m_mgr getnumberofentries ulllistparams ulllistparams dwselectedentry dwnumselectedentries dwnumberofgroups dwnumberofentries m_blocked m_bmodified m_bminimized ulllistparams dwselectedentry dwnumselectedentries m_blocked m_bmodified dwnumberofentries ulllistparams m_ulllastlistparams bforceupdate m_ulllastlistparams ulllistparams cstring strstatus strstatus dwnumberofgroups dwnumberofentries setstatustextex strstatus strstatus dwnumselectedentries dword_max dwnumselectedentries m_bfileopen m_clist getitemcount setstatustextex strstatus dwfirstentryindex _listseltoentryindex dwselectedentry pw_entry dwfirstentryindex dword_max m_mgr getentry dwfirstentryindex showentrydetails m_bfileopen utb_ensure_enabled_state m_btntbaddentry utb_ensure_enabled_state m_cquickfind m_bfilereadonly utb_ensure_enabled_state m_btntbsave utb_ensure_enabled_state m_btntbsave utb_ensure_enabled_state m_btntbaddentry utb_ensure_enabled_state m_cquickfind utb_ensure_enabled_state m_btntbsave m_blocked utb_ensure_enabled_state m_btntbnew utb_ensure_enabled_state m_btntbopen utb_ensure_enabled_state m_btntbnew utb_ensure_enabled_state m_btntbopen dwselectedentry dword_max dwnumselectedentries utb_ensure_enabled_state m_btntbcopyuser utb_ensure_enabled_state m_btntbcopypw utb_ensure_enabled_state m_btntbeditentry utb_ensure_enabled_state m_btntbcopyuser utb_ensure_enabled_state m_btntbcopypw utb_ensure_enabled_state m_btntbeditentry dwselectedentry dword_max dwnumselectedentries utb_ensure_enabled_state m_btntbdeleteentry utb_ensure_enabled_state m_btntbdeleteentry m_bfileopen dwnumberofentries utb_ensure_enabled_state m_btntbfind utb_ensure_enabled_state m_btntbfind m_bfileopen m_blocked utb_ensure_enabled_state m_btntblock utb_ensure_enabled_state m_btntblock pfocuswnd bneedsetfocus pfocuswnd setfocus void c pw safe dlg updatetitlebar c string str full pwm product name str short pwm product name short c string str str ref if m blocked true str t str trl workspace locked str t str full str str short str else if m bfileopen true str t if m bshowfullpath false str cs file only m strfile else str m strfileabsolute if m bmodified true str t str t str full str str short str this get window text str ref if str ref str full this set window text str full notifyicondata only supports tooltip texts up to 63 characters if str short get length 63 str short str short left 63 m systray set tooltip text str short cpwsafedlg _updatetitlebar cstring strfull pwm_product_name strshort pwm_product_name_short cstring strref m_blocked _t _t strfull strshort m_bfileopen _t m_bshowfullpath csfileonly m_strfile m_strfileabsolute m_bmodified _t _t strfull strshort getwindowtext strref strref strfull setwindowtext strfull strshort getlength strshort strshort m_systray settooltiptext strshort void c pw safe dlg updateguitomanager m mgr m dwlastselectedgroupid get selected group id m mgr m dwlasttopvisiblegroupid m cgroups get item data m cgroups get first visible item dword dw index listseltoentryindex dword m clist get top index if dw index dword max pw entry p en m mgr get entry dw index assert entry p en if p en null memcpy m mgr m alasttopvisibleentryuuid p en uuid 16 dw index listseltoentryindex if dw index dword max pw entry p en2 m mgr get entry dw index assert entry p en2 if p en2 null memcpy m mgr m alastselectedentryuuid p en2 uuid 16 cpwsafedlg _updateguitomanager m_mgr m_dwlastselectedgroupid getselectedgroupid m_mgr m_dwlasttopvisiblegroupid m_cgroups getitemdata m_cgroups getfirstvisibleitem dwindex _listseltoentryindex m_clist gettopindex dwindex dword_max pw_entry pen m_mgr getentry dwindex assert_entry pen pen m_mgr m_alasttopvisibleentryuuid pen dwindex _listseltoentryindex dwindex dword_max pw_entry pen2 m_mgr getentry dwindex assert_entry pen2 pen2 m_mgr m_alastselectedentryuuid pen2 void c pw safe dlg touchgroup dword dw group id bool b edit pw group p group pw time t now p group m mgr get group by id dw group id assert p group null getcurrentpwtime t now p group t last access t now if b edit true p group t last mod t now if m bsaveonlatmod true m bmodified true cpwsafedlg _touchgroup dwgroupid bedit pw_group pgroup pw_time tnow pgroup m_mgr getgroupbyid dwgroupid pgroup _getcurrentpwtime tnow pgroup tlastaccess tnow bedit pgroup tlastmod tnow m_bsaveonlatmod m_bmodified void c pw safe dlg touchentry dword dw list index bool b edit lv item lvi tchar sz temp 1024 c string str temp byte a uuid 16 pw time t now pw entry p entry if dw list index dword m clist get item count return assert dw list index dword max if dw list index dword max return zero memory lvi sizeof lv item lvi i item int dw list index lvi i sub item 9 lvi mask lvif text lvi psz text sz temp lvi cch text max 1024 m clist get item lvi str temp lvi psz text stringtouuid str temp a uuid erasec string str temp p entry m mgr get entry by uuid a uuid assert entry p entry getcurrentpwtime t now p entry t last access t now if b edit true p entry t last mod t now list setentry dw list index p entry false t now if m bsaveonlatmod true m bmodified true cpwsafedlg _touchentry dwlistindex bedit lv_item sztemp cstring strtemp auuid pw_time tnow pw_entry pentry dwlistindex m_clist getitemcount dwlistindex dword_max dwlistindex dword_max zeromemory lv_item iitem dwlistindex isubitem lvif_text psztext sztemp cchtextmax m_clist getitem strtemp psztext _stringtouuid strtemp auuid erasecstring strtemp pentry m_mgr getentrybyuuid auuid assert_entry pentry _getcurrentpwtime tnow pentry tlastaccess tnow bedit pentry tlastmod tnow _list_setentry dwlistindex pentry tnow m_bsaveonlatmod m_bmodified void c pw safe dlg syncsubtree c tree ctrl p tree htreeitem h item bool b gui to mgr htreeitem h assert p tree null if h item null return h h item while 1 if p tree item has children h true syncitem p tree h b gui to mgr syncsubtree p tree p tree get child item h b gui to mgr h p tree get next sibling item h if h null break cpwsafedlg _syncsubtree ctreectrl ptree hitem bguitomgr ptree hitem hitem ptree itemhaschildren _syncitem ptree bguitomgr _syncsubtree ptree ptree getchilditem bguitomgr ptree getnextsiblingitem void c pw safe dlg syncitem c tree ctrl p tree htreeitem h item bool b gui to mgr assert p tree null h item null if p tree null h item null return dword dw group id p tree get item data h item pw group p group m mgr get group by id dw group id if p group null if b gui to mgr true if p tree get item state h item uint max tvis expanded p group dw flags pwgf expanded set bit else p group dw flags pwgf expanded remove bit else if p group dw flags pwgf expanded p tree expand h item tve expand else p tree expand h item tve collapse cpwsafedlg _syncitem ctreectrl ptree hitem bguitomgr ptree hitem ptree hitem dwgroupid ptree getitemdata hitem pw_group pgroup m_mgr getgroupbyid dwgroupid pgroup bguitomgr ptree getitemstate hitem uint_max tvis_expanded pgroup dwflags pwgf_expanded pgroup dwflags pwgf_expanded pgroup dwflags pwgf_expanded ptree hitem tve_expand ptree hitem tve_collapse void c pw safe dlg sortlist dword dw by field bool b auto sort call dword dw group id get selected group id if dw group id dword max return if dw group id m mgr get group id pws searchgroup removesearchgroup m clist delete all items return int n top m clist get top index m mgr sort group dw group id dword dw by field if b auto sort call false m bmodified true update password list updatetoolbar m clist ensure visible m clist get item count 1 false m clist ensure visible n top false cpwsafedlg _sortlist dwbyfield bautosortcall dwgroupid getselectedgroupid dwgroupid dword_max dwgroupid m_mgr getgroupid pws_searchgroup _removesearchgroup m_clist deleteallitems ntop m_clist gettopindex m_mgr sortgroup dwgroupid dwbyfield bautosortcall m_bmodified updatepasswordlist _updatetoolbar m_clist ensurevisible m_clist getitemcount m_clist ensurevisible ntop bool c pw safe dlg checkifcansort if m nautosort 0 return true message box trl auto sorting of the password list is enabled you cannot sort the list manually now trl stop mb iconwarning mb ok return false cpwsafedlg _checkifcansort m_nautosort messagebox mb_iconwarning mb_ok htreeitem c pw safe dlg findselectintree c tree ctrl p tree htreeitem h root dword dw group id htreeitem h assert p tree null if h root null return null h h root while 1 if p tree get item data h dw group id return h if p tree item has children h true htreeitem h sub findselectintree p tree p tree get child item h dw group id if h sub null return h sub h p tree get next sibling item h if h null break return null cpwsafedlg _findselectintree ctreectrl ptree hroot dwgroupid ptree hroot hroot ptree getitemdata dwgroupid ptree itemhaschildren hsub _findselectintree ptree ptree getchilditem dwgroupid hsub hsub ptree getnextsiblingitem bool c pw safe dlg isunsafeallowed if m bdisableunsafeatstart false return true c string str trl unsafe operations are disabled str t r n r n str trl to execute this operation you must enable unsafe operations in the options dialog message box str trl stop mb iconwarning mb ok return false cpwsafedlg _isunsafeallowed m_bdisableunsafeatstart cstring _t messagebox mb_iconwarning mb_ok void c pw safe dlg opendatabase c pw manager p db mgr const tchar psz file const tchar psz password const tchar psz key file bool b open locked lpctstr lp pre select path bool b ignore corrupted notify user activity c string str file str filter str text dword dw flags int n ret idcancel n open attempts n allowed attempts n err const tchar p suffix t c password dlg p dlg pass null pwdb repair info repair info c pw manager p mgr dword dw op flags 0 dword a op params 7 if p db mgr null p mgr m mgr else p mgr p db mgr zero memory repair info sizeof pwdb repair info if b open locked true dw op flags 1 if b ignore corrupted true dw op flags 2 a op params 0 0 currently unused a op params 1 dword p db mgr a op params 2 dword psz file a op params 3 dword psz password a op params 4 dword psz key file a op params 5 dword lp pre select path a op params 6 dw op flags if callplugins kpm opendb pre a op params 0 false return str filter trl password safe files str filter t kdb pwd kdb pwd str filter trl all files str filter t dw flags ofn longnames ofn extensiondifferent ofn explorer 0x00080000 ofn enablesizing 0x00800000 dw flags 0x00080000 0x00800000 dw flags ofn pathmustexist ofn filemustexist ofn hidereadonly c file dialog dlg true null null dw flags str filter this m bdisplaydialog true if psz file null n ret dlg do modal else str file psz file m bdisplaydialog false if psz file null n ret idok if p db mgr null if m bfileopen true on file close if m bfileopen true message box trl first close the open file before opening another one trl password safe mb ok mb iconwarning return if psz file null str file dlg get path name if p db mgr null m strlastdb str file if b open locked true p db mgr null m strfile str file m strfileabsolute get shortest absolute path m strfile c string str extended m blocked true str extended trl unlock workspace str extended t t str extended getcmdaccelext t lock workspace m menu set menu text id file lock str extended mf bycommand set status text ex trl workspace locked m btntblock set tooltip text trl unlock workspace else if psz password null psz key file null n allowed attempts 1 else n allowed attempts 3 for n open attempts 0 n open attempts n allowed attempts n open attempts assert p dlg pass null if p dlg pass null p dlg pass free passwords delete p dlg pass p dlg pass new c password dlg assert p dlg pass null if p dlg pass null continue p dlg pass m bloadmode true p dlg pass m bconfirm false p dlg pass m hwindowicon m hicon p dlg pass m lppreselectpath lp pre select path if psz file null p dlg pass m strdescriptivename dlg get file name else p dlg pass m strdescriptivename cs file only str file if psz password null psz key file null m bdisplaydialog true if p dlg pass do modal idcancel delete p dlg pass p dlg pass null m bdisplaydialog false return m bdisplaydialog false else if psz key file null p dlg pass m bkeyfile true p dlg pass m lpkey tcssafedupalloc psz key file if psz password null p dlg pass m lpkey2 tcssafedupalloc psz password p dlg pass m bkeymethod pwm keymethod and else p dlg pass m bkeymethod pwm keymethod or else psz key file null p dlg pass m bkeyfile false p dlg pass m lpkey tcssafedupalloc psz password p dlg pass m bkeymethod pwm keymethod or if p dlg pass m bkeymethod pwm keymethod or n err p mgr set master key p dlg pass m lpkey p dlg pass m bkeyfile null null false else n err p mgr set master key p dlg pass m lpkey p dlg pass m bkeyfile p dlg pass m lpkey2 null false p dlg pass free passwords delete p dlg pass p dlg pass null if n err pwe success message box pwm formatstaticerror n err 0 trl password safe mb ok mb iconwarning continue if b ignore corrupted true n err p mgr open database str file repair info else n err p mgr open database str file null if b ignore corrupted true c string str repaired pwm formatstaticerror n err pwff no intro c string strr temp trl repair kee pass database file strr temp remove t c string strr title strr temp str repaired t r n r n str repaired trl group strr temp format t u u r n p mgr get number of groups repair info dw original group count str repaired strr temp str repaired trl entry strr temp format t u u r n meta u p mgr get number of entries repair info dw original entry count repair info dw recognized meta stream count repair info dw recognized meta stream count str repaired strr temp message box str repaired strr title mb iconinformation mb ok n err pwe success if n err pwe success message box pwm formatstaticerror n err 0 trl password safe mb iconwarning mb ok else if p db mgr null m bhashvalid sha256 hashfile str file byte m ahashoffile if psz file null m bfilereadonly dlg get read only pref else m bfilereadonly false if filelock islocked str file true c string str message trl the file you are trying to open is locked i e someone else has currently opened the file and is editing it str message t r n r n str message trl open the file in read only mode str message t r n r n str message trl click yes to open the file in read only mode str message t r n str message trl click no to open the file in normal writing mode int n open ret message box str message trl open the file in read only mode mb yesno mb iconquestion if n open ret idyes m bfilereadonly true else m bfilereadonly false filelock lock str file true m nfilerelockcountdown fl time relock after 60 else filelock lock str file true m nfilerelockcountdown fl time relock after 60 m strfile str file m strfileabsolute get shortest absolute path m strfile m bfileopen true m bmodified false m clist enable window true m cgroups enable window true m blocked false p suffix getcmdaccelext t lock workspace str text trl lock workspace if tcslen p suffix 0 str text t t str text p suffix m menu set menu text id file lock str text mf bycommand m btntblock set tooltip text trl lock workspace update group list htreeitem h h groupidtohtreeitem p mgr m dwlastselectedgroupid if h null m cgroups select item h update password list h groupidtohtreeitem p mgr m dwlasttopvisiblegroupid if h null m cgroups select h tvgn firstvisible m cgroups set item state h 0 tvis selected dword dw entry pos entryuuidtolistpos p mgr m alasttopvisibleentryuuid if dw entry pos dword max m clist ensure visible m clist get item count 1 false m clist ensure visible int dw entry pos false dw entry pos entryuuidtolistpos p mgr m alastselectedentryuuid if dw entry pos dword max m clist set item state int dw entry pos lvis selected lvis selected set status text ex trl ready break else if p db mgr null break assert p dlg pass null if p db mgr null if m blocked false m systray set icon m htrayiconnormal if m bautoshowexpired true m bautoshowexpiredsoon true showexpiredentries false m bautoshowexpired m bautoshowexpiredsoon callplugins kpm opendb post 0 0 else m systray set icon m htrayiconlocked updatetoolbar true updates titlebar too else callplugins kpm opendb post 1 0 notify user activity m clist set focus cpwsafedlg _opendatabase cpwmanager pdbmgr pszfile pszpassword pszkeyfile bopenlocked lppreselectpath bignorecorrupted notifyuseractivity cstring strfile strfilter strtext dwflags nret nopenattempts nallowedattempts nerr psuffix _t cpassworddlg pdlgpass pwdb_repair_info repairinfo cpwmanager pmgr dwopflags aopparams pdbmgr pmgr m_mgr pmgr pdbmgr zeromemory repairinfo pwdb_repair_info bopenlocked dwopflags bignorecorrupted dwopflags aopparams aopparams pdbmgr aopparams pszfile aopparams pszpassword aopparams pszkeyfile aopparams lppreselectpath aopparams dwopflags _callplugins kpm_opendb_pre aopparams strfilter strfilter _t strfilter strfilter _t dwflags ofn_longnames ofn_extensiondifferent ofn_explorer ofn_enablesizing dwflags dwflags ofn_pathmustexist ofn_filemustexist ofn_hidereadonly cfiledialog dwflags strfilter m_bdisplaydialog pszfile nret domodal strfile pszfile m_bdisplaydialog pszfile nret pdbmgr m_bfileopen onfileclose m_bfileopen messagebox mb_ok mb_iconwarning pszfile strfile getpathname pdbmgr m_strlastdb strfile bopenlocked pdbmgr m_strfile strfile m_strfileabsolute getshortestabsolutepath m_strfile cstring strextended m_blocked strextended strextended _t strextended _getcmdaccelext _t m_menu setmenutext id_file_lock strextended mf_bycommand setstatustextex m_btntblock settooltiptext pszpassword pszkeyfile nallowedattempts nallowedattempts nopenattempts nopenattempts nallowedattempts nopenattempts pdlgpass pdlgpass pdlgpass freepasswords pdlgpass pdlgpass cpassworddlg pdlgpass pdlgpass pdlgpass m_bloadmode pdlgpass m_bconfirm pdlgpass m_hwindowicon m_hicon pdlgpass m_lppreselectpath lppreselectpath pszfile pdlgpass m_strdescriptivename getfilename pdlgpass m_strdescriptivename csfileonly strfile pszpassword pszkeyfile m_bdisplaydialog pdlgpass domodal pdlgpass pdlgpass m_bdisplaydialog m_bdisplaydialog pszkeyfile pdlgpass m_bkeyfile pdlgpass m_lpkey _tcssafedupalloc pszkeyfile pszpassword pdlgpass m_lpkey2 _tcssafedupalloc pszpassword pdlgpass m_bkeymethod pwm_keymethod_and pdlgpass m_bkeymethod pwm_keymethod_or pszkeyfile pdlgpass m_bkeyfile pdlgpass m_lpkey _tcssafedupalloc pszpassword pdlgpass m_bkeymethod pwm_keymethod_or pdlgpass m_bkeymethod pwm_keymethod_or nerr pmgr setmasterkey pdlgpass m_lpkey pdlgpass m_bkeyfile nerr pmgr setmasterkey pdlgpass m_lpkey pdlgpass m_bkeyfile pdlgpass m_lpkey2 pdlgpass freepasswords pdlgpass pdlgpass nerr pwe_success messagebox pwm_formatstaticerror nerr mb_ok mb_iconwarning bignorecorrupted nerr pmgr opendatabase strfile repairinfo nerr pmgr opendatabase strfile bignorecorrupted cstring strrepaired pwm_formatstaticerror nerr pwff_no_intro cstring strrtemp keepass strrtemp _t cstring strrtitle strrtemp strrepaired _t strrepaired strrtemp _t pmgr getnumberofgroups repairinfo dworiginalgroupcount strrepaired strrtemp strrepaired strrtemp _t nmeta pmgr getnumberofentries repairinfo dworiginalentrycount repairinfo dwrecognizedmetastreamcount repairinfo dwrecognizedmetastreamcount strrepaired strrtemp messagebox strrepaired strrtitle mb_iconinformation mb_ok nerr pwe_success nerr pwe_success messagebox pwm_formatstaticerror nerr mb_iconwarning mb_ok pdbmgr m_bhashvalid sha256_hashfile strfile m_ahashoffile pszfile m_bfilereadonly getreadonlypref m_bfilereadonly filelock_islocked strfile cstring strmessage strmessage _t strmessage strmessage _t strmessage strmessage _t strmessage nopenret messagebox strmessage mb_yesno mb_iconquestion nopenret m_bfilereadonly m_bfilereadonly filelock_lock strfile m_nfilerelockcountdown fl_time_relock_after filelock_lock strfile m_nfilerelockcountdown fl_time_relock_after m_strfile strfile m_strfileabsolute getshortestabsolutepath m_strfile m_bfileopen m_bmodified m_clist enablewindow m_cgroups enablewindow m_blocked psuffix _getcmdaccelext _t strtext _tcslen psuffix strtext _t strtext psuffix m_menu setmenutext id_file_lock strtext mf_bycommand m_btntblock settooltiptext updategrouplist _groupidtohtreeitem pmgr m_dwlastselectedgroupid m_cgroups selectitem updatepasswordlist _groupidtohtreeitem pmgr m_dwlasttopvisiblegroupid m_cgroups tvgn_firstvisible m_cgroups setitemstate tvis_selected dwentrypos _entryuuidtolistpos pmgr m_alasttopvisibleentryuuid dwentrypos dword_max m_clist ensurevisible m_clist getitemcount m_clist ensurevisible dwentrypos dwentrypos _entryuuidtolistpos pmgr m_alastselectedentryuuid dwentrypos dword_max m_clist setitemstate dwentrypos lvis_selected lvis_selected setstatustextex pdbmgr pdlgpass pdbmgr m_blocked m_systray seticon m_htrayiconnormal m_bautoshowexpired m_bautoshowexpiredsoon _showexpiredentries m_bautoshowexpired m_bautoshowexpiredsoon _callplugins kpm_opendb_post m_systray seticon m_htrayiconlocked _updatetoolbar _callplugins kpm_opendb_post notifyuseractivity m_clist setfocus bool c pw safe dlg changemasterkey c pw manager p db mgr bool b create new c password dlg dlg int n confirm attempts bool b success c pw manager p mgr dword dw op flags 0 dword a op params 3 if b create new true dw op flags 1 a op params 0 0 buffer for return value plugins should fill it a op params 1 dword p db mgr a op params 2 dw op flags if callplugins kpm change master key pre a op params 0 false return a op params 0 0 false true if p db mgr null p mgr m mgr else p mgr p db mgr m bdisplaydialog true dlg m bkeymethod pwm keymethod or dlg m bloadmode false dlg m bconfirm false dlg m hwindowicon m hicon dlg m bchanging b create new false true false if dlg do modal idcancel m bdisplaydialog false return false if dlg m bkeyfile false dlg m bkeymethod pwm keymethod and b success false for n confirm attempts 0 n confirm attempts 3 n confirm attempts c password dlg p dlg2 new c password dlg assert p dlg2 null if p dlg2 null continue p dlg2 m bkeymethod pwm keymethod or p dlg2 m bloadmode false p dlg2 m bconfirm true p dlg2 m hwindowicon m hicon p dlg2 m bchanging b create new true false true if p dlg2 do modal idcancel assert p dlg2 m lpkey null p dlg2 m lpkey2 null safe delete p dlg2 m bdisplaydialog false return false if dlg m bkeymethod pwm keymethod or if tcscmp p dlg2 m lpkey dlg m lpkey 0 p dlg2 m bkeyfile true p dlg2 free passwords safe delete p dlg2 message box trl password and repeated password aren t identical trl password safe mb iconwarning continue else dlg m nkeymethod pwm keymethod and if tcscmp p dlg2 m lpkey dlg m lpkey2 0 p dlg2 m bkeyfile true p dlg2 free passwords safe delete p dlg2 message box trl password and repeated password aren t identical trl password safe mb iconwarning continue p dlg2 free passwords safe delete p dlg2 b success true break if b success false dlg free passwords m bdisplaydialog false return false c pw safe appri ri int n err code int n err code2 if dlg m bkeymethod pwm keymethod or n err code p mgr set master key dlg m lpkey dlg m bkeyfile null ri false else assert dlg m bkeyfile true n err code p mgr set master key dlg m lpkey dlg m bkeyfile dlg m lpkey2 ri false if n err code pwe success if dlg m bkeyfile true c string str msg trl a key file already exists on this drive do you want to overwrite or reuse it str msg t r n r n str msg trl click yes to overwrite the key file str msg t r n str msg trl click no to reuse the selected key file for this database str msg t r n str msg trl click cancel to abort changing the key int n msg message box str msg trl overwrite mb iconquestion mb yesnocancel if n msg idyes if dlg m bkeymethod pwm keymethod or n err code2 p mgr set master key dlg m lpkey dlg m bkeyfile null ri true else n err code2 p mgr set master key dlg m lpkey dlg m bkeyfile dlg m lpkey2 ri true if n err code2 pwe success dlg free passwords message box pwm formatstaticerror n err code2 0 trl password safe mb ok mb iconwarning m bdisplaydialog false return false else if n msg idno if dlg m bkeymethod pwm keymethod or n err code2 p mgr set master key dlg m lpkey dlg m bkeyfile null null false else n err code2 p mgr set master key dlg m lpkey dlg m bkeyfile dlg m lpkey2 null false if n err code2 pwe success dlg free passwords message box pwm formatstaticerror n err code2 0 trl password safe mb ok mb iconwarning m bdisplaydialog false return false else dlg free passwords m bdisplaydialog false return false else dlg free passwords message box pwm formatstaticerror n err code 0 trl password safe mb ok mb iconwarning m bdisplaydialog false return false if p db mgr null m bmodified true dlg free passwords if b create new false c string str str trl master key has been changed str t r n r n str trl save the database now in order to get the new key applied message box str trl success mb iconinformation mb ok m bdisplaydialog false return true cpwsafedlg _changemasterkey cpwmanager pdbmgr bcreatenew cpassworddlg nconfirmattempts bsuccess cpwmanager pmgr dwopflags aopparams bcreatenew dwopflags aopparams aopparams pdbmgr aopparams dwopflags _callplugins kpm_change_master_key_pre aopparams aopparams pdbmgr pmgr m_mgr pmgr pdbmgr m_bdisplaydialog m_bkeymethod pwm_keymethod_or m_bloadmode m_bconfirm m_hwindowicon m_hicon m_bchanging bcreatenew domodal m_bdisplaydialog m_bkeyfile m_bkeymethod pwm_keymethod_and bsuccess nconfirmattempts nconfirmattempts nconfirmattempts cpassworddlg pdlg2 cpassworddlg pdlg2 pdlg2 pdlg2 m_bkeymethod pwm_keymethod_or pdlg2 m_bloadmode pdlg2 m_bconfirm pdlg2 m_hwindowicon m_hicon pdlg2 m_bchanging bcreatenew pdlg2 domodal pdlg2 m_lpkey pdlg2 m_lpkey2 safe_delete pdlg2 m_bdisplaydialog m_bkeymethod pwm_keymethod_or _tcscmp pdlg2 m_lpkey m_lpkey pdlg2 m_bkeyfile pdlg2 freepasswords safe_delete pdlg2 messagebox mb_iconwarning m_nkeymethod pwm_keymethod_and _tcscmp pdlg2 m_lpkey m_lpkey2 pdlg2 m_bkeyfile pdlg2 freepasswords safe_delete pdlg2 messagebox mb_iconwarning pdlg2 freepasswords safe_delete pdlg2 bsuccess bsuccess freepasswords m_bdisplaydialog cpwsafeappri nerrcode nerrcode2 m_bkeymethod pwm_keymethod_or nerrcode pmgr setmasterkey m_lpkey m_bkeyfile m_bkeyfile nerrcode pmgr setmasterkey m_lpkey m_bkeyfile m_lpkey2 nerrcode pwe_success m_bkeyfile cstring strmsg strmsg _t strmsg strmsg _t strmsg strmsg _t strmsg nmsg messagebox strmsg mb_iconquestion mb_yesnocancel nmsg m_bkeymethod pwm_keymethod_or nerrcode2 pmgr setmasterkey m_lpkey m_bkeyfile nerrcode2 pmgr setmasterkey m_lpkey m_bkeyfile m_lpkey2 nerrcode2 pwe_success freepasswords messagebox pwm_formatstaticerror nerrcode2 mb_ok mb_iconwarning m_bdisplaydialog nmsg m_bkeymethod pwm_keymethod_or nerrcode2 pmgr setmasterkey m_lpkey m_bkeyfile nerrcode2 pmgr setmasterkey m_lpkey m_bkeyfile m_lpkey2 nerrcode2 pwe_success freepasswords messagebox pwm_formatstaticerror nerrcode2 mb_ok mb_iconwarning m_bdisplaydialog freepasswords m_bdisplaydialog freepasswords messagebox pwm_formatstaticerror nerrcode mb_ok mb_iconwarning m_bdisplaydialog pdbmgr m_bmodified freepasswords bcreatenew cstring _t messagebox mb_iconinformation mb_ok m_bdisplaydialog void c pw safe dlg printgroup dword dw group id notify user activity c pw export c exp pwexport options pwo tchar sz file max path 2 deletetemporaryfiles if m bfileopen false return if isunsafeallowed false return c exp set manager m mgr c exp set new line seq m bwindowsnewline c exp set format pwexp html get temp path max path 2 2 sz file if sz file tcslen sz file 1 t tcscat sz file t tcscat sz file t pwsafetmp html if get export options pwo c exp false return bool b ret b ret c exp export group sz file dw group id pwo null if b ret false message box trl cannot open temporary file for printing trl stop mb ok mb iconwarning return shell execute m hwnd t print sz file null null sw show m strtempfile sz file cpwsafedlg _printgroup dwgroupid notifyuseractivity cpwexport cexp pwexport_options szfile max_path _deletetemporaryfiles m_bfileopen _isunsafeallowed cexp setmanager m_mgr cexp setnewlineseq m_bwindowsnewline cexp setformat pwexp_html gettemppath max_path szfile szfile _tcslen szfile _t _tcscat szfile _t _tcscat szfile _t getexportoptions cexp bret bret cexp exportgroup szfile dwgroupid bret messagebox mb_ok mb_iconwarning shellexecute m_hwnd _t szfile sw_show m_strtempfile szfile void c pw safe dlg find dword dw find group id c find in db dlg dlg dword dw max items pw entry p c string str temp pw time t now dword dw find group index if m bfileopen false return dw max items m mgr get number of entries if dw max items 0 return nothing to search for m bdisplaydialog true if dw find group id dword max dw find group index m mgr get group by idn dw find group id else dw find group index dword max if dw find group index dword max pw group pg m mgr get group dw find group index if pg null dlg m lpgroupname pg psz group name if dlg do modal idok dword dw flags 0 m clist delete all items getcurrentpwtime t now if dlg m btitle true dw flags pwmf title if dlg m busername true dw flags pwmf user if dlg m burl true dw flags pwmf url if dlg m bpassword true dw flags pwmf password if dlg m badditional true dw flags pwmf additional if dlg m bgroupname true dw flags pwmf groupname dword dw 0 dword cnt 0 dword dw group id dword dw group inx create the search group if it doesn t exist already dw group id m mgr get group id pws searchgroup if dw group id dword max pw group pw template pw template psz group name tchar pws searchgroup pw template t creation t now m mgr getneverexpiretime pw template t expire pw template t last access t now pw template t last mod t now pw template u group id 0 0 create new group id pw template u image id 40 40 search icon pw template us level 0 pw template dw flags 0 verify m mgr add group pw template dw group id m mgr get group id pws searchgroup assert dw group id dword max dw group id 0 if dw group id dword max dw group id 0 m bdisplaydialog false return while 1 dw m mgr find dlg m strfind dlg m bcasesensitive dw flags cnt if dw dword max break else p m mgr get entry dw assert entry p if p null break if p u group id dw group id dw group inx m mgr get group by idn p u group id assert dw group inx dword max if dw find group index dword max dw find group index dw group inx if dlg m bexcludebackups true if tcscmp m mgr get group dw group inx psz group name pws backupgroup 0 cnt dw 1 if dword cnt dw max items break continue if tcscmp m mgr get group dw group inx psz group name pws backupgroup src 0 cnt dw 1 if dword cnt dw max items break continue the entry could get reallocated by add entry therefor save it to a local c string object m mgr unlock entry password p str temp p psz password m mgr lock entry password p list setentry m clist get item count p true t now erasec string str temp destroy the plaintext password cnt dw 1 if dword cnt dw max items break groups saveview update group list groups restoreview htreeitem h select groupidtohtreeitem dw group id if h select null m cgroups ensure visible h select m cgroups select item h select m bmodified true show entry details null updatetoolbar m bdisplaydialog false cpwsafedlg _find dwfindgroupid cfindindbdlg dwmaxitems pw_entry cstring strtemp pw_time tnow dwfindgroupindex m_bfileopen dwmaxitems m_mgr getnumberofentries dwmaxitems m_bdisplaydialog dwfindgroupid dword_max dwfindgroupindex m_mgr getgroupbyidn dwfindgroupid dwfindgroupindex dword_max dwfindgroupindex dword_max pw_group m_mgr getgroup dwfindgroupindex m_lpgroupname pszgroupname domodal dwflags m_clist deleteallitems _getcurrentpwtime tnow m_btitle dwflags pwmf_title m_busername dwflags pwmf_user m_burl dwflags pwmf_url m_bpassword dwflags pwmf_password m_badditional dwflags pwmf_additional m_bgroupname dwflags pwmf_groupname dwgroupid dwgroupinx dwgroupid m_mgr getgroupid pws_searchgroup dwgroupid dword_max pw_group pwtemplate pwtemplate pszgroupname pws_searchgroup pwtemplate tcreation tnow m_mgr _getneverexpiretime pwtemplate texpire pwtemplate tlastaccess tnow pwtemplate tlastmod tnow pwtemplate ugroupid pwtemplate uimageid pwtemplate uslevel pwtemplate dwflags m_mgr addgroup pwtemplate dwgroupid m_mgr getgroupid pws_searchgroup dwgroupid dword_max dwgroupid dwgroupid dword_max dwgroupid m_bdisplaydialog m_mgr m_strfind m_bcasesensitive dwflags dword_max m_mgr getentry assert_entry ugroupid dwgroupid dwgroupinx m_mgr getgroupbyidn ugroupid dwgroupinx dword_max dwfindgroupindex dword_max dwfindgroupindex dwgroupinx m_bexcludebackups _tcscmp m_mgr getgroup dwgroupinx pszgroupname pws_backupgroup dwmaxitems _tcscmp m_mgr getgroup dwgroupinx pszgroupname pws_backupgroup_src dwmaxitems addentry cstring m_mgr unlockentrypassword strtemp pszpassword m_mgr lockentrypassword _list_setentry m_clist getitemcount tnow erasecstring strtemp dwmaxitems _groups_saveview updategrouplist _groups_restoreview hselect _groupidtohtreeitem dwgroupid hselect m_cgroups ensurevisible hselect m_cgroups selectitem hselect m_bmodified showentrydetails _updatetoolbar m_bdisplaydialog void c pw safe dlg doquickfind const dword dw flags pwmf title pwmf user pwmf url pwmf password pwmf additional pwmf groupname update data true m clist delete all items pw time t now getcurrentpwtime t now dword dw 0 dword cnt 0 dword dw group id dword dw group inx pw entry p c string str temp dword dw max items m mgr get number of entries create the search group if it doesn t exist already dw group id m mgr get group id pws searchgroup if dw group id dword max pw group pw template pw template psz group name tchar pws searchgroup pw template t creation t now c pw manager getneverexpiretime pw template t expire pw template t last access t now pw template t last mod t now pw template u group id 0 0 create new group id pw template u image id 40 40 search icon pw template us level 0 pw template dw flags 0 verify m mgr add group pw template dw group id m mgr get group id pws searchgroup assert dw group id dword max dw group id 0 if dw group id dword max dw group id 0 return dword dw backup1 m mgr get group id pws backupgroup dword dw backup2 m mgr get group id pws backupgroup src while 1 dw m mgr find m strquickfind false dw flags cnt if dw dword max break else p m mgr get entry dw assert entry p if p null break if p u group id dw group id if m bquickfindincbackup true p u group id dw backup1 p u group id dw backup2 dw group inx m mgr get group by idn p u group id assert dw group inx dword max the entry could get reallocated by add entry therefore save it to a local c string object m mgr unlock entry password p str temp p psz password m mgr lock entry password p list setentry m clist get item count p true t now erasec string str temp destroy the plaintext password cnt dw 1 if dword cnt dw max items break groups saveview update group list groups restoreview htreeitem h select groupidtohtreeitem dw group id if h select null m cgroups ensure visible h select m cgroups select item h select m bmodified true show entry details null updatetoolbar cpwsafedlg _doquickfind dwflags pwmf_title pwmf_user pwmf_url pwmf_password pwmf_additional pwmf_groupname updatedata m_clist deleteallitems pw_time tnow _getcurrentpwtime tnow dwgroupid dwgroupinx pw_entry cstring strtemp dwmaxitems m_mgr getnumberofentries dwgroupid m_mgr getgroupid pws_searchgroup dwgroupid dword_max pw_group pwtemplate pwtemplate pszgroupname pws_searchgroup pwtemplate tcreation tnow cpwmanager _getneverexpiretime pwtemplate texpire pwtemplate tlastaccess tnow pwtemplate tlastmod tnow pwtemplate ugroupid pwtemplate uimageid pwtemplate uslevel pwtemplate dwflags m_mgr addgroup pwtemplate dwgroupid m_mgr getgroupid pws_searchgroup dwgroupid dword_max dwgroupid dwgroupid dword_max dwgroupid dwbackup1 m_mgr getgroupid pws_backupgroup dwbackup2 m_mgr getgroupid pws_backupgroup_src m_mgr m_strquickfind dwflags dword_max m_mgr getentry assert_entry ugroupid dwgroupid m_bquickfindincbackup ugroupid dwbackup1 ugroupid dwbackup2 dwgroupinx m_mgr getgroupbyidn ugroupid dwgroupinx dword_max addentry cstring m_mgr unlockentrypassword strtemp pszpassword m_mgr lockentrypassword _list_setentry m_clist getitemcount tnow erasecstring strtemp dwmaxitems _groups_saveview updategrouplist _groups_restoreview hselect _groupidtohtreeitem dwgroupid hselect m_cgroups ensurevisible hselect m_cgroups selectitem hselect m_bmodified showentrydetails _updatetoolbar void c pw safe dlg showexpiredentries bool b show if none bool b show expired bool b show soon to expire notify user activity c entry list dlg dlg if m bfileopen false return m bdisplaydialog true pw entry pe dword dw date now dw date pw time t now getcurrentpwtime t now dw date now dword t now sh year 16 dword t now bt month 8 dword t now bt day 0xff dlg m pmgr m mgr dlg m bpasswordstars m bpasswordstars dlg m buserstars m buserstars dlg m pimglist m ilicons dlg m strbannertitle trl expired entries dlg m strbannercaption trl this is a list of all expired entries zero memory dlg m auuid 16 if b show expired true b show soon to expire true dlg m ndisplaymode eldmode expsoonexp else if b show expired true dlg m ndisplaymode eldmode expired else if b show soon to expire true dlg m ndisplaymode eldmode soontoexp else assert false m bdisplaydialog false return if b show if none false dword i bool b at least one expired false dword dw invalid group1 m mgr get group id pws backupgroup src dword dw invalid group2 m mgr get group id pws backupgroup for i 0 i m mgr get number of entries i pe m mgr get entry i assert pe null if pe null continue if pe u group id dw invalid group1 pe u group id dw invalid group2 continue if b show expired true if pwtimecmp t now pe t expire 0 b at least one expired true break if b show soon to expire true dw date dword pe t expire sh year 16 dword pe t expire bt month 8 dword pe t expire bt day 0xff if dw date dw date now dw date dw date now pwv soontoexpire days b at least one expired true break if b at least one expired false m bdisplaydialog false return if dlg do modal idok if memcmp dlg m auuid g uuidzero 16 0 pw entry p m mgr get entry by uuid dlg m auuid assert p null if p null update group list htreeitem h groupidtohtreeitem p u group id m cgroups ensure visible h m cgroups select item h update password list dword dw pos m mgr get entry pos in group p assert dw pos dword max m clist ensure visible int dw pos false m clist set item state int dw pos lvis focused lvis selected lvis focused lvis selected m clist set focus notify user activity updatetoolbar m bdisplaydialog false cpwsafedlg _showexpiredentries bshowifnone bshowexpired bshowsoontoexpire notifyuseractivity centrylistdlg m_bfileopen m_bdisplaydialog pw_entry dwdatenow dwdate pw_time tnow _getcurrentpwtime tnow dwdatenow tnow shyear tnow btmonth tnow btday m_pmgr m_mgr m_bpasswordstars m_bpasswordstars m_buserstars m_buserstars m_pimglist m_ilicons m_strbannertitle m_strbannercaption zeromemory m_auuid bshowexpired bshowsoontoexpire m_ndisplaymode eldmode_expsoonexp bshowexpired m_ndisplaymode eldmode_expired bshowsoontoexpire m_ndisplaymode eldmode_soontoexp m_bdisplaydialog bshowifnone batleastoneexpired dwinvalidgroup1 m_mgr getgroupid pws_backupgroup_src dwinvalidgroup2 m_mgr getgroupid pws_backupgroup m_mgr getnumberofentries m_mgr getentry ugroupid dwinvalidgroup1 ugroupid dwinvalidgroup2 bshowexpired _pwtimecmp tnow texpire batleastoneexpired bshowsoontoexpire dwdate texpire shyear texpire btmonth texpire btday dwdate dwdatenow dwdate dwdatenow pwv_soontoexpire_days batleastoneexpired batleastoneexpired m_bdisplaydialog domodal m_auuid g_uuidzero pw_entry m_mgr getentrybyuuid m_auuid updategrouplist _groupidtohtreeitem ugroupid m_cgroups ensurevisible m_cgroups selectitem updatepasswordlist dwpos m_mgr getentryposingroup dwpos dword_max m_clist ensurevisible dwpos m_clist setitemstate dwpos lvis_focused lvis_selected lvis_focused lvis_selected m_clist setfocus notifyuseractivity _updatetoolbar m_bdisplaydialog bool c pw safe dlg parsecommandline c string str lpctstr lp password null lpctstr lp key file null lpctstr lp pre select path null if c pw safe app parse current command line str lp password lp key file lp pre select path false return false if fileaccessible str true opendatabase null str lp password lp key file false lp pre select path false return true cpwsafedlg _parsecommandline cstring lppassword lpkeyfile lppreselectpath cpwsafeapp parsecurrentcommandline lppassword lpkeyfile lppreselectpath _fileaccessible _opendatabase lppassword lpkeyfile lppreselectpath void c pw safe dlg parsespecandsetfont const tchar psz spec hfont h pre hfont m flistfont cdc pdc getdc hdc hdc pdc m hdc c string str font spec str temp logfont lf int n size assert psz spec null if psz spec null releasedc pdc return zero memory lf sizeof logfont if h pre null m flistfont delete object if tcslen psz spec 0 font spec format face size flags str font spec psz spec c string str face str size str flags int n chars str font spec reverse find t int n size end str font spec reverse find t str face str font spec left n chars str size str font spec mid n chars 1 n size end n chars 1 str flags str font spec right 4 n size ttoi str size int n weight fw normal if str flags get at 0 t 1 n weight fw bold byte b italic byte str flags get at 1 t 1 true false byte b underlined byte str flags get at 2 t 1 true false byte b strike out byte str flags get at 3 t 1 true false if n size 0 n size n size if str face get length 32 str face str face left 31 lf lf char set default charset lf lf clip precision clip default precis lf lf escapement 0 lf lf italic b italic lf lf orientation 0 lf lf out precision out default precis lf lf quality default quality lf lf pitch and family default pitch ff dontcare lf lf strike out b strike out lf lf underline b underlined lf lf weight n weight lf lf width 0 tcscpy lf lf face name str face lf lf height mul div n size get device caps hdc logpixelsy 72 m flistfont create font indirect lf else n size 8 m flistfont create font n size 0 0 0 fw normal 0 0 0 ansi charset out default precis clip default precis default quality default pitch ff dontcare t ms shell dlg zero memory lf sizeof logfont m flistfont get log font lf str font spec lf lf face name str font spec t str temp format t d n size str font spec str temp str font spec t if lf lf weight fw bold str font spec t 1 else str font spec t 0 if lf lf italic 0 str font spec t 1 else str font spec t 0 if lf lf underline 0 str font spec t 1 else str font spec t 0 if lf lf strike out 0 str font spec t 1 else str font spec t 0 m strfontspec str font spec m strlistfontface lf lf face name m nlistfontsize n size assert m flistfont m hobject null m cgroups set font m flistfont true m clist set font m flistfont true releasedc pdc cpwsafedlg _parsespecandsetfont pszspec hpre m_flistfont m_hdc cstring strfontspec strtemp nsize pszspec pszspec zeromemory hpre m_flistfont deleteobject _tcslen pszspec strfontspec pszspec cstring strface strsize strflags nchars strfontspec reversefind _t nsizeend strfontspec reversefind _t strface strfontspec nchars strsize strfontspec nchars nsizeend nchars strflags strfontspec nsize _ttoi strsize nweight fw_normal strflags getat _t nweight fw_bold bitalic strflags getat _t bunderlined strflags getat _t bstrikeout strflags getat _t nsize nsize nsize strface getlength strface strface lfcharset default_charset lfclipprecision clip_default_precis lfescapement lfitalic bitalic lforientation lfoutprecision out_default_precis lfquality default_quality lfpitchandfamily default_pitch ff_dontcare lfstrikeout bstrikeout lfunderline bunderlined lfweight nweight lfwidth _tcscpy lffacename strface lfheight muldiv nsize getdevicecaps m_flistfont createfontindirect nsize m_flistfont createfont nsize fw_normal ansi_charset out_default_precis clip_default_precis default_quality default_pitch ff_dontcare _t zeromemory m_flistfont getlogfont strfontspec lffacename strfontspec _t strtemp _t nsize strfontspec strtemp strfontspec _t lfweight fw_bold strfontspec _t strfontspec _t lfitalic strfontspec _t strfontspec _t lfunderline strfontspec _t strfontspec _t lfstrikeout strfontspec _t strfontspec _t m_strfontspec strfontspec m_strlistfontface lffacename m_nlistfontsize nsize m_flistfont m_hobject m_cgroups setfont m_flistfont m_clist setfont m_flistfont void c pw safe dlg showtoolbar bool b show int n command if b show false n command sw hide else n command sw show m btntbnew show window n command m btntbopen show window n command m btntbsave show window n command m btntbaddentry show window n command m btntbeditentry show window n command m btntbdeleteentry show window n command m btntbcopypw show window n command m btntbcopyuser show window n command m btntbfind show window n command m btntblock show window n command m btntbabout show window n command m cquickfind show window n command get dlg item idc static tbsep0 show window n command get dlg item idc static tbsep1 show window n command get dlg item idc static tbsep2 show window n command get dlg item idc static tbsep3 show window n command get dlg item idc static tbsep4 show window n command get dlg item idc static tbsep5 show window n command cpwsafedlg _showtoolbar bshow ncommand bshow ncommand sw_hide ncommand sw_show m_btntbnew showwindow ncommand m_btntbopen showwindow ncommand m_btntbsave showwindow ncommand m_btntbaddentry showwindow ncommand m_btntbeditentry showwindow ncommand m_btntbdeleteentry showwindow ncommand m_btntbcopypw showwindow ncommand m_btntbcopyuser showwindow ncommand m_btntbfind showwindow ncommand m_btntblock showwindow ncommand m_btntbabout showwindow ncommand m_cquickfind showwindow ncommand getdlgitem idc_static_tbsep0 showwindow ncommand getdlgitem idc_static_tbsep1 showwindow ncommand getdlgitem idc_static_tbsep2 showwindow ncommand getdlgitem idc_static_tbsep3 showwindow ncommand getdlgitem idc_static_tbsep4 showwindow ncommand getdlgitem idc_static_tbsep5 showwindow ncommand void c pw safe dlg enableviewmenuitems bc menu p menu int i uint uid id view title u state bool p flag for i 0 i 11 i if i 0 uid id view title p flag m bshowtitle else if i 1 uid id view username p flag m bshowusername else if i 2 uid id view url p flag m bshowurl else if i 3 uid id view password p flag m bshowpassword else if i 4 uid id view notes p flag m bshownotes else if i 5 uid id view creation p flag m bshowcreation else if i 6 uid id view lastmod p flag m bshowlastmod else if i 7 uid id view lastaccess p flag m bshowlastaccess else if i 8 uid id view expire p flag m bshowexpire else if i 9 uid id view uuid p flag m bshowuuid else if i 10 uid id view attach p flag m bshowattach else assert false break u state p flag true mf checked mf unchecked p menu check menu item uid mf bycommand u state cpwsafedlg _enableviewmenuitems bcmenu pmenu id_view_title ustate pflag id_view_title pflag m_bshowtitle id_view_username pflag m_bshowusername id_view_url pflag m_bshowurl id_view_password pflag m_bshowpassword id_view_notes pflag m_bshownotes id_view_creation pflag m_bshowcreation id_view_lastmod pflag m_bshowlastmod id_view_lastaccess pflag m_bshowlastaccess id_view_expire pflag m_bshowexpire id_view_uuid pflag m_bshowuuid id_view_attach pflag m_bshowattach ustate pflag mf_checked mf_unchecked pmenu checkmenuitem mf_bycommand ustate void c pw safe dlg finishdragging bool b dragging image list if m hdragginggroup null if b dragging image list true c image list drag leave null c image list end drag m hdragginggroup null release capture show cursor true m cgroups select drop target null cpwsafedlg _finishdragging bdraggingimagelist m_hdragginggroup bdraggingimagelist cimagelist dragleave cimagelist enddrag m_hdragginggroup releasecapture showcursor m_cgroups selectdroptarget bool c pw safe dlg pre translate message msg p msg assert p msg null if m haccel null c wnd p wnd get focus if p wnd null if p wnd m reentryview m bfileopen false m blocked true if translate accelerator this m hwnd m haccel p msg return true if p msg message wm keydown p msg message wm syskeydown m haccel null c wnd p focus wnd get focus if p focus wnd m reentryview if p msg w param c p msg w param a if translate accelerator this m hwnd m haccel p msg false return true else if p focus wnd m cquickfind if p msg w param c p msg w param a p msg w param v p msg w param x if translate accelerator this m hwnd m haccel p msg false return true else if translate accelerator this m hwnd m haccel p msg false return true if p msg message wm keydown p msg message wm keyup p msg w param vk return if get focus m cquickfind if p msg message wm keydown doquickfind return true also ignores wm keyup sent to the edit control m tip relay event p msg return c dialog pre translate message p msg cpwsafedlg pretranslatemessage pmsg pmsg m_haccel cwnd pwnd getfocus pwnd pwnd m_reentryview m_bfileopen m_blocked translateaccelerator m_hwnd m_haccel pmsg pmsg wm_keydown pmsg wm_syskeydown m_haccel cwnd pfocuswnd getfocus pfocuswnd m_reentryview pmsg wparam pmsg wparam translateaccelerator m_hwnd m_haccel pmsg pfocuswnd m_cquickfind pmsg wparam pmsg wparam pmsg wparam pmsg wparam translateaccelerator m_hwnd m_haccel pmsg translateaccelerator m_hwnd m_haccel pmsg pmsg wm_keydown pmsg wm_keyup pmsg wparam vk_return getfocus m_cquickfind pmsg wm_keydown _doquickfind wm_keyup m_tip relayevent pmsg cdialog pretranslatemessage pmsg void c pw safe dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c pw safe dlg ddx control pdx idc menuline m stcmenuline ddx control pdx idc edit quickfind m cquickfind ddx control pdx idc grouplist m cgroups ddx control pdx idc tb new m btntbnew ddx control pdx idc tb lock m btntblock ddx control pdx idc tb find m btntbfind ddx control pdx idc tb editentry m btntbeditentry ddx control pdx idc tb deleteentry m btntbdeleteentry ddx control pdx idc tb copyuser m btntbcopyuser ddx control pdx idc tb copypw m btntbcopypw ddx control pdx idc tb addentry m btntbaddentry ddx control pdx idc tb about m btntbabout ddx control pdx idc tb save m btntbsave ddx control pdx idc tb open m btntbopen ddx control pdx idc pwlist m clist ddx control pdx idc re entryview m reentryview ddx text pdx idc edit quickfind m strquickfind afx data map cpwsafedlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map cpwsafedlg ddx_control idc_menuline m_stcmenuline ddx_control idc_edit_quickfind m_cquickfind ddx_control idc_grouplist m_cgroups ddx_control idc_tb_new m_btntbnew ddx_control idc_tb_lock m_btntblock ddx_control idc_tb_find m_btntbfind ddx_control idc_tb_editentry m_btntbeditentry ddx_control idc_tb_deleteentry m_btntbdeleteentry ddx_control idc_tb_copyuser m_btntbcopyuser ddx_control idc_tb_copypw m_btntbcopypw ddx_control idc_tb_addentry m_btntbaddentry ddx_control idc_tb_about m_btntbabout ddx_control idc_tb_save m_btntbsave ddx_control idc_tb_open m_btntbopen ddx_control idc_pwlist m_clist ddx_control idc_re_entryview m_reentryview ddx_text idc_edit_quickfind m_strquickfind afx_data_map bool c pw safe dlg on notify wparam w param lparam l param lresult p result msgfilter lp msg filter msgfilter l param enlink pel enlink l param if l param 0 if loword w param idc re entryview lp msg filter nmhdr code en msgfilter lp msg filter msg wm rbuttondown point pt get cursor pos pt assert m pentryviewtrackablemenu null if m pentryviewtrackablemenu null m pentryviewtrackablemenu track popup menu tpm leftalign tpm rightbutton pt x pt y afx get main wnd else if loword w param idc re entryview pel nmhdr code en link pel msg wm lbuttondown charrange cr m reentryview get sel cr push current user selection m reentryview set sel pel chrg c string str selectedurl m reentryview get sel text m reentryview set sel cr pop current user selection dword dw cmp entry index listseltoentryindex dword max pw entry p cmp entry m mgr get entry dw cmp entry index if p cmp entry null if str selectedurl p cmp entry pszurl on pwlist visit url else parse and openurl with entry info str selectedurl p cmp entry else open url ex str selectedurl on pwlist visit url else if loword w param idc re entryview pel msg wm mousemove notify user activity else if w param 0 nmhdr l param code nm rclick point pt pt list get cursor pos pt pt list pt m clist screen to client pt list hdhittestinfo hit test hit test pt x pt list x m clist get scroll pos sb horz hit test pt y pt list y m clist get header ctrl send message hdm hittest 0 lparam hit test if hit test flags hht onheader hht ondivider hht ondivopen hht nowhere 0 m bdisplaydialog true m menucolview load menu idr colview menu m menucolview set menu draw mode bcmenu drawmode xp bcmenu drawmode original m menucolview set select disable mode false m menucolview setxp bitmap3d true m menucolview set bitmap background rgb 255 0 255 m menucolview set icon size 16 16 m menucolview load toolbar idr infoicons idb infoicons ex bc menu psub bc menu m menucolview get sub menu 0 translatemenu psub true null enableviewmenuitems psub psub track popup menu tpm leftalign tpm rightbutton pt x pt y afx get main wnd m menucolview destroy menu m bdisplaydialog false return c dialog on notify w param l param p result cpwsafedlg onnotify wparam lparam presult lpmsgfilter lparam lparam lparam wparam idc_re_entryview lpmsgfilter en_msgfilter lpmsgfilter wm_rbuttondown getcursorpos m_pentryviewtrackablemenu m_pentryviewtrackablemenu m_pentryviewtrackablemenu trackpopupmenu tpm_leftalign tpm_rightbutton afxgetmainwnd wparam idc_re_entryview en_link wm_lbuttondown m_reentryview getsel m_reentryview setsel cstring strselectedurl m_reentryview getseltext m_reentryview setsel dwcmpentryindex _listseltoentryindex dword_max pw_entry pcmpentry m_mgr getentry dwcmpentryindex pcmpentry strselectedurl pcmpentry onpwlistvisiturl parseandopenurlwithentryinfo strselectedurl pcmpentry openurlex strselectedurl onpwlistvisiturl wparam idc_re_entryview wm_mousemove notifyuseractivity wparam lparam nm_rclick ptlist getcursorpos ptlist m_clist screentoclient ptlist hittest hittest ptlist m_clist getscrollpos sb_horz hittest ptlist m_clist getheaderctrl sendmessage hdm_hittest hittest hittest hht_onheader hht_ondivider hht_ondivopen hht_nowhere m_bdisplaydialog m_menucolview loadmenu idr_colview_menu m_menucolview setmenudrawmode bcmenu_drawmode_xp bcmenu_drawmode_original m_menucolview setselectdisablemode m_menucolview setxpbitmap3d m_menucolview setbitmapbackground m_menucolview seticonsize m_menucolview loadtoolbar idr_infoicons idb_infoicons_ex bcmenu bcmenu m_menucolview getsubmenu _translatemenu _enableviewmenuitems trackpopupmenu tpm_leftalign tpm_rightbutton afxgetmainwnd m_menucolview destroymenu m_bdisplaydialog cdialog onnotify wparam lparam presult bool c pw safe dlg on init dialog c dialog on init dialog assert idm aboutbox 0xfff0 idm aboutbox assert idm aboutbox 0xf000 set icon m hicon true set icon m hicon false if m bcheckforinstance true m instancechecker track first instance running srand unsigned int time null m bwindowsnewline true m bfileopen false m bfilereadonly false m blocked false m bmodified false m dwoldlistparameters 0 m bminimized false m bmaximized false m bwasmaximized false m bcachedtoolbarupdate false m bcachedpwlistupdate false m bdragging false m bdisplaydialog false m hdragginggroup null m bdraggingentry false m bmenuexit false m bblockpwlistupdate false m brestartapplication false m mgr getneverexpiretime g tneverexpire m nfilerelockcountdown 1 m btansonly false m dwpwlistmode lvs report m bhashvalid false zero memory m ahashoffile 32 m clist m pparenti this m clist m pbshowcolumns bool m bshowcolumn m cgroups m pparenti this m harrowcursor afx get app load standard cursor idc arrow m hdragleftright afx get app load standard cursor idc sizewe m hdragupdown afx get app load standard cursor idc sizens m menu load menu idr mainmenu load the main menu setup menu style m menu set menu draw mode bcmenu drawmode xp bcmenu drawmode original m menu set select disable mode false m menu setxp bitmap3d true m menu set bitmap background rgb 255 0 255 m menu set icon size 16 16 make up the main menu insert the group list and password list menus to the edit menu bc menu p dest bc menu p src uint i uint u state uid u lastid uint 1 c string str m popmenu load menu idr grouplist menu p src bc menu m popmenu get sub menu 0 assert p src null if p src null p src m popmenu p dest bc menu m menu get sub menu 1 assert p dest null if p dest null p dest m menu p dest append menu mf separator for i 0 i p src get menu item count i uid p src get menu itemid i u state p src get menu state i mf byposition p src get menu text i str mf byposition if str t rearrange continue if str t export to continue if str t find in t his group continue if uid id group movetop uid id group movebottom continue if uid id group moveup uid id group movedown continue if str t pr int group continue if u lastid uid p dest append menu u state uid lptstr lpctstr str u lastid uid m popmenu destroy menu p dest get menu text 0 str mf byposition if str get length 0 p dest delete menu 0 mf byposition if p dest get menu itemid 0 0 p dest delete menu 0 mf byposition m popmenu load menu idr pwlist menu p dest bc menu m menu get sub menu 1 assert p dest null if p dest null p dest m menu p src bc menu m popmenu get sub menu 0 assert p src null if p src null p src m popmenu p dest append menu mf separator for i 0 i p src get menu item count 2 i uid p src get menu itemid i u state p src get menu state i mf byposition p src get menu text i str mf byposition if str t rearrange continue if uid id pwlist movetop uid id pwlist movebottom continue if uid id pwlist moveup uid id pwlist movedown continue if u lastid uid p dest append menu u state uid lptstr lpctstr str u lastid uid m popmenu destroy menu load the translation file c private config c config false tchar sz temp si regsize sz temp 0 0 sz temp 1 0 c config get pwmkey lang sz temp load translation table sz temp g psztneverexpires trl never expires c config get pwmkey pwgen options sz temp if tcslen sz temp 0 c string str options sz temp sz temp 0 0 sz temp 1 0 c config get pwmkey pwgen chars sz temp c string str char set sz temp sz temp 0 0 sz temp 1 0 c config get pwmkey pwgen numchars sz temp if tcslen sz temp 0 c pw generator dlg set options str options str char set uint ttoi sz temp else c pw generator dlg set options c string t 11100000001 c string t 16 c config get pwmkey lastdir sz temp if tcslen sz temp 0 set current directory sz temp c config get pwmkey clipboardmethod sz temp if tcslen sz temp 0 m nclipboardmethod ttoi sz temp else m nclipboardmethod 0 c config get pwmkey clipsecs sz temp if tcslen sz temp 0 m dwclipboardsecs dword ttol sz temp if m dwclipboardsecs 0 m dwclipboardsecs 10 1 if m dwclipboardsecs dword 1 m dwclipboardsecs 10 1 else m dwclipboardsecs 10 1 word wat hot keyvk word t a word wat hot key mod hotkeyf control hotkeyf alt dword dw defaultat hot key dword wat hot key mod 16 dword wat hot keyvk c config get pwmkey autotypehotkey sz temp if tcslen sz temp 0 m dwathotkey dword ttol sz temp else m dwathotkey dw defaultat hot key c config get pwmkey defaultexpire sz temp if tcslen sz temp 0 m dwdefaultexpire dword ttol sz temp else m dwdefaultexpire 0 m bwindowsnewline true assume windows c config get pwmkey newline sz temp if tcsicmp sz temp t unix 0 m bwindowsnewline false c config get pwmkey imgbtns sz temp if tcslen sz temp 0 if tcscmp sz temp t false 0 m bimgbuttons false else m bimgbuttons true else m bimgbuttons true newgui setimgbuttons m bimgbuttons m bdisableunsafe c config get bool pwmkey disableunsafe false m bdisableunsafeatstart m bdisableunsafe c config get pwmkey autosort sz temp if tcslen sz temp 0 m nautosort ttoi sz temp else m nautosort 0 m buseputtyforurls c config get bool pwmkey useputtyforurls false m bsaveonlatmod c config get bool pwmkey saveonlatmod false m bentrygrid c config get bool pwmkey entrygrid false m balwaysontop c config get bool pwmkey alwaystop false m bshowtitle c config get bool pwmkey showtitle true m bshowusername c config get bool pwmkey showuser true m bshowurl c config get bool pwmkey showurl true m bshowpassword c config get bool pwmkey showpass true m bshownotes c config get bool pwmkey shownotes true m bshowcreation c config get bool pwmkey showcreation false m bshowlastmod c config get bool pwmkey showlastmod false m bshowlastaccess c config get bool pwmkey showlastaccess false m bshowexpire c config get bool pwmkey showexpire false m bshowuuid c config get bool pwmkey showuuid false m bshowattach c config get bool pwmkey showattach false m bpasswordstars c config get bool pwmkey hidestars true m buserstars c config get bool pwmkey hideusers false m blockonminimize c config get bool pwmkey lockmin true m bminimizetotray c config get bool pwmkey mintray false m bstartminimized c config get bool pwmkey startminimized false m bcloseminimizes c config get bool pwmkey closemin false m bbackupentries c config get bool pwmkey backupentries true m bsecureedits c config get bool pwmkey secureedits true m bsingleclicktrayicon c config get bool pwmkey singleclicktray false m bautopwgen c config get bool pwmkey autopwgen true m bquickfindincbackup c config get bool pwmkey quickfindincbk true m bdeletebackupsonsave c config get bool pwmkey deletebkonsave false m bdisableautotype c config get bool pwmkey disableautotype false m bcopyurls c config get bool pwmkey copyurls false m bexitinsteadoflockat c config get bool pwmkey exitinsteadlock false m bshowtoolbar c config get bool pwmkey showtoolbar true m bshowfullpath c config get bool pwmkey showfullpath false m bsimpletanview c config get bool pwmkey simpletanview true m bshowtanindices c config get bool pwmkey showtanindices true c config get pwmkey rowcolor sz temp if tcslen sz temp 0 colorref cref colorref ttol sz temp m clist set row color ex cref c config get pwmkey autotypemethod sz temp if tcslen sz temp 0 m nautotypemethod ttoi sz temp else m nautotypemethod atm dropback c config get pwmkey urloverride sz temp if tcslen sz temp 0 m strurloverride sz temp else m strurloverride t m nlocktimedef 1 c config get pwmkey locktimer sz temp if tcslen sz temp 0 m nlocktimedef ttol sz temp m nlockcountdown m nlocktimedef m bautoshowexpired c config get bool pwmkey autoshowexpired false m bautoshowexpiredsoon c config get bool pwmkey autoshowexpireds false m bentryview c config get bool pwmkey entryview true m bcolautosize c config get bool pwmkey colautosize true translate the menu bc menu p sub menu m menu const tchar p suffix t c string str item str new int n item 0 n sub 0 uint nid while 1 if p sub menu get menu string uint n item str item mf byposition false break p suffix getcmdaccelext str item str new trl var str item if tcslen p suffix 0 str new t t str new p suffix nid p sub menu get menu itemid n item if p sub menu modify menu n item mf byposition mf string nid str new false assert false n item p sub menu bc menu m menu get sub menu n sub while 1 translatemenu p sub menu true m bcopyurls p sub menu bc menu m menu get sub menu n sub n sub if p sub menu null break p sub menu bc menu m menu get sub menu trl tools assert p sub menu null if p sub menu null m uoriginalextrasmenuitemcount p sub menu get menu item count else m uoriginalextrasmenuitemcount menu extras itemcount m menu load toolbar idr infoicons idb infoicons ex m bmenu set menu m menu assert m bmenu true rebuild context menus rec cpwsafedlg oninitdialog cdialog oninitdialog idm_aboutbox idm_aboutbox idm_aboutbox seticon m_hicon seticon m_hicon m_bcheckforinstance m_instancechecker trackfirstinstancerunning m_bwindowsnewline m_bfileopen m_bfilereadonly m_blocked m_bmodified m_dwoldlistparameters m_bminimized m_bmaximized m_bwasmaximized m_bcachedtoolbarupdate m_bcachedpwlistupdate m_bdragging m_bdisplaydialog m_hdragginggroup m_bdraggingentry m_bmenuexit m_bblockpwlistupdate m_brestartapplication m_mgr _getneverexpiretime g_tneverexpire m_nfilerelockcountdown m_btansonly m_dwpwlistmode lvs_report m_bhashvalid zeromemory m_ahashoffile m_clist m_pparenti m_clist m_pbshowcolumns m_bshowcolumn m_cgroups m_pparenti m_harrowcursor afxgetapp loadstandardcursor idc_arrow m_hdragleftright afxgetapp loadstandardcursor idc_sizewe m_hdragupdown afxgetapp loadstandardcursor idc_sizens m_menu loadmenu idr_mainmenu m_menu setmenudrawmode bcmenu_drawmode_xp bcmenu_drawmode_original m_menu setselectdisablemode m_menu setxpbitmap3d m_menu setbitmapbackground m_menu seticonsize bcmenu pdest bcmenu psrc ustate ulastid cstring m_popmenu loadmenu idr_grouplist_menu psrc bcmenu m_popmenu getsubmenu psrc psrc psrc m_popmenu pdest bcmenu m_menu getsubmenu pdest pdest pdest m_menu pdest appendmenu mf_separator psrc getmenuitemcount psrc getmenuitemid ustate psrc getmenustate mf_byposition psrc getmenutext mf_byposition _t _t _t id_group_movetop id_group_movebottom id_group_moveup id_group_movedown _t ulastid pdest appendmenu ustate ulastid m_popmenu destroymenu pdest getmenutext mf_byposition getlength pdest deletemenu mf_byposition pdest getmenuitemid pdest deletemenu mf_byposition m_popmenu loadmenu idr_pwlist_menu pdest bcmenu m_menu getsubmenu pdest pdest pdest m_menu psrc bcmenu m_popmenu getsubmenu psrc psrc psrc m_popmenu pdest appendmenu mf_separator psrc getmenuitemcount psrc getmenuitemid ustate psrc getmenustate mf_byposition psrc getmenutext mf_byposition _t id_pwlist_movetop id_pwlist_movebottom id_pwlist_moveup id_pwlist_movedown ulastid pdest appendmenu ustate ulastid m_popmenu destroymenu cprivateconfig cconfig sztemp si_regsize sztemp sztemp cconfig pwmkey_lang sztemp loadtranslationtable sztemp g_psztneverexpires cconfig pwmkey_pwgen_options sztemp _tcslen sztemp cstring stroptions sztemp sztemp sztemp cconfig pwmkey_pwgen_chars sztemp cstring strcharset sztemp sztemp sztemp cconfig pwmkey_pwgen_numchars sztemp _tcslen sztemp cpwgeneratordlg setoptions stroptions strcharset _ttoi sztemp cpwgeneratordlg setoptions cstring _t cstring _t cconfig pwmkey_lastdir sztemp _tcslen sztemp setcurrentdirectory sztemp cconfig pwmkey_clipboardmethod sztemp _tcslen sztemp m_nclipboardmethod _ttoi sztemp m_nclipboardmethod cconfig pwmkey_clipsecs sztemp _tcslen sztemp m_dwclipboardsecs _ttol sztemp m_dwclipboardsecs m_dwclipboardsecs m_dwclipboardsecs m_dwclipboardsecs m_dwclipboardsecs wathotkeyvk _t wathotkeymod hotkeyf_control hotkeyf_alt dwdefaultathotkey wathotkeymod wathotkeyvk cconfig pwmkey_autotypehotkey sztemp _tcslen sztemp m_dwathotkey _ttol sztemp m_dwathotkey dwdefaultathotkey cconfig pwmkey_defaultexpire sztemp _tcslen sztemp m_dwdefaultexpire _ttol sztemp m_dwdefaultexpire m_bwindowsnewline cconfig pwmkey_newline sztemp _tcsicmp sztemp _t m_bwindowsnewline cconfig pwmkey_imgbtns sztemp _tcslen sztemp _tcscmp sztemp _t m_bimgbuttons m_bimgbuttons m_bimgbuttons newgui_setimgbuttons m_bimgbuttons m_bdisableunsafe cconfig getbool pwmkey_disableunsafe m_bdisableunsafeatstart m_bdisableunsafe cconfig pwmkey_autosort sztemp _tcslen sztemp m_nautosort _ttoi sztemp m_nautosort m_buseputtyforurls cconfig getbool pwmkey_useputtyforurls m_bsaveonlatmod cconfig getbool pwmkey_saveonlatmod m_bentrygrid cconfig getbool pwmkey_entrygrid m_balwaysontop cconfig getbool pwmkey_alwaystop m_bshowtitle cconfig getbool pwmkey_showtitle m_bshowusername cconfig getbool pwmkey_showuser m_bshowurl cconfig getbool pwmkey_showurl m_bshowpassword cconfig getbool pwmkey_showpass m_bshownotes cconfig getbool pwmkey_shownotes m_bshowcreation cconfig getbool pwmkey_showcreation m_bshowlastmod cconfig getbool pwmkey_showlastmod m_bshowlastaccess cconfig getbool pwmkey_showlastaccess m_bshowexpire cconfig getbool pwmkey_showexpire m_bshowuuid cconfig getbool pwmkey_showuuid m_bshowattach cconfig getbool pwmkey_showattach m_bpasswordstars cconfig getbool pwmkey_hidestars m_buserstars cconfig getbool pwmkey_hideusers m_blockonminimize cconfig getbool pwmkey_lockmin m_bminimizetotray cconfig getbool pwmkey_mintray m_bstartminimized cconfig getbool pwmkey_startminimized m_bcloseminimizes cconfig getbool pwmkey_closemin m_bbackupentries cconfig getbool pwmkey_backupentries m_bsecureedits cconfig getbool pwmkey_secureedits m_bsingleclicktrayicon cconfig getbool pwmkey_singleclicktray m_bautopwgen cconfig getbool pwmkey_autopwgen m_bquickfindincbackup cconfig getbool pwmkey_quickfindincbk m_bdeletebackupsonsave cconfig getbool pwmkey_deletebkonsave m_bdisableautotype cconfig getbool pwmkey_disableautotype m_bcopyurls cconfig getbool pwmkey_copyurls m_bexitinsteadoflockat cconfig getbool pwmkey_exitinsteadlock m_bshowtoolbar cconfig getbool pwmkey_showtoolbar m_bshowfullpath cconfig getbool pwmkey_showfullpath m_bsimpletanview cconfig getbool pwmkey_simpletanview m_bshowtanindices cconfig getbool pwmkey_showtanindices cconfig pwmkey_rowcolor sztemp _tcslen sztemp _ttol sztemp m_clist setrowcolorex cconfig pwmkey_autotypemethod sztemp _tcslen sztemp m_nautotypemethod _ttoi sztemp m_nautotypemethod atm_dropback cconfig pwmkey_urloverride sztemp _tcslen sztemp m_strurloverride sztemp m_strurloverride _t m_nlocktimedef cconfig pwmkey_locktimer sztemp _tcslen sztemp m_nlocktimedef _ttol sztemp m_nlockcountdown m_nlocktimedef m_bautoshowexpired cconfig getbool pwmkey_autoshowexpired m_bautoshowexpiredsoon cconfig getbool pwmkey_autoshowexpireds m_bentryview cconfig getbool pwmkey_entryview m_bcolautosize cconfig getbool pwmkey_colautosize bcmenu psubmenu m_menu psuffix _t cstring stritem strnew nitem nsub psubmenu getmenustring nitem stritem mf_byposition psuffix _getcmdaccelext stritem strnew trl_var stritem _tcslen psuffix strnew _t strnew psuffix psubmenu getmenuitemid nitem psubmenu modifymenu nitem mf_byposition mf_string strnew nitem psubmenu bcmenu m_menu getsubmenu nsub _translatemenu psubmenu m_bcopyurls psubmenu bcmenu m_menu getsubmenu nsub nsub psubmenu psubmenu bcmenu m_menu getsubmenu psubmenu psubmenu m_uoriginalextrasmenuitemcount psubmenu getmenuitemcount m_uoriginalextrasmenuitemcount menu_extras_itemcount m_menu loadtoolbar idr_infoicons idb_infoicons_ex m_bmenu setmenu m_menu m_bmenu rebuildcontextmenus void c pw safe dlg on sys command uint nid lparam l param bool m brestore false if m bdisplaydialog true return no dialog must be displayed at this time map close button to minimize button if the user wants this if nid sc close m bcloseminimizes true send message wm syscommand sc minimize 0 return if nid sc maximize m bwasmaximized true else if nid sc restore m bmaximized true m bwasmaximized false else if nid sc restore m bminimized false m bwasmaximized false if nid 0xfff0 idm aboutbox c about dlg dlg about dlg about do modal else if nid sc minimize if m bminimizetotray true m bshowwindow false m systray minimise to tray this else c dialog on sys command nid l param else if nid sc restore if m bminimizetotray true m bminimized true m systray maximise from tray this m bshowwindow true else c dialog on sys command nid l param else c dialog on sys command nid l param if nid sc maximize m bminimized false m bmaximized true else if nid sc restore if m blocked true on file lock m bminimized false else if nid sc minimize if m blocked false m blockonminimize true on file lock lock or unlock toggle lock state was the locking successful if not restore window if m bfileopen true m blocked false nid sc minimize m brestore true m bminimized true windowplacement wp wp length sizeof windowplacement get window placement wp m bmaximized wp show cmd sw showmaximized true false updatetoolbar if m brestore true send message wm syscommand sc restore 0 if m brestore true show window sw restore cpwsafedlg onsyscommand lparam m_brestore m_bdisplaydialog sc_close m_bcloseminimizes sendmessage wm_syscommand sc_minimize sc_maximize m_bwasmaximized sc_restore m_bmaximized m_bwasmaximized sc_restore m_bminimized m_bwasmaximized idm_aboutbox caboutdlg dlgabout dlgabout domodal sc_minimize m_bminimizetotray m_bshowwindow m_systray minimisetotray cdialog onsyscommand lparam sc_restore m_bminimizetotray m_bminimized m_systray maximisefromtray m_bshowwindow cdialog onsyscommand lparam cdialog onsyscommand lparam sc_maximize m_bminimized m_bmaximized sc_restore m_blocked onfilelock m_bminimized sc_minimize m_blocked m_blockonminimize onfilelock m_bfileopen m_blocked sc_minimize m_brestore m_bminimized getwindowplacement m_bmaximized showcmd sw_showmaximized _updatetoolbar m_brestore sendmessage wm_syscommand sc_restore m_brestore showwindow sw_restore void c pw safe dlg on paint if is iconic c paintdc dc this send message wm iconerasebkgnd wparam dc get safe hdc 0 int cx icon get system metrics sm cxicon int cy icon get system metrics sm cyicon c rect rect get client rect rect int x rect width cx icon 1 2 int y rect height cy icon 1 2 dc draw icon x y m hicon else c dialog on paint cpwsafedlg onpaint isiconic cpaintdc sendmessage wm_iconerasebkgnd getsafehdc cxicon getsystemmetrics sm_cxicon cyicon getsystemmetrics sm_cyicon crect getclientrect cxicon cyicon drawicon m_hicon cdialog onpaint hcursor c pw safe dlg on query drag icon return hcursor m hicon cpwsafedlg onquerydragicon m_hicon void c pw safe dlg on size uint n type int cx int cy if cx 314 cx 314 minimum sizes if cy 207 cy 207 c dialog on size n type cx cy process resize cpwsafedlg onsize ntype cdialog onsize ntype processresize void c pw safe dlg on sizing uint n side lprect lp rect if lp rect right lp rect left 314 lp rect right 314 lp rect left if lp rect bottom lp rect top 207 lp rect bottom 207 lp rect top c dialog on sizing n side lp rect process resize cpwsafedlg onsizing nside lprect lprect lprect lprect lprect lprect lprect lprect lprect cdialog onsizing nside lprect processresize void c pw safe dlg on measure item int nid ctl lpmeasureitemstruct lp measure item struct bool setflag false if lp measure item struct ctl type odt menu if is menu hmenu lp measure item struct itemid bc menu is menu hmenu lp measure item struct itemid m menu measure item lp measure item struct setflag true if setflag c dialog on measure item nid ctl lp measure item struct cpwsafedlg onmeasureitem nidctl lpmeasureitemstruct lpmeasureitemstruct ctltype odt_menu ismenu lpmeasureitemstruct bcmenu ismenu lpmeasureitemstruct m_menu measureitem lpmeasureitemstruct cdialog onmeasureitem nidctl lpmeasureitemstruct lresult c pw safe dlg on menu char uint n char uint n flags c menu p menu lresult lresult 0 if bc menu is menu p menu lresult bc menu find keyboard shortcut n char n flags p menu else lresult c dialog on menu char n char n flags p menu return lresult cpwsafedlg onmenuchar nchar nflags cmenu pmenu bcmenu ismenu pmenu bcmenu findkeyboardshortcut nchar nflags pmenu cdialog onmenuchar nchar nflags pmenu void c pw safe dlg on init menu popup c menu p popup menu uint n index bool b sys menu notify user activity m dwlastfirstselecteditem get selected entry m dwlastnumselecteditems get selected entries count m hlastselectedgroup m cgroups get selected item c menu p m menu get sub menu trl tools if p p popup menu rebuild plugin menu callplugins kpm init menu popup 0 0 c dialog on init menu popup p popup menu n index b sys menu on update flush p popup menu if b sys menu if bc menu is menu p popup menu bc menu update menu p popup menu cpwsafedlg oninitmenupopup cmenu ppopupmenu nindex bsysmenu notifyuseractivity m_dwlastfirstselecteditem getselectedentry m_dwlastnumselecteditems getselectedentriescount m_hlastselectedgroup m_cgroups getselecteditem cmenu m_menu getsubmenu ppopupmenu rebuildpluginmenu _callplugins kpm_init_menu_popup cdialog oninitmenupopup ppopupmenu nindex bsysmenu onupdateflush ppopupmenu bsysmenu bcmenu ismenu ppopupmenu bcmenu updatemenu ppopupmenu void c pw safe dlg onok notify user activity ignore enter in dialog clean up c dialog onok cpwsafedlg notifyuseractivity cleanup cdialog void c pw safe dlg on cancel notify user activity if m hdragginggroup null send message wm cancelmode return are we called because of an esc key press if get key state 27 0x8000 0 if m blocked false on file lock return if m bmenuexit false m bcloseminimizes true return if callplugins kpm wm cancel 0 0 false return m bexiting true on file close if m bfileopen true m bexiting false return clean up c dialog on cancel cpwsafedlg oncancel notifyuseractivity m_hdragginggroup sendmessage wm_cancelmode getkeystate m_blocked onfilelock m_bmenuexit m_bcloseminimizes _callplugins kpm_wm_cancel m_bexiting onfileclose m_bfileopen m_bexiting cleanup cdialog oncancel void c pw safe dlg on file exit notify user activity if callplugins kpm file exit pre 0 0 false return m bmenuexit true on cancel m bmenuexit false cpwsafedlg onfileexit notifyuseractivity _callplugins kpm_file_exit_pre m_bmenuexit oncancel m_bmenuexit void c pw safe dlg on info about notify user activity m bdisplaydialog true c about dlg dlg if callplugins kpm info about pre 0 0 false m bdisplaydialog false return dlg do modal m bdisplaydialog false cpwsafedlg oninfoabout notifyuseractivity m_bdisplaydialog caboutdlg _callplugins kpm_info_about_pre m_bdisplaydialog domodal m_bdisplaydialog void c pw safe dlg on safe add group notify user activity c string str group name c add group dlg dlg pw group pw template pw time pw time if m bfileopen false return m bdisplaydialog true dlg m niconid 48 dlg m strgroupname empty dlg m pparentimagelist m ilicons dlg m beditmode false if callplugins kpm group add pre 0 0 false m bdisplaydialog false return if dlg do modal idok getcurrentpwtime pw time pw template psz group name lptstr lpctstr dlg m strgroupname pw template t creation pw time m mgr getneverexpiretime pw template t expire pw template t last access pw time pw template t last mod pw time pw template u group id 0 0 create new group pw template u image id dword dlg m niconid pw template us level 0 pw template dw flags 0 if callplugins kpm group add pw template 0 false m bdisplaydialog false return verify m mgr add group pw template update group list htreeitem h last getlastgroupitem m cgroups assert h last null we have added a group there must be at least one m cgroups ensure visible h last m cgroups select item h last update password list m clist set focus dlg m strgroupname empty m bmodified true updatetoolbar m bdisplaydialog false cpwsafedlg onsafeaddgroup notifyuseractivity cstring strgroupname caddgroupdlg pw_group pwtemplate pw_time pwtime m_bfileopen m_bdisplaydialog m_niconid m_strgroupname m_pparentimagelist m_ilicons m_beditmode _callplugins kpm_group_add_pre m_bdisplaydialog domodal _getcurrentpwtime pwtime pwtemplate pszgroupname m_strgroupname pwtemplate tcreation pwtime m_mgr _getneverexpiretime pwtemplate texpire pwtemplate tlastaccess pwtime pwtemplate tlastmod pwtime pwtemplate ugroupid pwtemplate uimageid m_niconid pwtemplate uslevel pwtemplate dwflags _callplugins kpm_group_add pwtemplate m_bdisplaydialog m_mgr addgroup pwtemplate updategrouplist hlast _getlastgroupitem m_cgroups hlast m_cgroups ensurevisible hlast m_cgroups selectitem hlast updatepasswordlist m_clist setfocus m_strgroupname m_bmodified _updatetoolbar m_bdisplaydialog void c pw safe dlg on view hide stars notify user activity uint u state bool b checked int n item lv item lvi if callplugins kpm view hide stars pre 0 0 false return if m bpasswordstars true isunsafeallowed false return u state m menu get menu state id view hidestars mf bycommand assert u state 0xffffffff if u state mf checked b checked true else b checked false if b checked true u state mf unchecked toggle m bpasswordstars false else u state mf checked toggle m bpasswordstars true m menu check menu item id view hidestars mf bycommand u state if m bpasswordstars true zero memory lvi sizeof lv item lvi mask lvif text lvi i sub item 3 lvi psz text pwm password string for n item 0 n item m clist get item count n item lvi i item n item m clist set item lvi else refresh password list refresh list based on uui ds m bcachedtoolbarupdate true updatetoolbar true cpwsafedlg onviewhidestars notifyuseractivity ustate bchecked nitem lv_item _callplugins kpm_view_hide_stars_pre m_bpasswordstars _isunsafeallowed ustate m_menu getmenustate id_view_hidestars mf_bycommand ustate ustate mf_checked bchecked bchecked bchecked ustate mf_unchecked m_bpasswordstars ustate mf_checked m_bpasswordstars m_menu checkmenuitem id_view_hidestars mf_bycommand ustate m_bpasswordstars zeromemory lv_item lvif_text isubitem psztext pwm_password_string nitem nitem m_clist getitemcount nitem iitem nitem m_clist setitem refreshpasswordlist uuids m_bcachedtoolbarupdate _updatetoolbar void c pw safe dlg on pwlist add notify user activity c add entry dlg dlg dword u group id get selected group id pw entry pw template pw time t now dword dw initial group id byte a uuid 16 if m bfileopen false return if u group id dword max return no group selected or other error m bdisplaydialog true dlg m pmgr m mgr dlg m dwentryindex dword max dlg m pparenticons m ilicons dlg m bstars m bpasswordstars dlg m ngroupid int m mgr get group by idn u group id m ngroupid of the dialog is an index not an id dlg m niconid 0 dlg m beditmode false dlg m dwdefaultexpire m dwdefaultexpire dlg m bautopwgen m bautopwgen dw initial group u group id id if m dwdefaultexpire 0 m mgr getneverexpiretime dlg m texpire else c time t c time get current time t c time span long m dwdefaultexpire 0 0 0 dlg m texpire bt day byte t get day dlg m texpire bt hour byte t get hour dlg m texpire bt minute byte t get minute dlg m texpire bt month byte t get month dlg m texpire bt second byte t get second dlg m texpire sh year ushort t get year if callplugins kpm add entry pre 0 0 false m bdisplaydialog false return if dlg do modal idok assert dlg m lppassword null if dlg m lppassword null dlg m lppassword new tchar 2 dlg m lppassword 0 0 assert dlg m lprepeatpw null if dlg m lprepeatpw null dlg m lprepeatpw new tchar 2 dlg m lprepeatpw 0 0 getcurrentpwtime t now memset pw template 0 sizeof pw entry pw template psz additional tchar lpctstr dlg m strnotes pw template psz password dlg m lppassword pw template psz title tchar lpctstr dlg m strtitle pw template pszurl tchar lpctstr dlg m strurl pw template psz user name tchar lpctstr dlg m strusername pw template t creation t now pw template t expire dlg m texpire pw template t last access t now pw template t last mod t now pw template u group id m mgr get group id by index dword dlg m ngroupid pw template u image id dword dlg m niconid pw template u password len dword tcslen pw template psz password pw template psz binary desc t if callplugins kpm add entry pw template 0 false m bdisplaydialog false return add the entry to the password manager verify m mgr add entry pw template c secure edit ex delete password dlg m lppassword dlg m lppassword null c secure edit ex delete password dlg m lprepeatpw dlg m lprepeatpw null pw entry p new m mgr get last edited entry int n attach len dlg m strattachment get length int n escape len int tcslen pws new attachment memcpy a uuid p new uuid 16 if n attach len n escape len if dlg m strattachment left tcslen pws new attachment c string pws new attachment m mgr attach file as binary data p new dlg m strattachment right dlg m strattachment get length tcslen pws new attachment add the password to the gui but only if it s visible if p new u group id dw initial group dw initial group is an id list setentry dword max p new true t now no unlock needed sortlistifautosort adjust pw list mode adjust column widths if m nautosort 0 m clist ensure visible m clist get item count 1 false m clist set item state m clist get item count 1 lvis selected lvis selected else dword dw entryuuidtolistpos a uuid assert dw dword max if dw dword max m clist ensure visible int dw false m clist set item state int dw lvis selected lvis selected m bmodified true haven t we cleanup dialog data erasec string dlg m strtitle erasec string dlg m strusername erasec string dlg m strurl erasec string dlg m strnotes erasec string dlg m strattachment updatetoolbar m bdisplaydialog false cpwsafedlg onpwlistadd notifyuseractivity caddentrydlg ugroupid getselectedgroupid pw_entry pwtemplate pw_time tnow dwinitialgroup auuid m_bfileopen ugroupid dword_max m_bdisplaydialog m_pmgr m_mgr m_dwentryindex dword_max m_pparenticons m_ilicons m_bstars m_bpasswordstars m_ngroupid m_mgr getgroupbyidn ugroupid m_ngroupid m_niconid m_beditmode m_dwdefaultexpire m_dwdefaultexpire m_bautopwgen m_bautopwgen dwinitialgroup ugroupid m_dwdefaultexpire m_mgr _getneverexpiretime m_texpire ctime ctime getcurrenttime ctimespan m_dwdefaultexpire m_texpire btday getday m_texpire bthour gethour m_texpire btminute getminute m_texpire btmonth getmonth m_texpire btsecond getsecond m_texpire shyear getyear _callplugins kpm_add_entry_pre m_bdisplaydialog domodal m_lppassword m_lppassword m_lppassword m_lppassword m_lprepeatpw m_lprepeatpw m_lprepeatpw m_lprepeatpw _getcurrentpwtime tnow pwtemplate pw_entry pwtemplate pszadditional m_strnotes pwtemplate pszpassword m_lppassword pwtemplate psztitle m_strtitle pwtemplate m_strurl pwtemplate pszusername m_strusername pwtemplate tcreation tnow pwtemplate texpire m_texpire pwtemplate tlastaccess tnow pwtemplate tlastmod tnow pwtemplate ugroupid m_mgr getgroupidbyindex m_ngroupid pwtemplate uimageid m_niconid pwtemplate upasswordlen _tcslen pwtemplate pszpassword pwtemplate pszbinarydesc _t _callplugins kpm_add_entry pwtemplate m_bdisplaydialog m_mgr addentry pwtemplate csecureeditex deletepassword m_lppassword m_lppassword csecureeditex deletepassword m_lprepeatpw m_lprepeatpw pw_entry pnew m_mgr getlasteditedentry nattachlen m_strattachment getlength nescapelen _tcslen pws_new_attachment auuid pnew nattachlen nescapelen m_strattachment _tcslen pws_new_attachment cstring pws_new_attachment m_mgr attachfileasbinarydata pnew m_strattachment m_strattachment getlength _tcslen pws_new_attachment pnew ugroupid dwinitialgroup dwinitialgroup _list_setentry dword_max pnew tnow _sortlistifautosort adjustpwlistmode adjustcolumnwidths m_nautosort m_clist ensurevisible m_clist getitemcount m_clist setitemstate m_clist getitemcount lvis_selected lvis_selected _entryuuidtolistpos auuid dword_max dword_max m_clist ensurevisible m_clist setitemstate lvis_selected lvis_selected m_bmodified erasecstring m_strtitle erasecstring m_strusername erasecstring m_strurl erasecstring m_strnotes erasecstring m_strattachment _updatetoolbar m_bdisplaydialog void c pw safe dlg on pwlist edit notify user activity dword dw entry index pw entry p entry c add entry dlg dlg pw entry pw template pw time t now dword dw new group id bool b need full update false b need group update false int n modify level 0 dword dw selected entry get selected entry byte a uuid 16 pw entry pwe backup bool b do backup false if m bfileopen false return assert dw selected entry dword max if dw selected entry dword max return dw entry index listseltoentryindex dw selected entry assert dw entry index dword max if dw entry index dword max return p entry m mgr get entry dw entry index assert entry p entry if p entry null return m bdisplaydialog true dlg m pmgr m mgr dlg m dwentryindex dw entry index dlg m pparenticons m ilicons dlg m beditmode true dlg m bstars m bpasswordstars dlg m dwdefaultexpire m dwdefaultexpire dlg m ngroupid int m mgr get group by idn p entry u group id id to index dlg m strtitle p entry psz title dlg m strusername p entry psz user name dlg m strurl p entry pszurl dlg m strnotes p entry psz additional dlg m strattachment p entry psz binary desc copy binary description dlg m niconid int p entry u image id dlg m texpire p entry t expire copy expiration time m mgr unlock entry password p entry we must unlock the entry otherwise we cannot access the password dlg m lppassword tcssafedupalloc p entry psz password dlg m lprepeatpw tcssafedupalloc p entry psz password m mgr lock entry password p entry if callplugins kpm edit entry pre 0 0 false m bdisplaydialog false return if dlg do modal idok m mgr unlock entry password p entry assert entry p entry if dlg m strtitle p entry psz title n modify level 2 else if dlg m strusername p entry psz user name n modify level 2 else if dlg m strurl p entry pszurl n modify level 2 else if dlg m strnotes p entry psz additional n modify level 2 else if dlg m strattachment p entry psz binary desc n modify level 2 else if pwtimecmp dlg m texpire p entry t expire 0 n modify level 2 else if tcscmp dlg m lppassword p entry psz password 0 n modify level 2 else if dlg m ngroupid int m mgr get group by idn p entry u group id n modify level 1 else if dlg m niconid int p entry u image id n modify level 1 if n modify level 2 m bbackupentries true b do backup m mgr mem alloc copy entry p entry pwe backup m mgr lock entry password p entry pw template p entry getcurrentpwtime t now pw template psz additional tchar lpctstr dlg m strnotes pw template psz password dlg m lppassword pw template psz title tchar lpctstr dlg m strtitle pw template pszurl tchar lpctstr dlg m strurl pw template psz user name tchar lpctstr dlg m strusername pw template t creation p entry t creation pw template t expire dlg m texpire pw template t last access t now pw template t last mod t now pw template u image id dword dlg m niconid pw template u password len dword tcslen pw template psz password if the entry has been moved to a different group a full update of the list is required dw new group id m mgr get group id by index dword dlg m ngroupid if dw new group id pw template u group id b need full update true pw template u group id dw new group id verify m mgr set entry dw entry index pw template c secure edit ex delete password dlg m lppassword dlg m lppassword null c secure edit ex delete password dlg m lprepeatpw dlg m lprepeatpw null int n attach len dlg m strattachment get length int n escape len int tcslen pws new attachment if n attach len n escape len dlg m strattachment c string pws new attachment m mgr remove binary data m mgr get entry dw entry index else if n attach len n escape len if dlg m strattachment left int tcslen pws new attachment c string pws new attachment m mgr attach file as binary data m mgr get entry dw entry index dlg m strattachment right dlg m strattachment get length int tcslen pws new attachment pw entry p base m mgr get entry dw entry index assert entry p base memcpy a uuid p base uuid 16 if b do backup true if m mgr backup entry pwe backup b need group update false message box trl failed to create backup of this entry trl an error occured mb iconwarning mb ok m mgr mem free entry pwe backup if b need group update true groups saveview true update group list groups restoreview if b need full update true full list update needed list saveview update password list refresh is not enough list restoreview else just update the selected item not the whole list pw entry p updated m mgr get entry dw entry index assert p updated null list setentry dw selected entry p updated false t now adjust pw list mode adjust column widths sortlistifautosort dword dw list entry entryuuidtolistpos a uuid if dw list entry dword max m clist ensure visible int dw list entry false m clist set item state int dw list entry lvis selected lvis selected if n modify level 0 m bmodified true else touchentry get selected entry false user had viewed it only cleanup dialog data erasec string dlg m strtitle erasec string dlg m strusername erasec string dlg m strurl erasec string dlg m strnotes m ulllastlistparams 0 invalidate updatetoolbar m bdisplaydialog false cpwsafedlg onpwlistedit notifyuseractivity dwentryindex pw_entry pentry caddentrydlg pw_entry pwtemplate pw_time tnow dwnewgroupid bneedfullupdate bneedgroupupdate nmodifylevel dwselectedentry getselectedentry auuid pw_entry pwebackup bdobackup m_bfileopen dwselectedentry dword_max dwselectedentry dword_max dwentryindex _listseltoentryindex dwselectedentry dwentryindex dword_max dwentryindex dword_max pentry m_mgr getentry dwentryindex assert_entry pentry pentry m_bdisplaydialog m_pmgr m_mgr m_dwentryindex dwentryindex m_pparenticons m_ilicons m_beditmode m_bstars m_bpasswordstars m_dwdefaultexpire m_dwdefaultexpire m_ngroupid m_mgr getgroupbyidn pentry ugroupid m_strtitle pentry psztitle m_strusername pentry pszusername m_strurl pentry m_strnotes pentry pszadditional m_strattachment pentry pszbinarydesc m_niconid pentry uimageid m_texpire pentry texpire m_mgr unlockentrypassword pentry m_lppassword _tcssafedupalloc pentry pszpassword m_lprepeatpw _tcssafedupalloc pentry pszpassword m_mgr lockentrypassword pentry _callplugins kpm_edit_entry_pre m_bdisplaydialog domodal m_mgr unlockentrypassword pentry assert_entry pentry m_strtitle pentry psztitle nmodifylevel m_strusername pentry pszusername nmodifylevel m_strurl pentry nmodifylevel m_strnotes pentry pszadditional nmodifylevel m_strattachment pentry pszbinarydesc nmodifylevel _pwtimecmp m_texpire pentry texpire nmodifylevel _tcscmp m_lppassword pentry pszpassword nmodifylevel m_ngroupid m_mgr getgroupbyidn pentry ugroupid nmodifylevel m_niconid pentry uimageid nmodifylevel nmodifylevel m_bbackupentries bdobackup m_mgr memalloccopyentry pentry pwebackup m_mgr lockentrypassword pentry pwtemplate pentry _getcurrentpwtime tnow pwtemplate pszadditional m_strnotes pwtemplate pszpassword m_lppassword pwtemplate psztitle m_strtitle pwtemplate m_strurl pwtemplate pszusername m_strusername pwtemplate tcreation pentry tcreation pwtemplate texpire m_texpire pwtemplate tlastaccess tnow pwtemplate tlastmod tnow pwtemplate uimageid m_niconid pwtemplate upasswordlen _tcslen pwtemplate pszpassword dwnewgroupid m_mgr getgroupidbyindex m_ngroupid dwnewgroupid pwtemplate ugroupid bneedfullupdate pwtemplate ugroupid dwnewgroupid m_mgr setentry dwentryindex pwtemplate csecureeditex deletepassword m_lppassword m_lppassword csecureeditex deletepassword m_lprepeatpw m_lprepeatpw nattachlen m_strattachment getlength nescapelen _tcslen pws_new_attachment nattachlen nescapelen m_strattachment cstring pws_new_attachment m_mgr removebinarydata m_mgr getentry dwentryindex nattachlen nescapelen m_strattachment _tcslen pws_new_attachment cstring pws_new_attachment m_mgr attachfileasbinarydata m_mgr getentry dwentryindex m_strattachment m_strattachment getlength _tcslen pws_new_attachment pw_entry pbase m_mgr getentry dwentryindex assert_entry pbase auuid pbase bdobackup m_mgr backupentry pwebackup bneedgroupupdate messagebox mb_iconwarning mb_ok m_mgr memfreeentry pwebackup bneedgroupupdate _groups_saveview updategrouplist _groups_restoreview bneedfullupdate _list_saveview updatepasswordlist _list_restoreview pw_entry pupdated m_mgr getentry dwentryindex pupdated _list_setentry dwselectedentry pupdated tnow adjustpwlistmode adjustcolumnwidths _sortlistifautosort dwlistentry _entryuuidtolistpos auuid dwlistentry dword_max m_clist ensurevisible dwlistentry m_clist setitemstate dwlistentry lvis_selected lvis_selected nmodifylevel m_bmodified _touchentry getselectedentry erasecstring m_strtitle erasecstring m_strusername erasecstring m_strurl erasecstring m_strnotes m_ulllastlistparams _updatetoolbar m_bdisplaydialog void c pw safe dlg on pwlist delete notify user activity dword dw inv group1 dw inv group2 dword dw index dword dw sel pw entry p bool b b need group update false if m bfileopen false return if m dwlastnumselecteditems 0 return m bdisplaydialog true if callplugins kpm delete entry pre 0 0 false m bdisplaydialog false return c string str str trl this will remove all selected entries unrecoverably str t r n r n str trl are you sure you want to delete all selected entries int n res message box str trl delete entries confirmation mb iconquestion mb yesno if n res idno m bdisplaydialog false return dw inv group1 m mgr get group id pws backupgroup dw inv group2 m mgr get group id pws backupgroup src while 1 dw sel get selected entry if dw sel dword max break dw index listseltoentryindex dw sel assert dw index dword max if dw index dword max break if m bbackupentries false p m mgr get entry dw index assert p null if p null break if p u group id dw inv group1 p u group id dw inv group2 m mgr unlock entry password p b false m mgr backup entry p b b need group update b m mgr lock entry password p verify m mgr delete entry dw index delete from password manager verify m clist delete item int dw sel delete from gui if b need group update true groups saveview true update group list groups restoreview m clist redraw window m bmodified true updatetoolbar m bdisplaydialog false cpwsafedlg onpwlistdelete notifyuseractivity dwinvgroup1 dwinvgroup2 dwindex dwsel pw_entry bneedgroupupdate m_bfileopen m_dwlastnumselecteditems m_bdisplaydialog _callplugins kpm_delete_entry_pre m_bdisplaydialog cstring _t nres messagebox mb_iconquestion mb_yesno nres m_bdisplaydialog dwinvgroup1 m_mgr getgroupid pws_backupgroup dwinvgroup2 m_mgr getgroupid pws_backupgroup_src dwsel getselectedentry dwsel dword_max dwindex _listseltoentryindex dwsel dwindex dword_max dwindex dword_max m_bbackupentries m_mgr getentry dwindex ugroupid dwinvgroup1 ugroupid dwinvgroup2 m_mgr unlockentrypassword m_mgr backupentry bneedgroupupdate m_mgr lockentrypassword m_mgr deleteentry dwindex m_clist deleteitem dwsel bneedgroupupdate _groups_saveview updategrouplist _groups_restoreview m_clist redrawwindow m_bmodified _updatetoolbar m_bdisplaydialog void c pw safe dlg on rclick pwlist nmhdr pnmhdr lresult p result notify user activity point pt unreferenced parameter pnmhdr p result 0 if m bfileopen false return m bdisplaydialog true assert m ppwlisttrackablemenu null if m ppwlisttrackablemenu null m bdisplaydialog false return get cursor pos pt if callplugins kpm pwlist rclick m ppwlisttrackablemenu 0 false m bdisplaydialog false return m ppwlisttrackablemenu track popup menu tpm leftalign tpm rightbutton pt x pt y afx get main wnd updatetoolbar m bdisplaydialog false cpwsafedlg onrclickpwlist presult notifyuseractivity unreferenced_parameter presult m_bfileopen m_bdisplaydialog m_ppwlisttrackablemenu m_ppwlisttrackablemenu m_bdisplaydialog getcursorpos _callplugins kpm_pwlist_rclick m_ppwlisttrackablemenu m_bdisplaydialog m_ppwlisttrackablemenu trackpopupmenu tpm_leftalign tpm_rightbutton afxgetmainwnd _updatetoolbar m_bdisplaydialog void c pw safe dlg on click group list nmhdr pnmhdr lresult p result notify user activity point pt unreferenced parameter pnmhdr p result 0 get cursor pos pt m cgroups screen to client pt htreeitem h m cgroups hit test c point pt m cgroups select item h select the item the user pointed to remove the search group because we cannot handle it like a normal group groups saveview true dword dw cached first m dwgroupssavefirstvisible dword dw cached selected h null m cgroups get item data h dword max if removesearchgroup true update group list m dwgroupssavefirstvisible dw cached first m dwgroupssaveselected dw cached selected groups restoreview update password list updatetoolbar true cpwsafedlg onclickgrouplist presult notifyuseractivity unreferenced_parameter presult getcursorpos m_cgroups screentoclient m_cgroups hittest cpoint m_cgroups selectitem _groups_saveview dwcachedfirst m_dwgroupssavefirstvisible dwcachedselected m_cgroups getitemdata dword_max _removesearchgroup updategrouplist m_dwgroupssavefirstvisible dwcachedfirst m_dwgroupssaveselected dwcachedselected _groups_restoreview updatepasswordlist _updatetoolbar void c pw safe dlg on pwlist copy pw notify user activity m bdisplaydialog true if callplugins kpm pw copy 0 0 false m bdisplaydialog false return m bdisplaydialog false dword dw index listseltoentryindex pw entry p assert dw index dword max if dw index dword max return p m mgr get entry dw index assert entry p if p null return if m nclipboardmethod cm timed m mgr unlock entry password p copy string to clipboard p psz password m mgr lock entry password p set status text ex trl field copied to clipboard m nclipboardcountdown int m dwclipboardsecs else if m nclipboardmethod cm enhsecure m nclipboardstate clipboard delayed password make clipboard delay render m hwnd m hwndnextviewer c string str str trl field copied to clipboard str t str trl waiting for paste command set status text ex str if tcscmp p psz title pws tan entry 0 if it is a tan entry expire it getcurrentpwtime p t expire m bmodified true touchentry get selected entry false updatetoolbar cpwsafedlg onpwlistcopypw notifyuseractivity m_bdisplaydialog _callplugins kpm_pw_copy m_bdisplaydialog m_bdisplaydialog dwindex _listseltoentryindex pw_entry dwindex dword_max dwindex dword_max m_mgr getentry dwindex assert_entry m_nclipboardmethod cm_timed m_mgr unlockentrypassword copystringtoclipboard pszpassword m_mgr lockentrypassword setstatustextex m_nclipboardcountdown m_dwclipboardsecs m_nclipboardmethod cm_enhsecure m_nclipboardstate clipboard_delayed_password makeclipboarddelayrender m_hwnd m_hwndnextviewer cstring _t setstatustextex _tcscmp psztitle pws_tan_entry _getcurrentpwtime texpire m_bmodified _touchentry getselectedentry _updatetoolbar void c pw safe dlg on timer uint nid event if nid event appwnd timer id updater if m bcachedtoolbarupdate updatetoolbar m bcachedtoolbarupdate false if m bcachedpwlistupdate update password list m bcachedpwlistupdate false else if nid event appwnd timer id if m nclipboardcountdown 1 m nclipboardcountdown if m nclipboardcountdown 1 set status text ex trl ready clear clipboard if owner else if m nclipboardcountdown 0 set status text ex trl clipboard cleared else c string str str format trl field copied to clipboard clipboard will be cleared in d seconds m nclipboardcountdown set status text ex str if m blocked false m bfileopen true m bdisplaydialog false if m nlocktimedef 1 if m nlockcountdown 0 m nlockcountdown if m nlockcountdown 0 if m bexitinsteadoflockat false on file lock if m blocked true m bshowwindow true m bminimized false view hide handler else on file exit if m nfilerelockcountdown 1 m nfilerelockcountdown if m nfilerelockcountdown 1 if m bfileopen true m blocked true m strlastdb is empty false if filelock lock m strlastdb true true m nfilerelockcountdown fl time relock after 60 else m nfilerelockcountdown 30 else m nfilerelockcountdown fl time relock after 60 c dialog on timer nid event cpwsafedlg ontimer nidevent nidevent appwnd_timer_id_updater m_bcachedtoolbarupdate _updatetoolbar m_bcachedtoolbarupdate m_bcachedpwlistupdate updatepasswordlist m_bcachedpwlistupdate nidevent appwnd_timer_id m_nclipboardcountdown m_nclipboardcountdown m_nclipboardcountdown setstatustextex clearclipboardifowner m_nclipboardcountdown setstatustextex cstring m_nclipboardcountdown setstatustextex m_blocked m_bfileopen m_bdisplaydialog m_nlocktimedef m_nlockcountdown m_nlockcountdown m_nlockcountdown m_bexitinsteadoflockat onfilelock m_blocked m_bshowwindow m_bminimized viewhidehandler onfileexit m_nfilerelockcountdown m_nfilerelockcountdown m_nfilerelockcountdown m_bfileopen m_blocked m_strlastdb isempty filelock_lock m_strlastdb m_nfilerelockcountdown fl_time_relock_after m_nfilerelockcountdown m_nfilerelockcountdown fl_time_relock_after cdialog ontimer nidevent void c pw safe dlg on dblclk pwlist nmhdr pnmhdr lresult p result notify user activity nm listview pnm list view nm listview pnmhdr c string str data dword dw entry index listseltoentryindex pw entry p p result 0 if dw entry index dword max return p m mgr get entry dw entry index assert entry p if p null return bool b istan tcscmp p psz title pws tan entry 0 false true switch pnm list view i sub item case 0 if b istan true m dwpwlistmode lvs report on pwlist copy pw else on pwlist edit break case 1 on pwlist copy user break case 2 on pwlist visit url break case 3 on pwlist copy pw break case 4 str data p psz additional str data cs remove meta str data copy string to clipboard str data erasec string str data m nclipboardcountdown int m dwclipboardsecs set status text ex trl field copied to clipboard break case 5 pwtimetostring p t creation str data copy string to clipboard str data m nclipboardcountdown int m dwclipboardsecs set status text ex trl field copied to clipboard break case 6 pwtimetostring p t last mod str data copy string to clipboard str data m nclipboardcountdown int m dwclipboardsecs set status text ex trl field copied to clipboard break case 7 pwtimetostring p t last access str data copy string to clipboard str data m nclipboardcountdown int m dwclipboardsecs set status text ex trl field copied to clipboard break case 8 pwtimetostring p t expire str data copy string to clipboard str data m nclipboardcountdown int m dwclipboardsecs set status text ex trl field copied to clipboard break case 9 uuidtostring p uuid str data copy string to clipboard str data m nclipboardcountdown int m dwclipboardsecs set status text ex trl field copied to clipboard break case 10 copy string to clipboard p psz binary desc m nclipboardcountdown int m dwclipboardsecs set status text ex trl field copied to clipboard break default assert false break touchentry get selected entry false updatetoolbar cpwsafedlg ondblclkpwlist presult notifyuseractivity nm_listview pnmlistview nm_listview cstring strdata dwentryindex _listseltoentryindex pw_entry presult dwentryindex dword_max m_mgr getentry dwentryindex assert_entry bistan _tcscmp psztitle pws_tan_entry pnmlistview isubitem bistan m_dwpwlistmode lvs_report onpwlistcopypw onpwlistedit onpwlistcopyuser onpwlistvisiturl onpwlistcopypw strdata pszadditional strdata csremovemeta strdata copystringtoclipboard strdata erasecstring strdata m_nclipboardcountdown m_dwclipboardsecs setstatustextex _pwtimetostring tcreation strdata copystringtoclipboard strdata m_nclipboardcountdown m_dwclipboardsecs setstatustextex _pwtimetostring tlastmod strdata copystringtoclipboard strdata m_nclipboardcountdown m_dwclipboardsecs setstatustextex _pwtimetostring tlastaccess strdata copystringtoclipboard strdata m_nclipboardcountdown m_dwclipboardsecs setstatustextex _pwtimetostring texpire strdata copystringtoclipboard strdata m_nclipboardcountdown m_dwclipboardsecs setstatustextex _uuidtostring strdata copystringtoclipboard strdata m_nclipboardcountdown m_dwclipboardsecs setstatustextex copystringtoclipboard pszbinarydesc m_nclipboardcountdown m_dwclipboardsecs setstatustextex _touchentry getselectedentry _updatetoolbar void c pw safe dlg on rclick group list nmhdr pnmhdr lresult p result notify user activity point pt unreferenced parameter pnmhdr p result 0 if m bfileopen false return m bdisplaydialog true if callplugins kpm grouplist rclick pnmhdr 0 false m bdisplaydialog false return get cursor pos pt uint u flags point pt client pt m cgroups screen to client pt client htreeitem h item m cgroups hit test c point pt client u flags if u flags tvht onitem tvht onitemindent m cgroups select item h item else m cgroups select item null m cgroups select item m cgroups hit test c point pt client u flags assert m pgrouplisttrackablemenu null if m pgrouplisttrackablemenu null m bdisplaydialog false return m pgrouplisttrackablemenu track popup menu tpm leftalign tpm rightbutton pt x pt y afx get main wnd updatetoolbar m bdisplaydialog false cpwsafedlg onrclickgrouplist presult notifyuseractivity unreferenced_parameter presult m_bfileopen m_bdisplaydialog _callplugins kpm_grouplist_rclick m_bdisplaydialog getcursorpos uflags ptclient m_cgroups screentoclient ptclient hitem m_cgroups hittest cpoint ptclient uflags uflags tvht_onitem tvht_onitemindent m_cgroups selectitem hitem m_cgroups selectitem m_cgroups selectitem m_cgroups hittest cpoint ptclient uflags m_pgrouplisttrackablemenu m_pgrouplisttrackablemenu m_bdisplaydialog m_pgrouplisttrackablemenu trackpopupmenu tpm_leftalign tpm_rightbutton afxgetmainwnd _updatetoolbar m_bdisplaydialog void c pw safe dlg on pwlist copy user notify user activity m bdisplaydialog true if callplugins kpm user copy 0 0 false m bdisplaydialog false return m bdisplaydialog false if m nclipboardmethod cm timed dword dw entry index listseltoentryindex pw entry p assert dw entry index dword max if dw entry index dword max return p m mgr get entry dw entry index assert entry p if p null return if tcscmp p psz title pws tan entry 0 is it a tan entry it is a tan entry so copy the password instead of the user name on pwlist copy pw return copy string to clipboard p psz user name m nclipboardcountdown int m dwclipboardsecs else if m nclipboardmethod cm enhsecure m nclipboardstate clipboard delayed username make clipboard delay render m hwnd m hwndnextviewer set status text ex trl field copied to clipboard touchentry get selected entry false updatetoolbar cpwsafedlg onpwlistcopyuser notifyuseractivity m_bdisplaydialog _callplugins kpm_user_copy m_bdisplaydialog m_bdisplaydialog m_nclipboardmethod cm_timed dwentryindex _listseltoentryindex pw_entry dwentryindex dword_max dwentryindex dword_max m_mgr getentry dwentryindex assert_entry _tcscmp psztitle pws_tan_entry onpwlistcopypw copystringtoclipboard pszusername m_nclipboardcountdown m_dwclipboardsecs m_nclipboardmethod cm_enhsecure m_nclipboardstate clipboard_delayed_username makeclipboarddelayrender m_hwnd m_hwndnextviewer setstatustextex _touchentry getselectedentry _updatetoolbar void c pw safe dlg on pwlist visit url notify user activity int i uint u state pw entry p dword dw group id get selected group id c string strurl bool b launched false assert dw group id dword max if dw group id dword max return m bdisplaydialog true if callplugins kpm url visit 0 0 false m bdisplaydialog false return m bdisplaydialog false if m bcopyurls false for i 0 i m clist get item count i u state m clist get item state i lvis selected if u state lvis selected 0 p m mgr get entry by group dw group id dword i dword dw index listseltoentryindex dword i assert dw index dword max if dw index dword max continue p m mgr get entry dw index assert entry p parse and openurl with entry info p pszurl p touchentry dword i false else m bcopyurls true dword dw selected entry get selected entry assert dw selected entry dword max if dw selected entry dword max return dword dw entry index listseltoentryindex dw selected entry assert dw entry index dword max if dw entry index dword max return p m mgr get entry dw entry index assert entry p if p null return strurl p pszurl fixurl strurl m mgr unlock entry password p parseurl strurl p false m mgr lock entry password p if strurl get length 6 if strurl left 6 t cmd if m buseputtyforurls true if open url using putty strurl p psz user name false open url ex strurl else open url ex strurl b launched true else copy string to clipboard strurl else copy string to clipboard strurl erasec string strurl touchentry dw selected entry false if b launched false m nclipboardcountdown int m dwclipboardsecs set status text ex trl field copied to clipboard updatetoolbar cpwsafedlg onpwlistvisiturl notifyuseractivity ustate pw_entry dwgroupid getselectedgroupid cstring blaunched dwgroupid dword_max dwgroupid dword_max m_bdisplaydialog _callplugins kpm_url_visit m_bdisplaydialog m_bdisplaydialog m_bcopyurls m_clist getitemcount ustate m_clist getitemstate lvis_selected ustate lvis_selected m_mgr getentrybygroup dwgroupid dwindex _listseltoentryindex dwindex dword_max dwindex dword_max m_mgr getentry dwindex assert_entry parseandopenurlwithentryinfo _touchentry m_bcopyurls dwselectedentry getselectedentry dwselectedentry dword_max dwselectedentry dword_max dwentryindex _listseltoentryindex dwselectedentry dwentryindex dword_max dwentryindex dword_max m_mgr getentry dwentryindex assert_entry m_mgr unlockentrypassword m_mgr lockentrypassword getlength _t m_buseputtyforurls openurlusingputty pszusername openurlex openurlex blaunched copystringtoclipboard copystringtoclipboard erasecstring _touchentry dwselectedentry blaunched m_nclipboardcountdown m_dwclipboardsecs setstatustextex _updatetoolbar void c pw safe dlg on file new notify user activity if m blocked true return if m bfileopen true on file close if m bfileopen true message box trl first close the open file before opening another one trl password safe mb ok mb iconwarning return if callplugins kpm file new pre 0 0 false return m mgr new database if changemasterkey null true false return m bfileopen true m clist enable window true m cgroups enable window true m bmodified true pw group pw template pw time t now zero memory pw template sizeof pw group getcurrentpwtime t now pw template t creation t now m mgr getneverexpiretime pw template t expire pw template t last access t now pw template t last mod t now add standard groups pw template u image id 48 pw template psz group name tchar trl general pw template us level 0 pw template u group id 0 0 create new group id pw template dw flags pwgf expanded verify m mgr add group pw template pw template u image id 38 pw template psz group name tchar trl windows pw template us level 1 pw template u group id 0 0 create new group id pw template dw flags 0 verify m mgr add group pw template pw template u image id 3 pw template psz group name tchar trl network pw template us level 1 pw template u group id 0 0 create new group id verify m mgr add group pw template pw template u image id 1 pw template psz group name tchar trl internet pw template us level 1 pw template u group id 0 0 create new group id verify m mgr add group pw template pw template u image id 19 pw template psz group name tchar trl e mail pw template us level 1 pw template u group id 0 0 create new group id verify m mgr add group pw template pw template u image id 37 pw template psz group name tchar trl homebanking pw template us level 1 pw template u group id 0 0 create new group id verify m mgr add group pw template pw template u image id 37 pw template psz group name tchar trl mobile devices pw template us level 0 pw template u group id 0 0 create new group id verify m mgr add group pw template pw template u image id 37 pw template psz group name tchar trl credit cards pw template us level 0 pw template u group id 0 0 create new group id verify m mgr add group pw template testing code creates entries in the debug version ifdef pwsafe sample data pw entry pwt pwt p binary data null pwt psz binary desc null pwt u binary data len 0 pwt psz additional t some notes pwt psz password t the password pwt pszurl t google com pwt psz user name t anonymous pwt t creation t now m mgr getneverexpiretime pwt t expire pwt t last access t now pwt t last mod t now for int ix 0 ix 32 32 32 3 ix c string str str format t d group ix pw template u image id dword rand 30 pw template psz group name tchar lpctstr str pw template u group id 0 0 create new group pw template us level ushort rand 5 verify m mgr add group pw template pw time t expired t expired bt day 1 t expired bt hour 1 t expired bt minute 1 t expired bt month 1 t expired bt second 0 t expired sh year 2000 for int ir 0 ir 10 ir pwt psz title t i am expired pwt u group id m mgr get group id by index dword rand 6 pwt u image id rand 30 pwt t expire t expired zero memory pwt uuid 16 verify m mgr add entry pwt for int iy 0 iy 1024 256 3 iy c string str str format t sample d iy pwt psz title tchar lpctstr str pwt u group id m mgr get group id by index dword rand 8 pwt u image id dword rand 30 m mgr getneverexpiretime pwt t expire zero memory pwt uuid 16 verify m mgr add entry pwt endif m mgr fix group tree update group list update password list updatetoolbar m cgroups set focus callplugins kpm file new post 0 0 cpwsafedlg onfilenew notifyuseractivity m_blocked m_bfileopen onfileclose m_bfileopen messagebox mb_ok mb_iconwarning _callplugins kpm_file_new_pre m_mgr newdatabase _changemasterkey m_bfileopen m_clist enablewindow m_cgroups enablewindow m_bmodified pw_group pwtemplate pw_time tnow zeromemory pwtemplate pw_group _getcurrentpwtime tnow pwtemplate tcreation tnow m_mgr _getneverexpiretime pwtemplate texpire pwtemplate tlastaccess tnow pwtemplate tlastmod tnow pwtemplate uimageid pwtemplate pszgroupname pwtemplate uslevel pwtemplate ugroupid pwtemplate dwflags pwgf_expanded m_mgr addgroup pwtemplate pwtemplate uimageid pwtemplate pszgroupname pwtemplate uslevel pwtemplate ugroupid pwtemplate dwflags m_mgr addgroup pwtemplate pwtemplate uimageid pwtemplate pszgroupname pwtemplate uslevel pwtemplate ugroupid m_mgr addgroup pwtemplate pwtemplate uimageid pwtemplate pszgroupname pwtemplate uslevel pwtemplate ugroupid m_mgr addgroup pwtemplate pwtemplate uimageid pwtemplate pszgroupname email pwtemplate uslevel pwtemplate ugroupid m_mgr addgroup pwtemplate pwtemplate uimageid pwtemplate pszgroupname pwtemplate uslevel pwtemplate ugroupid m_mgr addgroup pwtemplate pwtemplate uimageid pwtemplate pszgroupname pwtemplate uslevel pwtemplate ugroupid m_mgr addgroup pwtemplate pwtemplate uimageid pwtemplate pszgroupname pwtemplate uslevel pwtemplate ugroupid m_mgr addgroup pwtemplate ___pwsafe_sample_data pw_entry pbinarydata pszbinarydesc ubinarydatalen pszadditional _t pszpassword _t _t pszusername _t tcreation tnow m_mgr _getneverexpiretime texpire tlastaccess tnow tlastmod tnow cstring _t pwtemplate uimageid pwtemplate pszgroupname pwtemplate ugroupid pwtemplate uslevel m_mgr addgroup pwtemplate pw_time texpired texpired btday texpired bthour texpired btminute texpired btmonth texpired btsecond texpired shyear psztitle _t ugroupid m_mgr getgroupidbyindex uimageid texpire texpired zeromemory m_mgr addentry cstring _t psztitle ugroupid m_mgr getgroupidbyindex uimageid m_mgr _getneverexpiretime texpire zeromemory m_mgr addentry m_mgr fixgrouptree updategrouplist updatepasswordlist _updatetoolbar m_cgroups setfocus _callplugins kpm_file_new_post void c pw safe dlg on file open notify user activity if m blocked true return m bdisplaydialog true if callplugins kpm file open pre 0 0 false m bdisplaydialog false return opendatabase null null null null false null false updatetoolbar m cgroups set focus m bdisplaydialog false cpwsafedlg onfileopen notifyuseractivity m_blocked m_bdisplaydialog _callplugins kpm_file_open_pre m_bdisplaydialog _opendatabase _updatetoolbar m_cgroups setfocus m_bdisplaydialog void c pw safe dlg on file save notify user activity if m bfileopen false return if m bfilereadonly true return m bdisplaydialog true if callplugins kpm file save pre 0 0 false m bdisplaydialog false return group sync states true if m strfile is empty on file save as m bdisplaydialog false return if m bhashvalid true byte a new hash 32 if sha256 hashfile m strfile byte a new hash true if memcmp a new hash m ahashoffile 32 0 c string str str trl the database file has been modified str t r n r n str trl most probably someone has changed the file while you were editing it str t r n r n str trl do you want to overwrite it if message box str trl overwrite mb yesno mb iconquestion idno m bdisplaydialog false return if m bdeletebackupsonsave true deletebackupentries removesearchgroup updateguitomanager int n err m mgr save database m strfile if n err pwe success message box pwm formatstaticerror n err 0 trl password safe mb iconwarning mb ok m bdisplaydialog false return callplugins kpm savedb post lpctstr m strfile 0 update file contents hash m bhashvalid sha256 hashfile m strfile byte m ahashoffile m strlastdb m strfile m bmodified false updatetoolbar updates titlebar too m bdisplaydialog false cpwsafedlg onfilesave notifyuseractivity m_bfileopen m_bfilereadonly m_bdisplaydialog _callplugins kpm_file_save_pre m_bdisplaydialog groupsyncstates m_strfile isempty onfilesaveas m_bdisplaydialog m_bhashvalid anewhash sha256_hashfile m_strfile anewhash anewhash m_ahashoffile cstring _t _t messagebox mb_yesno mb_iconquestion m_bdisplaydialog m_bdeletebackupsonsave _deletebackupentries _removesearchgroup _updateguitomanager nerr m_mgr savedatabase m_strfile nerr pwe_success messagebox pwm_formatstaticerror nerr mb_iconwarning mb_ok m_bdisplaydialog _callplugins kpm_savedb_post m_strfile m_bhashvalid sha256_hashfile m_strfile m_ahashoffile m_strlastdb m_strfile m_bmodified _updatetoolbar m_bdisplaydialog void c pw safe dlg on file save as notify user activity c string str file dword dw flags c string str filter if m bfileopen false return m bdisplaydialog true if callplugins kpm file saveas pre 0 0 false m bdisplaydialog false return group sync states true str filter trl password safe files str filter t kdb kdb str filter trl all files str filter t dw flags ofn longnames ofn hidereadonly ofn overwriteprompt dw flags ofn extensiondifferent ofn explorer 0x00080000 ofn enablesizing 0x00800000 dw flags 0x00080000 0x00800000 ofn noreadonlyreturn c file dialog dlg false t kdb t database kdb dw flags str filter this if dlg do modal idok str file dlg get path name if m bdeletebackupsonsave true deletebackupentries removesearchgroup updateguitomanager int n err m mgr save database str file if n err pwe success message box pwm formatstaticerror n err 0 trl password safe mb iconwarning mb ok else callplugins kpm savedb post lpctstr str file 0 update file contents hash m bhashvalid sha256 hashfile str file byte m ahashoffile m strfile str file m strfileabsolute get shortest absolute path m strfile m bmodified false m strlastdb str file m bfilereadonly false updatetitlebar updated by updatetoolbar updatetoolbar m bdisplaydialog false cpwsafedlg onfilesaveas notifyuseractivity cstring strfile dwflags cstring strfilter m_bfileopen m_bdisplaydialog _callplugins kpm_file_saveas_pre m_bdisplaydialog groupsyncstates strfilter strfilter _t strfilter strfilter _t dwflags ofn_longnames ofn_hidereadonly ofn_overwriteprompt dwflags ofn_extensiondifferent ofn_explorer ofn_enablesizing dwflags ofn_noreadonlyreturn cfiledialog _t _t dwflags strfilter domodal strfile getpathname m_bdeletebackupsonsave _deletebackupentries _removesearchgroup _updateguitomanager nerr m_mgr savedatabase strfile nerr pwe_success messagebox pwm_formatstaticerror nerr mb_iconwarning mb_ok _callplugins kpm_savedb_post strfile m_bhashvalid sha256_hashfile strfile m_ahashoffile m_strfile strfile m_strfileabsolute getshortestabsolutepath m_strfile m_bmodified m_strlastdb strfile m_bfilereadonly _updatetitlebar _updatetoolbar _updatetoolbar m_bdisplaydialog void c pw safe dlg on file close notify user activity int n res m bdisplaydialog true if callplugins kpm file close pre 0 0 false m bdisplaydialog false return group sync states true if m bfileopen true m bmodified true if m bexiting true m bautosavedb true n res idyes else c string str str trl the current file has been modified str t r n r n str trl do you want to save the changes before closing set foreground window n res message box str trl kee pass save before close lock mb yesnocancel mb iconquestion if n res idcancel m bdisplaydialog false return else if n res idyes on file save if m bmodified true m bexiting true c string str msg str msg trl the file couldn t be saved str msg t r n r n str msg trl maybe it s read only or the storage media has been removed str msg t r n str msg trl if you exit now all changes to the current database will be lost str msg t r n r n str msg trl would you like to exit anyway int n ret message box str msg trl exit mb yesno mb iconquestion if n ret idyes m bmodified false else m bmodified false n res idno if m bmodified true m bdisplaydialog false return m cquickfind set window text t clear clipboard if owner if m bfilereadonly false m nfilerelockcountdown 1 filelock lock m strfile false unlock the database file m clist delete all items m cgroups delete all items show entry details null m mgr new database m strfile empty m strfileabsolute empty m bfileopen false m bfilereadonly false m bmodified false m clist enable window false m cgroups enable window false deletetemporaryfiles m systray set icon m htrayiconnormal updatetitlebar updated by updatetoolbar updatetoolbar m bdisplaydialog false cpwsafedlg onfileclose notifyuseractivity nres m_bdisplaydialog _callplugins kpm_file_close_pre m_bdisplaydialog groupsyncstates m_bfileopen m_bmodified m_bexiting m_bautosavedb nres cstring _t setforegroundwindow nres messagebox keepass mb_yesnocancel mb_iconquestion nres m_bdisplaydialog nres onfilesave m_bmodified m_bexiting cstring strmsg strmsg strmsg _t strmsg strmsg _t strmsg strmsg _t strmsg nret messagebox strmsg mb_yesno mb_iconquestion nret m_bmodified m_bmodified nres m_bmodified m_bdisplaydialog m_cquickfind setwindowtext _t clearclipboardifowner m_bfilereadonly m_nfilerelockcountdown filelock_lock m_strfile m_clist deleteallitems m_cgroups deleteallitems showentrydetails m_mgr newdatabase m_strfile m_strfileabsolute m_bfileopen m_bfilereadonly m_bmodified m_clist enablewindow m_cgroups enablewindow _deletetemporaryfiles m_systray seticon m_htrayiconnormal _updatetitlebar _updatetoolbar _updatetoolbar m_bdisplaydialog void c pw safe dlg on safe options notify user activity c options dlg dlg bool b rebuild context menus false b restart needed false bool b start with windows c pw safe app get start with windows m bdisplaydialog true dlg m pparentdlg this if m bwindowsnewline true dlg m nnewlinesequence 0 else dlg m nnewlinesequence 1 dlg m uclipboardseconds m dwclipboardsecs 1 dlg m nclipboardmethod m nclipboardmethod dlg m bopenlastdb m bopenlastdb dlg m bstartminimized m bstartminimized dlg m bimgbuttons m bimgbuttons dlg m bentrygrid m bentrygrid dlg m bautosave m bautosavedb dlg m strfontspec m strfontspec dlg m blockonminimize m blockonminimize dlg m bminimizetotray m bminimizetotray dlg m bcloseminimizes m bcloseminimizes dlg m blockaftertime m nlocktimedef 1 true false if m nlocktimedef 1 dlg m nlockafter uint m nlocktimedef else dlg m nlockafter 0 dlg m rgbrowhighlight m clist get row color ex dlg m bcolautosize m bcolautosize dlg m bdisableunsafe m bdisableunsafe dlg m brememberlast m brememberlast dlg m buseputtyforurls m buseputtyforurls dlg m bsaveonlatmod m bsaveonlatmod dlg m dwathotkey m dwathotkey dlg m bautoshowexpired m bautoshowexpired dlg m bautoshowexpiredsoon m bautoshowexpiredsoon dlg m bstartwithwindows b start with windows dlg m bbackupentries m bbackupentries dlg m bsingleinstance m bcheckforinstance dlg m bsecureedits m bsecureedits dlg m bsingleclicktrayicon m bsingleclicktrayicon dlg m dwdefaultexpire m dwdefaultexpire dlg m bautopwgen m bautopwgen dlg m bquickfindincbackup m bquickfindincbackup dlg m bminimizebeforeat m nautotypemethod atm minimize true false dlg m bdeletebackupsonsave m bdeletebackupsonsave dlg m bshowfullpath m bshowfullpath dlg m bdisableautotype m bdisableautotype dlg m bcopyurls m bcopyurls dlg m bexitinsteadoflockat m bexitinsteadoflockat if callplugins kpm options pre 0 0 false m bdisplaydialog false return if dlg do modal idok m bwindowsnewline dlg m nnewlinesequence 0 true false m dwclipboardsecs dlg m uclipboardseconds 1 m bopenlastdb dlg m bopenlastdb m bstartminimized dlg m bstartminimized m bimgbuttons dlg m bimgbuttons m bentrygrid dlg m bentrygrid m bautosavedb dlg m bautosave m blockonminimize dlg m blockonminimize m bminimizetotray dlg m bminimizetotray m bcloseminimizes dlg m bcloseminimizes if dlg m rgbrowhighlight 0xff000000 dlg m rgbrowhighlight rgb 238 238 255 m clist set row color ex dlg m rgbrowhighlight m bcolautosize dlg m bcolautosize m brememberlast dlg m brememberlast m buseputtyforurls dlg m buseputtyforurls m bsaveonlatmod dlg m bsaveonlatmod m dwathotkey dlg m dwathotkey hot key change is made by c options dlg m bautoshowexpired dlg m bautoshowexpired m bautoshowexpiredsoon dlg m bautoshowexpiredsoon m bbackupentries dlg m bbackupentries m bcheckforinstance dlg m bsingleinstance m bsecureedits dlg m bsecureedits m bsingleclicktrayicon dlg m bsingleclicktrayicon m bautopwgen dlg m bautopwgen m bquickfindincbackup dlg m bquickfindincbackup m bdeletebackupsonsave dlg m bdeletebackupsonsave m bshowfullpath dlg m bshowfullpath m bdisableautotype dlg m bdisableautotype m bexitinsteadoflockat dlg m bexitinsteadoflockat m nautotypemethod dlg m bminimizebeforeat true atm minimize atm dropback if dlg m bdefaultexpire false m dwdefaultexpire 0 else m dwdefaultexpire dlg m dwdefaultexpire if dlg m bstartwithwindows b start with windows if c pw safe app set start with windows dlg m bstartwithwindows false message box trl unable to create remove the auto start key of kee pass in the windows registry trl stop mb iconwarning mb ok if dlg m nclipboardmethod m nclipboardmethod clear clipboard if owner m nclipboardmethod dlg m nclipboardmethod if dlg m bdisableunsafe m bdisableunsafe b restart needed true m bdisableunsafe dlg m bdisableunsafe if dlg m blockaftertime true m nlocktimedef long dlg m nlockafter else m nlocktimedef 1 if dlg m strfontspec m strfontspec parsespecandsetfont dlg m strfontspec if dlg m bcopyurls m bcopyurls m bcopyurls dlg m bcopyurls b rebuild context menus true newgui setimgbuttons m bimgbuttons setlistparameters callplugins kpm options post 0 0 process resize if b rebuild context menus true rebuild context menus if b restart needed true c string str str trl you have changed an option that requires restarting kee pass to get active str t r n r n str trl do you wish to restart kee pass now int n ret message box str trl restart kee pass mb yesno mb iconquestion if n ret idyes m brestartapplication true m bdisplaydialog false on file exit also calls save options save options notify user activity m ulllastlistparams 0 invalidate updatetoolbar true m bdisplaydialog false cpwsafedlg onsafeoptions notifyuseractivity coptionsdlg brebuildcontextmenus brestartneeded bstartwithwindows cpwsafeapp getstartwithwindows m_bdisplaydialog m_pparentdlg m_bwindowsnewline m_nnewlinesequence m_nnewlinesequence m_uclipboardseconds m_dwclipboardsecs m_nclipboardmethod m_nclipboardmethod m_bopenlastdb m_bopenlastdb m_bstartminimized m_bstartminimized m_bimgbuttons m_bimgbuttons m_bentrygrid m_bentrygrid m_bautosave m_bautosavedb m_strfontspec m_strfontspec m_blockonminimize m_blockonminimize m_bminimizetotray m_bminimizetotray m_bcloseminimizes m_bcloseminimizes m_blockaftertime m_nlocktimedef m_nlocktimedef m_nlockafter m_nlocktimedef m_nlockafter m_rgbrowhighlight m_clist getrowcolorex m_bcolautosize m_bcolautosize m_bdisableunsafe m_bdisableunsafe m_brememberlast m_brememberlast m_buseputtyforurls m_buseputtyforurls m_bsaveonlatmod m_bsaveonlatmod m_dwathotkey m_dwathotkey m_bautoshowexpired m_bautoshowexpired m_bautoshowexpiredsoon m_bautoshowexpiredsoon m_bstartwithwindows bstartwithwindows m_bbackupentries m_bbackupentries m_bsingleinstance m_bcheckforinstance m_bsecureedits m_bsecureedits m_bsingleclicktrayicon m_bsingleclicktrayicon m_dwdefaultexpire m_dwdefaultexpire m_bautopwgen m_bautopwgen m_bquickfindincbackup m_bquickfindincbackup m_bminimizebeforeat m_nautotypemethod atm_minimize m_bdeletebackupsonsave m_bdeletebackupsonsave m_bshowfullpath m_bshowfullpath m_bdisableautotype m_bdisableautotype m_bcopyurls m_bcopyurls m_bexitinsteadoflockat m_bexitinsteadoflockat _callplugins kpm_options_pre m_bdisplaydialog domodal m_bwindowsnewline m_nnewlinesequence m_dwclipboardsecs m_uclipboardseconds m_bopenlastdb m_bopenlastdb m_bstartminimized m_bstartminimized m_bimgbuttons m_bimgbuttons m_bentrygrid m_bentrygrid m_bautosavedb m_bautosave m_blockonminimize m_blockonminimize m_bminimizetotray m_bminimizetotray m_bcloseminimizes m_bcloseminimizes m_rgbrowhighlight m_rgbrowhighlight m_clist setrowcolorex m_rgbrowhighlight m_bcolautosize m_bcolautosize m_brememberlast m_brememberlast m_buseputtyforurls m_buseputtyforurls m_bsaveonlatmod m_bsaveonlatmod m_dwathotkey m_dwathotkey hotkey coptionsdlg m_bautoshowexpired m_bautoshowexpired m_bautoshowexpiredsoon m_bautoshowexpiredsoon m_bbackupentries m_bbackupentries m_bcheckforinstance m_bsingleinstance m_bsecureedits m_bsecureedits m_bsingleclicktrayicon m_bsingleclicktrayicon m_bautopwgen m_bautopwgen m_bquickfindincbackup m_bquickfindincbackup m_bdeletebackupsonsave m_bdeletebackupsonsave m_bshowfullpath m_bshowfullpath m_bdisableautotype m_bdisableautotype m_bexitinsteadoflockat m_bexitinsteadoflockat m_nautotypemethod m_bminimizebeforeat atm_minimize atm_dropback m_bdefaultexpire m_dwdefaultexpire m_dwdefaultexpire m_dwdefaultexpire m_bstartwithwindows bstartwithwindows cpwsafeapp setstartwithwindows m_bstartwithwindows messagebox keepass mb_iconwarning mb_ok m_nclipboardmethod m_nclipboardmethod clearclipboardifowner m_nclipboardmethod m_nclipboardmethod m_bdisableunsafe m_bdisableunsafe brestartneeded m_bdisableunsafe m_bdisableunsafe m_blockaftertime m_nlocktimedef m_nlockafter m_nlocktimedef m_strfontspec m_strfontspec _parsespecandsetfont m_strfontspec m_bcopyurls m_bcopyurls m_bcopyurls m_bcopyurls brebuildcontextmenus newgui_setimgbuttons m_bimgbuttons _setlistparameters _callplugins kpm_options_post processresize brebuildcontextmenus rebuildcontextmenus brestartneeded cstring keepass _t keepass nret messagebox keepass mb_yesno mb_iconquestion nret m_brestartapplication m_bdisplaydialog onfileexit saveoptions saveoptions notifyuseractivity m_ulllastlistparams _updatetoolbar m_bdisplaydialog void c pw safe dlg on safe remove group cd word array a group ids notify user activity dword dw group id get selected group id int n res assert dw group id dword max if dw group id dword max return m bdisplaydialog true dword dw group index m mgr get group by idn dw group id pw group p m mgr get group dw group index assert p null if p null return ushort us top level p us level while 1 a group ids add dw group id dw group index if dw group index m mgr get number of groups break p m mgr get group dw group index assert p null if p null break if p us level us top level break dw group id p u group id if callplugins kpm group remove pre 0 0 false m bdisplaydialog false return c string str str trl deleting a group will delete all items and subgroups in that group too str t r n r n str trl are you sure you want to delete this group n res message box str trl delete group confirmation mb iconquestion mb yesno if n res idyes int i n count a group ids get size for i 0 i n count i verify m mgr delete group by id a group ids get at n count i 1 a group ids remove all groups saveview false update group list groups restoreview m cgroups select item m cgroups get root item update password list m bmodified true updatetoolbar m bdisplaydialog false cpwsafedlg onsaferemovegroup cdwordarray agroupids notifyuseractivity dwgroupid getselectedgroupid nres dwgroupid dword_max dwgroupid dword_max m_bdisplaydialog dwgroupindex m_mgr getgroupbyidn dwgroupid pw_group m_mgr getgroup dwgroupindex ustoplevel uslevel agroupids dwgroupid dwgroupindex dwgroupindex m_mgr getnumberofgroups m_mgr getgroup dwgroupindex uslevel ustoplevel dwgroupid ugroupid _callplugins kpm_group_remove_pre m_bdisplaydialog cstring _t nres messagebox mb_iconquestion mb_yesno nres ncount agroupids getsize ncount m_mgr deletegroupbyid agroupids getat ncount agroupids removeall _groups_saveview updategrouplist _groups_restoreview m_cgroups selectitem m_cgroups getrootitem updatepasswordlist m_bmodified _updatetoolbar m_bdisplaydialog void c pw safe dlg on file change master pw notify user activity if m bfileopen false return if callplugins kpm file change master key pre 0 0 false return changemasterkey null false updatetoolbar cpwsafedlg onfilechangemasterpw notifyuseractivity m_bfileopen _callplugins kpm_file_change_master_key_pre _changemasterkey _updatetoolbar void c pw safe dlg on update file save c cmdui p cmdui if m bfileopen true m bfilereadonly false p cmdui enable true else p cmdui enable false cpwsafedlg onupdatefilesave ccmdui pcmdui m_bfileopen m_bfilereadonly pcmdui pcmdui void c pw safe dlg on update file save as c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatefilesaveas ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on update file change master pw c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatefilechangemasterpw ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on update file close c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatefileclose ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on update pwlist copy pw c cmdui p cmdui p cmdui enable m dwlastfirstselecteditem dword max m dwlastnumselecteditems 1 true false cpwsafedlg onupdatepwlistcopypw ccmdui pcmdui pcmdui m_dwlastfirstselecteditem dword_max m_dwlastnumselecteditems void c pw safe dlg on update pwlist copy user c cmdui p cmdui p cmdui enable m dwlastfirstselecteditem dword max m dwlastnumselecteditems 1 true false cpwsafedlg onupdatepwlistcopyuser ccmdui pcmdui pcmdui m_dwlastfirstselecteditem dword_max m_dwlastnumselecteditems void c pw safe dlg on update pwlist delete c cmdui p cmdui p cmdui enable m dwlastfirstselecteditem dword max true false cpwsafedlg onupdatepwlistdelete ccmdui pcmdui pcmdui m_dwlastfirstselecteditem dword_max void c pw safe dlg on update pwlist edit c cmdui p cmdui p cmdui enable m dwlastfirstselecteditem dword max m dwlastnumselecteditems 1 true false cpwsafedlg onupdatepwlistedit ccmdui pcmdui pcmdui m_dwlastfirstselecteditem dword_max m_dwlastnumselecteditems void c pw safe dlg on update pwlist visit url c cmdui p cmdui if m bcopyurls false p cmdui enable m dwlastfirstselecteditem dword max m dwlastnumselecteditems 1 true false else p cmdui enable m dwlastfirstselecteditem dword max m dwlastnumselecteditems 1 true false cpwsafedlg onupdatepwlistvisiturl ccmdui pcmdui m_bcopyurls pcmdui m_dwlastfirstselecteditem dword_max m_dwlastnumselecteditems pcmdui m_dwlastfirstselecteditem dword_max m_dwlastnumselecteditems void c pw safe dlg on update safe remove group c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdatesaferemovegroup ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on update safe add group c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatesafeaddgroup ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on update pwlist add c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatepwlistadd ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on export txt notify user activity c pw export c exp pwexport options pwo c string str file if m bfileopen false return if isunsafeallowed false return c exp set manager m mgr c exp set new line seq m bwindowsnewline c exp set format pwexp txt str file get export file pwexp txt cs file only m strfile false if str file get length 0 if get export options pwo c exp true c exp export all str file pwo null cpwsafedlg onexporttxt notifyuseractivity cpwexport cexp pwexport_options cstring strfile m_bfileopen _isunsafeallowed cexp setmanager m_mgr cexp setnewlineseq m_bwindowsnewline cexp setformat pwexp_txt strfile getexportfile pwexp_txt csfileonly m_strfile strfile getlength getexportoptions cexp cexp exportall strfile void c pw safe dlg on export html notify user activity c pw export c exp pwexport options pwo c string str file if m bfileopen false return if isunsafeallowed false return c exp set manager m mgr c exp set new line seq m bwindowsnewline c exp set format pwexp html str file get export file pwexp html cs file only m strfile false if str file get length 0 if get export options pwo c exp true c exp export all str file pwo null cpwsafedlg onexporthtml notifyuseractivity cpwexport cexp pwexport_options cstring strfile m_bfileopen _isunsafeallowed cexp setmanager m_mgr cexp setnewlineseq m_bwindowsnewline cexp setformat pwexp_html strfile getexportfile pwexp_html csfileonly m_strfile strfile getlength getexportoptions cexp cexp exportall strfile void c pw safe dlg on export xml notify user activity c pw export c exp pwexport options pwo c string str file if m bfileopen false return if isunsafeallowed false return c exp set manager m mgr c exp set new line seq m bwindowsnewline c exp set format pwexp xml str file get export file pwexp xml cs file only m strfile false if str file get length 0 if get export options pwo c exp true c exp export all str file pwo null cpwsafedlg onexportxml notifyuseractivity cpwexport cexp pwexport_options cstring strfile m_bfileopen _isunsafeallowed cexp setmanager m_mgr cexp setnewlineseq m_bwindowsnewline cexp setformat pwexp_xml strfile getexportfile pwexp_xml csfileonly m_strfile strfile getlength getexportoptions cexp cexp exportall strfile void c pw safe dlg on export csv notify user activity c pw export c exp pwexport options pwo c string str file if m bfileopen false return if isunsafeallowed false return c exp set manager m mgr c exp set new line seq m bwindowsnewline c exp set format pwexp csv str file get export file pwexp csv cs file only m strfile false if str file get length 0 if get export options pwo c exp true c exp export all str file pwo null cpwsafedlg onexportcsv notifyuseractivity cpwexport cexp pwexport_options cstring strfile m_bfileopen _isunsafeallowed cexp setmanager m_mgr cexp setnewlineseq m_bwindowsnewline cexp setformat pwexp_csv strfile getexportfile pwexp_csv csfileonly m_strfile strfile getlength getexportoptions cexp cexp exportall strfile void c pw safe dlg on update export txt c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdateexporttxt ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on update export html c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdateexporthtml ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on update export xml c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdateexportxml ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on update export csv c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdateexportcsv ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on file print notify user activity if callplugins kpm file print pre 0 0 false return printgroup dword max printgroup handles everything like unsafe check etc cpwsafedlg onfileprint notifyuseractivity _callplugins kpm_file_print_pre _printgroup dword_max _printgroup void c pw safe dlg on update file print c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatefileprint ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on extras gen pw notify user activity c pw generator dlg dlg dword dw group id get selected group id byte a uuid 16 m bdisplaydialog true dlg m bhidepw m bpasswordstars if callplugins kpm gen password pre 0 0 false m bdisplaydialog false return if m bfileopen false dw group id dword max dlg m bcanaccept false dlg do modal else m bfileopen true dlg m bcanaccept true if dlg do modal idok pw time t now pw entry pw template getcurrentpwtime t now memset pw template 0 sizeof pw entry pw template psz additional t pw template psz password dlg m lppassword pw template psz title t pw template pszurl t pw template psz user name t pw template t creation t now m mgr getneverexpiretime pw template t expire pw template t last access t now pw template t last mod t now pw template u group id dw group id pw template u image id 0 pw template u password len 0 pw template psz binary desc t if m mgr add entry pw template true pw entry p new m mgr get last edited entry assert entry p new dword dw list index memcpy a uuid p new uuid 16 sortlistifautosort if m nautosort 0 update password list dw list index entryuuidtolistpos a uuid m clist ensure visible int dw list index false m clist set item state int dw list index lvis selected lvis selected c secure edit ex delete password dlg m lppassword dlg m lppassword null updatetoolbar m bdisplaydialog false cpwsafedlg onextrasgenpw notifyuseractivity cpwgeneratordlg dwgroupid getselectedgroupid auuid m_bdisplaydialog m_bhidepw m_bpasswordstars _callplugins kpm_gen_password_pre m_bdisplaydialog m_bfileopen dwgroupid dword_max m_bcanaccept domodal m_bfileopen m_bcanaccept domodal pw_time tnow pw_entry pwtemplate _getcurrentpwtime tnow pwtemplate pw_entry pwtemplate pszadditional _t pwtemplate pszpassword m_lppassword pwtemplate psztitle _t pwtemplate _t pwtemplate pszusername _t pwtemplate tcreation tnow m_mgr _getneverexpiretime pwtemplate texpire pwtemplate tlastaccess tnow pwtemplate tlastmod tnow pwtemplate ugroupid dwgroupid pwtemplate uimageid pwtemplate upasswordlen pwtemplate pszbinarydesc _t m_mgr addentry pwtemplate pw_entry pnew m_mgr getlasteditedentry assert_entry pnew dwlistindex auuid pnew _sortlistifautosort m_nautosort updatepasswordlist dwlistindex _entryuuidtolistpos auuid m_clist ensurevisible dwlistindex m_clist setitemstate dwlistindex lvis_selected lvis_selected csecureeditex deletepassword m_lppassword m_lppassword _updatetoolbar m_bdisplaydialog void c pw safe dlg on safe modify group notify user activity c string str group name c add group dlg dlg dword dw group id get selected group id dword dw group pw group p pw group pw template pw time t now if dw group id dword max return p m mgr get group by id dw group id assert p null if p null return dw group m mgr get group by idn dw group id assert dw group dword max if dw group dword max return m bdisplaydialog true dlg m niconid int p u image id dlg m strgroupname p psz group name dlg m pparentimagelist m ilicons dlg m beditmode true if callplugins kpm group modify pre 0 0 false m bdisplaydialog false return if dlg do modal idok getcurrentpwtime t now pw template p copy previous standard values like group id etc pw template t last access t now update times pw template t last mod t now pw template psz group name tchar lpctstr dlg m strgroupname pw template u image id dword dlg m niconid m mgr set group dw group pw template groups saveview update group list groups restoreview update password list m clist set focus dlg m strgroupname empty m bmodified true else touchgroup dw group id false updatetoolbar m bdisplaydialog false cpwsafedlg onsafemodifygroup notifyuseractivity cstring strgroupname caddgroupdlg dwgroupid getselectedgroupid dwgroup pw_group pw_group pwtemplate pw_time tnow dwgroupid dword_max m_mgr getgroupbyid dwgroupid dwgroup m_mgr getgroupbyidn dwgroupid dwgroup dword_max dwgroup dword_max m_bdisplaydialog m_niconid uimageid m_strgroupname pszgroupname m_pparentimagelist m_ilicons m_beditmode _callplugins kpm_group_modify_pre m_bdisplaydialog domodal _getcurrentpwtime tnow pwtemplate pwtemplate tlastaccess tnow pwtemplate tlastmod tnow pwtemplate pszgroupname m_strgroupname pwtemplate uimageid m_niconid m_mgr setgroup dwgroup pwtemplate _groups_saveview updategrouplist _groups_restoreview updatepasswordlist m_clist setfocus m_strgroupname m_bmodified _touchgroup dwgroupid _updatetoolbar m_bdisplaydialog void c pw safe dlg on update safe modify group c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdatesafemodifygroup ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on pwlist find notify user activity if callplugins kpm pwlist find pre 0 0 false return find dword max cpwsafedlg onpwlistfind notifyuseractivity _callplugins kpm_pwlist_find_pre _find dword_max void c pw safe dlg on update pwlist find c cmdui p cmdui p cmdui enable m bfileopen m mgr get number of entries 0 cpwsafedlg onupdatepwlistfind ccmdui pcmdui pcmdui m_bfileopen m_mgr getnumberofentries void c pw safe dlg on pwlist find in group notify user activity if callplugins kpm pwlist find in group pre 0 0 false return dword dw cur group get selected group id if dw cur group dword max return find dw cur group cpwsafedlg onpwlistfindingroup notifyuseractivity _callplugins kpm_pwlist_find_in_group_pre dwcurgroup getselectedgroupid dwcurgroup dword_max _find dwcurgroup void c pw safe dlg on update pwlist find in group c cmdui p cmdui if m bfileopen false m hlastselectedgroup null p cmdui enable false return dword dw group id m cgroups get item data m hlastselectedgroup dword dw ref id m mgr get group id pws searchgroup bool b enable dw group id dw ref id true false p cmdui enable b enable m mgr get number of entries 0 cpwsafedlg onupdatepwlistfindingroup ccmdui pcmdui m_bfileopen m_hlastselectedgroup pcmdui dwgroupid m_cgroups getitemdata m_hlastselectedgroup dwrefid m_mgr getgroupid pws_searchgroup benable dwgroupid dwrefid pcmdui benable m_mgr getnumberofentries void c pw safe dlg on pwlist duplicate notify user activity pw entry p pw entry pw template pw time t now int n item count m clist get item count int i dword dw entry index uint u state byte a uuid 16 if callplugins kpm duplicate entry pre 0 0 false return getcurrentpwtime t now for i 0 i n item count i u state m clist get item state i uint max if u state lvis selected dw entry index listseltoentryindex dword i assert dw entry index dword max if dw entry index dword max continue p m mgr get entry dw entry index assert entry p if p null continue pw template p duplicate memset pw template uuid 0 16 we need a new uuid pw template t creation t now set new times pw template t last mod t now pw template t last access t now m mgr unlock entry password pw template verify m mgr add entry pw template m mgr lock entry password pw template pw entry p new m mgr get last edited entry assert entry p new memcpy a uuid p new uuid 16 m bmodified true sortlistifautosort if m nautosort 0 update password list dword dw list item entryuuidtolistpos a uuid if dw list item dword max m clist ensure visible int dw list item false m clist set item state int dw list item lvis selected lvis selected updatetoolbar cpwsafedlg onpwlistduplicate notifyuseractivity pw_entry pw_entry pwtemplate pw_time tnow nitemcount m_clist getitemcount dwentryindex ustate auuid _callplugins kpm_duplicate_entry_pre _getcurrentpwtime tnow nitemcount ustate m_clist getitemstate uint_max ustate lvis_selected dwentryindex _listseltoentryindex dwentryindex dword_max dwentryindex dword_max m_mgr getentry dwentryindex assert_entry pwtemplate pwtemplate pwtemplate tcreation tnow pwtemplate tlastmod tnow pwtemplate tlastaccess tnow m_mgr unlockentrypassword pwtemplate m_mgr addentry pwtemplate m_mgr lockentrypassword pwtemplate pw_entry pnew m_mgr getlasteditedentry assert_entry pnew auuid pnew m_bmodified _sortlistifautosort m_nautosort updatepasswordlist dwlistitem _entryuuidtolistpos auuid dwlistitem dword_max m_clist ensurevisible dwlistitem m_clist setitemstate dwlistitem lvis_selected lvis_selected _updatetoolbar void c pw safe dlg on update pwlist duplicate c cmdui p cmdui p cmdui enable m dwlastfirstselecteditem dword max true false cpwsafedlg onupdatepwlistduplicate ccmdui pcmdui pcmdui m_dwlastfirstselecteditem dword_max void c pw safe dlg on info homepage notify user activity shell execute null t open pwm homepage null null sw show cpwsafedlg oninfohomepage notifyuseractivity shellexecute _t pwm_homepage sw_show void c pw safe dlg on view always on top notify user activity uint u state bool b checked u state m menu get menu state id view alwaysontop mf bycommand assert u state 0xffffffff if u state mf checked b checked true else b checked false if b checked true u state mf unchecked toggle set window pos wnd no top most 0 0 0 0 swp framechanged swp nomove swp nosize swp showwindow m balwaysontop false else u state mf checked toggle set window pos wnd top most 0 0 0 0 swp framechanged swp nomove swp nosize swp showwindow m balwaysontop true m menu check menu item id view alwaysontop mf bycommand u state cpwsafedlg onviewalwaysontop notifyuseractivity ustate bchecked ustate m_menu getmenustate id_view_alwaysontop mf_bycommand ustate ustate mf_checked bchecked bchecked bchecked ustate mf_unchecked setwindowpos wndnotopmost swp_framechanged swp_nomove swp_nosize swp_showwindow m_balwaysontop ustate mf_checked setwindowpos wndtopmost swp_framechanged swp_nomove swp_nosize swp_showwindow m_balwaysontop m_menu checkmenuitem id_view_alwaysontop mf_bycommand ustate void c pw safe dlg on safe export group html notify user activity export selected group pwexp html cpwsafedlg onsafeexportgrouphtml notifyuseractivity exportselectedgroup pwexp_html void c pw safe dlg on safe export group xml notify user activity export selected group pwexp xml cpwsafedlg onsafeexportgroupxml notifyuseractivity exportselectedgroup pwexp_xml void c pw safe dlg on safe export group csv notify user activity export selected group pwexp csv cpwsafedlg onsafeexportgroupcsv notifyuseractivity exportselectedgroup pwexp_csv void c pw safe dlg on update safe export group html c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdatesafeexportgrouphtml ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on update safe export group xml c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdatesafeexportgroupxml ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on update safe export group csv c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdatesafeexportgroupcsv ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on safe print group notify user activity dword dw group get selected group id if dw group dword max return if callplugins kpm group print pre dw group 0 false return printgroup dw group cpwsafedlg onsafeprintgroup notifyuseractivity dwgroup getselectedgroupid dwgroup dword_max _callplugins kpm_group_print_pre dwgroup _printgroup dwgroup void c pw safe dlg on update safe print group c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdatesafeprintgroup ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on pwlist move up notify user activity dword dw relative entry get selected entry if dw relative entry 0 return dword dw entry index listseltoentryindex dw relative entry assert dw entry index dword max if dw entry index dword max return pw entry p touchentry dw relative entry false if m nautosort 0 message box trl auto sorting of the password list is enabled you cannot move entries manually trl stop mb ok mb iconwarning return p m mgr get entry dw entry index assert p null if p null return m mgr move in group p u group id dw relative entry dw relative entry 1 list saveview update password list list restoreview m clist set item state dw relative entry 1 lvis focused lvis selected lvis focused lvis selected m clist ensure visible dw relative entry 1 false m bmodified true updatetoolbar cpwsafedlg onpwlistmoveup notifyuseractivity dwrelativeentry getselectedentry dwrelativeentry dwentryindex _listseltoentryindex dwrelativeentry dwentryindex dword_max dwentryindex dword_max pw_entry _touchentry dwrelativeentry m_nautosort messagebox mb_ok mb_iconwarning m_mgr getentry dwentryindex m_mgr moveingroup ugroupid dwrelativeentry dwrelativeentry _list_saveview updatepasswordlist _list_restoreview m_clist setitemstate dwrelativeentry lvis_focused lvis_selected lvis_focused lvis_selected m_clist ensurevisible dwrelativeentry m_bmodified _updatetoolbar void c pw safe dlg on update pwlist move up c cmdui p cmdui p cmdui enable m dwlastfirstselecteditem dword max m dwlastnumselecteditems 1 true false cpwsafedlg onupdatepwlistmoveup ccmdui pcmdui pcmdui m_dwlastfirstselecteditem dword_max m_dwlastnumselecteditems void c pw safe dlg on pwlist move top notify user activity dword dw relative entry get selected entry if dw relative entry 0 return dword dw entry index listseltoentryindex dw relative entry assert dw entry index dword max if dw entry index dword max return pw entry p touchentry dw relative entry false if m nautosort 0 message box trl auto sorting of the password list is enabled you cannot move entries manually trl stop mb ok mb iconwarning return p m mgr get entry dw entry index assert p null if p null return m mgr move in group p u group id dw relative entry 0 list saveview update password list list restoreview m clist set item state 0 lvis focused lvis selected lvis focused lvis selected m clist ensure visible 0 false m bmodified true updatetoolbar cpwsafedlg onpwlistmovetop notifyuseractivity dwrelativeentry getselectedentry dwrelativeentry dwentryindex _listseltoentryindex dwrelativeentry dwentryindex dword_max dwentryindex dword_max pw_entry _touchentry dwrelativeentry m_nautosort messagebox mb_ok mb_iconwarning m_mgr getentry dwentryindex m_mgr moveingroup ugroupid dwrelativeentry _list_saveview updatepasswordlist _list_restoreview m_clist setitemstate lvis_focused lvis_selected lvis_focused lvis_selected m_clist ensurevisible m_bmodified _updatetoolbar void c pw safe dlg on update pwlist move top c cmdui p cmdui p cmdui enable m dwlastfirstselecteditem dword max m dwlastnumselecteditems 1 true false cpwsafedlg onupdatepwlistmovetop ccmdui pcmdui pcmdui m_dwlastfirstselecteditem dword_max m_dwlastnumselecteditems void c pw safe dlg on pwlist move down notify user activity dword dw item count dword m clist get item count pw entry p dword dw relative entry get selected entry if dw relative entry dw item count 1 return dword dw entry index listseltoentryindex assert dw entry index dword max if dw entry index dword max return touchentry dw relative entry false if m nautosort 0 message box trl auto sorting of the password list is enabled you cannot move entries manually trl stop mb ok mb iconwarning return p m mgr get entry dw entry index assert p null if p null return m mgr move in group p u group id dw relative entry dw relative entry 1 list saveview update password list list restoreview int n sel min dw relative entry 1 dw item count 1 m clist set item state n sel lvis focused lvis selected lvis focused lvis selected m clist ensure visible n sel false m bmodified true updatetoolbar cpwsafedlg onpwlistmovedown notifyuseractivity dwitemcount m_clist getitemcount pw_entry dwrelativeentry getselectedentry dwrelativeentry dwitemcount dwentryindex _listseltoentryindex dwentryindex dword_max dwentryindex dword_max _touchentry dwrelativeentry m_nautosort messagebox mb_ok mb_iconwarning m_mgr getentry dwentryindex m_mgr moveingroup ugroupid dwrelativeentry dwrelativeentry _list_saveview updatepasswordlist _list_restoreview nsel dwrelativeentry dwitemcount m_clist setitemstate nsel lvis_focused lvis_selected lvis_focused lvis_selected m_clist ensurevisible nsel m_bmodified _updatetoolbar void c pw safe dlg on update pwlist move down c cmdui p cmdui p cmdui enable m dwlastfirstselecteditem dword max m dwlastnumselecteditems 1 true false cpwsafedlg onupdatepwlistmovedown ccmdui pcmdui pcmdui m_dwlastfirstselecteditem dword_max m_dwlastnumselecteditems void c pw safe dlg on pwlist move bottom notify user activity dword dw item count dword m clist get item count pw entry p dword dw relative entry get selected entry if dw relative entry dw item count 1 return dword dw entry index listseltoentryindex dw relative entry if dw entry index dword max return touchentry dw relative entry false if m nautosort 0 message box trl auto sorting of the password list is enabled you cannot move entries manually trl stop mb ok mb iconwarning return p m mgr get entry dw entry index assert p null if p null return m mgr move in group p u group id dw relative entry dw item count 1 list saveview update password list list restoreview int n sel int dw item count 1 m clist set item state n sel lvis focused lvis selected lvis focused lvis selected m clist ensure visible n sel false m bmodified true updatetoolbar cpwsafedlg onpwlistmovebottom notifyuseractivity dwitemcount m_clist getitemcount pw_entry dwrelativeentry getselectedentry dwrelativeentry dwitemcount dwentryindex _listseltoentryindex dwrelativeentry dwentryindex dword_max _touchentry dwrelativeentry m_nautosort messagebox mb_ok mb_iconwarning m_mgr getentry dwentryindex m_mgr moveingroup ugroupid dwrelativeentry dwitemcount _list_saveview updatepasswordlist _list_restoreview nsel dwitemcount m_clist setitemstate nsel lvis_focused lvis_selected lvis_focused lvis_selected m_clist ensurevisible nsel m_bmodified _updatetoolbar void c pw safe dlg on update pwlist move bottom c cmdui p cmdui p cmdui enable m dwlastfirstselecteditem dword max m dwlastnumselecteditems 1 true false cpwsafedlg onupdatepwlistmovebottom ccmdui pcmdui pcmdui m_dwlastfirstselecteditem dword_max m_dwlastnumselecteditems void c pw safe dlg on begin drag pwlist nmhdr pnmhdr lresult p result notify user activity nm listview pnm list view nm listview pnmhdr p result 0 if m bfileopen false return dword dw entry index listseltoentryindex if dw entry index dword max return pw entry p m mgr get entry dw entry index assert entry p if p null return m bdisplaydialog true m cgroups m drop set drag accept true c ole drop source p drop source new c ole drop source c ole data source p data source new c ole data source try c shared file file shared try c archive ar file shared c archive store try c string str data switch pnm list view i sub item case 0 str data p psz title break case 1 str data p psz user name break case 2 str data p pszurl break case 3 m mgr unlock entry password p str data p psz password m mgr lock entry password p break case 4 str data p psz additional break case 5 pwtimetostring p t creation str data break case 6 pwtimetostring p t last mod str data break case 7 pwtimetostring p t last access str data break case 8 pwtimetostring p t expire str data break case 9 uuidtostring p uuid str data break case 10 str data p psz binary desc break default assert false break ar write lpctstr str data str data get length sizeof tchar ar close catch all e inner assert false end catch all catch all e middle assert false end catch all p data source cache global data cf text file shared detach p data source do drag drop dropeffect move dropeffect copy null p drop source catch all e outer assert false end catch all safe delete p data source safe delete p drop source m cgroups m drop removedropselection m cgroups m drop set drag accept false touchentry get selected entry false updatetoolbar m bdisplaydialog false cpwsafedlg onbegindragpwlist presult notifyuseractivity nm_listview pnmlistview nm_listview presult m_bfileopen dwentryindex _listseltoentryindex dwentryindex dword_max pw_entry m_mgr getentry dwentryindex assert_entry m_bdisplaydialog m_cgroups m_drop setdragaccept coledropsource pdropsource coledropsource coledatasource pdatasource coledatasource csharedfile fileshared carchive fileshared carchive cstring strdata pnmlistview isubitem strdata psztitle strdata pszusername strdata m_mgr unlockentrypassword strdata pszpassword m_mgr lockentrypassword strdata pszadditional _pwtimetostring tcreation strdata _pwtimetostring tlastmod strdata _pwtimetostring tlastaccess strdata _pwtimetostring texpire strdata _uuidtostring strdata strdata pszbinarydesc strdata strdata getlength catch_all einner end_catch_all catch_all emiddle end_catch_all pdatasource cacheglobaldata cf_text fileshared pdatasource dodragdrop dropeffect_move dropeffect_copy pdropsource catch_all eouter end_catch_all safe_delete pdatasource safe_delete pdropsource m_cgroups m_drop _removedropselection m_cgroups m_drop setdragaccept _touchentry getselectedentry _updatetoolbar m_bdisplaydialog void c pw safe dlg on file change language notify user activity c languages dlg dlg m bdisplaydialog true if dlg do modal idok m brestartapplication true m bdisplaydialog false on file exit m bdisplaydialog false cpwsafedlg onfilechangelanguage notifyuseractivity clanguagesdlg m_bdisplaydialog domodal m_brestartapplication m_bdisplaydialog onfileexit m_bdisplaydialog void c pw safe dlg on info readme notify user activity openlocalfile pwm readme file olf open cpwsafedlg oninforeadme notifyuseractivity _openlocalfile pwm_readme_file olf_open void c pw safe dlg on view title notify user activity selchangeview id view title cpwsafedlg onviewtitle notifyuseractivity _selchangeview id_view_title void c pw safe dlg on view username notify user activity selchangeview id view username cpwsafedlg onviewusername notifyuseractivity _selchangeview id_view_username void c pw safe dlg on view url notify user activity selchangeview id view url cpwsafedlg onviewurl notifyuseractivity _selchangeview id_view_url void c pw safe dlg on view password notify user activity selchangeview id view password cpwsafedlg onviewpassword notifyuseractivity _selchangeview id_view_password void c pw safe dlg on view notes notify user activity selchangeview id view notes cpwsafedlg onviewnotes notifyuseractivity _selchangeview id_view_notes void c pw safe dlg on file lock notify user activity if m bdisplaydialog true return cannot do anything while displaying a dialog this is a thread critical function therefore we fake to show a dialog this prevents the timer function from doing anything that could interfer with us m bdisplaydialog true if callplugins kpm file lock pre 0 0 false m bdisplaydialog false return c string str menu item c string str extended const tchar p suffix t if m bfileopen false m blocked false m bdisplaydialog false return m menu get menu text id file lock str menu item mf bycommand p suffix getcmdaccelext t lock workspace str extended trl lock workspace str extended t t str extended p suffix if str menu item trl lock workspace str menu item str extended deletetemporaryfiles m nlockedviewparams 0 long m cgroups get first visible item m nlockedviewparams 1 get selected entry groups saveview m nlockedviewparams 2 m clist get top index dword dw last selected listseltoentryindex dword max if dw last selected dword max memcpy m pprelockitemuuid m mgr get entry dw last selected uuid 16 else memset m pprelockitemuuid 0 16 m bexiting true on file close m bexiting false if m bfileopen true message box trl first close the open file before opening another one trl password safe mb ok mb iconwarning m bdisplaydialog false return if m strlastdb is empty true m bdisplaydialog false return m blocked true str extended trl unlock workspace str extended t t str extended getcmdaccelext t lock workspace m menu set menu text id file lock str extended mf bycommand set status text ex trl workspace locked m btntblock set tooltip text trl unlock workspace updatetitlebar updated by updatetoolbar m systray set icon m htrayiconlocked show entry details null if m bentryview true m reentryview set focus else if m bshowtoolbar true m cquickfind set focus else m clist set focus else opendatabase null m strlastdb null null false null false if m bfileopen false str extended pwm product name str extended t str extended trl workspace locked str extended t set window text str extended m systray set tooltip text str extended done in opendatabase already m systray set icon m htrayiconlocked message box trl workspace cannot be unlocked trl password safe mb iconinformation mb ok set status text ex trl workspace cannot be unlocked m bdisplaydialog false return notify user activity m blocked false str extended trl lock workspace str extended t t str extended getcmdaccelext t lock workspace m menu set menu text id file lock str extended mf bycommand m btntblock set tooltip text trl lock workspace m cgroups select set first visible htreeitem m nlockedviewparams 0 m cgroups select item htreeitem m nlockedviewparams 1 groups restoreview update password list m clist ensure visible m clist get item count 1 false m clist ensure visible m nlockedviewparams 2 false if m nlockedviewparams 1 dword max m clist set item state int m nlockedviewparams 1 lvis selected lvis selected set status text ex trl ready str extended pwm product name str extended t str extended cs file only m strfile set window text str extended m systray set icon m htrayiconnormal m systray set tooltip text str extended byte a no uuid 16 memset a no uuid 0 16 if memcmp m pprelockitemuuid a no uuid 16 0 pw entry p m mgr get entry by uuid m pprelockitemuuid assert p null show entry details p m clist set focus updatetoolbar m bdisplaydialog false cpwsafedlg onfilelock notifyuseractivity m_bdisplaydialog m_bdisplaydialog _callplugins kpm_file_lock_pre m_bdisplaydialog cstring strmenuitem cstring strextended psuffix _t m_bfileopen m_blocked m_bdisplaydialog m_menu getmenutext id_file_lock strmenuitem mf_bycommand psuffix _getcmdaccelext _t strextended strextended _t strextended psuffix strmenuitem strmenuitem strextended _deletetemporaryfiles m_nlockedviewparams m_cgroups getfirstvisibleitem m_nlockedviewparams getselectedentry _groups_saveview m_nlockedviewparams m_clist gettopindex dwlastselected _listseltoentryindex dword_max dwlastselected dword_max m_pprelockitemuuid m_mgr getentry dwlastselected m_pprelockitemuuid m_bexiting onfileclose m_bexiting m_bfileopen messagebox mb_ok mb_iconwarning m_bdisplaydialog m_strlastdb isempty m_bdisplaydialog m_blocked strextended strextended _t strextended _getcmdaccelext _t m_menu setmenutext id_file_lock strextended mf_bycommand setstatustextex m_btntblock settooltiptext _updatetitlebar _updatetoolbar m_systray seticon m_htrayiconlocked showentrydetails m_bentryview m_reentryview setfocus m_bshowtoolbar m_cquickfind setfocus m_clist setfocus _opendatabase m_strlastdb m_bfileopen strextended pwm_product_name strextended _t strextended strextended _t setwindowtext strextended m_systray settooltiptext strextended _opendatabase m_systray seticon m_htrayiconlocked messagebox mb_iconinformation mb_ok setstatustextex m_bdisplaydialog notifyuseractivity m_blocked strextended strextended _t strextended _getcmdaccelext _t m_menu setmenutext id_file_lock strextended mf_bycommand m_btntblock settooltiptext m_cgroups selectsetfirstvisible m_nlockedviewparams m_cgroups selectitem m_nlockedviewparams _groups_restoreview updatepasswordlist m_clist ensurevisible m_clist getitemcount m_clist ensurevisible m_nlockedviewparams m_nlockedviewparams dword_max m_clist setitemstate m_nlockedviewparams lvis_selected lvis_selected setstatustextex strextended pwm_product_name strextended _t strextended csfileonly m_strfile setwindowtext strextended m_systray seticon m_htrayiconnormal m_systray settooltiptext strextended anouuid anouuid m_pprelockitemuuid anouuid pw_entry m_mgr getentrybyuuid m_pprelockitemuuid showentrydetails m_clist setfocus _updatetoolbar m_bdisplaydialog void c pw safe dlg on update file lock c cmdui p cmdui p cmdui enable m bfileopen m blocked cpwsafedlg onupdatefilelock ccmdui pcmdui pcmdui m_bfileopen m_blocked void c pw safe dlg on group move top notify user activity dword dw group id get selected group id if dw group id dword max return touchgroup dw group id false dword dw group m mgr get group by idn dw group id m mgr move group dw group 0 update group list list saveview m cgroups select item m cgroups get root item update password list list restoreview m cgroups select set first visible m cgroups get root item m bmodified true updatetoolbar cpwsafedlg ongroupmovetop notifyuseractivity dwgroupid getselectedgroupid dwgroupid dword_max _touchgroup dwgroupid dwgroup m_mgr getgroupbyidn dwgroupid m_mgr movegroup dwgroup updategrouplist _list_saveview m_cgroups selectitem m_cgroups getrootitem updatepasswordlist _list_restoreview m_cgroups selectsetfirstvisible m_cgroups getrootitem m_bmodified _updatetoolbar void c pw safe dlg on update group move top c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdategroupmovetop ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on group move bottom notify user activity dword dw group id get selected group id if dw group id dword max return touchgroup dw group id false dword dw group m mgr get group by idn dw group id m mgr move group dw group dword m cgroups get count 1 update group list htreeitem h item groupidtohtreeitem dw group id m cgroups ensure visible h item m cgroups select item h item list saveview update password list list restoreview m bmodified true updatetoolbar cpwsafedlg ongroupmovebottom notifyuseractivity dwgroupid getselectedgroupid dwgroupid dword_max _touchgroup dwgroupid dwgroup m_mgr getgroupbyidn dwgroupid m_mgr movegroup dwgroup m_cgroups getcount updategrouplist hitem _groupidtohtreeitem dwgroupid m_cgroups ensurevisible hitem m_cgroups selectitem hitem _list_saveview updatepasswordlist _list_restoreview m_bmodified _updatetoolbar void c pw safe dlg on update group move bottom c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdategroupmovebottom ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on group move up notify user activity dword dw group id get selected group id if dw group id dword max return touchgroup dw group id false dword dw group m mgr get group by idn dw group id if dw group 0 return already is the top item verify m mgr move group dw group dw group 1 groups saveview update group list groups restoreview list saveview update password list list restoreview m bmodified true updatetoolbar cpwsafedlg ongroupmoveup notifyuseractivity dwgroupid getselectedgroupid dwgroupid dword_max _touchgroup dwgroupid dwgroup m_mgr getgroupbyidn dwgroupid dwgroup m_mgr movegroup dwgroup dwgroup _groups_saveview updategrouplist _groups_restoreview _list_saveview updatepasswordlist _list_restoreview m_bmodified _updatetoolbar void c pw safe dlg on update group move up c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdategroupmoveup ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on group move down notify user activity dword dw group id get selected group id if dw group id dword max return touchgroup dw group id false dword dw group m mgr get group by idn dw group id if dw group m mgr get number of groups 1 return already is last group verify m mgr move group dw group dw group 1 groups saveview update group list groups restoreview list saveview update password list list restoreview m bmodified true updatetoolbar cpwsafedlg ongroupmovedown notifyuseractivity dwgroupid getselectedgroupid dwgroupid dword_max _touchgroup dwgroupid dwgroup m_mgr getgroupbyidn dwgroupid dwgroup m_mgr getnumberofgroups m_mgr movegroup dwgroup dwgroup _groups_saveview updategrouplist _groups_restoreview _list_saveview updatepasswordlist _list_restoreview m_bmodified _updatetoolbar void c pw safe dlg on update group move down c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdategroupmovedown ccmdui pcmdui pcmdui m_hlastselectedgroup lresult c pw safe dlg on tray notification wparam w param lparam l param if m bsingleclicktrayicon true if l param wm lbuttondblclk return 0 if l param wm lbuttonup l param wm lbuttondblclk return m systray on tray notification w param l param cpwsafedlg ontraynotification wparam lparam m_bsingleclicktrayicon lparam wm_lbuttondblclk lparam wm_lbuttonup lparam wm_lbuttondblclk m_systray ontraynotification wparam lparam lresult c pw safe dlg on update clipboard wparam w param lparam l param static int i spinner 0 unreferenced parameter w param unreferenced parameter l param if m nclipboardmethod cm enhsecure return 0 if make clipboard delay render m hwnd m hwndnextviewer i spinner 100 if we could not get onwership of the clipboard try again sometimes we post wm my updateclipboard message to soon after putting delayed data on the clipboard whoever requested the clipboard data still hasn t freed their lock on the clipboard i spinner post message wm my updateclipboard failed to own clipboard so try again else i spinner 0 stop posting wm my updateclipboard messages return 0 cpwsafedlg onupdateclipboard wparam lparam ispinner unreferenced_parameter wparam unreferenced_parameter lparam m_nclipboardmethod cm_enhsecure makeclipboarddelayrender m_hwnd m_hwndnextviewer ispinner wm_my_updateclipboard ispinner postmessage wm_my_updateclipboard ispinner wm_my_updateclipboard void c pw safe dlg on view hide notify user activity if m bdisplaydialog true return view hide handler cpwsafedlg onviewhide notifyuseractivity m_bdisplaydialog viewhidehandler void c pw safe dlg on import csv notify user activity c pw import pvi c string str file dword dw flags c string str filter int n ret dword dw group id dw result m bdisplaydialog true str filter trl csv files str filter t csv csv str filter trl all files str filter t dw flags ofn longnames ofn extensiondifferent ofn explorer 0x00080000 ofn enablesizing 0x00800000 dw flags 0x00080000 0x00800000 dw flags ofn pathmustexist ofn filemustexist ofn hidereadonly c file dialog dlg true t csv t csv dw flags str filter this n ret dlg do modal if n ret idok str file dlg get path name dw group id get selected group id assert dw group id dword max dw result pvi import csv to db str file m mgr dw group id if dw result dword max sortlistifautosort if m nautosort 0 update password list m bmodified true else c string str trl an error occured while importing the file file cannot be imported str t r n r n str trl entry str t c string str temp str temp format t u dw result str str temp message box str trl an error occured mb iconwarning mb ok updatetoolbar m bdisplaydialog false cpwsafedlg onimportcsv notifyuseractivity cpwimport cstring strfile dwflags cstring strfilter nret dwgroupid dwresult m_bdisplaydialog strfilter strfilter _t strfilter strfilter _t dwflags ofn_longnames ofn_extensiondifferent ofn_explorer ofn_enablesizing dwflags dwflags ofn_pathmustexist ofn_filemustexist ofn_hidereadonly cfiledialog _t _t dwflags strfilter nret domodal nret strfile getpathname dwgroupid getselectedgroupid dwgroupid dword_max dwresult importcsvtodb strfile m_mgr dwgroupid dwresult dword_max _sortlistifautosort m_nautosort updatepasswordlist m_bmodified cstring _t _t cstring strtemp strtemp _t dwresult strtemp messagebox mb_iconwarning mb_ok _updatetoolbar m_bdisplaydialog void c pw safe dlg on update import csv c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdateimportcsv ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on click pwlist nmhdr pnmhdr lresult p result notify user activity p result 0 unreferenced parameter pnmhdr this would break the multiselect ability of the list therefor we removed it if get key state vk control 0x8000 0 on pwlist edit updatetoolbar cpwsafedlg onclickpwlist presult notifyuseractivity presult unreferenced_parameter getkeystate vk_control onpwlistedit _updatetoolbar void c pw safe dlg on importc wallet notify user activity c pw import pvi c string str file dword dw flags c string str filter int n ret m bdisplaydialog true str filter trl text files str filter t txt txt str filter trl all files str filter t dw flags ofn longnames ofn extensiondifferent ofn explorer 0x00080000 ofn enablesizing 0x00800000 dw flags 0x00080000 0x00800000 dw flags ofn pathmustexist ofn filemustexist ofn hidereadonly c file dialog dlg true t txt t txt dw flags str filter this n ret dlg do modal if n ret idok str file dlg get path name if pvi importc wallet to db str file m mgr true update group list m cgroups ensure visible getlastgroupitem m cgroups sortlistifautosort if m nautosort 0 update password list m bmodified true else message box trl an error occured while importing the file file cannot be imported trl password safe mb iconwarning updatetoolbar m bdisplaydialog false cpwsafedlg onimportcwallet notifyuseractivity cpwimport cstring strfile dwflags cstring strfilter nret m_bdisplaydialog strfilter strfilter _t strfilter strfilter _t dwflags ofn_longnames ofn_extensiondifferent ofn_explorer ofn_enablesizing dwflags dwflags ofn_pathmustexist ofn_filemustexist ofn_hidereadonly cfiledialog _t _t dwflags strfilter nret domodal nret strfile getpathname importcwallettodb strfile m_mgr updategrouplist m_cgroups ensurevisible _getlastgroupitem m_cgroups _sortlistifautosort m_nautosort updatepasswordlist m_bmodified messagebox mb_iconwarning _updatetoolbar m_bdisplaydialog void c pw safe dlg on update importc wallet c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdateimportcwallet ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on update file new c cmdui p cmdui p cmdui enable m blocked false cpwsafedlg onupdatefilenew ccmdui pcmdui pcmdui m_blocked void c pw safe dlg on update file open c cmdui p cmdui p cmdui enable m blocked false cpwsafedlg onupdatefileopen ccmdui pcmdui pcmdui m_blocked void c pw safe dlg on import pw safe notify user activity c pw import pvi c string str file dword dw flags c string str filter int n ret dword dw group id m bdisplaydialog true str filter trl text files str filter t txt txt str filter trl all files str filter t dw flags ofn longnames ofn extensiondifferent ofn explorer 0x00080000 ofn enablesizing 0x00800000 dw flags 0x00080000 0x00800000 dw flags ofn pathmustexist ofn filemustexist ofn hidereadonly c file dialog dlg true t txt t txt dw flags str filter this n ret dlg do modal if n ret idok str file dlg get path name dw group id get selected group id assert dw group id dword max if pvi import pw safe to db str file m mgr true groups saveview update group list groups restoreview sortlistifautosort if m nautosort 0 update password list m bmodified true else message box trl an error occured while importing the file file cannot be imported trl password safe mb iconwarning updatetoolbar m bdisplaydialog false cpwsafedlg onimportpwsafe notifyuseractivity cpwimport cstring strfile dwflags cstring strfilter nret dwgroupid m_bdisplaydialog strfilter strfilter _t strfilter strfilter _t dwflags ofn_longnames ofn_extensiondifferent ofn_explorer ofn_enablesizing dwflags dwflags ofn_pathmustexist ofn_filemustexist ofn_hidereadonly cfiledialog _t _t dwflags strfilter nret domodal nret strfile getpathname dwgroupid getselectedgroupid dwgroupid dword_max importpwsafetodb strfile m_mgr _groups_saveview updategrouplist _groups_restoreview _sortlistifautosort m_nautosort updatepasswordlist m_bmodified messagebox mb_iconwarning _updatetoolbar m_bdisplaydialog void c pw safe dlg on update import pw safe c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdateimportpwsafe ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on view creation notify user activity selchangeview id view creation cpwsafedlg onviewcreation notifyuseractivity _selchangeview id_view_creation void c pw safe dlg on view last mod notify user activity selchangeview id view lastmod cpwsafedlg onviewlastmod notifyuseractivity _selchangeview id_view_lastmod void c pw safe dlg on view last access notify user activity selchangeview id view lastaccess cpwsafedlg onviewlastaccess notifyuseractivity _selchangeview id_view_lastaccess void c pw safe dlg on view expire notify user activity selchangeview id view expire cpwsafedlg onviewexpire notifyuseractivity _selchangeview id_view_expire void c pw safe dlg on view uuid notify user activity selchangeview id view uuid cpwsafedlg onviewuuid notifyuseractivity _selchangeview id_view_uuid void c pw safe dlg on tb open on file open cpwsafedlg ontbopen onfileopen void c pw safe dlg on tb save on file save cpwsafedlg ontbsave onfilesave void c pw safe dlg on tb new on file new cpwsafedlg ontbnew onfilenew void c pw safe dlg on tb copy user on pwlist copy user cpwsafedlg ontbcopyuser onpwlistcopyuser void c pw safe dlg on tb copy pw on pwlist copy pw cpwsafedlg ontbcopypw onpwlistcopypw void c pw safe dlg on tb add entry on pwlist add cpwsafedlg ontbaddentry onpwlistadd void c pw safe dlg on tb edit entry on pwlist edit cpwsafedlg ontbeditentry onpwlistedit void c pw safe dlg on tb delete entry on pwlist delete cpwsafedlg ontbdeleteentry onpwlistdelete void c pw safe dlg on tb find on pwlist find cpwsafedlg ontbfind onpwlistfind void c pw safe dlg on tb lock on file lock cpwsafedlg ontblock onfilelock void c pw safe dlg on tb about on info about cpwsafedlg ontbabout oninfoabout void c pw safe dlg on view show tool bar notify user activity uint u state bool b checked u state m menu get menu state id view showtoolbar mf bycommand assert u state 0xffffffff if u state mf checked b checked true else b checked false if b checked true u state mf unchecked toggle b checked false else u state mf checked toggle b checked true m menu check menu item id view showtoolbar mf bycommand u state m bshowtoolbar b checked showtoolbar m bshowtoolbar process resize cpwsafedlg onviewshowtoolbar notifyuseractivity ustate bchecked ustate m_menu getmenustate id_view_showtoolbar mf_bycommand ustate ustate mf_checked bchecked bchecked bchecked ustate mf_unchecked bchecked ustate mf_checked bchecked m_menu checkmenuitem id_view_showtoolbar mf_bycommand ustate m_bshowtoolbar bchecked _showtoolbar m_bshowtoolbar processresize void c pw safe dlg on pwlist mass modify notify user activity c entry properties dlg dlg uint u state dword i dword dw index pw entry p dword dw group id if m bfileopen false return m bdisplaydialog true dlg m pmgr m mgr dlg m pparenticons m ilicons dlg m dwdefaultexpire m dwdefaultexpire if callplugins kpm massmodify entries pre 0 0 false m bdisplaydialog false return if dlg do modal true dw group id m mgr get group id by index dword dlg m ngroupinx assert dw group id dword max for i 0 i dword m clist get item count i u state m clist get item state int i lvis selected if u state lvis selected dw index listseltoentryindex i uses uuid to get the entry assert dw index dword max if dw index dword max continue p m mgr get entry dw index assert p null if p null continue if dlg m bmodgroup true p u group id dw group id if dlg m bmodicon true p u image id dword dlg m niconid if dlg m bmodexpire true p t expire dlg m texpire touchentry i true doesn t change the entry except the time fields if dlg m bmodgroup true we need a full update list saveview sortlistifautosort if m nautosort 0 update password list list restoreview else refresh is enough no entries have been moved sortlistifautosort if m nautosort 0 refresh password list m bmodified true m bdisplaydialog false cpwsafedlg onpwlistmassmodify notifyuseractivity centrypropertiesdlg ustate dwindex pw_entry dwgroupid m_bfileopen m_bdisplaydialog m_pmgr m_mgr m_pparenticons m_ilicons m_dwdefaultexpire m_dwdefaultexpire _callplugins kpm_massmodify_entries_pre m_bdisplaydialog domodal dwgroupid m_mgr getgroupidbyindex m_ngroupinx dwgroupid dword_max m_clist getitemcount ustate m_clist getitemstate lvis_selected ustate lvis_selected dwindex _listseltoentryindex dwindex dword_max dwindex dword_max m_mgr getentry dwindex m_bmodgroup ugroupid dwgroupid m_bmodicon uimageid m_niconid m_bmodexpire texpire m_texpire _touchentry m_bmodgroup _list_saveview _sortlistifautosort m_nautosort updatepasswordlist _list_restoreview _sortlistifautosort m_nautosort refreshpasswordlist m_bmodified m_bdisplaydialog void c pw safe dlg on update pwlist mass modify c cmdui p cmdui p cmdui enable m bfileopen m dwlastnumselecteditems 1 true false cpwsafedlg onupdatepwlistmassmodify ccmdui pcmdui pcmdui m_bfileopen m_dwlastnumselecteditems void c pw safe dlg on key down pwlist nmhdr pnmhdr lresult p result notify user activity unreferenced parameter pnmhdr p result 0 m bcachedtoolbarupdate true cpwsafedlg onkeydownpwlist presult notifyuseractivity unreferenced_parameter presult m_bcachedtoolbarupdate void c pw safe dlg on mouse move uint n flags c point point notify user activity long n add top rect rect window if m hdragginggroup null c point pt local copy of point because we will modify it here pt point client to screen pt c image list drag move pt c image list drag show nolock false if c wnd window from point pt m cgroups m bcandraggroup false set cursor afx get app load standard cursor idc no else if get key state vk control 0x1000 set cursor afx get app load standard cursor idc uparrow else set cursor afx get app load standard cursor idc arrow tvhittestinfo tvhti tvhti pt pt m cgroups screen to client tvhti pt htreeitem h item sel m cgroups hit test tvhti if tvhti flags tvht onitem tvht onitemindent m cgroups select drop target tvhti h item else m cgroups select drop target null if h item sel m hdragginggroup cannot drag on itself set cursor afx get app load standard cursor idc no c image list drag show nolock true return get window rect rect window if m bshowtoolbar true n add top 26 else n add top 0 int cy menu get system metrics sm cymenu if m bdragging true if m bdragginghoriz true m lsplitterposhoriz point x 3 else m lsplitterposvert rect window bottom rect window top point y n add top 3 cy menu 2 process resize rect rect group list rect rect pw list rect rect entry view m cgroups get window rect rect group list screen to client rect group list m clist get window rect rect pw list screen to client rect pw list m reentryview get window rect rect entry view screen to client rect entry view if point x rect group list right 1 point x rect pw list left 1 set cursor m hdragleftright else if point y rect group list bottom 1 point y rect entry view top 1 if m bentryview true set cursor m hdragupdown else set cursor m harrowcursor c dialog on mouse move n flags point cpwsafedlg onmousemove nflags cpoint notifyuseractivity naddtop rectwindow m_hdragginggroup cpoint clienttoscreen cimagelist dragmove cimagelist dragshownolock cwnd windowfrompoint m_cgroups m_bcandraggroup setcursor afxgetapp loadstandardcursor idc_no getkeystate vk_control setcursor afxgetapp loadstandardcursor idc_uparrow setcursor afxgetapp loadstandardcursor idc_arrow m_cgroups screentoclient hitemsel m_cgroups hittest tvht_onitem tvht_onitemindent m_cgroups selectdroptarget hitem m_cgroups selectdroptarget hitemsel m_hdragginggroup setcursor afxgetapp loadstandardcursor idc_no cimagelist dragshownolock getwindowrect rectwindow m_bshowtoolbar naddtop naddtop cymenu getsystemmetrics sm_cymenu m_bdragging m_bdragginghoriz m_lsplitterposhoriz m_lsplitterposvert rectwindow rectwindow naddtop cymenu processresize rectgrouplist rectpwlist rectentryview m_cgroups getwindowrect rectgrouplist screentoclient rectgrouplist m_clist getwindowrect rectpwlist screentoclient rectpwlist m_reentryview getwindowrect rectentryview screentoclient rectentryview rectgrouplist rectpwlist setcursor m_hdragleftright rectgrouplist rectentryview m_bentryview setcursor m_hdragupdown setcursor m_harrowcursor cdialog onmousemove nflags void c pw safe dlg onl button down uint n flags c point point notify user activity c dialog onl button down n flags point if m bdragging false rect rect group list rect rect pw list rect rect entry view m cgroups get window rect rect group list screen to client rect group list m clist get window rect rect pw list screen to client rect pw list m reentryview get window rect rect entry view screen to client rect entry view if point x rect group list right 1 point x rect pw list left 1 set cursor m hdragleftright m bdragginghoriz true m bdragging true else if point y rect group list bottom 1 point y rect entry view top 1 if m bentryview true set cursor m hdragupdown m bdragginghoriz false m bdragging true if m bdragging true set capture cpwsafedlg onlbuttondown nflags cpoint notifyuseractivity cdialog onlbuttondown nflags m_bdragging rectgrouplist rectpwlist rectentryview m_cgroups getwindowrect rectgrouplist screentoclient rectgrouplist m_clist getwindowrect rectpwlist screentoclient rectpwlist m_reentryview getwindowrect rectentryview screentoclient rectentryview rectgrouplist rectpwlist setcursor m_hdragleftright m_bdragginghoriz m_bdragging rectgrouplist rectentryview m_bentryview setcursor m_hdragupdown m_bdragginghoriz m_bdragging m_bdragging setcapture void c pw safe dlg onl button up uint n flags c point point notify user activity if m hdragginggroup null if m bcandraggroup true c point pt point client to screen pt bool b copy get key state vk control 0x1000 0 true false htreeitem h item drop to m cgroups get drop hilight item if h item drop to m hdragginggroup dword dw drag group id m cgroups get item data m hdragginggroup dword dw drag group pos m mgr get group by idn dw drag group id dword dw new group id dw drag group id pw group p new null assert dw drag group pos dword max if dw drag group pos dword max pw group grp new m mgr get group dw drag group pos grp new us level 0 grp new u group id 0 create new group m mgr add group grp new p new m mgr get group m mgr get number of groups 1 dw new group id p new u group id if h item drop to null dropped on item dword dw drag to group id m cgroups get item data h item drop to assert dw drag to group id dword max dword dw drag to group pos m mgr get group by idn dw drag to group id assert dw drag to group pos dword max dword dwv parent m mgr get last child group dw drag to group pos if p new null p new us level ushort m mgr get group dw drag to group pos us level 1 m mgr get group dw drag to group pos dw flags pwgf expanded m mgr move group m mgr get number of groups 1 dwv parent 1 else dropped on empty space fix group id unassociate all entries from the group that we will delete if b copy false m mgr subst entry group ids dw drag group id dw new group id if moving delete source group if b copy false m mgr delete group by id dw drag group id if h item drop to null syncitem m cgroups h item drop to false m cgroups select drop target null groups saveview false update group list groups restoreview m bmodified true m cgroups select drop target null finishdragging true redraw window else if m bdragging true release capture m bdragging false c dialog onl button up n flags point cpwsafedlg onlbuttonup nflags cpoint notifyuseractivity m_hdragginggroup m_bcandraggroup cpoint clienttoscreen bcopy getkeystate vk_control hitemdropto m_cgroups getdrophilightitem hitemdropto m_hdragginggroup dwdraggroupid m_cgroups getitemdata m_hdragginggroup dwdraggrouppos m_mgr getgroupbyidn dwdraggroupid dwnewgroupid dwdraggroupid pw_group pnew dwdraggrouppos dword_max dwdraggrouppos dword_max pw_group grpnew m_mgr getgroup dwdraggrouppos grpnew uslevel grpnew ugroupid m_mgr addgroup grpnew pnew m_mgr getgroup m_mgr getnumberofgroups dwnewgroupid pnew ugroupid hitemdropto dwdragtogroupid m_cgroups getitemdata hitemdropto dwdragtogroupid dword_max dwdragtogrouppos m_mgr getgroupbyidn dwdragtogroupid dwdragtogrouppos dword_max dwvparent m_mgr getlastchildgroup dwdragtogrouppos pnew pnew uslevel m_mgr getgroup dwdragtogrouppos uslevel m_mgr getgroup dwdragtogrouppos dwflags pwgf_expanded m_mgr movegroup m_mgr getnumberofgroups dwvparent bcopy m_mgr substentrygroupids dwdraggroupid dwnewgroupid bcopy m_mgr deletegroupbyid dwdraggroupid hitemdropto _syncitem m_cgroups hitemdropto m_cgroups selectdroptarget _groups_saveview updategrouplist _groups_restoreview m_bmodified m_cgroups selectdroptarget _finishdragging redrawwindow m_bdragging releasecapture m_bdragging cdialog onlbuttonup nflags void c pw safe dlg on view entry view notify user activity uint u state bool b checked u state m menu get menu state id view entryview mf bycommand assert u state 0xffffffff if u state mf checked b checked true else b checked false if b checked true u state mf unchecked toggle m bentryview false else u state mf checked toggle m bentryview true m menu check menu item id view entryview mf bycommand u state m reentryview show window m bentryview true sw show sw hide m bcachedtoolbarupdate true process resize cpwsafedlg onviewentryview notifyuseractivity ustate bchecked ustate m_menu getmenustate id_view_entryview mf_bycommand ustate ustate mf_checked bchecked bchecked bchecked ustate mf_unchecked m_bentryview ustate mf_checked m_bentryview m_menu checkmenuitem id_view_entryview mf_bycommand ustate m_reentryview showwindow m_bentryview sw_show sw_hide m_bcachedtoolbarupdate processresize void c pw safe dlg on re copy sel notify user activity m reentryview copy cpwsafedlg onrecopysel notifyuseractivity m_reentryview void c pw safe dlg on re copy all notify user activity long l start l end m reentryview get sel l start l end m reentryview set sel 0 1 m reentryview copy m reentryview set sel l start l end cpwsafedlg onrecopyall notifyuseractivity lstart lend m_reentryview getsel lstart lend m_reentryview setsel m_reentryview m_reentryview setsel lstart lend void c pw safe dlg on re select all notify user activity m reentryview set sel 0 1 cpwsafedlg onreselectall notifyuseractivity m_reentryview setsel void c pw safe dlg on extras tan wizard notify user activity c tan wizard dlg dlg pw entry pw template pw time t now c string str sub string str temp bool b valid sub string b acceptable int i tchar tch dword dw cur group id get selected group id dword dw number 0 assert dw cur group id dword max if dw cur group id dword max return m bdisplaydialog true if callplugins kpm tanwizard pre 0 0 false m bdisplaydialog false return if dlg do modal idok memset pw template 0 sizeof pw entry getcurrentpwtime t now pw template t creation t now pw template t last mod t now pw template t last access t now pw template psz title tchar pws tan entry pw template pszurl t pw template psz user name t m mgr getneverexpiretime pw template t expire pw template u image id 29 pw template u group id dw cur group id pw template p binary data null pw template psz binary desc t pw template u binary data len 0 dw number dlg m dwstartnumber dlg m strtans t append terminating char b valid sub string false for i 0 i dlg m strtans get length i tch dlg m strtans get at i b acceptable false if tch t 0 tch t 9 b acceptable true if tch t a tch t z b acceptable true if tch t a tch t z b acceptable true if b acceptable true b valid sub string false str sub string tch b valid sub string true else if b acceptable true b valid sub string true str sub string tch else if b acceptable false b valid sub string true memset pw template uuid 0 16 pw template psz password tchar lpctstr str sub string pw template u password len str sub string get length if dlg m bassignnumbers false pw template psz additional t else str temp format t 03u dw number pw template psz additional lptstr lpctstr str temp dw number verify m mgr add entry pw template b valid sub string false erasec string str sub string erasec string dlg m strtans sortlistifautosort if m nautosort 0 update password list m bmodified true updatetoolbar m bdisplaydialog false cpwsafedlg onextrastanwizard notifyuseractivity ctanwizarddlg pw_entry pwtemplate pw_time tnow cstring strsubstring strtemp bvalidsubstring bacceptable dwcurgroupid getselectedgroupid dwnumber dwcurgroupid dword_max dwcurgroupid dword_max m_bdisplaydialog _callplugins kpm_tanwizard_pre m_bdisplaydialog domodal pwtemplate pw_entry _getcurrentpwtime tnow pwtemplate tcreation tnow pwtemplate tlastmod tnow pwtemplate tlastaccess tnow pwtemplate psztitle pws_tan_entry pwtemplate _t pwtemplate pszusername _t m_mgr _getneverexpiretime pwtemplate texpire pwtemplate uimageid pwtemplate ugroupid dwcurgroupid pwtemplate pbinarydata pwtemplate pszbinarydesc _t pwtemplate ubinarydatalen dwnumber m_dwstartnumber m_strtans _t bvalidsubstring m_strtans getlength m_strtans getat bacceptable _t _t bacceptable _t _t bacceptable _t _t bacceptable bacceptable bvalidsubstring strsubstring bvalidsubstring bacceptable bvalidsubstring strsubstring bacceptable bvalidsubstring pwtemplate pwtemplate pszpassword strsubstring pwtemplate upasswordlen strsubstring getlength m_bassignnumbers pwtemplate pszadditional _t strtemp _t dwnumber pwtemplate pszadditional strtemp dwnumber m_mgr addentry pwtemplate bvalidsubstring erasecstring strsubstring erasecstring m_strtans _sortlistifautosort m_nautosort updatepasswordlist m_bmodified _updatetoolbar m_bdisplaydialog void c pw safe dlg on update extras tan wizard c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdateextrastanwizard ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on file print preview notify user activity c pw export c exp pwexport options pwo tchar sz file max path 2 deletetemporaryfiles if m bfileopen false return if isunsafeallowed false return m bdisplaydialog true c exp set manager m mgr c exp set new line seq m bwindowsnewline c exp set format pwexp html if callplugins kpm file printpreview pre 0 0 false m bdisplaydialog false return get temp path max path 2 sz file if sz file tcslen sz file 1 t tcscat sz file t tcscat sz file t pwsafetmp html if get export options pwo c exp false m bdisplaydialog false return bool b ret b ret c exp export group sz file dword max pwo null export all set group id to dword max if b ret false message box trl cannot open temporary file for printing trl stop mb ok mb iconwarning m bdisplaydialog false return shell execute m hwnd t open sz file null null sw show m strtempfile sz file m bdisplaydialog false cpwsafedlg onfileprintpreview notifyuseractivity cpwexport cexp pwexport_options szfile max_path _deletetemporaryfiles m_bfileopen _isunsafeallowed m_bdisplaydialog cexp setmanager m_mgr cexp setnewlineseq m_bwindowsnewline cexp setformat pwexp_html _callplugins kpm_file_printpreview_pre m_bdisplaydialog gettemppath max_path szfile szfile _tcslen szfile _t _tcscat szfile _t _tcscat szfile _t getexportoptions cexp m_bdisplaydialog bret bret cexp exportgroup szfile dword_max dword_max bret messagebox mb_ok mb_iconwarning m_bdisplaydialog shellexecute m_hwnd _t szfile sw_show m_strtempfile szfile m_bdisplaydialog void c pw safe dlg on update file print preview c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatefileprintpreview ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on info translation notify user activity c string str str trl currently used language str t if tcscmp trl languagename t languagename 0 str trl languagename else str t unknown or english version str t r n str trl language file version str t if tcscmp trl languageversion t languageversion 0 str trl languageversion else str t unknown or english version str t r n str trl author str t if tcscmp trl languageauthor t languageauthor 0 str trl languageauthor else str t unknown or english version str t r n str trl translation author contact str t if tcscmp trl languageauthoremail t languageauthoremail 0 str trl languageauthoremail else str t unknown or english version message box str trl translation information mb ok mb iconinformation cpwsafedlg oninfotranslation notifyuseractivity cstring _t _tcscmp _t _t _t _t _tcscmp _t _t _t _t _tcscmp _t _t _t _t _tcscmp _t _t messagebox mb_ok mb_iconinformation void c pw safe dlg on safe add subgroup notify user activity m bdisplaydialog true if callplugins kpm group add subgroup pre 0 0 false m bdisplaydialog false return m bdisplaydialog false dword dw group count m mgr get number of groups assert dw group count 1 if dw group count 0 return htreeitem h item m cgroups get selected item assert h item null if h item null return dword dw real parent id m cgroups get item data h item assert dw real parent id dword max if dw real parent id dword max return groups saveview on safe add group have we added a group if m mgr get number of groups dw group count 1 pw group p real parent m mgr get group by id dw real parent id assert p real parent null if p real parent null return dword dwv parent pos m mgr get last child group m mgr get group by idn dw real parent id assert dwv parent pos dword max if dwv parent pos dword max dwv parent pos m mgr get group by idn dw real parent id pw group pv parent m mgr get group dwv parent pos assert pv parent null if pv parent null return dword dwv parent group id pv parent u group id assert dwv parent group id dword max if dwv parent group id dword max return assert dwv parent pos m mgr get number of groups assert m mgr get group by id dwv parent group id null get the position of the added group dword dw new group pos m mgr get number of groups 1 dword dw new group id m mgr get group dw new group pos u group id set new level of the added group and expand its parent m mgr get group dw new group pos us level ushort p real parent us level 1 p real parent dw flags pwgf expanded group sync states false send expanded flag to gui move it to the correct position m mgr move group dw new group pos dwv parent pos 1 update group list groups restoreview htreeitem h groupidtohtreeitem dw new group id if h null m cgroups select item h update password list cpwsafedlg onsafeaddsubgroup notifyuseractivity m_bdisplaydialog _callplugins kpm_group_add_subgroup_pre m_bdisplaydialog m_bdisplaydialog dwgroupcount m_mgr getnumberofgroups dwgroupcount dwgroupcount hitem m_cgroups getselecteditem hitem hitem dwrealparentid m_cgroups getitemdata hitem dwrealparentid dword_max dwrealparentid dword_max _groups_saveview onsafeaddgroup m_mgr getnumberofgroups dwgroupcount pw_group prealparent m_mgr getgroupbyid dwrealparentid prealparent prealparent dwvparentpos m_mgr getlastchildgroup m_mgr getgroupbyidn dwrealparentid dwvparentpos dword_max dwvparentpos dword_max dwvparentpos m_mgr getgroupbyidn dwrealparentid pw_group pvparent m_mgr getgroup dwvparentpos pvparent pvparent dwvparentgroupid pvparent ugroupid dwvparentgroupid dword_max dwvparentgroupid dword_max dwvparentpos m_mgr getnumberofgroups m_mgr getgroupbyid dwvparentgroupid dwnewgrouppos m_mgr getnumberofgroups dwnewgroupid m_mgr getgroup dwnewgrouppos ugroupid m_mgr getgroup dwnewgrouppos uslevel prealparent uslevel prealparent dwflags pwgf_expanded groupsyncstates m_mgr movegroup dwnewgrouppos dwvparentpos updategrouplist _groups_restoreview _groupidtohtreeitem dwnewgroupid m_cgroups selectitem updatepasswordlist void c pw safe dlg on update safe add subgroup c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdatesafeaddsubgroup ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on begin drag grouplist nmhdr pnmhdr lresult p result notify user activity nm treeview pnm tree view nm treeview pnmhdr p result 0 m bdisplaydialog true c image list p drag image list null point pt offset rect rc item p drag image list m cgroups create drag image pnm tree view item new h item assert p drag image list null if p drag image list null m bdisplaydialog false return if m cgroups get item rect pnm tree view item new h item rc item true false c point pt drag begin int nx ny pt drag begin pnm tree view pt drag imagelist geticonsize p drag image list get safe handle nx ny pt offset x pt drag begin x rc item left nx rc item right rc item left pt offset y pt drag begin y rc item top ny rc item bottom rc item top map window points null rc item else get window rect rc item pt offset x pt offset y 8 bool b drag begun p drag image list begin drag 0 pt offset if b drag begun false safe delete p drag image list assert false m bdisplaydialog false return c point pt drag enter pnm tree view pt drag client to screen pt drag enter if p drag image list drag enter null pt drag enter false safe delete p drag image list assert false m bdisplaydialog false return safe delete p drag image list set focus invalidate rect rc item true update window set capture m hdragginggroup pnm tree view item new h item if m cgroups item has children m hdragginggroup true m bcandraggroup false else m bcandraggroup true m bdisplaydialog false cpwsafedlg onbegindraggrouplist presult notifyuseractivity nm_treeview pnmtreeview nm_treeview presult m_bdisplaydialog cimagelist pdragimagelist ptoffset rcitem pdragimagelist m_cgroups createdragimage pnmtreeview itemnew hitem pdragimagelist pdragimagelist m_bdisplaydialog m_cgroups getitemrect pnmtreeview itemnew hitem rcitem cpoint ptdragbegin ptdragbegin pnmtreeview ptdrag imagelist_geticonsize pdragimagelist getsafehandle ptoffset ptdragbegin rcitem rcitem rcitem ptoffset ptdragbegin rcitem rcitem rcitem mapwindowpoints rcitem getwindowrect rcitem ptoffset ptoffset bdragbegun pdragimagelist begindrag ptoffset bdragbegun safe_delete pdragimagelist m_bdisplaydialog cpoint ptdragenter pnmtreeview ptdrag clienttoscreen ptdragenter pdragimagelist dragenter ptdragenter safe_delete pdragimagelist m_bdisplaydialog safe_delete pdragimagelist setfocus invalidaterect rcitem updatewindow setcapture m_hdragginggroup pnmtreeview itemnew hitem m_cgroups itemhaschildren m_hdragginggroup m_bcandraggroup m_bcandraggroup m_bdisplaydialog void c pw safe dlg on cancel mode notify user activity finishdragging true redraw window c dialog on cancel mode cpwsafedlg oncancelmode notifyuseractivity _finishdragging redrawwindow cdialog oncancelmode void c pw safe dlg on group sort notify user activity if m bfileopen false m blocked true return if callplugins kpm group sort pre 0 0 false return m mgr sort group list update group list update password list m bmodified true cpwsafedlg ongroupsort notifyuseractivity m_bfileopen m_blocked _callplugins kpm_group_sort_pre m_mgr sortgrouplist updategrouplist updatepasswordlist m_bmodified void c pw safe dlg on update group sort c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdategroupsort ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on pwlist sort title notify user activity if checkifcansort false return sortlist 0 false cpwsafedlg onpwlistsorttitle notifyuseractivity _checkifcansort _sortlist void c pw safe dlg on update pwlist sort title c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatepwlistsorttitle ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on pwlist sort user notify user activity if checkifcansort false return sortlist 1 false cpwsafedlg onpwlistsortuser notifyuseractivity _checkifcansort _sortlist void c pw safe dlg on update pwlist sort user c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatepwlistsortuser ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on pwlist sort url notify user activity if checkifcansort false return sortlist 2 false cpwsafedlg onpwlistsorturl notifyuseractivity _checkifcansort _sortlist void c pw safe dlg on update pwlist sort url c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatepwlistsorturl ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on pwlist sort password notify user activity if checkifcansort false return sortlist 3 false cpwsafedlg onpwlistsortpassword notifyuseractivity _checkifcansort _sortlist void c pw safe dlg on update pwlist sort password c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatepwlistsortpassword ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on pwlist sort notes notify user activity if checkifcansort false return sortlist 4 false cpwsafedlg onpwlistsortnotes notifyuseractivity _checkifcansort _sortlist void c pw safe dlg on update pwlist sort notes c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatepwlistsortnotes ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on pwlist sort creation notify user activity if checkifcansort false return sortlist 5 false cpwsafedlg onpwlistsortcreation notifyuseractivity _checkifcansort _sortlist void c pw safe dlg on update pwlist sort creation c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatepwlistsortcreation ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on pwlist sort lastmodify notify user activity if checkifcansort false return sortlist 6 false cpwsafedlg onpwlistsortlastmodify notifyuseractivity _checkifcansort _sortlist void c pw safe dlg on update pwlist sort lastmodify c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatepwlistsortlastmodify ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on pwlist sort lastaccess notify user activity if checkifcansort false return sortlist 7 false cpwsafedlg onpwlistsortlastaccess notifyuseractivity _checkifcansort _sortlist void c pw safe dlg on update pwlist sort lastaccess c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatepwlistsortlastaccess ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on pwlist sort expire notify user activity if checkifcansort false return sortlist 8 false cpwsafedlg onpwlistsortexpire notifyuseractivity _checkifcansort _sortlist void c pw safe dlg on update pwlist sort expire c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatepwlistsortexpire ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on group move left notify user activity dword dw group id get selected group id pw group p group m mgr get group by id dw group id assert p group null if p group null return if p group us level 0 p group us level m mgr fix group tree groups saveview update group list groups restoreview m bmodified true cpwsafedlg ongroupmoveleft notifyuseractivity dwgroupid getselectedgroupid pw_group pgroup m_mgr getgroupbyid dwgroupid pgroup pgroup pgroup uslevel pgroup uslevel m_mgr fixgrouptree _groups_saveview updategrouplist _groups_restoreview m_bmodified void c pw safe dlg on update group move left c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdategroupmoveleft ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on group move right notify user activity dword dw group id get selected group id dword dw group pos m mgr get group by idn dw group id pw group p group m mgr get group dw group pos pw group p parent if dw group pos 0 p parent m mgr get group dw group pos 1 else p parent null assert p group null if p group null return if p group us level 0xffff p group us level if p parent null p parent dw flags pwgf expanded m mgr fix group tree groups saveview update group list groups restoreview m bmodified true cpwsafedlg ongroupmoveright notifyuseractivity dwgroupid getselectedgroupid dwgrouppos m_mgr getgroupbyidn dwgroupid pw_group pgroup m_mgr getgroup dwgrouppos pw_group pparent dwgrouppos pparent m_mgr getgroup dwgrouppos pparent pgroup pgroup pgroup uslevel pgroup uslevel pparent pparent dwflags pwgf_expanded m_mgr fixgrouptree _groups_saveview updategrouplist _groups_restoreview m_bmodified void c pw safe dlg on update group move right c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdategroupmoveright ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on view hide users notify user activity uint u state bool b checked int n item lv item lvi if m buserstars true if isunsafeallowed false return u state m menu get menu state id view hideusers mf bycommand assert u state 0xffffffff if u state mf checked b checked true else b checked false if b checked true u state mf unchecked toggle m buserstars false else u state mf checked toggle m buserstars true m menu check menu item id view hideusers mf bycommand u state if m buserstars true zero memory lvi sizeof lv item lvi mask lvif text lvi i sub item 1 lvi psz text pwm password string for n item 0 n item m clist get item count n item lvi i item n item m clist set item lvi else refresh password list refresh list based on uui ds m bcachedtoolbarupdate true updatetoolbar true cpwsafedlg onviewhideusers notifyuseractivity ustate bchecked nitem lv_item m_buserstars _isunsafeallowed ustate m_menu getmenustate id_view_hideusers mf_bycommand ustate ustate mf_checked bchecked bchecked bchecked ustate mf_unchecked m_buserstars ustate mf_checked m_buserstars m_menu checkmenuitem id_view_hideusers mf_bycommand ustate m_buserstars zeromemory lv_item lvif_text isubitem psztext pwm_password_string nitem nitem m_clist getitemcount nitem iitem nitem m_clist setitem refreshpasswordlist uuids m_bcachedtoolbarupdate _updatetoolbar void c pw safe dlg on view attach notify user activity selchangeview id view attach cpwsafedlg onviewattach notifyuseractivity _selchangeview id_view_attach void c pw safe dlg on pwlist save attach notify user activity dword dw flags c string str sample c string str filter pw entry p entry dword dw selected inx listseltoentryindex if m bfileopen false return if dw selected inx dword max return p entry m mgr get entry dw selected inx assert p entry null if p entry null return m bdisplaydialog true if tcslen p entry psz binary desc 0 message box trl there is no file attached with this entry trl password safe mb iconinformation m bdisplaydialog false return str sample p entry psz binary desc str filter trl all files str filter t dw flags ofn longnames ofn hidereadonly ofn overwriteprompt dw flags ofn extensiondifferent ofn explorer 0x00080000 ofn enablesizing 0x00800000 dw flags 0x00080000 0x00800000 ofn noreadonlyreturn c file dialog dlg false null str sample dw flags str filter this if dlg do modal idok m mgr save binary data p entry dlg get path name m bdisplaydialog false cpwsafedlg onpwlistsaveattach notifyuseractivity dwflags cstring strsample cstring strfilter pw_entry pentry dwselectedinx _listseltoentryindex m_bfileopen dwselectedinx dword_max pentry m_mgr getentry dwselectedinx pentry pentry m_bdisplaydialog _tcslen pentry pszbinarydesc messagebox mb_iconinformation m_bdisplaydialog strsample pentry pszbinarydesc strfilter strfilter _t dwflags ofn_longnames ofn_hidereadonly ofn_overwriteprompt dwflags ofn_extensiondifferent ofn_explorer ofn_enablesizing dwflags ofn_noreadonlyreturn cfiledialog strsample dwflags strfilter domodal m_mgr savebinarydata pentry getpathname m_bdisplaydialog void c pw safe dlg on update pwlist save attach c cmdui p cmdui bool b enable true if m dwlastfirstselecteditem dword max b enable false if m dwlastnumselecteditems 1 b enable false p cmdui enable b enable cpwsafedlg onupdatepwlistsaveattach ccmdui pcmdui benable m_dwlastfirstselecteditem dword_max benable m_dwlastnumselecteditems benable pcmdui benable void c pw safe dlg on file show db info notify user activity c db settings dlg dlg int n algorithm old dword dw old key enc rounds m bdisplaydialog true dlg m nalgorithm m mgr get algorithm n algorithm old dlg m nalgorithm dlg m dwnumkeyenc m mgr get key enc rounds dw old key enc rounds dlg m dwnumkeyenc if callplugins kpm file dbsettings pre 0 0 false m bdisplaydialog false return if dlg do modal idok m mgr set algorithm dlg m nalgorithm if n algorithm old dlg m nalgorithm m bmodified true m mgr set key enc rounds dlg m dwnumkeyenc if dw old key enc rounds dlg m dwnumkeyenc m bmodified true notify user activity updatetoolbar m bdisplaydialog false cpwsafedlg onfileshowdbinfo notifyuseractivity cdbsettingsdlg nalgorithmold dwoldkeyencrounds m_bdisplaydialog m_nalgorithm m_mgr getalgorithm nalgorithmold m_nalgorithm m_dwnumkeyenc m_mgr getkeyencrounds dwoldkeyencrounds m_dwnumkeyenc _callplugins kpm_file_dbsettings_pre m_bdisplaydialog domodal m_mgr setalgorithm m_nalgorithm nalgorithmold m_nalgorithm m_bmodified m_mgr setkeyencrounds m_dwnumkeyenc dwoldkeyencrounds m_dwnumkeyenc m_bmodified notifyuseractivity _updatetoolbar m_bdisplaydialog void c pw safe dlg on update file show db info c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatefileshowdbinfo ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on extras show expired showexpiredentries true true false cpwsafedlg onextrasshowexpired _showexpiredentries void c pw safe dlg on update extras show expired c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdateextrasshowexpired ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on import pvault notify user activity c pw import pvi c string str file dword dw flags c string str filter int n ret dword dw group id m bdisplaydialog true str filter trl text files str filter t txt txt str filter trl all files str filter t dw flags ofn longnames ofn extensiondifferent ofn explorer 0x00080000 ofn enablesizing 0x00800000 dw flags 0x00080000 0x00800000 dw flags ofn pathmustexist ofn filemustexist ofn hidereadonly c file dialog dlg true t txt t txt dw flags str filter this n ret dlg do modal if n ret idok str file dlg get path name dw group id get selected group id assert dw group id dword max if pvi importp vault to db str file m mgr true groups saveview update group list groups restoreview sortlistifautosort if m nautosort 0 update password list m bmodified true else message box trl an error occured while importing the file file cannot be imported trl password safe mb iconwarning updatetoolbar m bdisplaydialog false cpwsafedlg onimportpvault notifyuseractivity cpwimport cstring strfile dwflags cstring strfilter nret dwgroupid m_bdisplaydialog strfilter strfilter _t strfilter strfilter _t dwflags ofn_longnames ofn_extensiondifferent ofn_explorer ofn_enablesizing dwflags dwflags ofn_pathmustexist ofn_filemustexist ofn_hidereadonly cfiledialog _t _t dwflags strfilter nret domodal nret strfile getpathname dwgroupid getselectedgroupid dwgroupid dword_max importpvaulttodb strfile m_mgr _groups_saveview updategrouplist _groups_restoreview _sortlistifautosort m_nautosort updatepasswordlist m_bmodified messagebox mb_iconwarning _updatetoolbar m_bdisplaydialog void c pw safe dlg on update import pvault c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdateimportpvault ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on safe export group txt notify user activity export selected group pwexp txt cpwsafedlg onsafeexportgrouptxt notifyuseractivity exportselectedgroup pwexp_txt void c pw safe dlg on update safe export group txt c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdatesafeexportgrouptxt ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on pwlist select all notify user activity int i assert m bfileopen true if m bfileopen false return m clist set focus for i 0 i m clist get item count i m clist set item state i lvis selected lvis selected updatetoolbar true cpwsafedlg onpwlistselectall notifyuseractivity m_bfileopen m_bfileopen m_clist setfocus m_clist getitemcount m_clist setitemstate lvis_selected lvis_selected _updatetoolbar void c pw safe dlg on update pwlist select all c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdatepwlistselectall ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on view autosort creation notify user activity m nautosort 6 update auto sort menu items sortlistifautosort cpwsafedlg onviewautosortcreation notifyuseractivity m_nautosort updateautosortmenuitems _sortlistifautosort void c pw safe dlg on view autosort expire notify user activity m nautosort 9 update auto sort menu items sortlistifautosort cpwsafedlg onviewautosortexpire notifyuseractivity m_nautosort updateautosortmenuitems _sortlistifautosort void c pw safe dlg on view autosort lastaccess notify user activity m nautosort 8 update auto sort menu items sortlistifautosort cpwsafedlg onviewautosortlastaccess notifyuseractivity m_nautosort updateautosortmenuitems _sortlistifautosort void c pw safe dlg on view autosort lastmodify notify user activity m nautosort 7 update auto sort menu items sortlistifautosort cpwsafedlg onviewautosortlastmodify notifyuseractivity m_nautosort updateautosortmenuitems _sortlistifautosort void c pw safe dlg on view autosort nosort notify user activity m nautosort 0 update auto sort menu items sortlistifautosort cpwsafedlg onviewautosortnosort notifyuseractivity m_nautosort updateautosortmenuitems _sortlistifautosort void c pw safe dlg on view autosort notes notify user activity m nautosort 5 update auto sort menu items sortlistifautosort cpwsafedlg onviewautosortnotes notifyuseractivity m_nautosort updateautosortmenuitems _sortlistifautosort void c pw safe dlg on view autosort password notify user activity m nautosort 4 update auto sort menu items sortlistifautosort cpwsafedlg onviewautosortpassword notifyuseractivity m_nautosort updateautosortmenuitems _sortlistifautosort void c pw safe dlg on view autosort title notify user activity m nautosort 1 update auto sort menu items sortlistifautosort cpwsafedlg onviewautosorttitle notifyuseractivity m_nautosort updateautosortmenuitems _sortlistifautosort void c pw safe dlg on view autosort url notify user activity m nautosort 3 update auto sort menu items sortlistifautosort cpwsafedlg onviewautosorturl notifyuseractivity m_nautosort updateautosortmenuitems _sortlistifautosort void c pw safe dlg on view autosort user notify user activity m nautosort 2 update auto sort menu items sortlistifautosort cpwsafedlg onviewautosortuser notifyuseractivity m_nautosort updateautosortmenuitems _sortlistifautosort void c pw safe dlg on update safe options c cmdui p cmdui p cmdui enable m blocked false true false cpwsafedlg onupdatesafeoptions ccmdui pcmdui pcmdui m_blocked void c pw safe dlg on pwlist auto type notify user activity if m bdisableautotype true return dword dw entry listseltoentryindex pw entry p assert dw entry dword max if dw entry dword max return p m mgr get entry dw entry assert p null if p null return autotype p true cpwsafedlg onpwlistautotype notifyuseractivity m_bdisableautotype dwentry _listseltoentryindex pw_entry dwentry dword_max dwentry dword_max m_mgr getentry dwentry _autotype void c pw safe dlg on update pwlist auto type c cmdui p cmdui p cmdui enable m dwlastfirstselecteditem dword max m dwlastnumselecteditems 1 true false m bdisableautotype cpwsafedlg onupdatepwlistautotype ccmdui pcmdui pcmdui m_dwlastfirstselecteditem dword_max m_dwlastnumselecteditems m_bdisableautotype void c pw safe dlg on column click pwlist nmhdr pnmhdr lresult p result notify user activity nm listview pnm list view nm listview pnmhdr p result 0 if checkifcansort false return sortlist dword pnm list view i sub item false cpwsafedlg oncolumnclickpwlist presult notifyuseractivity nm_listview pnmlistview nm_listview presult _checkifcansort _sortlist pnmlistview isubitem void c pw safe dlg on extras plugin mgr notify user activity c plugins dlg dlg m bdisplaydialog true dlg m ppimgr m pimgr dlg m pimglist m ilicons dlg do modal notify user activity updatetoolbar m bdisplaydialog false cpwsafedlg onextraspluginmgr notifyuseractivity cpluginsdlg m_bdisplaydialog m_ppimgr m_pimgr m_pimglist m_ilicons domodal notifyuseractivity _updatetoolbar m_bdisplaydialog lresult c pw safe dlg on hot key wparam w param lparam l param unreferenced parameter l param if m bdisableautotype true return 0 assert w param hotkeyid autotype w param hotkeyid restore if w param hotkeyid autotype notify user activity if m blocked true hwnd h wnd save get foreground window save currently active window set foreground window on file lock if h wnd save null h wnd save this m hwnd return 0 set foreground window h wnd save sleep 10 if m blocked true return 0 if m bfileopen false return 0 hwnd h wnd get foreground window int n len get window text length h wnd if n len 0 n len 1 return 0 tchar psz window new tchar n len 3 assert psz window null if psz window null return 0 m bdisplaydialog true get window text h wnd psz window n len 2 dword i pw entry pe null c string str cur window psz window c string str window exp bool b left b right int n sub len dword dw window field c entry list dlg dlg pw uuid struct pw uuid dlg m ndisplaymode eldmode list dlg m pmgr m mgr dlg m pimglist m ilicons dlg m bpasswordstars m bpasswordstars dlg m buserstars m buserstars zero memory dlg m auuid 16 dlg m strbannertitle trl auto type entry selection dlg m strbannercaption trl multiple entries exist for the current window please select the entry to auto type dword dw invalid id1 m mgr get group id pws backupgroup src dword dw invalid id2 m mgr get group id pws backupgroup str cur window make lower for i 0 i m mgr get number of entries i pe m mgr get entry i assert pe null if pe null continue if pe u group id dw invalid id1 pe u group id dw invalid id2 continue dw window field 0 while 1 search all auto type window strings str window exp extract parameter from string pe psz additional t auto type window dw window field str window exp make lower if str window exp get length 0 an auto type window definition has been found b left str window exp left 1 t true false b right str window exp right 1 t true false if b left str window exp delete 0 1 if b right str window exp delete str window exp get length 1 1 n sub len str window exp get length if b left b right n sub len n len if str cur window find str window exp 0 1 memcpy pw uuid uuid pe uuid 16 dlg m ventrylist push back pw uuid else if b left n sub len n len if str cur window right n sub len str window exp memcpy pw uuid uuid pe uuid 16 dlg m ventrylist push back pw uuid else if b right n sub len n len if str cur window left n sub len str window exp memcpy pw uuid uuid pe uuid 16 dlg m ventrylist push back pw uuid else if n sub len n len if str cur window str window exp memcpy pw uuid uuid pe uuid 16 dlg m ventrylist push back pw uuid else if dw window field 0 entry doesn t have an auto type window definition str window exp pe psz title n sub len str window exp get length if n sub len 0 n sub len n len str window exp make lower if str cur window find str window exp 0 1 memcpy pw uuid uuid pe uuid 16 dlg m ventrylist push back pw uuid break else break dw window field dword dw matching entries count dword dlg m ventrylist size if dw matching entries count 0 if dw matching entries count 1 pe m mgr get entry by uuid dlg m ventrylist 0 uuid else set foreground window dlg do modal check if the target window still exists is valid if is window h wnd true verify set foreground window h wnd true restore window focus if c pw manager is zerouuid dlg m auuid false pe m mgr get entry by uuid dlg m auuid else pe null else pe null if pe null autotype pe false dlg m ventrylist clear safe delete array psz window m bdisplaydialog false else if w param hotkeyid restore notify user activity set foreground window if m bminimized true m bshowwindow false view hide handler return 0 cpwsafedlg onhotkey wparam lparam unreferenced_parameter lparam m_bdisableautotype wparam hotkeyid_autotype wparam hotkeyid_restore wparam hotkeyid_autotype notifyuseractivity m_blocked hwndsave getforegroundwindow setforegroundwindow onfilelock hwndsave hwndsave m_hwnd setforegroundwindow hwndsave m_blocked m_bfileopen hwnd getforegroundwindow nlen getwindowtextlength hwnd nlen nlen pszwindow nlen pszwindow pszwindow m_bdisplaydialog getwindowtext hwnd pszwindow nlen pw_entry cstring strcurwindow pszwindow cstring strwindowexp bleft bright nsublen dwwindowfield centrylistdlg pw_uuid_struct pwuuid m_ndisplaymode eldmode_list m_pmgr m_mgr m_pimglist m_ilicons m_bpasswordstars m_bpasswordstars m_buserstars m_buserstars zeromemory m_auuid m_strbannertitle m_strbannercaption dwinvalidid1 m_mgr getgroupid pws_backupgroup_src dwinvalidid2 m_mgr getgroupid pws_backupgroup strcurwindow makelower m_mgr getnumberofentries m_mgr getentry ugroupid dwinvalidid1 ugroupid dwinvalidid2 dwwindowfield strwindowexp extractparameterfromstring pszadditional _t dwwindowfield strwindowexp makelower strwindowexp getlength bleft strwindowexp _t bright strwindowexp _t bleft strwindowexp bright strwindowexp strwindowexp getlength nsublen strwindowexp getlength bleft bright nsublen nlen strcurwindow strwindowexp pwuuid m_ventrylist push_back pwuuid bleft nsublen nlen strcurwindow nsublen strwindowexp pwuuid m_ventrylist push_back pwuuid bright nsublen nlen strcurwindow nsublen strwindowexp pwuuid m_ventrylist push_back pwuuid nsublen nlen strcurwindow strwindowexp pwuuid m_ventrylist push_back pwuuid dwwindowfield strwindowexp psztitle nsublen strwindowexp getlength nsublen nsublen nlen strwindowexp makelower strcurwindow strwindowexp pwuuid m_ventrylist push_back pwuuid dwwindowfield dwmatchingentriescount m_ventrylist dwmatchingentriescount dwmatchingentriescount m_mgr getentrybyuuid m_ventrylist setforegroundwindow domodal iswindow hwnd setforegroundwindow hwnd cpwmanager iszerouuid m_auuid m_mgr getentrybyuuid m_auuid _autotype m_ventrylist safe_delete_array pszwindow m_bdisplaydialog wparam hotkeyid_restore notifyuseractivity setforegroundwindow m_bminimized m_bshowwindow viewhidehandler void c pw safe dlg on import get more shell execute null t open pwm url plugins null null sw show cpwsafedlg onimportgetmore shellexecute _t pwm_url_plugins sw_show void c pw safe dlg on info donate notify user activity shell execute null t open pwm url donate null null sw show cpwsafedlg oninfodonate notifyuseractivity shellexecute _t pwm_url_donate sw_show void c pw safe dlg on extras repair db notify user activity if m blocked true return m bdisplaydialog true if callplugins kpm file open pre 0 0 false m bdisplaydialog false return opendatabase null null null null false null true updatetoolbar m cgroups set focus m bdisplaydialog false cpwsafedlg onextrasrepairdb notifyuseractivity m_blocked m_bdisplaydialog _callplugins kpm_file_open_pre m_bdisplaydialog _opendatabase _updatetoolbar m_cgroups setfocus m_bdisplaydialog void c pw safe dlg on update extras repair db c cmdui p cmdui p cmdui enable m bfileopen false m blocked false cpwsafedlg onupdateextrasrepairdb ccmdui pcmdui pcmdui m_bfileopen m_blocked void c pw safe dlg on import kee pass c import options dlg dlg c pw manager mgr import notify user activity opendatabase mgr import null null null false null false if mgr import get number of groups 0 groups saveview true list saveview if dlg do modal idcancel return bool b newi ds dlg m nimportmethod 0 true false bool b compare times dlg m nimportmethod 2 true false m mgr merge in mgr import b newi ds b compare times m bmodified true update group list groups restoreview update password list list restoreview updatetoolbar notify user activity cpwsafedlg onimportkeepass cimportoptionsdlg cpwmanager mgrimport notifyuseractivity _opendatabase mgrimport mgrimport getnumberofgroups _groups_saveview _list_saveview domodal bnewids m_nimportmethod bcomparetimes m_nimportmethod m_mgr mergein mgrimport bnewids bcomparetimes m_bmodified updategrouplist _groups_restoreview updatepasswordlist _list_restoreview _updatetoolbar notifyuseractivity void c pw safe dlg on update import kee pass c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdateimportkeepass ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on safe export group kee pass dword dw selected group get selected group id assert dw selected group dword max if dw selected group dword max return export group to kee pass dw selected group cpwsafedlg onsafeexportgroupkeepass dwselectedgroup getselectedgroupid dwselectedgroup dword_max dwselectedgroup dword_max exportgrouptokeepass dwselectedgroup void c pw safe dlg on update safe export group kee pass c cmdui p cmdui p cmdui enable m hlastselectedgroup null true false cpwsafedlg onupdatesafeexportgroupkeepass ccmdui pcmdui pcmdui m_hlastselectedgroup void c pw safe dlg on export kee pass export group to kee pass dword max cpwsafedlg onexportkeepass exportgrouptokeepass dword_max void c pw safe dlg on update export kee pass c cmdui p cmdui p cmdui enable m bfileopen cpwsafedlg onupdateexportkeepass ccmdui pcmdui pcmdui m_bfileopen void c pw safe dlg on view simpletan view m bsimpletanview m bsimpletanview false true false m menu check menu item id view simpletanview mf bycommand m bsimpletanview true mf checked mf unchecked refresh password list cpwsafedlg onviewsimpletanview m_bsimpletanview m_bsimpletanview m_menu checkmenuitem id_view_simpletanview mf_bycommand m_bsimpletanview mf_checked mf_unchecked refreshpasswordlist void c pw safe dlg on view showtan indices m bshowtanindices m bshowtanindices false true false m menu check menu item id view showtanindices mf bycommand m bshowtanindices true mf checked mf unchecked refresh password list cpwsafedlg onviewshowtanindices m_bshowtanindices m_bshowtanindices m_menu checkmenuitem id_view_showtanindices mf_bycommand m_bshowtanindices mf_checked mf_unchecked refreshpasswordlist void c pw safe dlg on plugin message uint nid notify user activity m pimgr call plugins kpm direct exec lparam nid 0 cpwsafedlg onpluginmessage notifyuseractivity m_pimgr callplugins kpm_direct_exec void c pw safe dlg on update plugin message c cmdui p cmdui int i j kp menu item p menu item for i 0 i int m pimgr m plugins size i for j 0 j int m pimgr m plugins i info dw num commands j p menu item m pimgr m plugins i info p menu items j if p menu item dw commandid dword p cmdui m nid p cmdui enable p menu item dw flags kpmif disabled 0 false true if p menu item dw flags kpmif checkbox p cmdui set check p menu item dw state kpmis checked true false return cpwsafedlg onupdatepluginmessage ccmdui pcmdui kp_menu_item pmenuitem m_pimgr m_plugins m_pimgr m_plugins dwnumcommands pmenuitem m_pimgr m_plugins pmenuitems pmenuitem dwcommandid pcmdui m_nid pcmdui pmenuitem dwflags kpmif_disabled pmenuitem dwflags kpmif_checkbox pcmdui setcheck pmenuitem dwstate kpmis_checked void c pw safe dlg on render format uint n format if m nclipboardmethod cm enhsecure c dialog on render format n format return dword dw index listseltoentryindex pw entry p c string str if dw index dword max return p m mgr get entry dw index assert entry p if p null return str trl field has been pasted str t str trl clipboard cleared c dialog on render format n format switch m nclipboardstate case clipboard delayed username m nclipboardstate clipboard delayed none copy delay rendered clipboard data p psz user name m nclipboardstate clipboard delayed none set status text ex str post message wm my updateclipboard break case clipboard delayed password m nclipboardstate clipboard delayed none m mgr unlock entry password p copy delay rendered clipboard data p psz password m mgr lock entry password p m nclipboardstate clipboard delayed none set status text ex str post message wm my updateclipboard break case clipboard delayed none copy delay rendered clipboard data t c string str2 str2 trl paste operation completed str2 t str2 trl clipboard cleared set status text ex str2 if m hwndnextviewer null change clipboard chain m hwndnextviewer m hwndnextviewer null break default assert false break cpwsafedlg onrenderformat nformat m_nclipboardmethod cm_enhsecure cdialog onrenderformat nformat dwindex _listseltoentryindex pw_entry cstring dwindex dword_max m_mgr getentry dwindex assert_entry _t cdialog onrenderformat nformat m_nclipboardstate clipboard_delayed_username m_nclipboardstate clipboard_delayed_none copydelayrenderedclipboarddata pszusername m_nclipboardstate clipboard_delayed_none setstatustextex postmessage wm_my_updateclipboard clipboard_delayed_password m_nclipboardstate clipboard_delayed_none m_mgr unlockentrypassword copydelayrenderedclipboarddata pszpassword m_mgr lockentrypassword m_nclipboardstate clipboard_delayed_none setstatustextex postmessage wm_my_updateclipboard clipboard_delayed_none copydelayrenderedclipboarddata _t cstring _t setstatustextex m_hwndnextviewer changeclipboardchain m_hwndnextviewer m_hwndnextviewer void c pw safe dlg on render all formats if m nclipboardmethod cm enhsecure c dialog on render all formats return c dialog on render all formats user copied different contents to the windows clipboard set clipboard contents to blank string copy delay rendered clipboard data t cpwsafedlg onrenderallformats m_nclipboardmethod cm_enhsecure cdialog onrenderallformats cdialog onrenderallformats copydelayrenderedclipboarddata _t void c pw safe dlg on change cb chain hwnd h wnd remove hwnd h wnd after c dialog on change cb chain h wnd remove h wnd after if m nclipboardmethod cm enhsecure return if the next window is closing repair the chain if h wnd remove m hwndnextviewer m hwndnextviewer h wnd after otherwise pass the message to the next link else if m hwndnextviewer null send message m hwndnextviewer wm changecbchain wparam h wnd remove lparam h wnd after cpwsafedlg onchangecbchain hwndremove hwndafter cdialog onchangecbchain hwndremove hwndafter m_nclipboardmethod cm_enhsecure hwndremove m_hwndnextviewer m_hwndnextviewer hwndafter m_hwndnextviewer sendmessage m_hwndnextviewer wm_changecbchain hwndremove hwndafter void c pw safe dlg on draw clipboard if m nclipboardmethod cm enhsecure c dialog on draw clipboard return c dialog on draw clipboard clipboard contents changed cpwsafedlg ondrawclipboard m_nclipboardmethod cm_enhsecure cdialog ondrawclipboard cdialog ondrawclipboard bool c pw safe dlg on query end session return true cpwsafedlg onqueryendsession void c pw safe dlg on end session bool b ending if b ending true save options on file exit c wnd on end session b ending cpwsafedlg onendsession bending bending saveoptions onfileexit cwnd onendsession bending bool c pw safe dlg on copy data c wnd p wnd copydatastruct p copy data struct dword dw len dw password len dw key file len c string str data str password str key file str file unreferenced parameter p wnd notify user activity if p copy data struct null return true if p copy data struct lp data null dw len dword tcslen lpctstr p copy data struct lp data if dw len 0 p copy data struct dw data 0xf0fffff0 if m bminimized true m bshowwindow false view hide handler return true else if dw len 0 return true str data lpctstr p copy data struct lp data dw password len p copy data struct dw data 16 dw key file len p copy data struct dw data 0xffff if dw password len dw key file len dw len return true if dw password len 0 str password str data mid 0 dw password len if dw key file len 0 str key file str data mid dw password len dw key file len if dw password len dw key file len 0 str file str data right str data get length int dw password len int dw key file len else str file str data if str file get length 0 return true on file close if m bfileopen true return true if dw password len 0 dw key file len 0 opendatabase null str file str password str key file false null false else if dw password len 0 opendatabase null str file str password null false null false else if dw key file len 0 opendatabase null str file null str key file false null false else opendatabase null str file null null false null false if m bminimized true m bshowwindow false view hide handler return true cpwsafedlg oncopydata cwnd pwnd pcopydatastruct dwlen dwpasswordlen dwkeyfilelen cstring strdata strpassword strkeyfile strfile unreferenced_parameter pwnd notifyuseractivity pcopydatastruct pcopydatastruct lpdata dwlen _tcslen pcopydatastruct lpdata dwlen pcopydatastruct dwdata m_bminimized m_bshowwindow viewhidehandler dwlen strdata pcopydatastruct lpdata dwpasswordlen pcopydatastruct dwdata dwkeyfilelen pcopydatastruct dwdata dwpasswordlen dwkeyfilelen dwlen dwpasswordlen strpassword strdata dwpasswordlen dwkeyfilelen strkeyfile strdata dwpasswordlen dwkeyfilelen dwpasswordlen dwkeyfilelen strfile strdata strdata getlength dwpasswordlen dwkeyfilelen strfile strdata strfile getlength onfileclose m_bfileopen dwpasswordlen dwkeyfilelen _opendatabase strfile strpassword strkeyfile dwpasswordlen _opendatabase strfile strpassword dwkeyfilelen _opendatabase strfile strkeyfile _opendatabase strfile m_bminimized m_bshowwindow viewhidehandler lresult c pw safe dlg on taskbar created wparam w param lparam l param unreferenced parameter w param unreferenced parameter l param when the taskbar gets recreated possibly because of a crash in explorer re add the icon m systray add icon return 0 cpwsafedlg ontaskbarcreated wparam lparam unreferenced_parameter wparam unreferenced_parameter lparam m_systray addicon c string geturl const return m strurl cstring m_strurl colorref get link colour const return m crlinkcolour getlinkcolour m_crlinkcolour colorref get visited colour const return m crvisitedcolour getvisitedcolour m_crvisitedcolour colorref get hover colour const return m crhovercolour gethovercolour m_crhovercolour colorref get background colour const return m crbackground getbackgroundcolour m_crbackground bool get visited const return m bvisited getvisited m_bvisited hcursor cx hyper link get link cursor const return m hlinkcursor cxhyperlink getlinkcursor m_hlinkcursor int get underline const return m nunderline getunderline m_nunderline bool get auto size const return m badjusttofit getautosize m_badjusttofit void enable tooltip bool b flag m btooltip b flag m tooltip activate m btooltip enabletooltip bflag m_btooltip bflag m_tooltip m_btooltip bool is tooltip emabled const return m btooltip istooltipemabled m_btooltip void set always open new bool b flag m balwaysopennew b flag setalwaysopennew bflag m_balwaysopennew bflag bool get always open new const return m balwaysopennew getalwaysopennew m_balwaysopennew cx hyper link cx hyper link m hlinkcursor null no cursor as yet m crlinkcolour rgb 0 0 238 blue m crvisitedcolour rgb 85 26 139 purple m crhovercolour rgb 255 0 0 red m bovercontrol false cursor not yet over control m bvisited false hasn t been visited yet m nunderline ul hover underline the link m badjusttofit true resize the window to fit the text m strurl t m ntimerid 100 m bnotifyparent false true notify parent m bisurlenabled true true navigate to url m btooltip true true display tooltip m crbackground uint 1 set to default no bg color m balwaysopennew false true always open new browser window cxhyperlink cxhyperlink m_hlinkcursor m_crlinkcolour m_crvisitedcolour m_crhovercolour m_bovercontrol m_bvisited m_nunderline ulhover m_badjusttofit m_strurl _t m_ntimerid m_bnotifyparent m_bisurlenabled m_btooltip m_crbackground m_balwaysopennew cx hyper link cx hyper link trace t in cx hyper link cx hyper link n if m hlinkcursor destroy cursor m hlinkcursor m hlinkcursor null m underlinefont delete object if m brush get safe handle m brush delete object cxhyperlink cxhyperlink _t cxhyperlink cxhyperlink m_hlinkcursor destroycursor m_hlinkcursor m_hlinkcursor m_underlinefont deleteobject m_brush getsafehandle m_brush deleteobject void cx hyper link seturl c string strurl m strurl strurl if is window get safe hwnd position window m tooltip update tip text strurl this tooltip id cxhyperlink cstring m_strurl iswindow getsafehwnd positionwindow m_tooltip updatetiptext tooltip_id c string geturl const return m strurl cstring m_strurl colorref cr hover colour 1 m crlinkcolour cr link colour m crvisitedcolour cr visited colour if cr hover colour 1 m crhovercolour get sys color color highlight else m crhovercolour cr hover colour if is window m hwnd invalidate crhovercolour m_crlinkcolour crlinkcolour m_crvisitedcolour crvisitedcolour crhovercolour m_crhovercolour getsyscolor color_highlight m_crhovercolour crhovercolour iswindow m_hwnd colorref get link colour const return m crlinkcolour getlinkcolour m_crlinkcolour colorref get visited colour const return m crvisitedcolour getvisitedcolour m_crvisitedcolour colorref get hover colour const return m crhovercolour gethovercolour m_crhovercolour void cx hyper link set background colour colorref cr background m crbackground cr background if m brush get safe handle m brush delete object m brush create solid brush m crbackground cxhyperlink setbackgroundcolour crbackground m_crbackground crbackground m_brush getsafehandle m_brush deleteobject m_brush createsolidbrush m_crbackground colorref get background colour const return m crbackground getbackgroundcolour m_crbackground void cx hyper link set visited bool b visited true m bvisited b visited if is window get safe hwnd invalidate cxhyperlink setvisited bvisited m_bvisited bvisited iswindow getsafehwnd bool get visited const return m bvisited getvisited m_bvisited void cx hyper link set link cursor hcursor h cursor m hlinkcursor h cursor if m hlinkcursor null set default cursor cxhyperlink setlinkcursor hcursor m_hlinkcursor hcursor m_hlinkcursor setdefaultcursor hcursor cx hyper link get link cursor const return m hlinkcursor cxhyperlink getlinkcursor m_hlinkcursor void cx hyper link set underline int n underline ul hover if m nunderline n underline return if is window get safe hwnd if n underline ul always set font m underlinefont else set font m stdfont invalidate m nunderline n underline cxhyperlink setunderline nunderline ulhover m_nunderline nunderline iswindow getsafehwnd nunderline ulalways setfont m_underlinefont setfont m_stdfont m_nunderline nunderline int get underline const return m nunderline getunderline m_nunderline void cx hyper link set auto size bool b auto size true m badjusttofit b auto size if is window get safe hwnd position window cxhyperlink setautosize bautosize m_badjusttofit bautosize iswindow getsafehwnd positionwindow bool get auto size const return m badjusttofit getautosize m_badjusttofit void enable tooltip bool b flag m btooltip b flag m tooltip activate m btooltip enabletooltip bflag m_btooltip bflag m_tooltip m_btooltip bool is tooltip emabled const return m btooltip istooltipemabled m_btooltip void set always open new bool b flag m balwaysopennew b flag setalwaysopennew bflag m_balwaysopennew bflag bool get always open new const return m balwaysopennew getalwaysopennew m_balwaysopennew void cx hyper link set window text lpctstr lpsz string assert lpsz string if lpsz string return c static set window text t redraw window c static set window text lpsz string position window cxhyperlink setwindowtext lpszstring lpszstring lpszstring cstatic setwindowtext _t redrawwindow cstatic setwindowtext lpszstring positionwindow hinstance cx hyper link gotourl lpctstr url int showcmd bool b always open new false if no url then this is not an internet link if url url 0 t 0 return hinstance hinstance error 1 tchar key max path 2 first try shell execute tchar verb t open if b always open new verb t new hinstance result shell execute null verb url null null showcmd if it failed get the htm regkey and lookup the program if uint result hinstance error if get reg key hkey classes root t htm key error success tcscat key t shell open command if get reg key hkey classes root key key error success tchar pos pos tcsstr key t 1 if pos null no quotes found pos tcsstr key t 1 check for 1 without quotes if pos null no parameter at all pos key tcslen key 1 else pos t 0 remove the parameter else pos t 0 remove the parameter tcscat pos t tcscat pos url result hinstance t win exec key word showcmd return result cxhyperlink balwaysopennew _t hinstance_error max_path shellexecute _t balwaysopennew _t shellexecute hinstance_error getregkey hkey_classes_root _t error_success _tcscat _t getregkey hkey_classes_root error_success _tcsstr _t _tcsstr _t _tcslen _t _t _tcscat _t _tcscat twinexec bool cx hyper link pre translate message msg p msg m tooltip relay event p msg return c static pre translate message p msg cxhyperlink pretranslatemessage pmsg m_tooltip relayevent pmsg cstatic pretranslatemessage pmsg bool cx hyper link destroy window kill timer m ntimerid return c static destroy window cxhyperlink destroywindow killtimer m_ntimerid cstatic destroywindow void cx hyper link pre subclass window we want to get mouse clicks via stn clicked dword dw style get style set window long get safe hwnd gwl style dw style ss notify set the url as the window text if m strurl is empty get window text m strurl check that the window text isn t empty if it is set it as the url c string str wnd text get window text str wnd text if str wnd text is empty assert m strurl is empty window and url both null duh set window text m strurl c font p font get font if p font hfont h font hfont get stock object default gui font if h font null h font hfont get stock object ansi var font if h font p font c font from handle h font assert p font get safe handle create the underline font logfont lf p font get log font lf m stdfont create font indirect lf lf lf underline byte true m underlinefont create font indirect lf position window adjust size of window to fit url if necessary set default cursor try and load up a hand cursor set underline create the tooltip if m btooltip c rect rect get client rect rect m tooltip create this m tooltip add tool this m strurl rect tooltip id c static pre subclass window cxhyperlink presubclasswindow stn_clicked dwstyle getstyle setwindowlong getsafehwnd gwl_style dwstyle ss_notify m_strurl isempty getwindowtext m_strurl cstring strwndtext getwindowtext strwndtext strwndtext isempty m_strurl isempty setwindowtext m_strurl cfont pfont getfont pfont hfont getstockobject default_gui_font hfont hfont getstockobject ansi_var_font hfont pfont cfont fromhandle hfont pfont getsafehandle pfont getlogfont m_stdfont createfontindirect lfunderline m_underlinefont createfontindirect positionwindow setdefaultcursor setunderline m_btooltip crect getclientrect m_tooltip m_tooltip addtool m_strurl tooltip_id cstatic presubclasswindow long cx hyper link get reg key hkey key lpctstr subkey lptstr retdata hkey hkey long retval reg open key ex key subkey 0 key query value hkey if retval error success long datasize max path tchar data max path reg query value hkey null data datasize tcscpy retdata data reg close key hkey return retval cxhyperlink getregkey regopenkeyex key_query_value error_success max_path max_path regqueryvalue _tcscpy regclosekey void cx hyper link notify parent if m bnotifyparent c wnd p parent get parent if p parent is window p parent m hwnd w param will contain control id p parent send message wm xhyperlink clicked get dlg ctrlid cxhyperlink notifyparent m_bnotifyparent cwnd pparent getparent pparent iswindow pparent m_hwnd wparam pparent sendmessage wm_xhyperlink_clicked getdlgctrlid void cx hyper link position window if is window get safe hwnd m badjusttofit return get the current window position c rect wnd rect client rect get window rect wnd rect get client rect client rect client to screen client rect c wnd p parent get parent if p parent p parent screen to client wnd rect p parent screen to client client rect get the size of the window text c string str wnd text get window text str wnd text cdc pdc getdc c font p old font pdc select object m underlinefont c size extent pdc get text extent str wnd text pdc select object p old font releasedc pdc adjust for window borders extent cx wnd rect width client rect width extent cy wnd rect height client rect height get the text justification via the window style dword dw style get style recalc the window size and position based on the text justification if dw style ss centerimage wnd rect deflate rect 0 wnd rect height extent cy 2 else wnd rect bottom wnd rect top extent cy if dw style ss center wnd rect deflate rect wnd rect width extent cx 2 0 else if dw style ss right wnd rect left wnd rect right extent cx else ss left 0 so we can t test for it explicitly wnd rect right wnd rect left extent cx move the window set window pos null wnd rect left wnd rect top wnd rect width wnd rect height swp nozorder cxhyperlink positionwindow iswindow getsafehwnd m_badjusttofit crect wndrect clientrect getwindowrect wndrect getclientrect clientrect clienttoscreen clientrect cwnd pparent getparent pparent pparent screentoclient wndrect pparent screentoclient clientrect cstring strwndtext getwindowtext strwndtext cfont poldfont selectobject m_underlinefont csize gettextextent strwndtext selectobject poldfont wndrect clientrect wndrect clientrect dwstyle getstyle dwstyle ss_centerimage wndrect deflaterect wndrect wndrect wndrect dwstyle ss_center wndrect deflaterect wndrect dwstyle ss_right wndrect wndrect ss_left wndrect wndrect setwindowpos wndrect wndrect wndrect wndrect swp_nozorder void cx hyper link report error int n error ifdef xhyperlink report error c string str switch n error case 0 str the operating system is out nof memory or resources break case se err pnf str the specified path was not found break case se err fnf str the specified file was not found break case error bad format str the exe file is invalid n non win32 exe or error in exe image break case se err accessdenied str the operating system denied naccess to the specified file break case se err associncomplete str the filename association is nincomplete or invalid break case se err ddebusy str the dde transaction could not nbe completed because other dde transactions nwere being processed break case se err ddefail str the dde transaction failed break case se err ddetimeout str the dde transaction could not nbe completed because the request timed out break case se err dllnotfound str the specified dynamic link library was not found break case se err noassoc str there is no application associated nwith the given filename extension break case se err oom str there was not enough memory to complete the operation break case se err share str a sharing violation occurred default str format t unknown error d occurred n error break str unable to open hyperlink n n str afx message box str mb iconexclamation mb ok else unused always n error endif xhyperlink report error cxhyperlink reporterror nerror xhyperlink_report_error cstring nerror se_err_pnf se_err_fnf error_bad_format se_err_accessdenied se_err_associncomplete se_err_ddebusy se_err_ddefail se_err_ddetimeout se_err_dllnotfound se_err_noassoc se_err_oom se_err_share _t nerror afxmessagebox mb_iconexclamation mb_ok unused_always nerror xhyperlink_report_error void cx hyper link set default cursor if m hlinkcursor null no cursor handle try to load one first try to load the win98 windows 2000 hand cursor trace t loading from idc hand n m hlinkcursor afx get app load standard cursor idc hand if m hlinkcursor null still no cursor handle load the win help hand cursor the following appeared in paul di lascia s jan 1998 msj articles it loads a hand cursor from the winhlp32 exe module trace t loading from winhlp32 n get the windows directory c string str wnd dir get windows directory str wnd dir get buffer max path max path str wnd dir release buffer str wnd dir t winhlp32 exe this retrieves cursor 106 from winhlp32 exe which is a hand pointer hmodule h module load library str wnd dir if h module hcursor h hand cursor load cursor h module makeintresource 106 if h hand cursor m hlinkcursor copy cursor h hand cursor free library h module cxhyperlink setdefaultcursor m_hlinkcursor _t idc_hand m_hlinkcursor afxgetapp loadstandardcursor idc_hand m_hlinkcursor winhelp dilascia _t cstring strwnddir getwindowsdirectory strwnddir getbuffer max_path max_path strwnddir releasebuffer strwnddir _t hmodule loadlibrary strwnddir hmodule hhandcursor loadcursor hmodule hhandcursor m_hlinkcursor copycursor hhandcursor freelibrary hmodule endif assert n ctl color ctlcolor static if m bovercontrol pdc set text color m crhovercolour else if m bvisited pdc set text color m crvisitedcolour else pdc set text color m crlinkcolour transparent text pdc set bk mode transparent if m brush get safe handle pdc set bk color m crbackground return hbrush m brush else return hbrush get stock object null brush nctlcolor ctlcolor_static m_bovercontrol settextcolor m_crhovercolour m_bvisited settextcolor m_crvisitedcolour settextcolor m_crlinkcolour setbkmode m_brush getsafehandle setbkcolor m_crbackground m_brush getstockobject null_brush bool cx hyper link on set cursor c wnd p wnd uint n hit test uint message if m hlinkcursor set cursor m hlinkcursor return true return false cxhyperlink onsetcursor cwnd pwnd nhittest m_hlinkcursor setcursor m_hlinkcursor void cx hyper link on mouse move uint n flags c point point if m bovercontrol cursor has just moved over control m bovercontrol true if m nunderline ul hover set font m underlinefont invalidate set timer m ntimerid 100 null c static on mouse move n flags point cxhyperlink onmousemove nflags cpoint m_bovercontrol m_bovercontrol m_nunderline ulhover setfont m_underlinefont settimer m_ntimerid cstatic onmousemove nflags bool cx hyper link on erase bkgnd cdc pdc c rect rect get client rect rect if m crbackground uint 1 pdc fill solid rect rect m crbackground else pdc fill solid rect rect get sys color color 3dface return true cxhyperlink onerasebkgnd crect getclientrect m_crbackground fillsolidrect m_crbackground fillsolidrect getsyscolor color_3dface void cx hyper link on timer uint nid event c point p get message pos screen to client p c rect rect get client rect rect if rect pt in rect p m bovercontrol false kill timer m ntimerid if m nunderline ul always set font m stdfont rect bottom 10 invalidate rect rect c static on timer nid event cxhyperlink ontimer nidevent cpoint getmessagepos screentoclient crect getclientrect ptinrect m_bovercontrol killtimer m_ntimerid m_nunderline ulalways setfont m_stdfont invalidaterect cstatic ontimer nidevent void cx hyper link on clicked m bovercontrol false int result hinstance error 1 if m bisurlenabled result int gotourl m strurl sw show m balwaysopennew m bvisited result hinstance error if m bvisited message beep mb iconexclamation unable to follow link report error result else set visited repaint to show visited colour notify parent cxhyperlink onclicked m_bovercontrol hinstance_error m_bisurlenabled m_strurl sw_show m_balwaysopennew m_bvisited hinstance_error m_bvisited messagebeep mb_iconexclamation reporterror setvisited notifyparent c memdc cdc pdc int n offset 0 cdc assert pdc null m pdc pdc m poldbitmap null m bmemdc pdc is printing if m bmemdc create a memory dc pdc get clip box m rect create compatibledc pdc m bitmap create compatible bitmap pdc m rect width n offset m rect height m poldbitmap select object m bitmap set window org m rect left m rect top else make a copy of the relevent parts of the current dc for printing m bprinting pdc m bprinting m hdc pdc m hdc m hattribdc pdc m hattribdc fill solid rect m rect pdc get bk color cmemdc noffset m_pdc m_poldbitmap m_bmemdc isprinting m_bmemdc getclipbox m_rect createcompatibledc m_bitmap createcompatiblebitmap m_rect noffset m_rect m_poldbitmap selectobject m_bitmap setwindoworg m_rect m_rect m_bprinting m_bprinting m_hdc m_hdc m_hattribdc m_hattribdc fillsolidrect m_rect getbkcolor c memdc if m bmemdc copy the offscreen bitmap onto the screen m pdc bit blt m rect left m rect top m rect width m rect height this m rect left m rect top srccopy swap back the original bitmap select object m poldbitmap else all we need to do is replace the dc with an illegal value this keeps us from accidently deleting the handles associated with the cdc that was passed to the constructor m hdc m hattribdc null cmemdc m_bmemdc m_pdc bitblt m_rect m_rect m_rect m_rect m_rect m_rect selectobject m_poldbitmap m_hdc m_hattribdc c memdc cdc pdc int n offset 0 cdc assert pdc null m pdc pdc m poldbitmap null m bmemdc pdc is printing if m bmemdc create a memory dc pdc get clip box m rect create compatibledc pdc m bitmap create compatible bitmap pdc m rect width n offset m rect height m poldbitmap select object m bitmap set window org m rect left m rect top else make a copy of the relevent parts of the current dc for printing m bprinting pdc m bprinting m hdc pdc m hdc m hattribdc pdc m hattribdc fill solid rect m rect pdc get bk color cmemdc noffset m_pdc m_poldbitmap m_bmemdc isprinting m_bmemdc getclipbox m_rect createcompatibledc m_bitmap createcompatiblebitmap m_rect noffset m_rect m_poldbitmap selectobject m_bitmap setwindoworg m_rect m_rect m_bprinting m_bprinting m_hdc m_hdc m_hattribdc m_hattribdc fillsolidrect m_rect getbkcolor c memdc if m bmemdc copy the offscreen bitmap onto the screen m pdc bit blt m rect left m rect top m rect width m rect height this m rect left m rect top srccopy swap back the original bitmap select object m poldbitmap else all we need to do is replace the dc with an illegal value this keeps us from accidently deleting the handles associated with the cdc that was passed to the constructor m hdc m hattribdc null cmemdc m_bmemdc m_pdc bitblt m_rect m_rect m_rect m_rect m_rect m_rect selectobject m_poldbitmap m_hdc m_hattribdc c dialog c add entry dlg idd p parent afx data init c add entry dlg m bstars true m strtitle t m strurl t pwae stdurl a m strusername t m strattachment t m bexpires false afx data init m pmgr null m ngroupid 1 m niconid 0 m beditmode false m pparenticons null m strnotes t m lppassword m lprepeatpw null m dwdefaultexpire 0 m bautopwgen true cdialog caddentrydlg pparent afx_data_init caddentrydlg m_bstars m_strtitle _t m_strurl _t pwae_stdurl_a m_strusername _t m_strattachment _t m_bexpires afx_data_init m_pmgr m_ngroupid m_niconid m_beditmode m_pparenticons m_strnotes _t m_lppassword m_lprepeatpw m_dwdefaultexpire m_bautopwgen void c add entry dlg clean up m renotes empty undo buffer m cbgroups reset content m fstyle delete object m fsymbol delete object caddentrydlg cleanup m_renotes emptyundobuffer m_cbgroups resetcontent m_fstyle deleteobject m_fsymbol deleteobject void c add entry dlg update controls status update data true if m strattachment get length 0 m strattachment c string pws new attachment m btsetattachment enable window true m btsaveattachment enable window false m btremoveattachment enable window false else m btsetattachment enable window true if m strattachment left int tcslen pws new attachment c string pws new attachment m btsaveattachment enable window true else m btsaveattachment enable window false m btremoveattachment enable window true if m strtitle c string pws tan entry m btsetattachment enable window false unchangable if m bexpires true m editdate enable window true m edittime enable window true else m editdate enable window false m edittime enable window false if m dwdefaultexpire 0 m btsettodefaultexpire enable window false unchangable caddentrydlg updatecontrolsstatus updatedata m_strattachment getlength m_strattachment cstring pws_new_attachment m_btsetattachment enablewindow m_btsaveattachment enablewindow m_btremoveattachment enablewindow m_btsetattachment enablewindow m_strattachment _tcslen pws_new_attachment cstring pws_new_attachment m_btsaveattachment enablewindow m_btsaveattachment enablewindow m_btremoveattachment enablewindow m_strtitle cstring pws_tan_entry m_btsetattachment enablewindow m_bexpires m_editdate enablewindow m_edittime enablewindow m_editdate enablewindow m_edittime enablewindow m_dwdefaultexpire m_btsettodefaultexpire enablewindow void c add entry dlg set expire days dword dw days bool b set time update data true m bexpires true c time t c time get current time t c time span long dw days 0 0 0 m editdate set date t beware of daylight saving if b set time true m edittime set time t update data false update controls status caddentrydlg setexpiredays dwdays bsettime updatedata m_bexpires ctime ctime getcurrenttime ctimespan dwdays m_editdate setdate bsettime m_edittime settime updatedata updatecontrolsstatus bool c add entry dlg pre translate message msg p msg m tipsecclear relay event p msg return c dialog pre translate message p msg caddentrydlg pretranslatemessage pmsg m_tipsecclear relayevent pmsg cdialog pretranslatemessage pmsg void c add entry dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c add entry dlg ddx control pdx idc seldefexpires btn m btseldefexpires ddx control pdx idc setdefaultexpire btn m btsettodefaultexpire ddx control pdx idc combo groups m cbgroups ddx control pdx idc hl help url m hlhelpurl ddx control pdx idc hl help autotype m hlhelpautotype ddx control pdx idc progress passquality m cpassquality ddx control pdx idc removeattach btn m btremoveattachment ddx control pdx idc saveattach btn m btsaveattachment ddx control pdx idc setattach btn m btsetattachment ddx control pdx idc edit expire time m edittime ddx control pdx idc edit expire date m editdate ddx control pdx idc check hidepw m bthidepw ddx control pdx idok m btok ddx control pdx idcancel m btcancel ddx control pdx idc randompw btn m btrandompw ddx control pdx idc pickicon btn m btpickicon ddx control pdx idc edit url m purl ddx control pdx idc edit repeatpw m prepeatpw ddx control pdx idc edit password m peditpw ddx check pdx idc check hidepw m bstars ddx text pdx idc edit title m strtitle ddx text pdx idc edit url m strurl ddx text pdx idc edit username m strusername ddx control pdx idc re notes m renotes ddx text pdx idc edit attachment m strattachment ddx check pdx idc check expires m bexpires afx data map caddentrydlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map caddentrydlg ddx_control idc_seldefexpires_btn m_btseldefexpires ddx_control idc_setdefaultexpire_btn m_btsettodefaultexpire ddx_control idc_combo_groups m_cbgroups ddx_control idc_hl_help_url m_hlhelpurl ddx_control idc_hl_help_autotype m_hlhelpautotype ddx_control idc_progress_passquality m_cpassquality ddx_control idc_removeattach_btn m_btremoveattachment ddx_control idc_saveattach_btn m_btsaveattachment ddx_control idc_setattach_btn m_btsetattachment ddx_control idc_edit_expire_time m_edittime ddx_control idc_edit_expire_date m_editdate ddx_control idc_check_hidepw m_bthidepw ddx_control m_btok ddx_control m_btcancel ddx_control idc_randompw_btn m_btrandompw ddx_control idc_pickicon_btn m_btpickicon ddx_control idc_edit_url m_purl ddx_control idc_edit_repeatpw m_prepeatpw ddx_control idc_edit_password m_peditpw ddx_check idc_check_hidepw m_bstars ddx_text idc_edit_title m_strtitle ddx_text idc_edit_url m_strurl ddx_text idc_edit_username m_strusername ddx_control idc_re_notes m_renotes ddx_text idc_edit_attachment m_strattachment ddx_check idc_check_expires m_bexpires afx_data_map bool c add entry dlg on notify wparam w param lparam l param lresult p result msgfilter lp msg filter msgfilter l param if w param idc re notes lp msg filter nmhdr code en msgfilter lp msg filter msg wm rbuttondown point pt get cursor pos pt m popmenu load menu idr rectx menu m popmenu set menu draw mode bcmenu drawmode xp bcmenu drawmode original m popmenu set select disable mode false m popmenu setxp bitmap3d true m popmenu set bitmap background rgb 255 0 255 m popmenu set icon size 16 16 m popmenu load toolbar idr infoicons idb infoicons ex bc menu psub bc menu m popmenu get sub menu 0 c pw safe dlg translatemenu psub true null psub track popup menu tpm leftalign tpm rightbutton pt x pt y this m popmenu destroy menu return c dialog on notify w param l param p result caddentrydlg onnotify wparam lparam presult lpmsgfilter lparam wparam idc_re_notes lpmsgfilter en_msgfilter lpmsgfilter wm_rbuttondown getcursorpos m_popmenu loadmenu idr_rectx_menu m_popmenu setmenudrawmode bcmenu_drawmode_xp bcmenu_drawmode_original m_popmenu setselectdisablemode m_popmenu setxpbitmap3d m_popmenu setbitmapbackground m_popmenu seticonsize m_popmenu loadtoolbar idr_infoicons idb_infoicons_ex bcmenu bcmenu m_popmenu getsubmenu cpwsafedlg _translatemenu trackpopupmenu tpm_leftalign tpm_rightbutton m_popmenu destroymenu cdialog onnotify wparam lparam presult bool c add entry dlg on init dialog c dialog on init dialog assert m pparenticons null parent must set image list first translate all windows enum child windows this m hwnd newgui translatewindowcb 0 the password dots font m fstyle create font 12 0 0 0 0 false false 0 default charset out default precis clip default precis default quality default pitch ff modern t tahoma m fsymbol create font 13 0 0 0 0 false false 0 default charset out default precis clip default precis default quality default pitch ff modern c pw safe app get password font if m bstars false get dlg item idc edit password set font m fstyle true m peditpw set font m fstyle true get dlg item idc edit repeatpw set font m fstyle true m prepeatpw set font m fstyle true m peditpw enable secure mode false m prepeatpw enable secure mode false else get dlg item idc edit password set font m fsymbol true m peditpw set font m fsymbol true get dlg item idc edit repeatpw set font m fsymbol true m prepeatpw set font m fsymbol true m peditpw enable secure mode c pw safe dlg m bsecureedits m prepeatpw enable secure mode c pw safe dlg m bsecureedits get dlg item idc check hidepw set font m fsymbol true m bthidepw set font m fsymbol true newgui configqualitymeter m cpassquality make the buttons look cool newgui xpbutton m btok idb ok idb ok newgui xpbutton m btcancel idb cancel idb cancel newgui xpbutton m btrandompw 1 1 newgui xpbutton m btpickicon 1 1 newgui xpbutton m bthidepw 1 1 newgui xpbutton m btsetattachment idb file idb file true newgui xpbutton m btsaveattachment idb disk idb disk true newgui xpbutton m btremoveattachment idb tb deleteentry idb tb deleteentry true newgui xpbutton m btsettodefaultexpire idb tb defaultexpire idb tb defaultexpire true newgui xpbutton m btseldefexpires idb clock idb clock true m bthidepw set color c buttonst btnst color fg in rgb 0 0 255 true c string strtt trl hide passwords behind asterisks strtt remove t m bthidepw set tooltip text strtt true m btrandompw set tooltip text trl generate a random password m btsetattachment set tooltip text trl open file and set as attachment m btsaveattachment set tooltip text trl save attached file to disk m btremoveattachment set tooltip text trl remove the currently attached file strtt trl change expiration time strtt remove t m btseldefexpires set tooltip text strtt m btseldefexpires set menu idr expiresmenu this m hwnd true null c size 16 15 strtt trl pick one strtt remove t m btpickicon set tooltip text strtt true if m niconid 0 m pparenticons null m btpickicon set icon m pparenticons extract icon m niconid if m dwdefaultexpire 0 c string str str temp str format trl click to expire the entry in u days m dwdefaultexpire c time t c time get current time t c time span long m dwdefaultexpire 0 0 0 str temp format t 04d 02d 02d t get year t get month t get day str str temp m btsettodefaultexpire set tooltip text str newgui makehyperlink m hlhelpautotype m hlhelpautotype enable tooltip false m hlhelpautotype set notify parent true m hlhelpautotype enableurl false newgui makehyperlink m hlhelpurl m hlhelpurl enable tooltip false m hlhelpurl set notify parent true m hlhelpurl enableurl false m cbgroups set image list m pparenticons assert m pmgr null must have been initialized by parent unsigned int i pw group p comboboxexitem cbi for i 0 i unsigned int m pmgr get number of groups i p m pmgr get group i assert p null if p null continue zero memory cbi sizeof comboboxexitem cbi mask cbeif image cbeif text cbeif indent cbeif selectedimage cbi i item int i cbi psz text lptstr p psz group name cbi cch text max int tcslen p psz group name cbi i image cbi i selected image int p u image id cbi i indent int p us level m cbgroups insert item cbi assert m ngroupid 1 must have been initialized by parent if m ngroupid 1 m cbgroups set cur sel m ngroupid configure banner control newgui configsidebanner m banner this m banner set icon afx get app load icon idi entry edit kcsb icon left kcsb icon vcenter if m beditmode false m banner set title trl add entry m banner set caption trl add a new password entry set window text trl add entry else m banner set title trl edit entry m banner set caption trl modify a password entry set window text trl edit entry z 27 is that black dot in tahoma tchar tch dot tchar t z 27 tchar tch dot c pw safe app get password character c string str stars str stars tch dot str stars tch dot str stars tch dot get dlg item idc check hidepw set window text str stars configure link edit control m purl set link option heol auto m purl set underline option heou always m purl set visited false m purl setie colours m purl set dbl clk to jump true m purl set window text m strurl c ole date time ole min ams min oledatetime c ole date time ole max 2999 12 31 23 59 59 m editdate set range ole min ole max m editdate set date int unsigned int m texpire sh year int unsigned int m texpire bt month int unsigned int m texpire bt day m edittime set range ole min ole max m edittime setampm true m edittime show24 hour format true m edittime show seconds true m edittime set time int unsigned int m texpire bt hour int unsigned int m texpire bt minute int unsigned int m texpire bt second pw time t never m pmgr getneverexpiretime t never if pwtimecmp t never m texpire 0 m bexpires false else m bexpires true m renotes limit text 0 m renotes set event mask enm mouseevents enm link m renotes send message em autourldetect true 0 ifdef unicode m renotes setrtf m strnotes sf text sf unicode else m renotes setrtf m strnotes sf text endif m tipsecclear create this 0x40 m tipsecclear add tool m peditpw c pw safe dlg getsecureedittiptext t enter password m tipsecclear add tool m prepeatpw c pw safe dlg getsecureedittiptext t enter password m tipsecclear set max tip width 630 m tipsecclear activate m peditpw is secure mode enabled update data false removed m bstars true parent can decide to show the password or not on check hide pw update gui based on m bstars flag if m beditmode false generate a pseudo random password if m bautopwgen true c new random p rand new c new random c base64 codec base64 dword dw size 32 byte pb random 16 pb string 32 assert p rand null p rand initialize get system entropy p rand get random buffer pb random 16 verify base64 encode pb random 16 pb string dw size safe delete p rand pb string strlen char pb string 3 0 tchar pb stringt utf8tostring utf8 byte pb string 1 m peditpw set password pb stringt m prepeatpw set password pb stringt mem erase byte pb stringt tcslen pb stringt sizeof tchar safe delete array pb stringt mem erase pb random 16 mem erase pb string 32 update data false else m peditpw set password t m prepeatpw set password t update controls status if m beditmode true if m lppassword null m peditpw set password m lppassword m peditpw delete password m lppassword m lppassword null if m lprepeatpw null m prepeatpw set password m lprepeatpw m prepeatpw delete password m lprepeatpw m lprepeatpw null if m strtitle pws tan entry get dlg item idc edit title enable window false get dlg item idc edit username enable window false get dlg item idc edit url enable window false get dlg item idc randompw btn enable window false m btrandompw enable window false get dlg item idc pickicon btn enable window false m btpickicon enable window false get dlg item idc edit password set focus else get dlg item idc edit title enable window true get dlg item idc edit username enable window true get dlg item idc edit url enable window true get dlg item idc randompw btn enable window true get dlg item idc pickicon btn enable window true get dlg item idc edit title set focus lptstr lp temp m peditpw get password newgui showqualitymeter m cpassquality get dlg item idc static passbits lp temp m peditpw delete password lp temp lp temp null c string str test m btrandompw get window text str test if str test find t g 0 0 extend buttons if using a language that has special accelerator tips rect rc mover m peditpw get window rect rc mover screen to client rc mover rc mover right 25 m peditpw move window rc mover m prepeatpw get window rect rc mover screen to client rc mover rc mover right 25 m prepeatpw move window rc mover m btrandompw get window rect rc mover screen to client rc mover rc mover left 25 m btrandompw move window rc mover m bthidepw get window rect rc mover screen to client rc mover rc mover left 25 m bthidepw move window rc mover return false return true unless you set the focus to a control caddentrydlg oninitdialog cdialog oninitdialog m_pparenticons enumchildwindows m_hwnd newgui_translatewindowcb m_fstyle createfont default_charset out_default_precis clip_default_precis default_quality default_pitch ff_modern _t m_fsymbol createfont default_charset out_default_precis clip_default_precis default_quality default_pitch ff_modern cpwsafeapp getpasswordfont m_bstars getdlgitem idc_edit_password setfont m_fstyle m_peditpw setfont m_fstyle getdlgitem idc_edit_repeatpw setfont m_fstyle m_prepeatpw setfont m_fstyle m_peditpw enablesecuremode m_prepeatpw enablesecuremode getdlgitem idc_edit_password setfont m_fsymbol m_peditpw setfont m_fsymbol getdlgitem idc_edit_repeatpw setfont m_fsymbol m_prepeatpw setfont m_fsymbol m_peditpw enablesecuremode cpwsafedlg m_bsecureedits m_prepeatpw enablesecuremode cpwsafedlg m_bsecureedits getdlgitem idc_check_hidepw setfont m_fsymbol m_bthidepw setfont m_fsymbol newgui_configqualitymeter m_cpassquality newgui_xpbutton m_btok idb_ok idb_ok newgui_xpbutton m_btcancel idb_cancel idb_cancel newgui_xpbutton m_btrandompw newgui_xpbutton m_btpickicon newgui_xpbutton m_bthidepw newgui_xpbutton m_btsetattachment idb_file idb_file newgui_xpbutton m_btsaveattachment idb_disk idb_disk newgui_xpbutton m_btremoveattachment idb_tb_deleteentry idb_tb_deleteentry newgui_xpbutton m_btsettodefaultexpire idb_tb_defaultexpire idb_tb_defaultexpire newgui_xpbutton m_btseldefexpires idb_clock idb_clock m_bthidepw setcolor cbuttonst btnst_color_fg_in cstring _t m_bthidepw settooltiptext m_btrandompw settooltiptext m_btsetattachment settooltiptext m_btsaveattachment settooltiptext m_btremoveattachment settooltiptext _t m_btseldefexpires settooltiptext m_btseldefexpires setmenu idr_expiresmenu m_hwnd csize _t m_btpickicon settooltiptext m_niconid m_pparenticons m_btpickicon seticon m_pparenticons extracticon m_niconid m_dwdefaultexpire cstring strtemp m_dwdefaultexpire ctime ctime getcurrenttime ctimespan m_dwdefaultexpire strtemp _t getyear getmonth getday strtemp m_btsettodefaultexpire settooltiptext newgui_makehyperlink m_hlhelpautotype m_hlhelpautotype enabletooltip m_hlhelpautotype setnotifyparent m_hlhelpautotype newgui_makehyperlink m_hlhelpurl m_hlhelpurl enabletooltip m_hlhelpurl setnotifyparent m_hlhelpurl m_cbgroups setimagelist m_pparenticons m_pmgr pw_group m_pmgr getnumberofgroups m_pmgr getgroup zeromemory cbeif_image cbeif_text cbeif_indent cbeif_selectedimage iitem psztext pszgroupname cchtextmax _tcslen pszgroupname iimage iselectedimage uimageid iindent uslevel m_cbgroups insertitem m_ngroupid m_ngroupid m_cbgroups setcursel m_ngroupid newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_entry_edit kcsb_icon_left kcsb_icon_vcenter m_beditmode m_banner settitle m_banner setcaption setwindowtext m_banner settitle m_banner setcaption setwindowtext tchdot _t tchdot cpwsafeapp getpasswordcharacter cstring strstars strstars tchdot strstars tchdot strstars tchdot getdlgitem idc_check_hidepw setwindowtext strstars m_purl setlinkoption heol_auto m_purl setunderlineoption heou_always m_purl setvisited m_purl setiecolours m_purl setdblclktojump m_purl setwindowtext m_strurl coledatetime olemin ams_min_oledatetime coledatetime olemax m_editdate setrange olemin olemax m_editdate setdate m_texpire shyear m_texpire btmonth m_texpire btday m_edittime setrange olemin olemax m_edittime m_edittime show24hourformat m_edittime showseconds m_edittime settime m_texpire bthour m_texpire btminute m_texpire btsecond pw_time tnever m_pmgr _getneverexpiretime tnever _pwtimecmp tnever m_texpire m_bexpires m_bexpires m_renotes limittext m_renotes seteventmask enm_mouseevents enm_link m_renotes sendmessage em_autourldetect _unicode m_renotes m_strnotes sf_text sf_unicode m_renotes m_strnotes sf_text m_tipsecclear m_tipsecclear addtool m_peditpw cpwsafedlg _getsecureedittiptext _t m_tipsecclear addtool m_prepeatpw cpwsafedlg _getsecureedittiptext _t m_tipsecclear setmaxtipwidth m_tipsecclear m_peditpw issecuremodeenabled updatedata m_bstars oncheckhidepw m_bstars m_beditmode m_bautopwgen cnewrandom prand cnewrandom cbase64codec dwsize pbrandom pbstring prand prand prand getrandombuffer pbrandom pbrandom pbstring dwsize safe_delete prand pbstring pbstring pbstringt _utf8tostring utf8_byte pbstring m_peditpw setpassword pbstringt m_prepeatpw setpassword pbstringt mem_erase pbstringt _tcslen pbstringt safe_delete_array pbstringt mem_erase pbrandom mem_erase pbstring updatedata m_peditpw setpassword _t m_prepeatpw setpassword _t updatecontrolsstatus m_beditmode m_lppassword m_peditpw setpassword m_lppassword m_peditpw deletepassword m_lppassword m_lppassword m_lprepeatpw m_prepeatpw setpassword m_lprepeatpw m_prepeatpw deletepassword m_lprepeatpw m_lprepeatpw m_strtitle pws_tan_entry getdlgitem idc_edit_title enablewindow getdlgitem idc_edit_username enablewindow getdlgitem idc_edit_url enablewindow getdlgitem idc_randompw_btn enablewindow m_btrandompw enablewindow getdlgitem idc_pickicon_btn enablewindow m_btpickicon enablewindow getdlgitem idc_edit_password setfocus getdlgitem idc_edit_title enablewindow getdlgitem idc_edit_username enablewindow getdlgitem idc_edit_url enablewindow getdlgitem idc_randompw_btn enablewindow getdlgitem idc_pickicon_btn enablewindow getdlgitem idc_edit_title setfocus lptemp m_peditpw getpassword newgui_showqualitymeter m_cpassquality getdlgitem idc_static_passbits lptemp m_peditpw deletepassword lptemp lptemp cstring strtest m_btrandompw getwindowtext strtest strtest _t rcmover m_peditpw getwindowrect rcmover screentoclient rcmover rcmover m_peditpw movewindow rcmover m_prepeatpw getwindowrect rcmover screentoclient rcmover rcmover m_prepeatpw movewindow rcmover m_btrandompw getwindowrect rcmover screentoclient rcmover rcmover m_btrandompw movewindow rcmover m_bthidepw getwindowrect rcmover screentoclient rcmover rcmover m_bthidepw movewindow rcmover void c add entry dlg onok update data true if m editdate get window text length 0 m editdate set date 2999 12 28 if m edittime get window text length 0 m edittime set time 23 59 59 assert m lppassword null if m lppassword null c secure edit ex delete password m lppassword m lppassword m peditpw get password assert m lprepeatpw null if m lprepeatpw null c secure edit ex delete password m lprepeatpw m lprepeatpw m prepeatpw get password c string str group test m cbgroups getlb text m cbgroups get cur sel str group test if c pw manager is allowed store group lpctstr str group test pws searchgroup false message box trl the group you selected cannot store entries please select an other group trl stop mb iconwarning mb ok return if m bexpires true m texpire sh year ushort m editdate get year m texpire bt month byte m editdate get month m texpire bt day byte m editdate get day m texpire bt hour byte m edittime get hour m texpire bt minute byte m edittime get minute m texpire bt second byte m edittime get second else m pmgr getneverexpiretime m texpire m renotes get window text m strnotes m ngroupid m cbgroups get cur sel if tcscmp m lppassword m lprepeatpw 0 c secure edit ex delete password m lppassword m lppassword null c secure edit ex delete password m lprepeatpw m lprepeatpw null message box trl password and repeated password aren t identical trl stop mb ok mb iconwarning return if the user hasn t changed the standard url assume no url if m strurl pwae stdurl m strurl empty update data false clean up c dialog onok caddentrydlg updatedata m_editdate getwindowtextlength m_editdate setdate m_edittime getwindowtextlength m_edittime settime m_lppassword m_lppassword csecureeditex deletepassword m_lppassword m_lppassword m_peditpw getpassword m_lprepeatpw m_lprepeatpw csecureeditex deletepassword m_lprepeatpw m_lprepeatpw m_prepeatpw getpassword cstring strgrouptest m_cbgroups getlbtext m_cbgroups getcursel strgrouptest cpwmanager isallowedstoregroup strgrouptest pws_searchgroup messagebox mb_iconwarning mb_ok m_bexpires m_texpire shyear m_editdate getyear m_texpire btmonth m_editdate getmonth m_texpire btday m_editdate getday m_texpire bthour m_edittime gethour m_texpire btminute m_edittime getminute m_texpire btsecond m_edittime getsecond m_pmgr _getneverexpiretime m_texpire m_renotes getwindowtext m_strnotes m_ngroupid m_cbgroups getcursel _tcscmp m_lppassword m_lprepeatpw csecureeditex deletepassword m_lppassword m_lppassword csecureeditex deletepassword m_lprepeatpw m_lprepeatpw messagebox mb_ok mb_iconwarning m_strurl pwae_stdurl m_strurl updatedata cleanup cdialog void c add entry dlg on cancel clean up c dialog on cancel caddentrydlg oncancel cleanup cdialog oncancel void c add entry dlg on check hide pw update data true if m bstars false m peditpw enable secure mode false m prepeatpw enable secure mode false m peditpw set password char 0 m prepeatpw set password char 0 m peditpw set font m fstyle true m prepeatpw set font m fstyle true else m bstars true m peditpw enable secure mode c pw safe dlg m bsecureedits m prepeatpw enable secure mode c pw safe dlg m bsecureedits tchar tch dot tchar t z 27 tchar tch dot c pw safe app get password character m peditpw set password char tch dot m prepeatpw set password char tch dot m peditpw set font m fsymbol true m prepeatpw set font m fsymbol true m tipsecclear activate m peditpw is secure mode enabled update data false m prepeatpw set focus m peditpw set focus caddentrydlg oncheckhidepw updatedata m_bstars m_peditpw enablesecuremode m_prepeatpw enablesecuremode m_peditpw setpasswordchar m_prepeatpw setpasswordchar m_peditpw setfont m_fstyle m_prepeatpw setfont m_fstyle m_bstars m_peditpw enablesecuremode cpwsafedlg m_bsecureedits m_prepeatpw enablesecuremode cpwsafedlg m_bsecureedits tchdot _t tchdot cpwsafeapp getpasswordcharacter m_peditpw setpasswordchar tchdot m_prepeatpw setpasswordchar tchdot m_peditpw setfont m_fsymbol m_prepeatpw setfont m_fsymbol m_tipsecclear m_peditpw issecuremodeenabled updatedata m_prepeatpw setfocus m_peditpw setfocus void c add entry dlg on pick icon btn c icon picker dlg dlg dlg m pimagelist m pparenticons dlg m unumicons uint m pparenticons get image count dlg m nselectedicon m niconid if dlg do modal idok m niconid dlg m nselectedicon if m niconid 0 m pparenticons null m btpickicon set icon m pparenticons extract icon m niconid caddentrydlg onpickiconbtn ciconpickerdlg m_pimagelist m_pparenticons m_unumicons m_pparenticons getimagecount m_nselectedicon m_niconid domodal m_niconid m_nselectedicon m_niconid m_pparenticons m_btpickicon seticon m_pparenticons extracticon m_niconid void c add entry dlg on random pw btn c pw generator dlg dlg update data true dlg m bcanaccept true dlg m bhidepw m bstars if dlg do modal idok m peditpw set password lpctstr dlg m lppassword m prepeatpw set password lpctstr dlg m lppassword c secure edit ex delete password dlg m lppassword dlg m lppassword null update data false lptstr lp m peditpw get password newgui showqualitymeter m cpassquality get dlg item idc static passbits lp m peditpw delete password lp lp null caddentrydlg onrandompwbtn cpwgeneratordlg updatedata m_bcanaccept m_bhidepw m_bstars domodal m_peditpw setpassword m_lppassword m_prepeatpw setpassword m_lppassword csecureeditex deletepassword m_lppassword m_lppassword updatedata m_peditpw getpassword newgui_showqualitymeter m_cpassquality getdlgitem idc_static_passbits m_peditpw deletepassword void c add entry dlg on re copy all long l start l end m renotes get sel l start l end m renotes set sel 0 1 m renotes copy m renotes set sel l start l end caddentrydlg onrecopyall lstart lend m_renotes getsel lstart lend m_renotes setsel m_renotes m_renotes setsel lstart lend void c add entry dlg on re copy sel m renotes copy caddentrydlg onrecopysel m_renotes void c add entry dlg on re delete m renotes clear caddentrydlg onredelete m_renotes void c add entry dlg on re paste m renotes paste caddentrydlg onrepaste m_renotes void c add entry dlg on re select all m renotes set sel 0 1 caddentrydlg onreselectall m_renotes setsel void c add entry dlg on re cut m renotes cut caddentrydlg onrecut m_renotes void c add entry dlg on re undo m renotes undo caddentrydlg onreundo m_renotes void c add entry dlg on set attach btn dword dw flags c string str filter update data true str filter trl all files str filter t dw flags ofn longnames ofn extensiondifferent ofn explorer 0x00080000 ofn enablesizing 0x00800000 dw flags 0x00080000 0x00800000 dw flags ofn pathmustexist ofn filemustexist ofn hidereadonly c file dialog dlg true null null dw flags str filter this if dlg do modal idok int n ret if m strattachment c string pws new attachment n ret idyes else if m strattachment is empty false c string str msg str msg trl there already is a file attached with this entry str msg t r n r n str msg trl do you want to overwrite the current attachment n ret message box str msg trl overwrite mb yesno mb iconquestion else n ret idyes if n ret idyes m strattachment c string pws new attachment dlg get path name update data false update controls status caddentrydlg onsetattachbtn dwflags cstring strfilter updatedata strfilter strfilter _t dwflags ofn_longnames ofn_extensiondifferent ofn_explorer ofn_enablesizing dwflags dwflags ofn_pathmustexist ofn_filemustexist ofn_hidereadonly cfiledialog dwflags strfilter domodal nret m_strattachment cstring pws_new_attachment nret m_strattachment isempty cstring strmsg strmsg strmsg _t strmsg nret messagebox strmsg mb_yesno mb_iconquestion nret nret m_strattachment cstring pws_new_attachment getpathname updatedata updatecontrolsstatus void c add entry dlg on save attach btn update data true dword dw flags c string str sample c string str filter pw entry p entry if m dwentryindex dword max return p entry m pmgr get entry m dwentryindex assert p entry null if p entry null return if tcslen p entry psz binary desc 0 message box trl there is no file attached with this entry trl password safe mb iconinformation return str sample p entry psz binary desc str filter trl all files str filter t dw flags ofn longnames ofn hidereadonly ofn overwriteprompt dw flags ofn extensiondifferent ofn explorer 0x00080000 ofn enablesizing 0x00800000 dw flags 0x00080000 0x00800000 ofn noreadonlyreturn c file dialog dlg false null str sample dw flags str filter this if dlg do modal idok m pmgr save binary data p entry dlg get path name update data false update controls status caddentrydlg onsaveattachbtn updatedata dwflags cstring strsample cstring strfilter pw_entry pentry m_dwentryindex dword_max pentry m_pmgr getentry m_dwentryindex pentry pentry _tcslen pentry pszbinarydesc messagebox mb_iconinformation strsample pentry pszbinarydesc strfilter strfilter _t dwflags ofn_longnames ofn_hidereadonly ofn_overwriteprompt dwflags ofn_extensiondifferent ofn_explorer ofn_enablesizing dwflags ofn_noreadonlyreturn cfiledialog strsample dwflags strfilter domodal m_pmgr savebinarydata pentry getpathname updatedata updatecontrolsstatus void c add entry dlg on remove attach btn update data true m strattachment c string pws new attachment update data false update controls status caddentrydlg onremoveattachbtn updatedata m_strattachment cstring pws_new_attachment updatedata updatecontrolsstatus void c add entry dlg on change edit password update data true lptstr lp m peditpw get password newgui showqualitymeter m cpassquality get dlg item idc static passbits lp m peditpw delete password lp lp null caddentrydlg onchangeeditpassword updatedata m_peditpw getpassword newgui_showqualitymeter m_cpassquality getdlgitem idc_static_passbits m_peditpw deletepassword void c add entry dlg on check expires update controls status caddentrydlg oncheckexpires updatecontrolsstatus void c add entry dlg on set default expire btn if m dwdefaultexpire 0 return set expire days m dwdefaultexpire false caddentrydlg onsetdefaultexpirebtn m_dwdefaultexpire setexpiredays m_dwdefaultexpire hbrush c add entry dlg on ctl color cdc pdc c wnd p wnd uint n ctl color hbrush hbr c dialog on ctl color pdc p wnd n ctl color if n ctl color ctlcolor edit p wnd null if p wnd get dlg ctrlid idc edit url pdc null pdc set text color rgb 0 0 255 return hbr caddentrydlg onctlcolor cwnd pwnd nctlcolor cdialog onctlcolor pwnd nctlcolor nctlcolor ctlcolor_edit pwnd pwnd getdlgctrlid idc_edit_url settextcolor void c add entry dlg on expires1 week set expire days 7 false caddentrydlg onexpires1week setexpiredays void c add entry dlg on expires2 weeks set expire days 14 false caddentrydlg onexpires2weeks setexpiredays void c add entry dlg on expires1 month set expire days 30 false caddentrydlg onexpires1month setexpiredays void c add entry dlg on expires3 months set expire days 91 false caddentrydlg onexpires3months setexpiredays void c add entry dlg on expires6 months set expire days 182 false caddentrydlg onexpires6months setexpiredays void c add entry dlg on expires12 months set expire days 365 false caddentrydlg onexpires12months setexpiredays void c add entry dlg on expires now set expire days 0 true caddentrydlg onexpiresnow setexpiredays void c add entry dlg on re notes click link nmhdr pnmhdr lresult p result enlink p en link reinterpret cast enlink pnmhdr if p en link null return if p en link nmhdr id from idc re notes p en link msg wm lbuttondown charrange cr m renotes get sel cr push current user selection m renotes set sel p en link chrg c string str selectedurl m renotes get sel text m renotes set sel cr pop current user selection if str selectedurl get length 0 open url ex str selectedurl p result 0 caddentrydlg onrenotesclicklink presult penlink reinterpret_cast penlink penlink idfrom idc_re_notes penlink wm_lbuttondown m_renotes getsel m_renotes setsel penlink cstring strselectedurl m_renotes getseltext m_renotes setsel strselectedurl getlength openurlex strselectedurl presult lresult c add entry dlg onx hyper link clicked wparam w param lparam l param unreferenced parameter l param if w param idc hl help autotype wu openapphelp pwm help autotype else if w param idc hl help url wu openapphelp pwm help urls return 0 caddentrydlg onxhyperlinkclicked wparam lparam unreferenced_parameter lparam wparam idc_hl_help_autotype wu_openapphelp pwm_help_autotype wparam idc_hl_help_url wu_openapphelp pwm_help_urls c dialog c icon picker dlg idd p parent afx data init c icon picker dlg afx data init m pimagelist null m unumicons 0 m nselectedicon 0 cdialog ciconpickerdlg pparent afx_data_init ciconpickerdlg afx_data_init m_pimagelist m_unumicons m_nselectedicon void c icon picker dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c icon picker dlg ddx control pdx idok m btok ddx control pdx idcancel m btcancel ddx control pdx idc iconlist m clist afx data map ciconpickerdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map ciconpickerdlg ddx_control m_btok ddx_control m_btcancel ddx_control idc_iconlist m_clist afx_data_map void c icon picker dlg onok int i f 1 s 1 uint u state m nselectedicon 0 for i 0 i m clist get item count i u state m clist get item state i lvis selected lvis focused if u state lvis selected s i if u state lvis focused f i if f 1 m nselectedicon f if s 1 m nselectedicon s c dialog onok ciconpickerdlg ustate m_nselectedicon m_clist getitemcount ustate m_clist getitemstate lvis_selected lvis_focused ustate lvis_selected ustate lvis_focused m_nselectedicon m_nselectedicon cdialog void c icon picker dlg on cancel c dialog on cancel ciconpickerdlg oncancel cdialog oncancel bool c icon picker dlg on init dialog c dialog on init dialog assert m pimagelist null assert m unumicons 0 newgui translatecwnd this enum child windows this m hwnd newgui translatewindowcb 0 m clist set image list m pimagelist lvsil small assert lvm setextendedlistviewstyle 0x1000 54 m clist post message lvm setextendedlistviewstyle 0 lvs ex si report lvs ex oneclickactivate lvs ex underlinehot unsigned long i c string str for i 0 i m unumicons i str format t u i m clist insert item lvif image lvif text i str 0 0 i 0 if m nselectedicon 0 m nselectedicon m clist get item count m clist set item state m nselectedicon lvis selected lvis selected newgui xpbutton m btok idb ok idb ok newgui xpbutton m btcancel idb cancel idb cancel newgui configsidebanner m banner this m banner set icon afx get app load icon idi iconpic kcsb icon left kcsb icon vcenter m banner set title trl pick an icon m banner set caption trl pick an icon from the list and click ok to set it return true return true unless you set the focus to a control ciconpickerdlg oninitdialog cdialog oninitdialog m_pimagelist m_unumicons newgui_translatecwnd enumchildwindows m_hwnd newgui_translatewindowcb m_clist setimagelist m_pimagelist lvsil_small lvm_setextendedlistviewstyle m_clist postmessage lvm_setextendedlistviewstyle lvs_ex_si_report lvs_ex_oneclickactivate lvs_ex_underlinehot cstring m_unumicons _t m_clist insertitem lvif_image lvif_text m_nselectedicon m_nselectedicon m_clist getitemcount m_clist setitemstate m_nselectedicon lvis_selected lvis_selected newgui_xpbutton m_btok idb_ok idb_ok newgui_xpbutton m_btcancel idb_cancel idb_cancel newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_iconpic kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_banner setcaption c dialog c pw generator dlg idd p parent afx data init c pw generator dlg m ncharacters 16 m bcharspec false m strcharset t m bgetentropy false m bhidepw false afx data init m bcanaccept true m lppassword null cdialog cpwgeneratordlg pparent afx_data_init cpwgeneratordlg m_ncharacters m_bcharspec m_strcharset _t m_bgetentropy m_bhidepw afx_data_init m_bcanaccept m_lppassword void c pw generator dlg clean up m fstyle delete object m fsymbol delete object m ilicons delete image list cpwgeneratordlg cleanup m_fstyle deleteobject m_fsymbol deleteobject m_ilicons deleteimagelist void c pw generator dlg setcheck int inx item bool b enable lv item lvi adjust assert inx item m clist get item count if inx item m clist get item count return lvi adjust mask lvif image lvi adjust i item inx item lvi adjust i sub item 0 lvi adjust state 0 lvi adjust state mask 0 lvi adjust l param 0 lvi adjust i indent 0 lvi adjust i image b enable false 57 58 m clist set item lvi adjust cpwgeneratordlg _setcheck inxitem benable lv_item lviadjust inxitem m_clist getitemcount inxitem m_clist getitemcount lviadjust lvif_image lviadjust iitem inxitem lviadjust isubitem lviadjust lviadjust statemask lviadjust lparam lviadjust iindent lviadjust iimage benable m_clist setitem lviadjust bool c pw generator dlg getcheck int inx item lv item lvi zero memory lvi sizeof lv item lvi mask lvif image lvi i item inx item if m clist get item lvi false return false return lvi i image 57 false true cpwgeneratordlg _getcheck inxitem lv_item zeromemory lv_item lvif_image iitem inxitem m_clist getitem iimage void c pw generator dlg set options c string str options c string str char set uint n characters g stroptions str options g strcharset str char set g nchars n characters cpwgeneratordlg setoptions cstring stroptions cstring strcharset ncharacters g_stroptions stroptions g_strcharset strcharset g_nchars ncharacters void c pw generator dlg get options c string pstr options c string pstr char set uint pn characters pstr options g stroptions pstr char set g strcharset pn characters g nchars cpwgeneratordlg getoptions cstring pstroptions cstring pstrcharset pncharacters pstroptions g_stroptions pstrcharset g_strcharset pncharacters g_nchars bool c pw generator dlg pre translate message msg p msg m tipsecclear relay event p msg return c dialog pre translate message p msg cpwgeneratordlg pretranslatemessage pmsg m_tipsecclear relayevent pmsg cdialog pretranslatemessage pmsg void c pw generator dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c pw generator dlg ddx control pdx idc check hidepw m bthidepw ddx control pdx idc edit pw m ceditpw ddx control pdx idc progress passquality m cpassquality ddx control pdx idc spin numchars m spinnumchars ddx control pdx idc generate btn m btgenerate ddx control pdx idcancel m btncancel ddx control pdx idok m btnok ddx control pdx idc list options m clist ddx text pdx idc edit numcharacters m ncharacters ddx check pdx idc check charspec m bcharspec ddx text pdx idc edit onlycharspec m strcharset ddx check pdx idc check getentropy m bgetentropy ddx check pdx idc check hidepw m bhidepw afx data map cpwgeneratordlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map cpwgeneratordlg ddx_control idc_check_hidepw m_bthidepw ddx_control idc_edit_pw m_ceditpw ddx_control idc_progress_passquality m_cpassquality ddx_control idc_spin_numchars m_spinnumchars ddx_control idc_generate_btn m_btgenerate ddx_control m_btncancel ddx_control m_btnok ddx_control idc_list_options m_clist ddx_text idc_edit_numcharacters m_ncharacters ddx_check idc_check_charspec m_bcharspec ddx_text idc_edit_onlycharspec m_strcharset ddx_check idc_check_getentropy m_bgetentropy ddx_check idc_check_hidepw m_bhidepw afx_data_map void c pw generator dlg saveoptions int i g stroptions empty for i 0 i 9 i if getcheck i false g stroptions t 0 else g stroptions t 1 if m bcharspec false g stroptions t 0 else g stroptions t 1 if m bgetentropy false g stroptions t 0 else g stroptions t 1 g strcharset m strcharset g nchars m ncharacters cpwgeneratordlg _saveoptions g_stroptions _getcheck g_stroptions _t g_stroptions _t m_bcharspec g_stroptions _t g_stroptions _t m_bgetentropy g_stroptions _t g_stroptions _t g_strcharset m_strcharset g_nchars m_ncharacters void c pw generator dlg onok update data true assert m lppassword null if m lppassword null m ceditpw delete password m lppassword m lppassword m ceditpw get password assert m lppassword null if m lppassword null return if tcslen m lppassword 0 m ceditpw delete password m lppassword m lppassword null return saveoptions clean up c dialog onok cpwgeneratordlg updatedata m_lppassword m_lppassword m_ceditpw deletepassword m_lppassword m_lppassword m_ceditpw getpassword m_lppassword m_lppassword _tcslen m_lppassword m_ceditpw deletepassword m_lppassword m_lppassword _saveoptions cleanup cdialog void c pw generator dlg on cancel update data true saveoptions clean up c dialog on cancel cpwgeneratordlg oncancel updatedata _saveoptions cleanup cdialog oncancel bool c pw generator dlg on init dialog c dialog on init dialog newgui translatecwnd this enum child windows this m hwnd newgui translatewindowcb 0 m fstyle create font 12 0 0 0 0 false false 0 default charset out default precis clip default precis default quality default pitch ff modern t tahoma m fsymbol create font 13 0 0 0 0 false false 0 default charset out default precis clip default precis default quality default pitch ff modern c pw safe app get password font z 27 is that black dot in tahoma tchar tch dot tchar t z 27 tchar tch dot c pw safe app get password character c string str stars str stars tch dot str stars tch dot str stars tch dot m bthidepw set window text str stars newgui xpbutton m btnok idb ok idb ok newgui xpbutton m btncancel idb cancel idb cancel newgui xpbutton m btgenerate idb key small idb key small newgui xpbutton m bthidepw 1 1 m ceditpw set font m fstyle true m bthidepw set font m fsymbol true m bthidepw set color c buttonst btnst color fg in rgb 0 0 255 true c string strtt trl hide passwords behind asterisks strtt remove t m bthidepw set tooltip text strtt true newgui configqualitymeter m cpassquality newgui configsidebanner m banner this m banner set icon afx get app load icon idi key kcsb icon left kcsb icon vcenter m banner set title trl password generator m banner set caption trl this will generate a random password m clist post message lvm setextendedlistviewstyle 0 lvs ex si menu lvs ex fullrowselect m ilicons create idr infoicons 16 1 rgb 255 0 255 c pw safe app create hi color image list m ilicons idb infoicons ex 16 m clist set image list m ilicons lvsil small m clist delete all items rect rect m clist get client rect rect int n width rect right rect left get system metrics sm cxvscroll 8 m clist insert column 0 trl options lvcfmt left n width 0 m btnok enable window false int j 0 c string str m clist insert item lvif text lvif image j trl upper alphabetic characters a b c 0 0 0 0 j m clist insert item lvif text lvif image j trl lower alphabetic characters a b c 0 0 0 0 j m clist insert item lvif text lvif image j trl numerical characters 1 2 3 0 0 0 0 j m clist insert item lvif text lvif image j trl underline character 0 0 0 0 j m clist insert item lvif text lvif image j trl minus 0 0 0 0 j m clist insert item lvif text lvif image j trl space 0 0 0 0 j str trl special characters str t m clist insert item lvif text lvif image j str 0 0 0 0 j str trl higher ansi characters m clist insert item lvif text lvif image j str 0 0 0 0 j m clist insert item lvif text lvif image j trl special brackets 0 0 0 0 j if g stroptions get length 11 g stroptions t 11100000001 assert g stroptions get length 11 tchar tch int n item for n item 0 n item 9 n item tch g stroptions get at n item if tch t 1 setcheck n item true else setcheck n item false tch g stroptions get at 9 if tch t 1 m bcharspec true else m bcharspec false tch g stroptions get at 10 if tch t 0 m bgetentropy false else m bgetentropy true if m bcharspec false m clist enable window true get dlg item idc edit onlycharspec enable window false else m clist enable window false get dlg item idc edit onlycharspec enable window true m strcharset g strcharset m ncharacters g nchars update data false m spinnumchars set base 0 m spinnumchars set range 0 1024 m spinnumchars set pos 512 if m bcanaccept false m btnok show window sw hide m btncancel set window text trl close else m btnok show window sw show m tipsecclear create this 0x40 m tipsecclear add tool m ceditpw c pw safe dlg getsecureedittiptext t your new password m tipsecclear set max tip width 630 m tipsecclear activate m ceditpw is secure mode enabled newgui showqualitymeter m cpassquality get dlg item idc static passbits t on check hide pw return true cpwgeneratordlg oninitdialog cdialog oninitdialog newgui_translatecwnd enumchildwindows m_hwnd newgui_translatewindowcb m_fstyle createfont default_charset out_default_precis clip_default_precis default_quality default_pitch ff_modern _t m_fsymbol createfont default_charset out_default_precis clip_default_precis default_quality default_pitch ff_modern cpwsafeapp getpasswordfont tchdot _t tchdot cpwsafeapp getpasswordcharacter cstring strstars strstars tchdot strstars tchdot strstars tchdot m_bthidepw setwindowtext strstars newgui_xpbutton m_btnok idb_ok idb_ok newgui_xpbutton m_btncancel idb_cancel idb_cancel newgui_xpbutton m_btgenerate idb_key_small idb_key_small newgui_xpbutton m_bthidepw m_ceditpw setfont m_fstyle m_bthidepw setfont m_fsymbol m_bthidepw setcolor cbuttonst btnst_color_fg_in cstring _t m_bthidepw settooltiptext newgui_configqualitymeter m_cpassquality newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_key kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_banner setcaption m_clist postmessage lvm_setextendedlistviewstyle lvs_ex_si_menu lvs_ex_fullrowselect m_ilicons idr_infoicons cpwsafeapp createhicolorimagelist m_ilicons idb_infoicons_ex m_clist setimagelist m_ilicons lvsil_small m_clist deleteallitems m_clist getclientrect nwidth getsystemmetrics sm_cxvscroll m_clist insertcolumn lvcfmt_left nwidth m_btnok enablewindow cstring m_clist insertitem lvif_text lvif_image m_clist insertitem lvif_text lvif_image m_clist insertitem lvif_text lvif_image m_clist insertitem lvif_text lvif_image _ m_clist insertitem lvif_text lvif_image m_clist insertitem lvif_text lvif_image _t m_clist insertitem lvif_text lvif_image m_clist insertitem lvif_text lvif_image m_clist insertitem lvif_text lvif_image g_stroptions getlength g_stroptions _t g_stroptions getlength nitem nitem nitem nitem g_stroptions getat nitem _t _setcheck nitem _setcheck nitem g_stroptions getat _t m_bcharspec m_bcharspec g_stroptions getat _t m_bgetentropy m_bgetentropy m_bcharspec m_clist enablewindow getdlgitem idc_edit_onlycharspec enablewindow m_clist enablewindow getdlgitem idc_edit_onlycharspec enablewindow m_strcharset g_strcharset m_ncharacters g_nchars updatedata m_spinnumchars setbase m_spinnumchars setrange m_spinnumchars setpos m_bcanaccept m_btnok showwindow sw_hide m_btncancel setwindowtext m_btnok showwindow sw_show m_tipsecclear m_tipsecclear addtool m_ceditpw cpwsafedlg _getsecureedittiptext _t m_tipsecclear setmaxtipwidth m_tipsecclear m_ceditpw issecuremodeenabled newgui_showqualitymeter m_cpassquality getdlgitem idc_static_passbits _t oncheckhidepw void c pw generator dlg on generate btn c get random dlg dlg c new random newrand sha256 ctx ctx unsigned long u counter 0 u final chars 0 j byte a temp 32 tchar t bool b upper alpha b lower alpha b num b underline b minus b space b special b high b brackets c string str password assert sizeof unsigned long 4 update data true newrand initialize if m ncharacters 0 m ncharacters 16 if m bcharspec true m strcharset get length 0 message box trl the password must consist of at least one character trl password safe mb ok mb iconwarning return b upper alpha getcheck 0 b lower alpha getcheck 1 b num getcheck 2 b underline getcheck 3 b minus getcheck 4 b space getcheck 5 b special getcheck 6 b high getcheck 7 b brackets getcheck 8 if m bcharspec false if b upper alpha b lower alpha b num b underline b minus b space b special b high b brackets 0 message box trl select at least one of the options in the list above trl password safe mb ok mb iconwarning return if m bgetentropy true if dlg do modal idcancel return else newrand get random buffer dlg m pfinalrandom 32 j 32 while 1 if u final chars m ncharacters break if j 32 sha256 begin ctx sha256 hash dlg m pfinalrandom 32 ctx sha256 hash byte u counter 4 ctx sha256 end a temp ctx j 0 u counter some additional randomness byte bt newrand get random buffer bt 1 if bt 130 j continue t tchar a temp j if m bcharspec false if t 0 t t r t t n if b upper alpha true if t t a t t z str password t u final chars if b lower alpha true if t t a t t z str password t u final chars if b num true if t t 0 t t 9 str password t u final chars if b underline true t t str password t u final chars if b minus true t t str password t u final chars if b space true t t str password t u final chars if b special true if t t t t t t t t t t t t if t t t t str password t u final chars if t t t t str password t u final chars if t t t t str password t u final chars if b high true byte t t str password t u final chars if b brackets true if t t t t t t t t str password t u final chars else m bcharspec true bool b found false for int ix 0 ix m strcharset get length ix if m strcharset ix t b found true if b found true str password t u final chars j assert str password get length int m ncharacters if str password get length int m ncharacters str password str password left int m ncharacters update data false newgui showqualitymeter m cpassquality get dlg item idc static passbits str password m ceditpw set password str password erasec string str password if m bcanaccept true m btnok enable window true cpwgeneratordlg ongeneratebtn cgetrandomdlg cnewrandom sha256_ctx ucounter ufinalchars atemp bupperalpha bloweralpha bnum bunderline bminus bspace bspecial bhigh bbrackets cstring strpassword updatedata m_ncharacters m_ncharacters m_bcharspec m_strcharset getlength messagebox mb_ok mb_iconwarning bupperalpha _getcheck bloweralpha _getcheck bnum _getcheck bunderline _getcheck bminus _getcheck bspace _getcheck bspecial _getcheck bhigh _getcheck bbrackets _getcheck m_bcharspec bupperalpha bloweralpha bnum bunderline bminus bspace bspecial bhigh bbrackets messagebox mb_ok mb_iconwarning m_bgetentropy domodal getrandombuffer m_pfinalrandom ufinalchars m_ncharacters sha256_begin sha256_hash m_pfinalrandom sha256_hash ucounter sha256_end atemp ucounter getrandombuffer atemp m_bcharspec _t _t bupperalpha _t _t strpassword ufinalchars bloweralpha _t _t strpassword ufinalchars bnum _t _t strpassword ufinalchars bunderline _t _ strpassword ufinalchars bminus _t strpassword ufinalchars bspace _t strpassword ufinalchars bspecial _t _t _t _t _t _t _ _t _t strpassword ufinalchars _t _t strpassword ufinalchars _t _t strpassword ufinalchars bhigh _t strpassword ufinalchars bbrackets _t _t _t _t strpassword ufinalchars m_bcharspec bfound m_strcharset getlength m_strcharset bfound bfound strpassword ufinalchars strpassword getlength m_ncharacters strpassword getlength m_ncharacters strpassword strpassword m_ncharacters updatedata newgui_showqualitymeter m_cpassquality getdlgitem idc_static_passbits strpassword m_ceditpw setpassword strpassword erasecstring strpassword m_bcanaccept m_btnok enablewindow void c pw generator dlg on check char spec update data true if m bcharspec true get dlg item idc edit onlycharspec enable window true m clist enable window false else get dlg item idc edit onlycharspec enable window false m clist enable window true cpwgeneratordlg oncheckcharspec updatedata m_bcharspec getdlgitem idc_edit_onlycharspec enablewindow m_clist enablewindow getdlgitem idc_edit_onlycharspec enablewindow m_clist enablewindow void c pw generator dlg on click list options nmhdr pnmhdr lresult p result c point pointm get cursor pos pointm unreferenced parameter pnmhdr m clist screen to client pointm uint n flags 0 int n hit item m clist hit test pointm n flags if n flags lvht onitem setcheck n hit item getcheck n hit item p result 0 cpwgeneratordlg onclicklistoptions presult cpoint getcursorpos unreferenced_parameter m_clist screentoclient nflags nhititem m_clist hittest nflags nflags lvht_onitem _setcheck nhititem _getcheck nhititem presult void c pw generator dlg on rclick list options nmhdr pnmhdr lresult p result unreferenced parameter pnmhdr p result 0 cpwgeneratordlg onrclicklistoptions presult unreferenced_parameter presult void c pw generator dlg on delta pos spin num chars nmhdr pnmhdr lresult p result nm updown pnm up down nm updown pnmhdr p result 0 update data true int n pos int m ncharacters n pos pnm up down i delta if n pos 0 n pos 0 m ncharacters uint n pos m spinnumchars set pos 512 update data false cpwgeneratordlg ondeltaposspinnumchars presult nm_updown pnmupdown nm_updown presult updatedata npos m_ncharacters npos pnmupdown idelta npos npos m_ncharacters npos m_spinnumchars setpos updatedata void c pw generator dlg on change edit pw update data true lptstr lp m ceditpw get password if lp null newgui showqualitymeter m cpassquality get dlg item idc static passbits lp if tcslen lp 0 m btnok enable window false else m btnok enable window true m ceditpw delete password lp lp null cpwgeneratordlg onchangeeditpw updatedata m_ceditpw getpassword newgui_showqualitymeter m_cpassquality getdlgitem idc_static_passbits _tcslen m_btnok enablewindow m_btnok enablewindow m_ceditpw deletepassword void c pw generator dlg on check hide pw update data true if m bhidepw false m ceditpw enable secure mode false m ceditpw set password char 0 m ceditpw set font m fstyle true else tchar tch dot tchar t z 27 tchar tch dot c pw safe app get password character m ceditpw enable secure mode c pw safe dlg m bsecureedits m ceditpw set password char tch dot m ceditpw set font m fsymbol true m tipsecclear activate m ceditpw is secure mode enabled update data false m ceditpw redraw window m ceditpw set focus cpwgeneratordlg oncheckhidepw updatedata m_bhidepw m_ceditpw enablesecuremode m_ceditpw setpasswordchar m_ceditpw setfont m_fstyle tchdot _t tchdot cpwsafeapp getpasswordcharacter m_ceditpw enablesecuremode cpwsafedlg m_bsecureedits m_ceditpw setpasswordchar tchdot m_ceditpw setfont m_fsymbol m_tipsecclear m_ceditpw issecuremodeenabled updatedata m_ceditpw redrawwindow m_ceditpw setfocus c dialog c check options dlg idd p parent afx data init c check options dlg afx data init m dwnumparams 0 m pparams null parent must initialize cdialog ccheckoptionsdlg pparent afx_data_init ccheckoptionsdlg afx_data_init m_dwnumparams m_pparams void c check options dlg clean up m iloptionicons delete image list ccheckoptionsdlg cleanup m_iloptionicons deleteimagelist void c check options dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c check options dlg ddx control pdx idc list options m oloptions ddx control pdx idcancel m btcancel ddx control pdx idok m btok afx data map ccheckoptionsdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map ccheckoptionsdlg ddx_control idc_list_options m_oloptions ddx_control m_btcancel ddx_control m_btok afx_data_map bool c check options dlg on init dialog c dialog on init dialog assert m dwnumparams 0 assert m pparams null translate all windows enum child windows this m hwnd newgui translatewindowcb 0 newgui xpbutton m btok idb ok idb ok newgui xpbutton m btcancel idb cancel idb cancel configure banner control newgui configsidebanner m banner this m banner set icon afx get app load icon idi options kcsb icon left kcsb icon vcenter m banner set title m strtitle m banner set caption m strdescription set window text m strtitle m iloptionicons create idb optionicons ex 16 1 rgb 255 0 255 c pw safe app create hi color image list m iloptionicons idb optionicons ex 16 m oloptions init option list ex m iloptionicons dword i 0 for i 0 i m dwnumparams i if m pparams i pb value null m oloptions add group text m pparams i lp string m pparams i n icon else m oloptions add check item m pparams i lp string m pparams i pb value null ol link null return true ccheckoptionsdlg oninitdialog cdialog oninitdialog m_dwnumparams m_pparams enumchildwindows m_hwnd newgui_translatewindowcb newgui_xpbutton m_btok idb_ok idb_ok newgui_xpbutton m_btcancel idb_cancel idb_cancel newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_options kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_strtitle m_banner setcaption m_strdescription setwindowtext m_strtitle m_iloptionicons idb_optionicons_ex cpwsafeapp createhicolorimagelist m_iloptionicons idb_optionicons_ex m_oloptions initoptionlistex m_iloptionicons m_dwnumparams m_pparams pbvalue m_oloptions addgrouptext m_pparams lpstring m_pparams nicon m_oloptions addcheckitem m_pparams lpstring m_pparams pbvalue ol_link_null void c check options dlg onok clean up c dialog onok ccheckoptionsdlg cleanup cdialog void c check options dlg on cancel clean up c dialog on cancel ccheckoptionsdlg oncancel cleanup cdialog oncancel rijndael rijndael m state invalid m_state rijndael rijndael nothing here int rijndael init mode mode direction dir const rd uint8 key key length key len rd uint8 init vector not initialized yet m state invalid check the mode if mode cbc mode ecb mode cfb1 return rijndael unsupported mode m mode mode and the direction if dir encrypt dir decrypt return rijndael unsupported direction m direction dir allow to set an init vector if init vector specified init vector for int i 0 i max iv size i m initvector i init vector i else zero init vector for int i 0 i max iv size i m initvector i 0 rd uint32 u key len in bytes and check the key length switch key len case key16 bytes u key len in bytes 16 m urounds 10 break case key24 bytes u key len in bytes 24 m urounds 12 break case key32 bytes u key len in bytes 32 m urounds 14 break default return rijndael unsupported key length break the number of rounds is calculated as m urounds m ukeyleninbits 32 6 if key return rijndael bad key rd uint8 key matrix max key columns 4 for rd uint32 i 0 i u key len in bytes i key matrix i 2 i 3 key i key sched key matrix if m direction decrypt key enc to dec m state valid return rijndael success rd_uint8 keylength keylen rd_uint8 initvector m_state rijndael_unsupported_mode m_mode rijndael_unsupported_direction m_direction initvector max_iv_size m_initvector initvector max_iv_size m_initvector rd_uint32 ukeyleninbytes keylen key16bytes ukeyleninbytes m_urounds key24bytes ukeyleninbytes m_urounds key32bytes ukeyleninbytes m_urounds rijndael_unsupported_key_length m_urounds m_ukeyleninbits rijndael_bad_key rd_uint8 keymatrix _max_key_columns rd_uint32 ukeyleninbytes keymatrix keysched keymatrix m_direction keyenctodec m_state rijndael_success int rijndael block encrypt const rd uint8 input int input len rd uint8 out buffer int i k num blocks rd uint8 block 16 iv 4 4 if m state valid return rijndael not initialized if m direction encrypt return rijndael bad direction if input 0 input len 0 return 0 num blocks input len 128 switch m mode case ecb for i num blocks i 0 i encrypt input out buffer input 16 out buffer 16 break case cbc rd uint32 block 0 rd uint32 m initvector 0 rd uint32 input 0 rd uint32 block 1 rd uint32 m initvector 1 rd uint32 input 1 rd uint32 block 2 rd uint32 m initvector 2 rd uint32 input 2 rd uint32 block 3 rd uint32 m initvector 3 rd uint32 input 3 encrypt block out buffer input 16 for i num blocks 1 i 0 i rd uint32 block 0 rd uint32 out buffer 0 rd uint32 input 0 rd uint32 block 1 rd uint32 out buffer 1 rd uint32 input 1 rd uint32 block 2 rd uint32 out buffer 2 rd uint32 input 2 rd uint32 block 3 rd uint32 out buffer 3 rd uint32 input 3 out buffer 16 encrypt block out buffer input 16 break case cfb1 if strict align memcpy iv m initvector 16 else strict align rd uint32 iv 0 rd uint32 m initvector rd uint32 iv 1 rd uint32 m initvector 4 rd uint32 iv 2 rd uint32 m initvector 8 rd uint32 iv 3 rd uint32 m initvector 12 endif strict align for i num blocks i 0 i for k 0 k 128 k rd uint32 block rd uint32 iv 0 rd uint32 block 4 rd uint32 iv 1 rd uint32 block 8 rd uint32 iv 2 rd uint32 block 12 rd uint32 iv 3 encrypt block block out buffer k 8 block 0 0x80 k 7 iv 0 0 iv 0 0 1 iv 0 1 7 iv 0 1 iv 0 1 1 iv 0 2 7 iv 0 2 iv 0 2 1 iv 0 3 7 iv 0 3 iv 0 3 1 iv 1 0 7 iv 1 0 iv 1 0 1 iv 1 1 7 iv 1 1 iv 1 1 1 iv 1 2 7 iv 1 2 iv 1 2 1 iv 1 3 7 iv 1 3 iv 1 3 1 iv 2 0 7 iv 2 0 iv 2 0 1 iv 2 1 7 iv 2 1 iv 2 1 1 iv 2 2 7 iv 2 2 iv 2 2 1 iv 2 3 7 iv 2 3 iv 2 3 1 iv 3 0 7 iv 3 0 iv 3 0 1 iv 3 1 7 iv 3 1 iv 3 1 1 iv 3 2 7 iv 3 2 iv 3 2 1 iv 3 3 7 iv 3 3 iv 3 3 1 out buffer k 8 7 k 7 1 break default return 1 break return 128 num blocks blockencrypt rd_uint8 inputlen rd_uint8 outbuffer numblocks rd_uint8 m_state rijndael_not_initialized m_direction rijndael_bad_direction inputlen numblocks inputlen m_mode numblocks outbuffer outbuffer rd_uint32 rd_uint32 m_initvector rd_uint32 rd_uint32 rd_uint32 m_initvector rd_uint32 rd_uint32 rd_uint32 m_initvector rd_uint32 rd_uint32 rd_uint32 m_initvector rd_uint32 outbuffer numblocks rd_uint32 rd_uint32 outbuffer rd_uint32 rd_uint32 rd_uint32 outbuffer rd_uint32 rd_uint32 rd_uint32 outbuffer rd_uint32 rd_uint32 rd_uint32 outbuffer rd_uint32 outbuffer outbuffer strict_align m_initvector strict_align rd_uint32 rd_uint32 m_initvector rd_uint32 rd_uint32 m_initvector rd_uint32 rd_uint32 m_initvector rd_uint32 rd_uint32 m_initvector strict_align numblocks rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 outbuffer outbuffer numblocks int rijndael pad encrypt const rd uint8 input int input octets rd uint8 out buffer int i num blocks pad len rd uint8 block 16 iv if m state valid return rijndael not initialized if m direction encrypt return rijndael not initialized if input 0 input octets 0 return 0 num blocks input octets 16 switch m mode case ecb for i num blocks i 0 i encrypt input out buffer input 16 out buffer 16 pad len 16 input octets 16 num blocks assert pad len 0 pad len 16 memcpy block input 16 pad len memset block 16 pad len pad len pad len encrypt block out buffer break case cbc iv m initvector for i num blocks i 0 i rd uint32 block 0 rd uint32 input 0 rd uint32 iv 0 rd uint32 block 1 rd uint32 input 1 rd uint32 iv 1 rd uint32 block 2 rd uint32 input 2 rd uint32 iv 2 rd uint32 block 3 rd uint32 input 3 rd uint32 iv 3 encrypt block out buffer iv out buffer input 16 out buffer 16 pad len 16 input octets 16 num blocks assert pad len 0 pad len 16 do something here for i 0 i 16 pad len i block i input i iv i for i 16 pad len i 16 i block i rd uint8 pad len iv i encrypt block out buffer break default return 1 break return 16 num blocks 1 padencrypt rd_uint8 inputoctets rd_uint8 outbuffer numblocks padlen rd_uint8 m_state rijndael_not_initialized m_direction rijndael_not_initialized inputoctets numblocks inputoctets m_mode numblocks outbuffer outbuffer padlen inputoctets numblocks padlen padlen padlen padlen padlen padlen outbuffer m_initvector numblocks rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 outbuffer outbuffer outbuffer padlen inputoctets numblocks padlen padlen padlen padlen rd_uint8 padlen outbuffer numblocks int rijndael block decrypt const rd uint8 input int input len rd uint8 out buffer int i k num blocks rd uint8 block 16 iv 4 4 if m state valid return rijndael not initialized if m mode cfb1 m direction encrypt return rijndael bad direction if input 0 input len 0 return 0 num blocks input len 128 switch m mode case ecb for i num blocks i 0 i decrypt input out buffer input 16 out buffer 16 break case cbc if strict align memcpy iv m initvector 16 else rd uint32 iv 0 rd uint32 m initvector rd uint32 iv 1 rd uint32 m initvector 4 rd uint32 iv 2 rd uint32 m initvector 8 rd uint32 iv 3 rd uint32 m initvector 12 endif for i num blocks i 0 i decrypt input block rd uint32 block 0 rd uint32 iv 0 rd uint32 block 1 rd uint32 iv 1 rd uint32 block 2 rd uint32 iv 2 rd uint32 block 3 rd uint32 iv 3 if strict align memcpy iv input 16 memcpy out buf block 16 else rd uint32 iv 0 rd uint32 input 0 rd uint32 out buffer 0 rd uint32 block 0 rd uint32 iv 1 rd uint32 input 1 rd uint32 out buffer 1 rd uint32 block 1 rd uint32 iv 2 rd uint32 input 2 rd uint32 out buffer 2 rd uint32 block 2 rd uint32 iv 3 rd uint32 input 3 rd uint32 out buffer 3 rd uint32 block 3 endif input 16 out buffer 16 break case cfb1 if strict align memcpy iv m initvector 16 else rd uint32 iv 0 rd uint32 m initvector rd uint32 iv 1 rd uint32 m initvector 4 rd uint32 iv 2 rd uint32 m initvector 8 rd uint32 iv 3 rd uint32 m initvector 12 endif for i num blocks i 0 i for k 0 k 128 k rd uint32 block rd uint32 iv 0 rd uint32 block 4 rd uint32 iv 1 rd uint32 block 8 rd uint32 iv 2 rd uint32 block 12 rd uint32 iv 3 encrypt block block iv 0 0 iv 0 0 1 iv 0 1 7 iv 0 1 iv 0 1 1 iv 0 2 7 iv 0 2 iv 0 2 1 iv 0 3 7 iv 0 3 iv 0 3 1 iv 1 0 7 iv 1 0 iv 1 0 1 iv 1 1 7 iv 1 1 iv 1 1 1 iv 1 2 7 iv 1 2 iv 1 2 1 iv 1 3 7 iv 1 3 iv 1 3 1 iv 2 0 7 iv 2 0 iv 2 0 1 iv 2 1 7 iv 2 1 iv 2 1 1 iv 2 2 7 iv 2 2 iv 2 2 1 iv 2 3 7 iv 2 3 iv 2 3 1 iv 3 0 7 iv 3 0 iv 3 0 1 iv 3 1 7 iv 3 1 iv 3 1 1 iv 3 2 7 iv 3 2 iv 3 2 1 iv 3 3 7 iv 3 3 iv 3 3 1 input k 8 7 k 7 1 out buffer k 8 block 0 0x80 k 7 break default return 1 break return 128 num blocks blockdecrypt rd_uint8 inputlen rd_uint8 outbuffer numblocks rd_uint8 m_state rijndael_not_initialized m_mode m_direction rijndael_bad_direction inputlen numblocks inputlen m_mode numblocks outbuffer outbuffer strict_align m_initvector rd_uint32 rd_uint32 m_initvector rd_uint32 rd_uint32 m_initvector rd_uint32 rd_uint32 m_initvector rd_uint32 rd_uint32 m_initvector numblocks rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 strict_align outbuf rd_uint32 rd_uint32 rd_uint32 outbuffer rd_uint32 rd_uint32 rd_uint32 rd_uint32 outbuffer rd_uint32 rd_uint32 rd_uint32 rd_uint32 outbuffer rd_uint32 rd_uint32 rd_uint32 rd_uint32 outbuffer rd_uint32 outbuffer strict_align m_initvector rd_uint32 rd_uint32 m_initvector rd_uint32 rd_uint32 m_initvector rd_uint32 rd_uint32 m_initvector rd_uint32 rd_uint32 m_initvector numblocks rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 outbuffer numblocks int rijndael pad decrypt const rd uint8 input int input octets rd uint8 out buffer int i num blocks pad len rd uint8 block 16 rd uint32 iv 4 if m state valid return rijndael not initialized if m direction decrypt return rijndael bad direction if input null input octets 0 return 0 if input octets 16 0 return rijndael corrupted data num blocks input octets 16 switch m mode case ecb for i num blocks 1 i 0 i decrypt input out buffer input 16 out buffer 16 decrypt input block pad len block 15 if pad len 0 pad len 16 return rijndael corrupted data for i 16 pad len i 16 i if block i pad len return rijndael corrupted data memcpy out buffer block 16 pad len break case cbc memcpy iv m initvector 16 all blocks but last for i num blocks 1 i 0 i decrypt input block rd uint32 block 0 iv 0 rd uint32 block 1 iv 1 rd uint32 block 2 iv 2 rd uint32 block 3 iv 3 memcpy iv input 16 memcpy out buffer block 16 input 16 out buffer 16 last block decrypt input block rd uint32 block 0 iv 0 rd uint32 block 1 iv 1 rd uint32 block 2 iv 2 rd uint32 block 3 iv 3 pad len block 15 if pad len 0 pad len 16 return rijndael corrupted data for i 16 pad len i 16 i if block i pad len return rijndael corrupted data memcpy out buffer block 16 pad len break default return 1 break return 16 num blocks pad len paddecrypt rd_uint8 inputoctets rd_uint8 outbuffer numblocks padlen rd_uint8 rd_uint32 m_state rijndael_not_initialized m_direction rijndael_bad_direction inputoctets inputoctets rijndael_corrupted_data numblocks inputoctets m_mode numblocks outbuffer outbuffer padlen padlen padlen rijndael_corrupted_data padlen padlen rijndael_corrupted_data outbuffer padlen m_initvector numblocks rd_uint32 rd_uint32 rd_uint32 rd_uint32 outbuffer outbuffer rd_uint32 rd_uint32 rd_uint32 rd_uint32 padlen padlen padlen rijndael_corrupted_data padlen padlen rijndael_corrupted_data outbuffer padlen numblocks padlen void rijndael key sched rd uint8 key max key columns 4 int j rconpointer 0 calculate the necessary round keys the number of calculations depends on key bits and block bits int u key columns m urounds 6 rd uint8 temp key max key columns 4 copy the input key to the temporary key matrix for j 0 j u key columns j rd uint32 temp key j rd uint32 key j int r 0 int t 0 copy values into round key array for j 0 j u key columns r int m urounds for j u key columns t 4 j t rd uint32 m expandedkey r t rd uint32 temp key j if t 4 r t 0 while r int m urounds temp key 0 0 s temp key u key columns 1 1 temp key 0 1 s temp key u key columns 1 2 temp key 0 2 s temp key u key columns 1 3 temp key 0 3 s temp key u key columns 1 0 temp key 0 0 rcon rconpointer if u key columns 8 for j 1 j u key columns j rd uint32 temp key j rd uint32 temp key j 1 else for j 1 j u key columns 2 j rd uint32 temp key j rd uint32 temp key j 1 temp key u key columns 2 0 s temp key u key columns 2 1 0 temp key u key columns 2 1 s temp key u key columns 2 1 1 temp key u key columns 2 2 s temp key u key columns 2 1 2 temp key u key columns 2 3 s temp key u key columns 2 1 3 for j u key columns 2 1 j u key columns j rd uint32 temp key j rd uint32 temp key j 1 for j 0 j u key columns r int m urounds for j u key columns t 4 j t rd uint32 m expandedkey r t rd uint32 temp key j if t 4 r t 0 keysched rd_uint8 _max_key_columns keybits blockbits ukeycolumns m_urounds rd_uint8 tempkey _max_key_columns ukeycolumns rd_uint32 tempkey rd_uint32 ukeycolumns m_urounds ukeycolumns rd_uint32 m_expandedkey rd_uint32 tempkey m_urounds tempkey tempkey ukeycolumns tempkey tempkey ukeycolumns tempkey tempkey ukeycolumns tempkey tempkey ukeycolumns tempkey ukeycolumns ukeycolumns rd_uint32 tempkey rd_uint32 tempkey ukeycolumns rd_uint32 tempkey rd_uint32 tempkey tempkey ukeycolumns tempkey ukeycolumns tempkey ukeycolumns tempkey ukeycolumns tempkey ukeycolumns tempkey ukeycolumns tempkey ukeycolumns tempkey ukeycolumns ukeycolumns ukeycolumns rd_uint32 tempkey rd_uint32 tempkey ukeycolumns m_urounds ukeycolumns rd_uint32 m_expandedkey rd_uint32 tempkey void rijndael key enc to dec int r rd uint8 w for r 1 r int m urounds r w m expandedkey r 0 rd uint32 w rd uint32 u1 w 0 rd uint32 u2 w 1 rd uint32 u3 w 2 rd uint32 u4 w 3 w m expandedkey r 1 rd uint32 w rd uint32 u1 w 0 rd uint32 u2 w 1 rd uint32 u3 w 2 rd uint32 u4 w 3 w m expandedkey r 2 rd uint32 w rd uint32 u1 w 0 rd uint32 u2 w 1 rd uint32 u3 w 2 rd uint32 u4 w 3 w m expandedkey r 3 rd uint32 w rd uint32 u1 w 0 rd uint32 u2 w 1 rd uint32 u3 w 2 rd uint32 u4 w 3 keyenctodec rd_uint8 m_urounds m_expandedkey rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 void rijndael encrypt const rd uint8 a 16 rd uint8 b 16 int r rd uint8 temp 4 4 rd uint32 temp 0 rd uint32 a rd uint32 m expandedkey 0 0 rd uint32 temp 1 rd uint32 a 4 rd uint32 m expandedkey 0 1 rd uint32 temp 2 rd uint32 a 8 rd uint32 m expandedkey 0 2 rd uint32 temp 3 rd uint32 a 12 rd uint32 m expandedkey 0 3 rd uint32 b rd uint32 t1 temp 0 0 rd uint32 t2 temp 1 1 rd uint32 t3 temp 2 2 rd uint32 t4 temp 3 3 rd uint32 b 4 rd uint32 t1 temp 1 0 rd uint32 t2 temp 2 1 rd uint32 t3 temp 3 2 rd uint32 t4 temp 0 3 rd uint32 b 8 rd uint32 t1 temp 2 0 rd uint32 t2 temp 3 1 rd uint32 t3 temp 0 2 rd uint32 t4 temp 1 3 rd uint32 b 12 rd uint32 t1 temp 3 0 rd uint32 t2 temp 0 1 rd uint32 t3 temp 1 2 rd uint32 t4 temp 2 3 for r 1 r int m urounds 1 r rd uint32 temp 0 rd uint32 b rd uint32 m expandedkey r 0 rd uint32 temp 1 rd uint32 b 4 rd uint32 m expandedkey r 1 rd uint32 temp 2 rd uint32 b 8 rd uint32 m expandedkey r 2 rd uint32 temp 3 rd uint32 b 12 rd uint32 m expandedkey r 3 rd uint32 b rd uint32 t1 temp 0 0 rd uint32 t2 temp 1 1 rd uint32 t3 temp 2 2 rd uint32 t4 temp 3 3 rd uint32 b 4 rd uint32 t1 temp 1 0 rd uint32 t2 temp 2 1 rd uint32 t3 temp 3 2 rd uint32 t4 temp 0 3 rd uint32 b 8 rd uint32 t1 temp 2 0 rd uint32 t2 temp 3 1 rd uint32 t3 temp 0 2 rd uint32 t4 temp 1 3 rd uint32 b 12 rd uint32 t1 temp 3 0 rd uint32 t2 temp 0 1 rd uint32 t3 temp 1 2 rd uint32 t4 temp 2 3 rd uint32 temp 0 rd uint32 b rd uint32 m expandedkey m urounds 1 0 rd uint32 temp 1 rd uint32 b 4 rd uint32 m expandedkey m urounds 1 1 rd uint32 temp 2 rd uint32 b 8 rd uint32 m expandedkey m urounds 1 2 rd uint32 temp 3 rd uint32 b 12 rd uint32 m expandedkey m urounds 1 3 b 0 t1 temp 0 0 1 b 1 t1 temp 1 1 1 b 2 t1 temp 2 2 1 b 3 t1 temp 3 3 1 b 4 t1 temp 1 0 1 b 5 t1 temp 2 1 1 b 6 t1 temp 3 2 1 b 7 t1 temp 0 3 1 b 8 t1 temp 2 0 1 b 9 t1 temp 3 1 1 b 10 t1 temp 0 2 1 b 11 t1 temp 1 3 1 b 12 t1 temp 3 0 1 b 13 t1 temp 0 1 1 b 14 t1 temp 1 2 1 b 15 t1 temp 2 3 1 rd uint32 b rd uint32 m expandedkey m urounds 0 rd uint32 b 4 rd uint32 m expandedkey m urounds 1 rd uint32 b 8 rd uint32 m expandedkey m urounds 2 rd uint32 b 12 rd uint32 m expandedkey m urounds 3 rd_uint8 rd_uint8 rd_uint8 rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 m_urounds rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 m_expandedkey m_urounds rd_uint32 rd_uint32 rd_uint32 m_expandedkey m_urounds rd_uint32 rd_uint32 rd_uint32 m_expandedkey m_urounds rd_uint32 rd_uint32 rd_uint32 m_expandedkey m_urounds rd_uint32 rd_uint32 m_expandedkey m_urounds rd_uint32 rd_uint32 m_expandedkey m_urounds rd_uint32 rd_uint32 m_expandedkey m_urounds rd_uint32 rd_uint32 m_expandedkey m_urounds void rijndael decrypt const rd uint8 a 16 rd uint8 b 16 int r rd uint8 temp 4 4 rd uint32 temp 0 rd uint32 a rd uint32 m expandedkey m urounds 0 rd uint32 temp 1 rd uint32 a 4 rd uint32 m expandedkey m urounds 1 rd uint32 temp 2 rd uint32 a 8 rd uint32 m expandedkey m urounds 2 rd uint32 temp 3 rd uint32 a 12 rd uint32 m expandedkey m urounds 3 rd uint32 b rd uint32 t5 temp 0 0 rd uint32 t6 temp 3 1 rd uint32 t7 temp 2 2 rd uint32 t8 temp 1 3 rd uint32 b 4 rd uint32 t5 temp 1 0 rd uint32 t6 temp 0 1 rd uint32 t7 temp 3 2 rd uint32 t8 temp 2 3 rd uint32 b 8 rd uint32 t5 temp 2 0 rd uint32 t6 temp 1 1 rd uint32 t7 temp 0 2 rd uint32 t8 temp 3 3 rd uint32 b 12 rd uint32 t5 temp 3 0 rd uint32 t6 temp 2 1 rd uint32 t7 temp 1 2 rd uint32 t8 temp 0 3 for r m urounds 1 r 1 r rd uint32 temp 0 rd uint32 b rd uint32 m expandedkey r 0 rd uint32 temp 1 rd uint32 b 4 rd uint32 m expandedkey r 1 rd uint32 temp 2 rd uint32 b 8 rd uint32 m expandedkey r 2 rd uint32 temp 3 rd uint32 b 12 rd uint32 m expandedkey r 3 rd uint32 b rd uint32 t5 temp 0 0 rd uint32 t6 temp 3 1 rd uint32 t7 temp 2 2 rd uint32 t8 temp 1 3 rd uint32 b 4 rd uint32 t5 temp 1 0 rd uint32 t6 temp 0 1 rd uint32 t7 temp 3 2 rd uint32 t8 temp 2 3 rd uint32 b 8 rd uint32 t5 temp 2 0 rd uint32 t6 temp 1 1 rd uint32 t7 temp 0 2 rd uint32 t8 temp 3 3 rd uint32 b 12 rd uint32 t5 temp 3 0 rd uint32 t6 temp 2 1 rd uint32 t7 temp 1 2 rd uint32 t8 temp 0 3 rd uint32 temp 0 rd uint32 b rd uint32 m expandedkey 1 0 rd uint32 temp 1 rd uint32 b 4 rd uint32 m expandedkey 1 1 rd uint32 temp 2 rd uint32 b 8 rd uint32 m expandedkey 1 2 rd uint32 temp 3 rd uint32 b 12 rd uint32 m expandedkey 1 3 b 0 s5 temp 0 0 b 1 s5 temp 3 1 b 2 s5 temp 2 2 b 3 s5 temp 1 3 b 4 s5 temp 1 0 b 5 s5 temp 0 1 b 6 s5 temp 3 2 b 7 s5 temp 2 3 b 8 s5 temp 2 0 b 9 s5 temp 1 1 b 10 s5 temp 0 2 b 11 s5 temp 3 3 b 12 s5 temp 3 0 b 13 s5 temp 2 1 b 14 s5 temp 1 2 b 15 s5 temp 0 3 rd uint32 b rd uint32 m expandedkey 0 0 rd uint32 b 4 rd uint32 m expandedkey 0 1 rd uint32 b 8 rd uint32 m expandedkey 0 2 rd uint32 b 12 rd uint32 m expandedkey 0 3 rd_uint8 rd_uint8 rd_uint8 rd_uint32 rd_uint32 rd_uint32 m_expandedkey m_urounds rd_uint32 rd_uint32 rd_uint32 m_expandedkey m_urounds rd_uint32 rd_uint32 rd_uint32 m_expandedkey m_urounds rd_uint32 rd_uint32 rd_uint32 m_expandedkey m_urounds rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 m_urounds rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 m_expandedkey rd_uint32 rd_uint32 m_expandedkey c twofish c twofish ctwofish ctwofish c twofish c twofish ctwofish ctwofish bool c twofish init rd uint8 p key unsigned long u key len rd uint8 init vector assert p key null if p key null return false assert u key len 0 if u key len 0 return false if g binitialized false twofish initialise g binitialized true twofish prepare key twofish byte p key u key len m key if init vector null memcpy m pinitvector init vector 16 else memset m pinitvector 0 16 return true ctwofish rd_uint8 pkey ukeylen rd_uint8 initvector pkey pkey ukeylen ukeylen g_binitialized twofish_initialise g_binitialized twofish_prepare_key twofish_byte pkey ukeylen m_key initvector m_pinitvector initvector m_pinitvector int c twofish pad encrypt rd uint8 p input int n input octets rd uint8 p out buffer int i num blocks pad len rd uint8 block 16 iv assert p input null n input octets null p out buffer null if p input null n input octets 0 p out buffer null return 0 num blocks n input octets 16 iv m pinitvector for i num blocks i 0 i rd uint32 block 0 rd uint32 p input 0 rd uint32 iv 0 rd uint32 block 1 rd uint32 p input 1 rd uint32 iv 1 rd uint32 block 2 rd uint32 p input 2 rd uint32 iv 2 rd uint32 block 3 rd uint32 p input 3 rd uint32 iv 3 twofish encrypt m key twofish byte block twofish byte p out buffer iv p out buffer p input 16 p out buffer 16 pad len 16 n input octets 16 num blocks for i 0 i 16 pad len i block i rd uint8 p input i iv i for i 16 pad len i 16 i block i rd uint8 rd uint8 pad len iv i twofish encrypt m key twofish byte block twofish byte p out buffer return 16 num blocks 1 ctwofish padencrypt rd_uint8 pinput ninputoctets rd_uint8 poutbuffer numblocks padlen rd_uint8 pinput ninputoctets poutbuffer pinput ninputoctets poutbuffer numblocks ninputoctets m_pinitvector numblocks rd_uint32 rd_uint32 pinput rd_uint32 rd_uint32 rd_uint32 pinput rd_uint32 rd_uint32 rd_uint32 pinput rd_uint32 rd_uint32 rd_uint32 pinput rd_uint32 twofish_encrypt m_key twofish_byte twofish_byte poutbuffer poutbuffer pinput poutbuffer padlen ninputoctets numblocks padlen rd_uint8 pinput padlen rd_uint8 rd_uint8 padlen twofish_encrypt m_key twofish_byte twofish_byte poutbuffer numblocks int c twofish pad decrypt rd uint8 p input int n input octets rd uint8 p out buffer int i num blocks pad len rd uint8 block 16 rd uint32 iv 4 assert p input null n input octets null p out buffer null if p input null n input octets 0 p out buffer null return 0 if n input octets 16 0 assert false return 1 num blocks n input octets 16 memcpy iv m pinitvector 16 for i num blocks 1 i 0 i twofish decrypt m key twofish byte p input twofish byte block rd uint32 block 0 iv 0 rd uint32 block 1 iv 1 rd uint32 block 2 iv 2 rd uint32 block 3 iv 3 memcpy iv p input 16 memcpy p out buffer block 16 p input 16 p out buffer 16 twofish decrypt m key twofish byte p input twofish byte block rd uint32 block 0 iv 0 rd uint32 block 1 iv 1 rd uint32 block 2 iv 2 rd uint32 block 3 iv 3 pad len block 15 if pad len 0 pad len 16 return 1 for i 16 pad len i 16 i if block i pad len return 1 memcpy p out buffer block 16 pad len return 16 num blocks pad len ctwofish paddecrypt rd_uint8 pinput ninputoctets rd_uint8 poutbuffer numblocks padlen rd_uint8 rd_uint32 pinput ninputoctets poutbuffer pinput ninputoctets poutbuffer ninputoctets numblocks ninputoctets m_pinitvector numblocks twofish_decrypt m_key twofish_byte pinput twofish_byte rd_uint32 rd_uint32 rd_uint32 rd_uint32 pinput poutbuffer pinput poutbuffer twofish_decrypt m_key twofish_byte pinput twofish_byte rd_uint32 rd_uint32 rd_uint32 rd_uint32 padlen padlen padlen padlen padlen poutbuffer padlen numblocks padlen c dialog c find in db dlg idd p parent afx data init c find in db dlg m badditional true m bpassword true m btitle true m burl true m busername true m strfind t m bcasesensitive false m bgroupname false m bexcludebackups true afx data init m lpgroupname null cdialog cfindindbdlg pparent afx_data_init cfindindbdlg m_badditional m_bpassword m_btitle m_burl m_busername m_strfind _t m_bcasesensitive m_bgroupname m_bexcludebackups afx_data_init m_lpgroupname void c find in db dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c find in db dlg ddx control pdx idok m btok ddx control pdx idcancel m btcancel ddx check pdx idc check notes m badditional ddx check pdx idc check password m bpassword ddx check pdx idc check title m btitle ddx check pdx idc check url m burl ddx check pdx idc check username m busername ddx text pdx idc edit findtext m strfind ddx check pdx idc check casesensitive m bcasesensitive ddx check pdx idc check groupname m bgroupname ddx check pdx idc check excludebackups m bexcludebackups afx data map cfindindbdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map cfindindbdlg ddx_control m_btok ddx_control m_btcancel ddx_check idc_check_notes m_badditional ddx_check idc_check_password m_bpassword ddx_check idc_check_title m_btitle ddx_check idc_check_url m_burl ddx_check idc_check_username m_busername ddx_text idc_edit_findtext m_strfind ddx_check idc_check_casesensitive m_bcasesensitive ddx_check idc_check_groupname m_bgroupname ddx_check idc_check_excludebackups m_bexcludebackups afx_data_map bool c find in db dlg on init dialog c dialog on init dialog newgui translatecwnd this enum child windows this m hwnd newgui translatewindowcb 0 newgui xpbutton m btok idb ok idb ok newgui xpbutton m btcancel idb cancel idb cancel newgui configsidebanner m banner this m banner set icon afx get app load icon idi search kcsb icon left kcsb icon vcenter m banner set title trl find m banner set caption trl find a string in the password list get dlg item idc edit findtext set focus if m lpgroupname null c string str str trl find str t str trl group str t str m lpgroupname m banner set title str get dlg item idc check groupname enable window false get dlg item idc check excludebackups enable window false return false return true unless you set the focus to a control cfindindbdlg oninitdialog cdialog oninitdialog newgui_translatecwnd enumchildwindows m_hwnd newgui_translatewindowcb newgui_xpbutton m_btok idb_ok idb_ok newgui_xpbutton m_btcancel idb_cancel idb_cancel newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_search kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_banner setcaption getdlgitem idc_edit_findtext setfocus m_lpgroupname cstring _t _t m_lpgroupname m_banner settitle getdlgitem idc_check_groupname enablewindow getdlgitem idc_check_excludebackups enablewindow void c find in db dlg onok update data true c dialog onok cfindindbdlg updatedata cdialog void c find in db dlg on cancel c dialog on cancel cfindindbdlg oncancel cdialog oncancel c secure edit ex c secure edit ex int i m bsecmode true m apchars remove all m noldlen 0 m pxorpad new tchar se xorpad size assert m pxorpad null for i 0 i se xorpad size i m pxorpad i tchar rand csecureeditex csecureeditex m_bsecmode m_apchars removeall m_noldlen m_pxorpad se_xorpad_size m_pxorpad se_xorpad_size m_pxorpad c secure edit ex c secure edit ex deleteall set memory ex m pxorpad 0 se xorpad size sizeof tchar deletet ptr m pxorpad true false m pxorpad null csecureeditex csecureeditex _deleteall setmemoryex m_pxorpad se_xorpad_size deletetptr m_pxorpad m_pxorpad void c secure edit ex enable secure mode bool b enable if m bsecmode b enable return nothing to do lptstr lp source get password assert lp source null assert int tcslen lp source m noldlen deleteall m bsecmode b enable if lp source null m noldlen int tcslen lp source if b enable false set window text lp source else if m noldlen 0 insertcharacters 0 lp source unsigned int m noldlen tcsset lp source tch stdpwchar set window text lp source delete password lp source lp source null csecureeditex enablesecuremode benable m_bsecmode benable lpsource getpassword lpsource _tcslen lpsource m_noldlen _deleteall m_bsecmode benable lpsource m_noldlen _tcslen lpsource benable setwindowtext lpsource m_noldlen _insertcharacters lpsource m_noldlen _tcsset lpsource tch_stdpwchar setwindowtext lpsource deletepassword lpsource lpsource bool c secure edit ex is secure mode enabled return m bsecmode csecureeditex issecuremodeenabled m_bsecmode lptstr c secure edit ex get password int i n num chars lptstr tchp lptstr lp if m bsecmode true assert get window text length m apchars get size sync failed if m bsecmode false n num chars get window text length lp new tchar n num chars 1 assert lp null if lp null return null get window text lp n num chars 1 return lp n num chars m apchars get size lp new tchar n num chars 1 assert lp null if lp null return null for i 0 i n num chars i get one character tchp lptstr m apchars get at i assert tchp null if tchp null continue lp i tchar tchp m pxorpad i se xorpad size decrypt lp n num chars 0 terminate string return lp csecureeditex getpassword nnumchars m_bsecmode getwindowtextlength m_apchars getsize m_bsecmode nnumchars getwindowtextlength nnumchars getwindowtext nnumchars nnumchars m_apchars getsize nnumchars nnumchars m_apchars getat m_pxorpad se_xorpad_size nnumchars void c secure edit ex delete password lptstr lp password deletet ptr lp password true true csecureeditex deletepassword lppassword deletetptr lppassword void c secure edit ex set password lpctstr lp password deleteall if m bsecmode false if lp password null set window text lp password else set window text t return if lp password null unsigned int u len unsigned int tcslen lp password if u len 0 insertcharacters 0 lp password u len lptstr tsz buf new tchar u len 1 assert tsz buf null if tsz buf null tcscpy tsz buf lp password tcsset tsz buf tch stdpwchar m noldlen int tcslen tsz buf assert m noldlen int u len set window text tsz buf delete tsz buf tsz buf null else set window text t else set window text t csecureeditex setpassword lppassword _deleteall m_bsecmode lppassword setwindowtext lppassword setwindowtext _t lppassword ulen _tcslen lppassword ulen _insertcharacters lppassword ulen tszbuf ulen tszbuf tszbuf _tcscpy tszbuf lppassword _tcsset tszbuf tch_stdpwchar m_noldlen _tcslen tszbuf m_noldlen ulen setwindowtext tszbuf tszbuf tszbuf setwindowtext _t setwindowtext _t void c secure edit ex deleteall int i lptstr lp securely free the password characters for i 0 i m apchars get size i lp lptstr m apchars get at i deletet ptr lp false false m apchars remove all delete all character pointers m noldlen 0 csecureeditex _deleteall m_apchars getsize m_apchars getat deletetptr m_apchars removeall m_noldlen void c secure edit ex clearselection int n start n end if m bsecmode false return get sel n start n end if n start n end set sel n start n start false csecureeditex _clearselection nstart nend m_bsecmode getsel nstart nend nstart nend setsel nstart nstart void c secure edit ex insertcharacters unsigned int u pos lpctstr lp source unsigned int u num chars assert lp source null if lp source null return assert u num chars 0 if u num chars 0 return assert u pos unsigned int m apchars get size 1 if u pos unsigned int m apchars get size 1 return encryptbuffer false lptstr lp unsigned int i bool b append u pos unsigned int m apchars get size true false for i 0 i u num chars i lp new tchar assert lp null if lp null continue lp lp source i if b append false m apchars insert at int u pos i lp 1 else m apchars add lp encryptbuffer true csecureeditex _insertcharacters upos lpsource unumchars lpsource lpsource unumchars unumchars upos m_apchars getsize upos m_apchars getsize _encryptbuffer bappend upos m_apchars getsize unumchars lpsource bappend m_apchars insertat upos m_apchars _encryptbuffer void c secure edit ex deletecharacters unsigned int u pos unsigned int u count int i assert u pos u count unsigned int m apchars get size if u pos u count unsigned int m apchars get size return encryptbuffer false unlock buffer free the memory erases the characters before freeing them for i 0 i int u count i deletet ptr lptstr m apchars get at int u pos i false false m apchars remove at int u pos int u count remove pointers encryptbuffer true lock buffer again csecureeditex _deletecharacters upos ucount upos ucount m_apchars getsize upos ucount m_apchars getsize _encryptbuffer ucount deletetptr m_apchars getat upos m_apchars removeat upos ucount _encryptbuffer void c secure edit ex encryptbuffer bool b encrypt int i lptstr tchp xor encryption is self inverting no separation of encryption and decryption code needed unreferenced parameter b encrypt for i 0 i m apchars get size i tchp lptstr m apchars get at i assert tchp null if tchp null continue tchp m pxorpad i se xorpad size csecureeditex _encryptbuffer bencrypt unreferenced_parameter bencrypt m_apchars getsize m_apchars getat m_pxorpad se_xorpad_size void c secure edit ex set memory ex void p dest int c size t u count assert p dest null if p dest null return if u count 0 return memset p dest c u count csecureeditex setmemoryex pdest size_t ucount pdest pdest ucount pdest ucount void c secure edit ex deletet ptr lptstr lp bool b is array bool b is string assert lp null if lp null if b is string false lp 0 else set memory ex lp 0 tcslen lp sizeof tchar if b is array false delete lp else delete lp lp null csecureeditex deletetptr bisarray bisstring bisstring setmemoryex _tcslen bisarray void c secure edit ex on en update lptstr lp wnd int i wnd len i diff dword dw pos if m bsecmode false m noldlen get window text length return get information about the new contents of the edit control i wnd len get window text length i diff i wnd len m noldlen if i diff 0 return no change lp wnd new tchar i wnd len 1 assert lp wnd null if lp wnd null return get window text lp wnd i wnd len 1 dw pos get sel 0xffff get the new cursor position if i diff 0 assert i diff 1 deletecharacters dw pos unsigned int i diff else insertcharacters dw pos dword i diff lp wnd dw pos dword i diff unsigned int i diff assert m apchars get size i wnd len m noldlen m apchars get size tcsset lp wnd tch stdpwchar set window text lp wnd set sel int dw pos int dw pos false deletet ptr lp wnd true false memory overwritten already csecureeditex onenupdate lpwnd iwndlen idiff dwpos m_bsecmode m_noldlen getwindowtextlength iwndlen getwindowtextlength idiff iwndlen m_noldlen idiff lpwnd iwndlen lpwnd lpwnd getwindowtext lpwnd iwndlen dwpos getsel idiff idiff _deletecharacters dwpos idiff _insertcharacters dwpos idiff lpwnd dwpos idiff idiff m_apchars getsize iwndlen m_noldlen m_apchars getsize _tcsset lpwnd tch_stdpwchar setwindowtext lpwnd setsel dwpos dwpos deletetptr lpwnd void c secure edit ex on key down uint n char uint n rep cnt uint n flags if m bsecmode true if n char vk home n char vk end short sh shift get key state vk shift sh shift get key state vk lshift sh shift get key state vk rshift if sh shift 0x8000 0 deleteall set window text t set sel 0 0 false c edit on key down n char n rep cnt n flags clearselection csecureeditex onkeydown nchar nrepcnt nflags m_bsecmode nchar vk_home nchar vk_end shshift getkeystate vk_shift shshift getkeystate vk_lshift shshift getkeystate vk_rshift shshift _deleteall setwindowtext _t setsel cedit onkeydown nchar nrepcnt nflags _clearselection void c secure edit ex on key up uint n char uint n rep cnt uint n flags c edit on key up n char n rep cnt n flags clearselection csecureeditex onkeyup nchar nrepcnt nflags cedit onkeyup nchar nrepcnt nflags _clearselection void c secure edit ex on char uint n char uint n rep cnt uint n flags c edit on char n char n rep cnt n flags clearselection csecureeditex onchar nchar nrepcnt nflags cedit onchar nchar nrepcnt nflags _clearselection void c secure edit ex on dead char uint n char uint n rep cnt uint n flags c edit on dead char n char n rep cnt n flags clearselection csecureeditex ondeadchar nchar nrepcnt nflags cedit ondeadchar nchar nrepcnt nflags _clearselection void c secure edit ex on mouse move uint n flags c point point c edit on mouse move n flags point clearselection csecureeditex onmousemove nflags cpoint cedit onmousemove nflags _clearselection void c secure edit ex onl button dbl clk uint n flags c point point c edit onl button dbl clk n flags point clearselection csecureeditex onlbuttondblclk nflags cpoint cedit onlbuttondblclk nflags _clearselection void c secure edit ex onl button up uint n flags c point point c edit onl button up n flags point clearselection csecureeditex onlbuttonup nflags cpoint cedit onlbuttonup nflags _clearselection void c secure edit ex onm button dbl clk uint n flags c point point c edit onm button dbl clk n flags point clearselection csecureeditex onmbuttondblclk nflags cpoint cedit onmbuttondblclk nflags _clearselection void c secure edit ex onm button up uint n flags c point point c edit onm button up n flags point clearselection csecureeditex onmbuttonup nflags cpoint cedit onmbuttonup nflags _clearselection void c secure edit ex onr button dbl clk uint n flags c point point c edit onr button dbl clk n flags point clearselection csecureeditex onrbuttondblclk nflags cpoint cedit onrbuttondblclk nflags _clearselection void c secure edit ex onr button up uint n flags c point point c edit onr button up n flags point clearselection csecureeditex onrbuttonup nflags cpoint cedit onrbuttonup nflags _clearselection void c secure edit ex on set focus clearselection csecureeditex onsetfocus _clearselection c instance checker c instance checker const c string s unique name m executemutex false s unique name hive away the unique name as we will also be using it for the name of the memory mapped file m sname s unique name only one object of type c instance checker should be created assert instance data h instance data null m pexecutelock null cinstancechecker cinstancechecker cstring suniquename m_executemutex suniquename m_sname suniquename cinstancechecker instancedata hinstancedata m_pexecutelock c instance checker c instance checker free up the instance lock release lock cinstancechecker cinstancechecker releaselock void c instance checker activate checker assert m pexecutelock null ensure there is only ever one c instance checker instance active at any one time throughout the system m pexecutelock new c single lock m executemutex true cinstancechecker activatechecker m_pexecutelock cinstancechecker m_pexecutelock csinglelock m_executemutex bool c instance checker track first instance running if a previous instance is running just return prematurely if previous instance running return false if this is the first instance then copy in our info into the shared memory first create the mmf int nmmf size sizeof c window instance instance data h instance data create file mapping handle 0xffffffff null page readwrite 0 nmmf size getmmf filename if instance data h instance data null trace t failed to create the mmf even though this is the first instance you might want to consider overriding getmmf filename n return false open the mmf c window instance p instance data c window instance map view of file instance data h instance data file map read file map write 0 0 nmmf size assert p instance data null opening the mmf should work lock the data prior to updating it c single lock data lock m instancedatamutex true p instance data h main wnd get window to track unmap view of file p instance data since this will be the last function that will be called when this is the first instance we can release the lock release lock return true cinstancechecker trackfirstinstancerunning previousinstancerunning nmmfsize cwindowinstance instancedata hinstancedata createfilemapping page_readwrite nmmfsize getmmffilename instancedata hinstancedata _t getmmffilename cwindowinstance pinstancedata cwindowinstance mapviewoffile instancedata hinstancedata file_map_read file_map_write nmmfsize pinstancedata csinglelock datalock m_instancedatamutex pinstancedata hmainwnd getwindowtotrack unmapviewoffile pinstancedata releaselock bool c instance checker previous instance running try to open the mmf first to see if we are the second instance handle h prev instance open file mapping file map all access false getmmf filename bool b previous instance h prev instance null if h prev instance close handle h prev instance return b previous instance cinstancechecker previousinstancerunning hprevinstance openfilemapping file_map_all_access getmmffilename bpreviousinstance hprevinstance hprevinstance closehandle hprevinstance bpreviousinstance hwnd c instance checker activate previous instance lpctstr lp cmd line dword dw copy data item data try to open the previous instances mmf handle h prev instance open file mapping file map all access false getmmf filename if h prev instance open up the mmf int nmmf size sizeof c window instance c window instance p instance data c window instance map view of file h prev instance file map read file map write 0 0 nmmf size if p instance data null opening the mmf should work lock the data prior to reading from it c single lock data lock m instancedatamutex true activate the old window assert p instance data h main wnd something gone wrong with the mmf hwnd h window p instance data h main wnd if h window c wnd wnd prev wnd prev attach h window c wnd p wnd child wnd prev get last active popup restore the focus to the previous instance and bring it to the foreground if wnd prev is iconic wnd prev show window sw restore if p wnd child null p wnd child set foreground window if lp cmd line send the current apps command line to the previous instance using wm copydata copydatastruct cds cds dw data dw copy data item data int n cmd length tcslen lp cmd line 1 cds cb data n cmd length sizeof tchar tchar psz local cmd line new tchar n cmd length we use a local buffer so that we can specify a constant parameter to this function tcscpy psz local cmd line lp cmd line cds lp data psz local cmd line c wnd p main window afx get main wnd hwnd h sender null if p main window h sender p main window get safe hwnd send the message to the previous instance wnd prev send message wm copydata wparam h sender lparam cds tidy up the heap memory we have used delete psz local cmd line detach the c wnd we were using wnd prev detach unmap the mmf we were using unmap view of file p instance data close the file handle now that we close handle h prev instance when we have activate the previous instance we can release the lock release lock return the window handle of the previous instance return h window close the file handle now that we close handle h prev instance when we have activate the previous instance we can release the lock release lock return null cinstancechecker activatepreviousinstance lpcmdline dwcopydataitemdata hprevinstance openfilemapping file_map_all_access getmmffilename hprevinstance nmmfsize cwindowinstance cwindowinstance pinstancedata cwindowinstance mapviewoffile hprevinstance file_map_read file_map_write nmmfsize pinstancedata csinglelock datalock m_instancedatamutex pinstancedata hmainwnd hwindow pinstancedata hmainwnd hwindow cwnd wndprev wndprev hwindow cwnd pwndchild wndprev getlastactivepopup wndprev isiconic wndprev showwindow sw_restore pwndchild pwndchild setforegroundwindow lpcmdline wm_copydata dwdata dwcopydataitemdata ncmdlength _tcslen lpcmdline cbdata ncmdlength pszlocalcmdline ncmdlength _tcscpy pszlocalcmdline lpcmdline lpdata pszlocalcmdline cwnd pmainwindow afxgetmainwnd hsender pmainwindow hsender pmainwindow getsafehwnd wndprev sendmessage wm_copydata hsender pszlocalcmdline cwnd wndprev unmapviewoffile pinstancedata closehandle hprevinstance releaselock hwindow closehandle hprevinstance releaselock void c instance checker quit previous instance int n exit code try to open the previous instances mmf handle h prev instance open file mapping file map all access false getmmf filename if h prev instance open up the mmf int nmmf size sizeof c window instance c window instance p instance data c window instance map view of file h prev instance file map read file map write 0 0 nmmf size if p instance data null opening the mmf should work lock the data prior to reading from it c single lock data lock m instancedatamutex true activate the old window assert p instance data h main wnd something gone wrong with the mmf hwnd h window p instance data h main wnd ask it to exit if h window post message h window wm quit n exit code 0 close the file handle now that we close handle h prev instance cinstancechecker quitpreviousinstance nexitcode hprevinstance openfilemapping file_map_all_access getmmffilename hprevinstance nmmfsize cwindowinstance cwindowinstance pinstancedata cwindowinstance mapviewoffile hprevinstance file_map_read file_map_write nmmfsize pinstancedata csinglelock datalock m_instancedatamutex pinstancedata hmainwnd hwindow pinstancedata hmainwnd hwindow postmessage hwindow wm_quit nexitcode closehandle hprevinstance c string c instance checker getmmf filename c string smmf t cinstancechecker mmf smmf m sname return smmf cstring cinstancechecker getmmffilename cstring _t cinstancechecker_mmf_ m_sname hwnd c instance checker get window to track by default the window tracked will be the standard afx get main wnd assert afx get main wnd null did you forget to set up the mainfrm in init instance return afx get main wnd get safe hwnd cinstancechecker getwindowtotrack afxgetmainwnd afxgetmainwnd initinstance afxgetmainwnd getsafehwnd void c instance checker release lock if m pexecutelock delete m pexecutelock m pexecutelock null cinstancechecker releaselock m_pexecutelock m_pexecutelock m_pexecutelock instance data instance data h instance data null _instance_data _instance_data hinstancedata instance data instance data if h instance data null close handle h instance data h instance data null _instance_data _instance_data hinstancedata closehandle hinstancedata hinstancedata c private config c private config bool b require write access tchar tsz app dir max path 2 dword dw sub len tsz app dir 0 0 tsz app dir 1 0 assert si regsize max path 2 m szfilelocal 0 0 m szfilelocal 1 0 dw sub len 1 dword tcslen pwm exename 4 2 verify get application directory m szfilelocal max path 2 dw sub len true false tcscat m szfilelocal t tcscat m szfilelocal pwm exename tcscat m szfilelocal t ini m szfileuser 0 0 m szfileuser 1 0 hinstance h shell32 load library t shell32 if h shell32 null lpshgetspecialfolderpath lp get lpshgetspecialfolderpath get proc address h shell32 ifndef unicode sh get special folder patha else sh get special folder pathw endif winnt 4 0 doesn t support this function therefore check for null pointer without assertion if lp get null lp get null m szfileuser csidl appdata true lp get null free library h shell32 h shell32 null else assert false if m szfileuser 0 0 tcscpy m szfileuser pwm exename not found make the same as m szfilegeneric tcscat m szfileuser t ini else up to now m szfileuser just contains the users directory path make it a valid file location now dword u len dword tcslen m szfileuser assert u len 0 if u len 0 if m szfileuser u len 1 t tcscat m szfileuser t tcscat m szfileuser pwm exename tcscpy tsz app dir m szfileuser tcscat m szfileuser t tcscat m szfileuser pwm exename tcscat m szfileuser t ini tcscpy m szfilegeneric pwm exename tcscat m szfilegeneric t ini m nusedir 0 if b require write access true if filewritable m szfilelocal false m nusedir 1 if tsz app dir 0 0 create directory tsz app dir null if filewritable m szfileuser false m nusedir 2 hopefully this never happens else b req write access false if fileaccessible m szfilelocal false m nusedir 1 if fileaccessible m szfileuser false m nusedir 2 cprivateconfig cprivateconfig brequirewriteaccess tszappdir max_path dwsublen tszappdir tszappdir si_regsize max_path m_szfilelocal m_szfilelocal dwsublen _tcslen pwm_exename getapplicationdirectory m_szfilelocal max_path dwsublen _tcscat m_szfilelocal _t _tcscat m_szfilelocal pwm_exename _tcscat m_szfilelocal _t m_szfileuser m_szfileuser hshell32 loadlibrary _t hshell32 lpget getprocaddress hshell32 _unicode shgetspecialfolderpatha shgetspecialfolderpathw lpget lpget m_szfileuser csidl_appdata lpget freelibrary hshell32 hshell32 m_szfileuser _tcscpy m_szfileuser pwm_exename m_szfilegeneric _tcscat m_szfileuser _t m_szfileuser ulen _tcslen m_szfileuser ulen ulen m_szfileuser ulen _t _tcscat m_szfileuser _t _tcscat m_szfileuser pwm_exename _tcscpy tszappdir m_szfileuser _tcscat m_szfileuser _t _tcscat m_szfileuser pwm_exename _tcscat m_szfileuser _t _tcscpy m_szfilegeneric pwm_exename _tcscat m_szfilegeneric _t m_nusedir brequirewriteaccess _filewritable m_szfilelocal m_nusedir tszappdir createdirectory tszappdir _filewritable m_szfileuser m_nusedir breqwriteaccess _fileaccessible m_szfilelocal m_nusedir _fileaccessible m_szfileuser m_nusedir c private config c private config cprivateconfig cprivateconfig bool c private config set const tchar psz field pcfg in tchar psz value lpctstr lp exe name pwm exename bool b ret false assert psz field null if psz field null return false assert psz field 0 0 if psz field 0 0 return false psz value may be null this deletes the specified key ifndef win32 wce tchar tsz temp si regsize tsz temp 0 0 tsz temp 1 0 if psz value null delete key if the key doesn t exist we don t need to delete it if get psz field tsz temp false return true else check if the existing value in the ini file is the same as the one to be written if so we don t need to write it again for devices that cache reads but not writes this leads to a performance improvement thanks to brad clarke for the idea and patch if get psz field tsz temp true if tcscmp tsz temp psz value 0 return true if m nusedir 0 b ret write private profile string lp exe name psz field psz value m szfilelocal if b ret false if m nusedir 1 b ret write private profile string lp exe name psz field psz value m szfileuser if b ret false b ret write private profile string lp exe name psz field psz value m szfilegeneric else b ret false assert false implement before using on wince endif return b ret cprivateconfig pszfield pcfg_in pszvalue lpexename pwm_exename bret pszfield pszfield pszfield pszfield pszvalue _win32_wce tsztemp si_regsize tsztemp tsztemp pszvalue pszfield tsztemp pszfield tsztemp _tcscmp tsztemp pszvalue m_nusedir bret writeprivateprofilestring lpexename pszfield pszvalue m_szfilelocal bret m_nusedir bret writeprivateprofilestring lpexename pszfield pszvalue m_szfileuser bret bret writeprivateprofilestring lpexename pszfield pszvalue m_szfilegeneric bret bret bool c private config get const tchar psz field pcfg out tchar psz value lpctstr lp exe name pwm exename lpctstr lp not found pcfg notfound tchar tsz temp si regsize assert psz value null if psz value null return false psz value 0 0 psz value 1 0 reset string tsz temp 0 0 tsz temp 1 0 assert psz field null if psz field null return false assert psz field 0 0 if psz field 0 0 return false ifndef win32 wce if m nusedir 0 get private profile string lp exe name psz field lp not found tsz temp si regsize 1 m szfilelocal if tcscmp tsz temp lp not found 0 m nusedir 0 tsz temp 0 0 tsz temp 1 0 if m nusedir 1 get private profile string lp exe name psz field lp not found tsz temp si regsize 1 m szfileuser if tcscmp tsz temp lp not found 0 m nusedir 2 tsz temp 0 0 tsz temp 1 0 get private profile string lp exe name psz field lp not found tsz temp si regsize 1 m szfilegeneric if tcscmp tsz temp lp not found 0 return false tcscpy psz value tsz temp return true else assert false implement before using on wince return false endif cprivateconfig pszfield pcfg_out pszvalue lpexename pwm_exename lpnotfound pcfg_notfound tsztemp si_regsize pszvalue pszvalue pszvalue pszvalue tsztemp tsztemp pszfield pszfield pszfield pszfield _win32_wce m_nusedir getprivateprofilestring lpexename pszfield lpnotfound tsztemp si_regsize m_szfilelocal _tcscmp tsztemp lpnotfound m_nusedir tsztemp tsztemp m_nusedir getprivateprofilestring lpexename pszfield lpnotfound tsztemp si_regsize m_szfileuser _tcscmp tsztemp lpnotfound m_nusedir tsztemp tsztemp getprivateprofilestring lpexename pszfield lpnotfound tsztemp si_regsize m_szfilegeneric _tcscmp tsztemp lpnotfound _tcscpy pszvalue tsztemp bool c private config set bool const tchar psz field bool b value return set psz field b value false t false t true cprivateconfig setbool pszfield bvalue pszfield bvalue _t _t bool c private config get bool const tchar psz field bool b default tchar tsz temp si regsize if get psz field tsz temp false return b default if tcsicmp tsz temp t true 0 return true else if tcsicmp tsz temp t false 0 return false return b default cprivateconfig getbool pszfield bdefault tsztemp si_regsize pszfield tsztemp bdefault _tcsicmp tsztemp _t _tcsicmp tsztemp _t bdefault c plugin manager c plugin manager m dwfreepluginid 0 m plugins clear zero memory m kpappinfo sizeof kp app info m dwfirstcommand 0 m dwlastcommand 0 cpluginmanager cpluginmanager m_dwfreepluginid m_plugins zeromemory m_kpappinfo kp_app_info m_dwfirstcommand m_dwlastcommand c plugin manager c plugin manager cleanup cpluginmanager cpluginmanager _cleanup bool c plugin manager set app info const kp app info p app info assert p app info null if p app info null return false memcpy m kpappinfo p app info sizeof kp app info return true cpluginmanager setappinfo kp_app_info pappinfo pappinfo pappinfo m_kpappinfo pappinfo kp_app_info bool c plugin manager set direct command range dword dw first command dword dw last command assert dw first command dw last command if dw first command dw last command return false m dwfirstcommand dw first command m dwlastcommand dw last command return true cpluginmanager setdirectcommandrange dwfirstcommand dwlastcommand dwfirstcommand dwlastcommand dwfirstcommand dwlastcommand m_dwfirstcommand dwfirstcommand m_dwlastcommand dwlastcommand bool c plugin manager assign plugin commands unsigned int i dword j pos cmd m dwfirstcommand kp plugin instance p bool b ret true assert m dwlastcommand 0 if m dwlastcommand 0 return false for i 0 i unsigned int m plugins size i p m plugins i assert p null if p null return false if p hinstdll null p info dw num commands 0 p info p menu items null for j 0 j p info dw num commands j p info p menu items j dw commandid 0 0 command unused check if we have haven t run out of commands yet if pos cmd m dwlastcommand 1 continue p info p menu items j dw commandid pos cmd assign fix command string if p info p menu items j lp command string null p info p menu items j lp command string t pos cmd assert pos cmd m dwlastcommand 1 return b ret cpluginmanager assignplugincommands poscmd m_dwfirstcommand kp_plugin_instance bret m_dwlastcommand m_dwlastcommand m_plugins m_plugins dwnumcommands pmenuitems dwnumcommands pmenuitems dwcommandid poscmd m_dwlastcommand pmenuitems dwcommandid poscmd pmenuitems lpcommandstring pmenuitems lpcommandstring _t poscmd poscmd m_dwlastcommand bret bool c plugin manager add plugin lpctstr lp file kp plugin instance kppi kp plugin instance p file fp assert lp file null if lp file null return false zero memory kppi sizeof kp plugin instance fp tfopen lp file t rb if fp null return false fclose fp fp null kppi b enabled false kppi hinstdll null tcsncpy kppi tsz file lp file max path 1 int i bool b in list already false for i 0 i int m plugins size i p m plugins i if tcscmp lp file p tsz file 0 b in list already true break if b in list already false kppi dw pluginid m dwfreepluginid m dwfreepluginid m plugins push back kppi return true cpluginmanager addplugin lpfile kp_plugin_instance kp_plugin_instance lpfile lpfile zeromemory kp_plugin_instance _tfopen lpfile _t benabled _tcsncpy tszfile lpfile max_path binlistalready m_plugins m_plugins _tcscmp lpfile tszfile binlistalready binlistalready dwpluginid m_dwfreepluginid m_dwfreepluginid m_plugins push_back bool c plugin manager add all plugins lpctstr lp base search path lpctstr lp mask bool b show errors handle h find win32 find data wfd tchar tsz path max path assert lp base search path null if lp base search path null return false tcscpy tsz path lp base search path tcscat tsz path lp mask zero memory wfd sizeof win32 find data h find find first file tsz path wfd if h find invalid handle value return true valid but no files while 1 tcscpy tsz path lp base search path tcscat tsz path wfd c file name if add plugin tsz path false b show errors true c string str str trl plugin str t str wfd c file name str t str trl cannot be loaded message box get desktop window str trl plugin manager mb ok mb iconwarning if find next file h find wfd false break find close h find h find null return true cpluginmanager addallplugins lpbasesearchpath lpmask bshowerrors hfind win32_find_data tszpath max_path lpbasesearchpath lpbasesearchpath _tcscpy tszpath lpbasesearchpath _tcscat tszpath lpmask zeromemory win32_find_data hfind findfirstfile tszpath hfind invalid_handle_value _tcscpy tszpath lpbasesearchpath _tcscat tszpath cfilename addplugin tszpath bshowerrors cstring _t cfilename _t messagebox getdesktopwindow mb_ok mb_iconwarning findnextfile hfind findclose hfind hfind bool c plugin manager enable plugin byid dword dw pluginid bool b enable unsigned int i bool b ret false for i 0 i m plugins size i if m plugins i dw pluginid dw pluginid m plugins i b enabled b enable b ret true break return b ret cpluginmanager enablepluginbyid dwpluginid benable bret m_plugins m_plugins dwpluginid dwpluginid m_plugins benabled benable bret bret bool c plugin manager enable plugin by str lpctstr lp plugin file bool b enable c string strt str short unsigned int i bool b ret false assert lp plugin file null if lp plugin file null return false only plugins in the kee pass directory are allowed if tcschr lp plugin file t null return false if tcschr lp plugin file t null return false for i 0 i unsigned int m plugins size i strt m plugins i tsz file str short cs file only strt if tcscmp lpctstr str short lp plugin file 0 m plugins i b enabled b enable b ret true break return b ret cpluginmanager enablepluginbystr lppluginfile benable cstring strshort bret lppluginfile lppluginfile keepass _tcschr lppluginfile _t _tcschr lppluginfile _t m_plugins m_plugins tszfile strshort csfileonly _tcscmp strshort lppluginfile m_plugins benabled benable bret bret kp plugin instance c plugin manager get plugin byid dword dwid unsigned int i for i 0 i unsigned int m plugins size i if m plugins i dw pluginid dwid return m plugins i return null kp_plugin_instance cpluginmanager getpluginbyid m_plugins m_plugins dwpluginid m_plugins bool c plugin manager load all plugins unsigned int i kp plugin instance p for i 0 i unsigned int m plugins size i p m plugins i if p b enabled false continue disabled assert p hinstdll null if p hinstdll null continue loaded already p hinstdll load library p tsz file if p hinstdll null continue p lp init lpkeeplugininit get proc address p hinstdll kp i init if p lp init null free library p hinstdll p hinstdll null continue p lp call lpkeeplugincall get proc address p hinstdll kp i call if p lp call null free library p hinstdll p hinstdll null continue p lp exit lpkeepluginexit get proc address p hinstdll kp i exit if p lp exit null free library p hinstdll p hinstdll null continue call the initialization function of the plugin if p lp init m kpappinfo p info false free library p hinstdll p hinstdll null continue if p info dw for app ver m kpappinfo dw app version c string str tchar tsz temp 20 str trl plugin str t str p tsz file str t r n r n str trl this plugin has been designed for a different application version and may be incompatible with this one str t r n r n str trl application version str t stprintf tsz temp t u u u u m kpappinfo dw app version 24 0xff m kpappinfo dw app version 16 0xff m kpappinfo dw app version 8 0xff m kpappinfo dw app version 0xff str tsz temp str t r n str trl plugin has been designed for str t stprintf tsz temp t u u u u p info dw for app ver 24 0xff p info dw for app ver 16 0xff p info dw for app ver 8 0xff p info dw for app ver 0xff str tsz temp str t r n r n str trl it is possible that the plugin is compatible but it s also possible that it will crash kee pass str t r n str trl therefore save all data before you continue str t r n r n str trl do you want to load the plugin int n ret n ret message box get desktop window str trl plugin manager mb yesno mb iconquestion if n ret idno p lp exit 0 0 p b enabled false p lp init null p lp call null p lp exit null free library p hinstdll p hinstdll null continue return assign plugin commands cpluginmanager loadallplugins kp_plugin_instance m_plugins m_plugins benabled loadlibrary tszfile lpinit getprocaddress kp_i_init lpinit freelibrary lpcall getprocaddress kp_i_call lpcall freelibrary lpexit getprocaddress kp_i_exit lpexit freelibrary lpinit m_kpappinfo freelibrary dwforappver m_kpappinfo dwappversion cstring tsztemp _t tszfile _t _t _t _stprintf tsztemp _t m_kpappinfo dwappversion m_kpappinfo dwappversion m_kpappinfo dwappversion m_kpappinfo dwappversion tsztemp _t _t _stprintf tsztemp _t dwforappver dwforappver dwforappver dwforappver tsztemp _t keepass _t _t nret nret messagebox getdesktopwindow mb_yesno mb_iconquestion nret lpexit benabled lpinit lpcall lpexit freelibrary assignplugincommands bool c plugin manager unload all plugins unsigned int i kp plugin instance p for i 0 i unsigned int m plugins size i p m plugins i if p hinstdll null unloaded already assert p lp exit null if p lp exit null p lp exit 0 0 p lp init null p lp call null p lp exit null free library p hinstdll p hinstdll null return true cpluginmanager unloadallplugins kp_plugin_instance m_plugins m_plugins lpexit lpexit lpexit lpinit lpcall lpexit freelibrary bool c plugin manager call single plugin dword dw pluginid dword dw code lparam l paramw lparam l paraml kp plugin instance p get plugin byid dw pluginid assert p null if p null return false if p hinstdll null return p lp call dw code l paramw l paraml return true true continue work cpluginmanager callsingleplugin dwpluginid dwcode lparamw lparaml kp_plugin_instance getpluginbyid dwpluginid lpcall dwcode lparamw lparaml bool c plugin manager call plugins dword dw code lparam l paramw lparam l paraml bool b ret true unsigned int i j kp plugin instance p kp menu item p menu items if dw code kpm direct exec for i 0 i unsigned int m plugins size i p m plugins i if p hinstdll null continue p menu items p info p menu items for j 0 j unsigned int p info dw num commands j if p menu items j dw commandid dword l paramw return p lp call kpm direct exec l paramw l paraml else for i 0 i unsigned int m plugins size i call all plugins p m plugins i if p hinstdll null continue b ret p lp call dw code l paramw l paraml return b ret cpluginmanager callplugins dwcode lparamw lparaml bret kp_plugin_instance kp_menu_item pmenuitems dwcode kpm_direct_exec m_plugins m_plugins pmenuitems pmenuitems dwnumcommands pmenuitems dwcommandid lparamw lpcall kpm_direct_exec lparamw lparaml m_plugins m_plugins bret lpcall dwcode lparamw lparaml bret void c plugin manager cleanup unload all plugins m plugins clear m dwfreepluginid 0 zero memory m kpappinfo sizeof kp app info cpluginmanager _cleanup unloadallplugins m_plugins m_dwfreepluginid zeromemory m_kpappinfo kp_app_info c new random c new random reset cnewrandom cnewrandom c new random c new random reset cnewrandom cnewrandom void c new random reset mem erase m ppseudorandom intrand size m dwcounter 0 cnewrandom mem_erase m_ppseudorandom intrand_size m_dwcounter void c new random initialize dword inx word ww dword dw large integer li systemtime st point pt memorystatus ms system info si ifndef win32 wce startupinfo sui endif g dwnewrandominstancecounter reset inx 0 dw get tick count memcpy m ppseudorandom inx dw 4 inx 4 query performance counter li memcpy m ppseudorandom inx li sizeof large integer inx sizeof large integer get local time st memcpy m ppseudorandom inx st sizeof systemtime inx sizeof systemtime get cursor pos pt memcpy m ppseudorandom inx pt sizeof point inx sizeof point ww word rand memcpy m ppseudorandom inx ww 2 inx 2 ww word rand memcpy m ppseudorandom inx ww 2 inx 2 ww word rand memcpy m ppseudorandom inx ww 2 inx 2 get caret pos pt memcpy m ppseudorandom inx pt sizeof point inx sizeof point global memory status ms memcpy m ppseudorandom inx ms sizeof memorystatus inx sizeof memorystatus dw dword get active window memcpy m ppseudorandom inx dw 4 inx 4 dw dword get capture memcpy m ppseudorandom inx dw 4 inx 4 dw dword get clipboard owner memcpy m ppseudorandom inx dw 4 inx 4 ifndef win32 wce no support under windows ce dw dword get clipboard viewer memcpy m ppseudorandom inx dw 4 else leave the stack data random endif inx 4 dw get current process id memcpy m ppseudorandom inx dw 4 inx 4 dw dword get current process memcpy m ppseudorandom inx dw 4 inx 4 dw dword get active window memcpy m ppseudorandom inx dw 4 inx 4 dw get current thread id memcpy m ppseudorandom inx dw 4 inx 4 dw dword get current thread memcpy m ppseudorandom inx dw 4 inx 4 dw dword get desktop window memcpy m ppseudorandom inx dw 4 inx 4 dw dword get focus memcpy m ppseudorandom inx dw 4 inx 4 dw dword get foreground window memcpy m ppseudorandom inx dw 4 inx 4 ifndef win32 wce dw dword get input state memcpy m ppseudorandom inx dw 4 else leave the stack data random endif inx 4 dw get message pos memcpy m ppseudorandom inx dw 4 inx 4 ifndef win32 wce dw dword get message time memcpy m ppseudorandom inx dw 4 else leave the stack data random endif inx 4 dw dword get open clipboard window memcpy m ppseudorandom inx dw 4 inx 4 dw dword get process heap memcpy m ppseudorandom inx dw 4 inx 4 get system info si memcpy m ppseudorandom inx si sizeof system info inx sizeof system info dw dword rand xor shift memcpy m ppseudorandom inx dw 4 inx 4 ifndef win32 wce get startup info sui memcpy m ppseudorandom inx sui sizeof startupinfo else leave the stack data random endif inx sizeof startupinfo memcpy m ppseudorandom inx g dwnewrandominstancecounter 4 inx 4 assert inx intrand size cnewrandom large_integer system_info _win32_wce g_dwnewrandominstancecounter gettickcount m_ppseudorandom queryperformancecounter m_ppseudorandom large_integer large_integer getlocaltime m_ppseudorandom getcursorpos m_ppseudorandom m_ppseudorandom m_ppseudorandom m_ppseudorandom getcaretpos m_ppseudorandom globalmemorystatus m_ppseudorandom getactivewindow m_ppseudorandom getcapture m_ppseudorandom getclipboardowner m_ppseudorandom _win32_wce getclipboardviewer m_ppseudorandom getcurrentprocessid m_ppseudorandom getcurrentprocess m_ppseudorandom getactivewindow m_ppseudorandom getcurrentthreadid m_ppseudorandom getcurrentthread m_ppseudorandom getdesktopwindow m_ppseudorandom getfocus m_ppseudorandom getforegroundwindow m_ppseudorandom _win32_wce getinputstate m_ppseudorandom getmessagepos m_ppseudorandom _win32_wce getmessagetime m_ppseudorandom getopenclipboardwindow m_ppseudorandom getprocessheap m_ppseudorandom getsysteminfo m_ppseudorandom system_info system_info randxorshift m_ppseudorandom _win32_wce getstartupinfo m_ppseudorandom m_ppseudorandom g_dwnewrandominstancecounter intrand_size void c new random get random buffer byte p buf dword dw size sha256 ctx hashctx byte a temp 32 dword dw assert p buf null while dw size 0 m dwcounter sha256 begin hashctx sha256 hash m ppseudorandom intrand size hashctx sha256 hash byte m dwcounter 4 hashctx sha256 end a temp hashctx dw dw size 32 dw size 32 memcpy p buf a temp dw p buf dw dw size dw cnewrandom getrandombuffer pbuf dwsize sha256_ctx atemp pbuf dwsize m_dwcounter sha256_begin sha256_hash m_ppseudorandom intrand_size sha256_hash m_dwcounter sha256_end atemp dwsize dwsize pbuf atemp pbuf dwsize c base64 codec c base64 codec cbase64codec cbase64codec c base64 codec c base64 codec cbase64codec cbase64codec bool c base64 codec encode const byte p in dword u in len byte p out dword u out len dword i len2 leven byte p assert p in null u in len 0 p out null u out len null len2 u in len 2 3 2 if u out len len2 1 return false p p out leven 3 u in len 3 for i 0 i leven i 3 p g pcodes p in 0 2 p g pcodes p in 0 3 4 p in 1 4 p g pcodes p in 1 0xf 2 p in 2 6 p g pcodes p in 2 0x3f p in 3 if i u in len dword a p in 0 dword b i 1 u in len p in 1 0 dword c 0 p g pcodes a 2 p g pcodes a 3 4 b 4 p i 1 u in len g pcodes b 0xf 2 c 6 p p 0 append null byte u out len p p out return true cbase64codec pin uinlen pout uoutlen pin uinlen pout uoutlen uinlen uoutlen pout uinlen g_pcodes pin g_pcodes pin pin g_pcodes pin pin g_pcodes pin pin uinlen pin uinlen pin g_pcodes g_pcodes uinlen g_pcodes uoutlen pout bool c base64 codec decode const byte p in dword u in len byte p out dword u out len dword t x y z byte c dword g 3 assert p in null u in len 0 p out null u out len null for x y z t 0 x u in len x c g pmap p in x if c 255 continue if c 254 c 0 g t t 6 c if y 4 if z g u out len return false buffer overflow p out z byte t 16 255 if g 1 p out z byte t 8 255 if g 2 p out z byte t 255 y t 0 u out len z return true cbase64codec pin uinlen pout uoutlen pin uinlen pout uoutlen uinlen g_pmap pin uoutlen pout pout pout uoutlen c dialog c tan wizard dlg idd p parent afx data init c tan wizard dlg m strtans t m bassignnumbers false m dwstartnumber 0 afx data init cdialog ctanwizarddlg pparent afx_data_init ctanwizarddlg m_strtans _t m_bassignnumbers m_dwstartnumber afx_data_init void c tan wizard dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c tan wizard dlg ddx control pdx idcancel m btcancel ddx control pdx idok m btok ddx text pdx idc edit tans m strtans ddx check pdx idc check numbering m bassignnumbers ddx text pdx idc edit numbering start m dwstartnumber afx data map ctanwizarddlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map ctanwizarddlg ddx_control m_btcancel ddx_control m_btok ddx_text idc_edit_tans m_strtans ddx_check idc_check_numbering m_bassignnumbers ddx_text idc_edit_numbering_start m_dwstartnumber afx_data_map bool c tan wizard dlg on init dialog c dialog on init dialog newgui translatecwnd this enum child windows this m hwnd newgui translatewindowcb 0 newgui xpbutton m btok idb ok idb ok newgui xpbutton m btcancel idb cancel idb cancel newgui configsidebanner m banner this m banner set icon afx get app load icon idi options kcsb icon left kcsb icon vcenter m banner set title trl tan wizard m banner set caption trl using this wizard you can easily add tan entries get dlg item idc edit numbering start enable window false return true ctanwizarddlg oninitdialog cdialog oninitdialog newgui_translatecwnd enumchildwindows m_hwnd newgui_translatewindowcb newgui_xpbutton m_btok idb_ok idb_ok newgui_xpbutton m_btcancel idb_cancel idb_cancel newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_options kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_banner setcaption getdlgitem idc_edit_numbering_start enablewindow void c tan wizard dlg onok update data true c dialog onok ctanwizarddlg updatedata cdialog void c tan wizard dlg on cancel c dialog on cancel ctanwizarddlg oncancel cdialog oncancel void c tan wizard dlg on check numbering update data true if m bassignnumbers true get dlg item idc edit numbering start enable window true else get dlg item idc edit numbering start enable window false ctanwizarddlg onchecknumbering updatedata m_bassignnumbers getdlgitem idc_edit_numbering_start enablewindow getdlgitem idc_edit_numbering_start enablewindow c dialog c password dlg idd p parent afx data init c password dlg m bstars true m bkeymethod false afx data init m bloadmode true m bconfirm false m bchanging false m strdescriptivename t m bonce false m hwindowicon null m lppreselectpath m lpkey m lpkey2 null cdialog cpassworddlg pparent afx_data_init cpassworddlg m_bstars m_bkeymethod afx_data_init m_bloadmode m_bconfirm m_bchanging m_strdescriptivename _t m_bonce m_hwindowicon m_lppreselectpath m_lpkey m_lpkey2 void c password dlg clean up m cbdisklist reset content m ilicons delete image list m fstyle delete object m fsymbol delete object cpassworddlg cleanup m_cbdisklist resetcontent m_ilicons deleteimagelist m_fstyle deleteobject m_fsymbol deleteobject void c password dlg free passwords assert m lpkey null if m lpkey null m peditpw delete password m lpkey m lpkey null if m lpkey2 null m peditpw delete password m lpkey2 m lpkey2 null cpassworddlg freepasswords m_lpkey m_lpkey m_peditpw deletepassword m_lpkey m_lpkey m_lpkey2 m_peditpw deletepassword m_lpkey2 m_lpkey2 void c password dlg enable client windows update data true int n pw length m peditpw get window text length int n combo sel m cbdisklist get cur sel if m bkeymethod pwm keymethod or if n pw length 0 m hlselfile enable window false m btstars enable window true if m bconfirm false m btmakepw enable window true m peditpw enable window true m cbdisklist enable window false return else if n combo sel 0 m hlselfile enable window true m btstars enable window false if m bconfirm false m btmakepw enable window false m peditpw enable window false m cbdisklist enable window true return m btstars enable window true if m bconfirm false m btmakepw enable window true m peditpw enable window true m cbdisklist enable window true if n combo sel 0 m hlselfile enable window true else m hlselfile enable window false cpassworddlg enableclientwindows updatedata npwlength m_peditpw getwindowtextlength ncombosel m_cbdisklist getcursel m_bkeymethod pwm_keymethod_or npwlength m_hlselfile enablewindow m_btstars enablewindow m_bconfirm m_btmakepw enablewindow m_peditpw enablewindow m_cbdisklist enablewindow ncombosel m_hlselfile enablewindow m_btstars enablewindow m_bconfirm m_btmakepw enablewindow m_peditpw enablewindow m_cbdisklist enablewindow m_btstars enablewindow m_bconfirm m_btmakepw enablewindow m_peditpw enablewindow m_cbdisklist enablewindow ncombosel m_hlselfile enablewindow m_hlselfile enablewindow bool c password dlg pre translate message msg p msg m tipsecclear relay event p msg return c dialog pre translate message p msg cpassworddlg pretranslatemessage pmsg m_tipsecclear relayevent pmsg cdialog pretranslatemessage pmsg void c password dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c password dlg ddx control pdx idc combo disklist m cbdisklist ddx control pdx idc hl selectfile m hlselfile ddx control pdx idc progress passquality m cpassquality ddx control pdx idc check stars m btstars ddx control pdx idok m btok ddx control pdx idcancel m btcancel ddx control pdx idc makepassword btn m btmakepw ddx control pdx idc edit password m peditpw ddx check pdx idc check stars m bstars ddx check pdx idc check keymethod and m bkeymethod afx data map cpassworddlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map cpassworddlg ddx_control idc_combo_disklist m_cbdisklist ddx_control idc_hl_selectfile m_hlselfile ddx_control idc_progress_passquality m_cpassquality ddx_control idc_check_stars m_btstars ddx_control m_btok ddx_control m_btcancel ddx_control idc_makepassword_btn m_btmakepw ddx_control idc_edit_password m_peditpw ddx_check idc_check_stars m_bstars ddx_check idc_check_keymethod_and m_bkeymethod afx_data_map bool c password dlg on init dialog c dialog on init dialog assert m bonce false modify style ex ws ex appwindow ws ex appwindow assert m hwindowicon null if m hwindowicon null set icon m hwindowicon true set icon m hwindowicon false enum child windows this m hwnd newgui translatewindowcb 0 m fstyle create font 12 0 0 0 0 false false 0 default charset out default precis clip default precis default quality default pitch ff modern t tahoma m fsymbol create font 13 0 0 0 0 false false 0 default charset out default precis clip default precis default quality default pitch ff modern c pw safe app get password font newgui xpbutton m btok idb ok idb ok newgui xpbutton m btcancel idb cancel idb cancel newgui xpbutton m btmakepw idb key small idb key small newgui xpbutton m btstars 1 1 m btstars set font m fsymbol true m peditpw set font m fsymbol true m btstars set color c buttonst btnst color fg in rgb 0 0 255 true c string strtt trl hide passwords behind asterisks strtt remove t m btstars set tooltip text strtt true newgui configqualitymeter m cpassquality m ilicons create idr infoicons 16 1 rgb 255 0 255 purple is transparent c pw safe app create hi color image list m ilicons idb infoicons ex 16 m cbdisklist set image list m ilicons comboboxexitem cbi zero memory cbi sizeof comboboxexitem cbi mask cbeif image cbeif text cbeif indent cbeif selectedimage cbi i item 0 cbi psz text lptstr trl no drive selected cbi cch text max int tcslen cbi psz text cbi i image cbi i selected image icoidx nodrive cbi i indent 0 m cbdisklist insert item cbi int i tchar c uint u stat c string str byte idx image int j 1 for i 0 i 26 i c tchar i t a str c string c t u stat get drive type lpctstr str if u stat drive no root dir idx image 0 if u stat drive removable idx image icoidx removable if u stat drive fixed idx image icoidx fixed if u stat drive remote idx image icoidx remote if u stat drive cdrom idx image icoidx cdrom if u stat drive ramdisk idx image icoidx ramdisk zero memory cbi sizeof comboboxexitem cbi mask cbeif image cbeif text cbeif indent cbeif selectedimage cbi i item j j cbi psz text lptstr lpctstr str cbi cch text max int tcslen cbi psz text cbi i image cbi i selected image int idx image cbi i indent 0 m cbdisklist insert item cbi m cbdisklist set cur sel 0 dword dw m cbdisklist get extended style dw cbes ex noeditimage m cbdisklist set extended style 0 dw newgui makehyperlink m hlselfile m hlselfile enable tooltip false m hlselfile set notify parent true m hlselfile enableurl false newgui configsidebanner m banner this if m bloadmode false m banner set icon afx get app load icon idi key kcsb icon left kcsb icon vcenter else m banner set icon afx get app load icon idi keyhole kcsb icon left kcsb icon vcenter lpctstr lp lp trl enter the passphrase and or select the key disk s drive get dlg item idc static intro set window text lp lp trl enter password get dlg item idc static enterpw set window text lp if m bconfirm false if m bloadmode false lp trl select the password disk drive where the key will be stored get dlg item idc static seldisk set window text lp lp trl save key file manually to m hlselfile set window text lp c string str str trl set master key if m strdescriptivename get length 0 str t str m strdescriptivename m banner set title str if m bchanging false set window text trl create a new password database enter master key m banner set caption trl enter the master key for the new database else set window text trl change password of this database enter new master key m banner set caption trl enter the new master key for this database else m bconfirm false m bloadmode true lp trl select the password disk drive to load the key from get dlg item idc static seldisk set window text lp lp trl select key file manually m hlselfile set window text lp set window text trl open database enter master key c string str str trl enter master key if m strdescriptivename get length 0 str t str m strdescriptivename m banner set title str m banner set caption trl enter the master key for this database m btmakepw show window sw hide m cpassquality show window sw hide get dlg item idc static passbits show window sw hide else m bconfirm true if m bloadmode false get dlg item idc static intro show window sw hide get dlg item idc static seldisk show window sw hide m cbdisklist show window sw hide m btmakepw enable window false m hlselfile show window sw hide if m bchanging false set window text trl create a new password database repeat master key m banner set caption trl repeat the master key for the new database else set window text trl repeat master key m banner set caption trl repeat the master key for this database m banner set title trl repeat master password m cpassquality show window sw hide get dlg item idc static passbits show window sw hide get dlg item idc check keymethod and show window sw hide else this combination isn t possible assert false just in case assume we want to load something lp trl select the password disk drive to load the key from get dlg item idc static seldisk set window text lp set window text trl open database enter master key c string str str trl enter master key if m strdescriptivename get length 0 str t str m strdescriptivename m banner set title str m banner set caption trl enter the master key for this database m btmakepw show window sw hide m tipsecclear create this 0x40 m tipsecclear add tool m peditpw c pw safe dlg getsecureedittiptext t enter password m tipsecclear set max tip width 630 m tipsecclear activate m peditpw is secure mode enabled alternative password asterisk character 0xb7 smaller dot tchar tch dot tchar t z 27 tchar tch dot c pw safe app get password character c string str stars str stars tch dot str stars tch dot str stars tch dot m btstars set window text str stars m bstars true on check stars update data false newgui showqualitymeter m cpassquality get dlg item idc static passbits t if m lppreselectpath null int i n spec len tcslen m lppreselectpath c string strcbi bool b found false for i 0 i m cbdisklist get count i m cbdisklist getlb text i strcbi if strcbi get length n spec len continue if tcsnicmp lpctstr strcbi m lppreselectpath n spec len 0 m cbdisklist set cur sel i on sel change combo disk list b found true break if b found false comboboxexitem cbi zero memory cbi sizeof comboboxexitem cbi mask cbeif image cbeif text cbeif indent cbeif selectedimage cbi i item m cbdisklist get count cbi psz text lptstr m lppreselectpath cbi cch text max int tcslen cbi psz text cbi i image cbi i selected image 28 cbi i indent 0 int nx m cbdisklist insert item cbi m cbdisklist set cur sel nx on sel change combo disk list m bkeymethod true update data false enable client windows m peditpw set focus return false return true unless you set the focus to a control cpassworddlg oninitdialog cdialog oninitdialog m_bonce modifystyleex ws_ex_appwindow ws_ex_appwindow m_hwindowicon m_hwindowicon seticon m_hwindowicon seticon m_hwindowicon enumchildwindows m_hwnd newgui_translatewindowcb m_fstyle createfont default_charset out_default_precis clip_default_precis default_quality default_pitch ff_modern _t m_fsymbol createfont default_charset out_default_precis clip_default_precis default_quality default_pitch ff_modern cpwsafeapp getpasswordfont newgui_xpbutton m_btok idb_ok idb_ok newgui_xpbutton m_btcancel idb_cancel idb_cancel newgui_xpbutton m_btmakepw idb_key_small idb_key_small newgui_xpbutton m_btstars m_btstars setfont m_fsymbol m_peditpw setfont m_fsymbol m_btstars setcolor cbuttonst btnst_color_fg_in cstring _t m_btstars settooltiptext newgui_configqualitymeter m_cpassquality m_ilicons idr_infoicons cpwsafeapp createhicolorimagelist m_ilicons idb_infoicons_ex m_cbdisklist setimagelist m_ilicons zeromemory cbeif_image cbeif_text cbeif_indent cbeif_selectedimage iitem psztext cchtextmax _tcslen psztext iimage iselectedimage icoidx_nodrive iindent m_cbdisklist insertitem ustat cstring idximage _t cstring _t ustat getdrivetype ustat drive_no_root_dir idximage ustat drive_removable idximage icoidx_removable ustat drive_fixed idximage icoidx_fixed ustat drive_remote idximage icoidx_remote ustat drive_cdrom idximage icoidx_cdrom ustat drive_ramdisk idximage icoidx_ramdisk zeromemory cbeif_image cbeif_text cbeif_indent cbeif_selectedimage iitem psztext cchtextmax _tcslen psztext iimage iselectedimage idximage iindent m_cbdisklist insertitem m_cbdisklist setcursel m_cbdisklist getextendedstyle cbes_ex_noeditimage m_cbdisklist setextendedstyle newgui_makehyperlink m_hlselfile m_hlselfile enabletooltip m_hlselfile setnotifyparent m_hlselfile newgui_configsidebanner m_banner m_bloadmode m_banner seticon afxgetapp loadicon idi_key kcsb_icon_left kcsb_icon_vcenter m_banner seticon afxgetapp loadicon idi_keyhole kcsb_icon_left kcsb_icon_vcenter getdlgitem idc_static_intro setwindowtext getdlgitem idc_static_enterpw setwindowtext m_bconfirm m_bloadmode getdlgitem idc_static_seldisk setwindowtext m_hlselfile setwindowtext cstring m_strdescriptivename getlength _t m_strdescriptivename m_banner settitle m_bchanging setwindowtext m_banner setcaption setwindowtext m_banner setcaption m_bconfirm m_bloadmode getdlgitem idc_static_seldisk setwindowtext m_hlselfile setwindowtext setwindowtext cstring m_strdescriptivename getlength _t m_strdescriptivename m_banner settitle m_banner setcaption m_btmakepw showwindow sw_hide m_cpassquality showwindow sw_hide getdlgitem idc_static_passbits showwindow sw_hide m_bconfirm m_bloadmode getdlgitem idc_static_intro showwindow sw_hide getdlgitem idc_static_seldisk showwindow sw_hide m_cbdisklist showwindow sw_hide m_btmakepw enablewindow m_hlselfile showwindow sw_hide m_bchanging setwindowtext m_banner setcaption setwindowtext m_banner setcaption m_banner settitle m_cpassquality showwindow sw_hide getdlgitem idc_static_passbits showwindow sw_hide getdlgitem idc_check_keymethod_and showwindow sw_hide getdlgitem idc_static_seldisk setwindowtext setwindowtext cstring m_strdescriptivename getlength _t m_strdescriptivename m_banner settitle m_banner setcaption m_btmakepw showwindow sw_hide m_tipsecclear m_tipsecclear addtool m_peditpw cpwsafedlg _getsecureedittiptext _t m_tipsecclear setmaxtipwidth m_tipsecclear m_peditpw issecuremodeenabled tchdot _t tchdot cpwsafeapp getpasswordcharacter cstring strstars strstars tchdot strstars tchdot strstars tchdot m_btstars setwindowtext strstars m_bstars oncheckstars updatedata newgui_showqualitymeter m_cpassquality getdlgitem idc_static_passbits _t m_lppreselectpath nspeclen _tcslen m_lppreselectpath cstring bfound m_cbdisklist getcount m_cbdisklist getlbtext getlength nspeclen _tcsnicmp m_lppreselectpath nspeclen m_cbdisklist setcursel onselchangecombodisklist bfound bfound zeromemory cbeif_image cbeif_text cbeif_indent cbeif_selectedimage iitem m_cbdisklist getcount psztext m_lppreselectpath cchtextmax _tcslen psztext iimage iselectedimage iindent m_cbdisklist insertitem m_cbdisklist setcursel onselchangecombodisklist m_bkeymethod updatedata enableclientwindows m_peditpw setfocus void c password dlg onok c string str temp ularge integer a bytes 3 lptstr lp password update data true assert m lpkey null m lpkey2 null m lpkey m peditpw get password lp password m lpkey if m bconfirm false validate input if m bkeymethod pwm keymethod or if tcslen m lpkey 0 m cbdisklist get cur sel 0 message box trl either enter a password passphrase or select a key disk drive trl password safe mb ok mb iconinformation free passwords return else m bkeymethod pwm keymethod and if tcslen m lpkey 0 m cbdisklist get cur sel 0 message box trl you ve selected the and key mode so you must enter a password and select a key file trl password safe mb ok mb iconinformation free passwords return if m bkeymethod pwm keymethod or m cbdisklist get cur sel 0 m bkeyfile false else m cbdisklist getlb text m cbdisklist get cur sel str temp if m bloadmode false if str temp get at str temp get length 1 t if get disk free space ex lpctstr str temp a bytes 0 a bytes 1 a bytes 2 false str temp trl cannot access the selected drive str temp t r n r n str temp trl make sure a writable medium is inserted message box str temp trl stop mb ok mb iconwarning free passwords return if a bytes 2 quad part 128 message box trl not enough free disk space trl stop mb ok mb iconwarning free passwords return file fp test c string str temp2 str temp str temp2 t t2ub8rf6 tmp just a random filename will work for directories and files fp test tfopen lpctstr str temp2 t wb if fp test null str temp trl cannot access the selected drive str temp t r n r n str temp trl make sure a writable medium is inserted message box str temp trl stop mb ok mb iconwarning free passwords return fclose fp test sleep 100 delete file str temp2 m bkeyfile true if m bkeymethod pwm keymethod or m peditpw delete password m lpkey else m lpkey2 m lpkey m lpkey new tchar str temp get length 1 assert m lpkey null if m lpkey null free passwords return tcscpy m lpkey lpctstr str temp clean up assert m bonce false m bonce true c dialog onok cpassworddlg cstring strtemp ularge_integer abytes lppassword updatedata m_lpkey m_lpkey2 m_lpkey m_peditpw getpassword lppassword m_lpkey m_bconfirm m_bkeymethod pwm_keymethod_or _tcslen m_lpkey m_cbdisklist getcursel messagebox mb_ok mb_iconinformation freepasswords m_bkeymethod pwm_keymethod_and _tcslen m_lpkey m_cbdisklist getcursel messagebox mb_ok mb_iconinformation freepasswords m_bkeymethod pwm_keymethod_or m_cbdisklist getcursel m_bkeyfile m_cbdisklist getlbtext m_cbdisklist getcursel strtemp m_bloadmode strtemp getat strtemp getlength _t getdiskfreespaceex strtemp abytes abytes abytes strtemp strtemp _t strtemp messagebox strtemp mb_ok mb_iconwarning freepasswords abytes quadpart messagebox mb_ok mb_iconwarning freepasswords fptest cstring strtemp2 strtemp strtemp2 _t fptest _tfopen strtemp2 _t fptest strtemp strtemp _t strtemp messagebox strtemp mb_ok mb_iconwarning freepasswords fptest deletefile strtemp2 m_bkeyfile m_bkeymethod pwm_keymethod_or m_peditpw deletepassword m_lpkey m_lpkey2 m_lpkey m_lpkey strtemp getlength m_lpkey m_lpkey freepasswords _tcscpy m_lpkey strtemp cleanup m_bonce m_bonce cdialog void c password dlg on cancel clean up assert m bonce false m bonce true c dialog on cancel cpassworddlg oncancel cleanup m_bonce m_bonce cdialog oncancel void c password dlg on check stars update data true if m bstars false m peditpw enable secure mode false m peditpw set password char 0 m peditpw set font m fstyle true else tchar tch dot tchar t z 27 tchar tch dot c pw safe app get password character m peditpw enable secure mode c pw safe dlg m bsecureedits m peditpw set password char tch dot m peditpw set font m fsymbol true m tipsecclear activate m peditpw is secure mode enabled update data false m peditpw redraw window m peditpw set focus cpassworddlg oncheckstars updatedata m_bstars m_peditpw enablesecuremode m_peditpw setpasswordchar m_peditpw setfont m_fstyle tchdot _t tchdot cpwsafeapp getpasswordcharacter m_peditpw enablesecuremode cpwsafedlg m_bsecureedits m_peditpw setpasswordchar tchdot m_peditpw setfont m_fsymbol m_tipsecclear m_peditpw issecuremodeenabled updatedata m_peditpw redrawwindow m_peditpw setfocus void c password dlg on make password btn c pw generator dlg dlg update data true dlg m bcanaccept true dlg m bhidepw m bstars if dlg do modal idok if dlg m lppassword null m peditpw set password dlg m lppassword newgui showqualitymeter m cpassquality get dlg item idc static passbits dlg m lppassword m peditpw delete password dlg m lppassword dlg m lppassword null update data false on check stars enable client windows cpassworddlg onmakepasswordbtn cpwgeneratordlg updatedata m_bcanaccept m_bhidepw m_bstars domodal m_lppassword m_peditpw setpassword m_lppassword newgui_showqualitymeter m_cpassquality getdlgitem idc_static_passbits m_lppassword m_peditpw deletepassword m_lppassword m_lppassword updatedata oncheckstars enableclientwindows void c password dlg on change edit password update data true lptstr lp m peditpw get password newgui showqualitymeter m cpassquality get dlg item idc static passbits lp m peditpw delete password lp lp null enable client windows cpassworddlg onchangeeditpassword updatedata m_peditpw getpassword newgui_showqualitymeter m_cpassquality getdlgitem idc_static_passbits m_peditpw deletepassword enableclientwindows void c password dlg on sel change combo disk list enable client windows cpassworddlg onselchangecombodisklist enableclientwindows void c password dlg on check keymethod and enable client windows cpassworddlg oncheckkeymethodand enableclientwindows lresult c password dlg onx hyper link clicked wparam w param lparam l param unreferenced parameter l param if w param idc hl selectfile c string str file dword dw flags c string str filter update data true str filter trl all files str filter t dw flags ofn longnames ofn extensiondifferent ofn explorer 0x00080000 ofn enablesizing 0x00800000 dw flags 0x00080000 0x00800000 if m bloadmode true dw flags ofn pathmustexist ofn filemustexist ofn hidereadonly else dw flags ofn hidereadonly c file dialog dlg m bloadmode null null dw flags str filter this if dlg do modal idok str file dlg get path name comboboxexitem cbi zero memory cbi sizeof comboboxexitem cbi mask cbeif image cbeif text cbeif indent cbeif selectedimage cbi i item m cbdisklist get count cbi psz text lptstr lpctstr str file cbi cch text max int tcslen cbi psz text cbi i image cbi i selected image 28 cbi i indent 0 int nx m cbdisklist insert item cbi m cbdisklist select string 1 lpctstr str file m cbdisklist set cur sel nx update data false return 0 cpassworddlg onxhyperlinkclicked wparam lparam unreferenced_parameter lparam wparam idc_hl_selectfile cstring strfile dwflags cstring strfilter updatedata strfilter strfilter _t dwflags ofn_longnames ofn_extensiondifferent ofn_explorer ofn_enablesizing dwflags m_bloadmode dwflags ofn_pathmustexist ofn_filemustexist ofn_hidereadonly dwflags ofn_hidereadonly cfiledialog m_bloadmode dwflags strfilter domodal strfile getpathname zeromemory cbeif_image cbeif_text cbeif_indent cbeif_selectedimage iitem m_cbdisklist getcount psztext strfile cchtextmax _tcslen psztext iimage iselectedimage iindent m_cbdisklist insertitem m_cbdisklist selectstring strfile m_cbdisklist setcursel updatedata c dialog c add group dlg idd p parent afx data init c add group dlg m strgroupname t afx data init m niconid 0 m pparentimagelist null m beditmode false cdialog caddgroupdlg pparent afx_data_init caddgroupdlg m_strgroupname _t afx_data_init m_niconid m_pparentimagelist m_beditmode void c add group dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c add group dlg ddx control pdx idok m btok ddx control pdx idcancel m btcancel ddx control pdx idc seticon btn m btseticon ddx text pdx idc edit groupname m strgroupname afx data map caddgroupdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map caddgroupdlg ddx_control m_btok ddx_control m_btcancel ddx_control idc_seticon_btn m_btseticon ddx_text idc_edit_groupname m_strgroupname afx_data_map bool c add group dlg on init dialog c dialog on init dialog assert m pparentimagelist null enum child windows this m hwnd newgui translatewindowcb 0 newgui xpbutton m btseticon 1 1 newgui xpbutton m btok idb ok idb ok newgui xpbutton m btcancel idb cancel idb cancel c string strtt trl pick one strtt remove t m btseticon set tooltip text strtt true if m niconid 0 m pparentimagelist null m btseticon set icon m pparentimagelist extract icon m niconid newgui configsidebanner m banner this m banner set icon afx get app load icon idi key kcsb icon left kcsb icon vcenter if m beditmode false m banner set title trl add group m banner set caption trl add a new password group set window text trl add group else m banner set title trl edit group m banner set caption trl modify a password group set window text trl edit group update data false get dlg item idc edit groupname set focus return false return true unless you set the focus to a control caddgroupdlg oninitdialog cdialog oninitdialog m_pparentimagelist enumchildwindows m_hwnd newgui_translatewindowcb newgui_xpbutton m_btseticon newgui_xpbutton m_btok idb_ok idb_ok newgui_xpbutton m_btcancel idb_cancel idb_cancel cstring _t m_btseticon settooltiptext m_niconid m_pparentimagelist m_btseticon seticon m_pparentimagelist extracticon m_niconid newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_key kcsb_icon_left kcsb_icon_vcenter m_beditmode m_banner settitle m_banner setcaption setwindowtext m_banner settitle m_banner setcaption setwindowtext updatedata getdlgitem idc_edit_groupname setfocus void c add group dlg onok c string str ref pws searchgroup str test pws searchgroup is translated str ref make lower update data true if m strgroupname get length 0 message box trl enter a group name trl stop mb iconinformation return str test m strgroupname str test make lower if str test str ref message box trl the group you selected cannot store entries please select an other group trl stop mb iconwarning mb ok return c dialog onok caddgroupdlg cstring strref pws_searchgroup strtest pws_searchgroup strref makelower updatedata m_strgroupname getlength messagebox mb_iconinformation strtest m_strgroupname strtest makelower strtest strref messagebox mb_iconwarning mb_ok cdialog void c add group dlg on cancel c dialog on cancel caddgroupdlg oncancel cdialog oncancel void c add group dlg on set icon btn c icon picker dlg dlg dlg m pimagelist m pparentimagelist dlg m unumicons m pparentimagelist get image count dlg m nselectedicon m niconid if dlg do modal idok m niconid dlg m nselectedicon if m niconid 0 m pparentimagelist null m btseticon set icon m pparentimagelist extract icon m niconid caddgroupdlg onseticonbtn ciconpickerdlg m_pimagelist m_pparentimagelist m_unumicons m_pparentimagelist getimagecount m_nselectedicon m_niconid domodal m_niconid m_nselectedicon m_niconid m_pparentimagelist m_btseticon seticon m_pparentimagelist extracticon m_niconid c dialog c languages dlg idd p parent afx data init c languages dlg afx data init cdialog clanguagesdlg pparent afx_data_init clanguagesdlg afx_data_init void c languages dlg loadlanguage lpctstr sz lang file fp null tchar sz file max path 2 int i 0 c private config c config true get module file name null sz file max path 2 for i tcslen sz file 1 i 1 i extract dir if sz file i t sz file i 0 break tcscat sz file t tcscat sz file sz lang if tcscmp sz lang t english 0 tcscat sz file t lng fp tfopen sz file t rb assert fp null if fp null message box trl language file cannot be opened trl loading error mb ok mb iconwarning return fclose fp if c config set pwmkey lang sz lang false message box trl language file cannot be registered trl loading error mb ok mb iconwarning return else c config set pwmkey lang t standard c string str str trl the language file has been installed str t r n r n str trl you must restart kee pass in order to use the new language str t r n r n str trl do you wish to restart kee pass now i message box str trl restart kee pass mb yesno mb iconquestion if i idyes c dialog onok clanguagesdlg _loadlanguage szlang szfile max_path cprivateconfig cconfig getmodulefilename szfile max_path _tcslen szfile szfile _t szfile _tcscat szfile _t _tcscat szfile szlang _tcscmp szlang _t _tcscat szfile _t _tfopen szfile _t messagebox mb_ok mb_iconwarning cconfig pwmkey_lang szlang messagebox mb_ok mb_iconwarning cconfig pwmkey_lang _t cstring _t keepass _t keepass messagebox keepass mb_yesno mb_iconquestion cdialog void c languages dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c languages dlg ddx control pdx idc btn getlanguage m btgetlang ddx control pdx idc languages list m listlang ddx control pdx idcancel m btclose afx data map clanguagesdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map clanguagesdlg ddx_control idc_btn_getlanguage m_btgetlang ddx_control idc_languages_list m_listlang ddx_control m_btclose afx_data_map bool c languages dlg on init dialog c dialog on init dialog newgui translatecwnd this enum child windows this m hwnd newgui translatewindowcb 0 newgui xpbutton m btclose idb cancel idb cancel newgui xpbutton m btgetlang idb language idb language newgui configsidebanner m banner this m banner set icon afx get app load icon idi world kcsb icon left kcsb icon vcenter m banner set title trl load a language file m banner set caption trl select one of the languages in the list below rect rc list m listlang get window rect rc list int n col size rc list right rc list left get system metrics sm cxvscroll 8 n col size 4 m listlang insert column 0 trl available languages lvcfmt left n col size 0 m listlang insert column 1 trl language file version lvcfmt left n col size 1 m listlang insert column 2 trl author lvcfmt left n col size 2 m listlang insert column 3 trl translation author contact lvcfmt left n col size 3 m ilicons create c pw safe app get client icons resourceid 16 1 rgb 255 0 255 c pw safe app create hi color image list m ilicons idb clienticons ex 16 m listlang set image list m ilicons lvsil small m listlang post message lvm setextendedlistviewstyle 0 lvs ex si report lvs ex fullrowselect lvs ex gridlines lvs ex oneclickactivate lvs ex underlinehot lv item lvi m listlang delete all items lvi i item m listlang insert item lvif text lvif image m listlang get item count t english 0 0 1 null c string str temp str temp pwm version str lvi i sub item 1 lvi mask lvif text lvi psz text lptstr lpctstr str temp m listlang set item lvi str temp pwmx english author lvi i sub item 2 lvi mask lvif text lvi psz text lptstr lpctstr str temp m listlang set item lvi str temp pwmx english contact lvi i sub item 3 lvi mask lvif text lvi psz text lptstr lpctstr str temp m listlang set item lvi c file find ff tchar sz this 1024 unsigned long i 0 c string cs tmp bool chk w false tchar sz currently loaded max path 2 tcscpy sz currently loaded get current translation table get module file name null sz this 1024 for i tcslen sz this 1 i 1 i extract dir if sz this i t sz this i 0 break tcscat sz this t lng chk w ff find file sz this 0 while chk w true chk w ff find next file cs tmp ff get file title cs tmp make lower if cs tmp t standard cs tmp t english load translation table lpctstr ff get file title str temp lpctstr ff get file title str temp t str temp trl languagename lvi i item m listlang insert item lvif text lvif image m listlang get item count str temp 0 0 1 null str temp trl languageversion if str temp t languageversion str temp empty lvi i sub item 1 lvi mask lvif text lvi psz text lptstr lpctstr str temp m listlang set item lvi str temp trl languageauthor if str temp t languageauthor str temp empty lvi i sub item 2 lvi mask lvif text lvi psz text lptstr lpctstr str temp m listlang set item lvi str temp trl languageauthoremail if str temp t languageauthoremail str temp empty lvi i sub item 3 lvi mask lvif text lvi psz text lptstr lpctstr str temp m listlang set item lvi ff close verify load translation table sz currently loaded return true clanguagesdlg oninitdialog cdialog oninitdialog newgui_translatecwnd enumchildwindows m_hwnd newgui_translatewindowcb newgui_xpbutton m_btclose idb_cancel idb_cancel newgui_xpbutton m_btgetlang idb_language idb_language newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_world kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_banner setcaption rclist m_listlang getwindowrect rclist ncolsize rclist rclist getsystemmetrics sm_cxvscroll ncolsize m_listlang insertcolumn lvcfmt_left ncolsize m_listlang insertcolumn lvcfmt_left ncolsize m_listlang insertcolumn lvcfmt_left ncolsize m_listlang insertcolumn lvcfmt_left ncolsize m_ilicons cpwsafeapp getclienticonsresourceid cpwsafeapp createhicolorimagelist m_ilicons idb_clienticons_ex m_listlang setimagelist m_ilicons lvsil_small m_listlang postmessage lvm_setextendedlistviewstyle lvs_ex_si_report lvs_ex_fullrowselect lvs_ex_gridlines lvs_ex_oneclickactivate lvs_ex_underlinehot lv_item m_listlang deleteallitems iitem m_listlang insertitem lvif_text lvif_image m_listlang getitemcount _t cstring strtemp strtemp pwm_version_str isubitem lvif_text psztext strtemp m_listlang setitem strtemp pwmx_english_author isubitem lvif_text psztext strtemp m_listlang setitem strtemp pwmx_english_contact isubitem lvif_text psztext strtemp m_listlang setitem cfilefind szthis cstring cstmp chk_w szcurrentlyloaded max_path _tcscpy szcurrentlyloaded getcurrenttranslationtable getmodulefilename szthis _tcslen szthis szthis _t szthis _tcscat szthis _t chk_w findfile szthis chk_w chk_w findnextfile cstmp getfiletitle cstmp makelower cstmp _t cstmp _t loadtranslationtable getfiletitle strtemp getfiletitle strtemp _t strtemp iitem m_listlang insertitem lvif_text lvif_image m_listlang getitemcount strtemp strtemp strtemp _t strtemp isubitem lvif_text psztext strtemp m_listlang setitem strtemp strtemp _t strtemp isubitem lvif_text psztext strtemp m_listlang setitem strtemp strtemp _t strtemp isubitem lvif_text psztext strtemp m_listlang setitem loadtranslationtable szcurrentlyloaded void c languages dlg onok c dialog onok clanguagesdlg cdialog void c languages dlg on cancel c dialog on cancel clanguagesdlg oncancel cdialog oncancel void c languages dlg on click languages list nmhdr pnmhdr lresult p result c point mouse point uint n flags 0 int n hit item 0 tchar tsz item max path unreferenced parameter pnmhdr get cursor pos mouse point m listlang screen to client mouse point n hit item m listlang hit test mouse point n flags m listlang get item text n hit item 0 tsz item 254 if n flags lvht onitem loadlanguage tsz item p result 0 clanguagesdlg onclicklanguageslist presult cpoint mousepoint nflags nhititem tszitem max_path unreferenced_parameter getcursorpos mousepoint m_listlang screentoclient mousepoint nhititem m_listlang hittest mousepoint nflags m_listlang getitemtext nhititem tszitem nflags lvht_onitem _loadlanguage tszitem presult void c languages dlg on btn get language shell execute get safe hwnd t open pwm url trl null null sw show on cancel clanguagesdlg onbtngetlanguage shellexecute getsafehwnd _t pwm_url_trl sw_show oncancel c dialog c options dlg idd p parent afx data init c options dlg m nnewlinesequence 1 m uclipboardseconds 0 m bimgbuttons false m bentrygrid false m blockonminimize false m bminimizetotray false m blockaftertime false m nlockafter 0 m bcolautosize false m bcloseminimizes false m bdisableunsafe false m buseputtyforurls false m bsaveonlatmod false m nclipboardmethod 1 m bsecureedits false m bdefaultexpire false m dwdefaultexpire 0 afx data init m pparentdlg null cdialog coptionsdlg pparent afx_data_init coptionsdlg m_nnewlinesequence m_uclipboardseconds m_bimgbuttons m_bentrygrid m_blockonminimize m_bminimizetotray m_blockaftertime m_nlockafter m_bcolautosize m_bcloseminimizes m_bdisableunsafe m_buseputtyforurls m_bsaveonlatmod m_nclipboardmethod m_bsecureedits m_bdefaultexpire m_dwdefaultexpire afx_data_init m_pparentdlg void c options dlg notify assoc changed lpshchangenotify lpsh change notify hinstance h shell32 h shell32 load library t shell32 dll if h shell32 null lpsh change notify lpshchangenotify get proc address h shell32 sh change notify if lpsh change notify null lpsh change notify shcne assocchanged shcnf idlist null null else assert false free library h shell32 else assert false coptionsdlg notifyassocchanged lpshchangenotify hshell32 hshell32 loadlibrary _t hshell32 lpshchangenotify getprocaddress hshell32 shchangenotify lpshchangenotify lpshchangenotify shcne_assocchanged shcnf_idlist freelibrary hshell32 void c options dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c options dlg ddx control pdx idc list advanced m oladvanced ddx control pdx idc hotkey autotype m hkautotype ddx control pdx idc btn deleteassoc m btndeleteassoc ddx control pdx idc btn createassoc m btncreateassoc ddx control pdx idc btn rowhighlightsel m btncolorrowhighlight ddx control pdx idc tab menu m tabmenu ddx control pdx idc btn selfont m btselfont ddx control pdx idcancel m btcancel ddx control pdx idok m btok ddx radio pdx idc radio newline 0 m nnewlinesequence ddx text pdx idc edit clipboardtime m uclipboardseconds ddx check pdx idc check imgbuttons m bimgbuttons ddx check pdx idc check entrygrid m bentrygrid ddx check pdx idc check lockmin m blockonminimize ddx check pdx idc check mintray m bminimizetotray ddx check pdx idc check lockaftertime m blockaftertime ddx text pdx idc edit lockseconds m nlockafter ddx check pdx idc check colautosize m bcolautosize ddx check pdx idc check closemin m bcloseminimizes ddx check pdx idc check disableunsafe m bdisableunsafe ddx check pdx idc check puttyurls m buseputtyforurls ddx check pdx idc check saveonlatmod m bsaveonlatmod ddx radio pdx idc radio clipmethod timed m nclipboardmethod ddx check pdx idc check secureedits m bsecureedits ddx check pdx idc check defaultexpire m bdefaultexpire ddx text pdx idc edit defaultexpire m dwdefaultexpire afx data map coptionsdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map coptionsdlg ddx_control idc_list_advanced m_oladvanced ddx_control idc_hotkey_autotype m_hkautotype ddx_control idc_btn_deleteassoc m_btndeleteassoc ddx_control idc_btn_createassoc m_btncreateassoc ddx_control idc_btn_rowhighlightsel m_btncolorrowhighlight ddx_control idc_tab_menu m_tabmenu ddx_control idc_btn_selfont m_btselfont ddx_control m_btcancel ddx_control m_btok ddx_radio idc_radio_newline_0 m_nnewlinesequence ddx_text idc_edit_clipboardtime m_uclipboardseconds ddx_check idc_check_imgbuttons m_bimgbuttons ddx_check idc_check_entrygrid m_bentrygrid ddx_check idc_check_lockmin m_blockonminimize ddx_check idc_check_mintray m_bminimizetotray ddx_check idc_check_lockaftertime m_blockaftertime ddx_text idc_edit_lockseconds m_nlockafter ddx_check idc_check_colautosize m_bcolautosize ddx_check idc_check_closemin m_bcloseminimizes ddx_check idc_check_disableunsafe m_bdisableunsafe ddx_check idc_check_puttyurls m_buseputtyforurls ddx_check idc_check_saveonlatmod m_bsaveonlatmod ddx_radio idc_radio_clipmethod_timed m_nclipboardmethod ddx_check idc_check_secureedits m_bsecureedits ddx_check idc_check_defaultexpire m_bdefaultexpire ddx_text idc_edit_defaultexpire m_dwdefaultexpire afx_data_map bool c options dlg on init dialog c dialog on init dialog assert m pparentdlg null newgui translatecwnd this enum child windows this m hwnd newgui translatewindowcb 0 newgui xpbutton m btok idb ok idb ok newgui xpbutton m btcancel idb cancel idb cancel newgui xpbutton m btselfont idb document small idb document small newgui xpbutton m btncreateassoc idb file idb file newgui xpbutton m btndeleteassoc idb cancel idb cancel newgui configsidebanner m banner this m banner set icon afx get app load icon idi options kcsb icon left kcsb icon vcenter m banner set title trl settings m banner set caption trl here you can configure kee pass m wndgrp add window get dlg item idc static newlinetext optgrp files true m wndgrp add window get dlg item idc radio newline 0 optgrp files true m wndgrp add window get dlg item idc radio newline 1 optgrp files true m wndgrp add window null optgrp files true m wndgrp add window get dlg item idc check saveonlatmod optgrp files true m wndgrp add window get dlg item idc static clipboardmethod optgrp memory true m wndgrp add window get dlg item idc radio clipmethod timed optgrp memory true m wndgrp add window get dlg item idc radio clipmethod secure optgrp memory true m wndgrp add window null optgrp memory true m wndgrp add window get dlg item idc static clipcleartxt optgrp memory true m wndgrp add window get dlg item idc edit clipboardtime optgrp memory true m wndgrp add window get dlg item idc check imgbuttons optgrp gui true m wndgrp add window get dlg item idc check entrygrid optgrp gui true m wndgrp add window get dlg item idc check colautosize optgrp gui true m wndgrp add window null optgrp gui true m wndgrp add window get dlg item idc check mintray optgrp gui true m wndgrp add window get dlg item idc check closemin optgrp gui true m wndgrp add window null optgrp gui true m wndgrp add window get dlg item idc static selfonttxt optgrp gui true m wndgrp add window get dlg item idc btn selfont optgrp gui true m wndgrp add window null optgrp gui true m wndgrp add window get dlg item idc static selrowhighlight optgrp gui true m wndgrp add window get dlg item idc btn rowhighlightsel optgrp gui true m wndgrp add window get dlg item idc check lockmin optgrp security true m wndgrp add window null optgrp security true m wndgrp add window get dlg item idc check lockaftertime optgrp security true m wndgrp add window get dlg item idc edit lockseconds optgrp security true m wndgrp add window null optgrp security true m wndgrp add window null optgrp security true m wndgrp add window get dlg item idc check disableunsafe optgrp security true m wndgrp add window get dlg item idc check secureedits optgrp security true m wndgrp add window null optgrp security true m wndgrp add window get dlg item idc check defaultexpire optgrp security true m wndgrp add window get dlg item idc edit defaultexpire optgrp security true m wndgrp add window get dlg item idc static assoc optgrp setup true m wndgrp add window null optgrp setup true m wndgrp add window get dlg item idc btn createassoc optgrp setup true m wndgrp add window null optgrp setup true m wndgrp add window get dlg item idc btn deleteassoc optgrp setup true m wndgrp add window null optgrp setup true m wndgrp add window null optgrp setup true m wndgrp add window get dlg item idc check puttyurls optgrp setup true m wndgrp add window null optgrp setup true m wndgrp add window null optgrp setup true m wndgrp add window get dlg item idc static autotypehk optgrp setup true m wndgrp add window get dlg item idc hotkey autotype optgrp setup true m wndgrp add window get dlg item idc list advanced optgrp advanced false m wndgrp hide all except optgrp security m wndgrp arrange windows this m ilicons create c pw safe app get client icons resourceid 16 1 rgb 255 0 255 c pw safe app create hi color image list m ilicons idb clienticons ex 16 m tabmenu set image list m ilicons m iloptionicons create idr optionicons 16 1 rgb 255 0 255 c pw safe app create hi color image list m iloptionicons idb optionicons ex 16 m oladvanced init option list ex m iloptionicons m oladvanced add group text trl integration 9 m oladvanced add check item trl start kee pass at windows startup for current user m bstartwithwindows null ol link null m oladvanced add check item trl single left click instead of double click for default tray icon action m bsingleclicktrayicon null ol link null m oladvanced add check item trl use alternative auto type method minimize window m bminimizebeforeat null ol link null m oladvanced add check item trl disable all auto type features m bdisableautotype null ol link null m oladvanced add check item trl copy ur ls to clipboard instead of launching them exception cmd ur ls m bcopyurls null ol link null m oladvanced add group text t 0 m oladvanced add group text trl start and exit 7 m oladvanced add check item trl remember last opened file m brememberlast m bopenlastdb ol link same trigger false m oladvanced add check item trl automatically open last used database on startup m bopenlastdb m brememberlast ol link same trigger true m oladvanced add check item trl start minimized and locked m bstartminimized null ol link null m oladvanced add check item trl automatically save database on exit and workspace locking m bautosave null ol link null m oladvanced add check item trl limit to single instance m bsingleinstance null ol link null m oladvanced add group text t 0 m oladvanced add group text trl immediately after opening a database 8 m oladvanced add check item trl show expired entries if any m bautoshowexpired null ol link null m oladvanced add check item trl show entries that will expire soon if any m bautoshowexpiredsoon null ol link null m oladvanced add group text t 0 m oladvanced add group text trl backup 10 m oladvanced add check item trl save backups of modified entries into the backup group m bbackupentries null ol link null m oladvanced add check item trl delete all backup entries before saving the database m bdeletebackupsonsave null ol link null m oladvanced add group text t 0 m oladvanced add group text trl advanced 11 m oladvanced add check item trl automatically generate random passwords for new entries m bautopwgen null ol link null m oladvanced add check item trl include backup entries in quick searches toolbar m bquickfindincbackup null ol link null m oladvanced add check item trl show full path in the titlebar instead of filename only m bshowfullpath null ol link null m oladvanced add check item trl exit program instead of locking the workspace after the specified time m bexitinsteadoflockat null ol link null tcitem tci zero memory tci sizeof tcitem tci mask tcif text tcif image tci cch text max tcslen trl optsz security tci psz text lptstr trl optsz security tci i image 29 m tabmenu insert item m tabmenu get item count tci tci cch text max tcslen trl optsz gui tci psz text lptstr trl optsz gui tci i image 6 m tabmenu insert item m tabmenu get item count tci tci cch text max tcslen trl optsz files tci psz text lptstr trl optsz files tci i image 26 m tabmenu insert item m tabmenu get item count tci tci cch text max tcslen trl optsz memory tci psz text lptstr trl optsz memory tci i image 42 m tabmenu insert item m tabmenu get item count tci tci cch text max tcslen trl optsz setup tci psz text lptstr trl optsz setup tci i image 30 m tabmenu insert item m tabmenu get item count tci tci cch text max tcslen trl optsz advanced tci psz text lptstr trl optsz advanced tci i image 21 m tabmenu insert item m tabmenu get item count tci m tabmenu set cur sel 0 m hkautotype set rules hkcomb none hkcomb s hotkeyf control hotkeyf alt m hkautotype set hot key word m dwathotkey 0x0000ffff word m dwathotkey 16 m btncolorrowhighlight set default color rgb 238 238 255 m btncolorrowhighlight set color m rgbrowhighlight m btncolorrowhighlight set custom text trl more colors m btncolorrowhighlight set default text trl default if m dwdefaultexpire 0 m bdefaultexpire false get dlg item idc edit defaultexpire enable window false else m bdefaultexpire true update data false on check lock after time return true coptionsdlg oninitdialog cdialog oninitdialog m_pparentdlg newgui_translatecwnd enumchildwindows m_hwnd newgui_translatewindowcb newgui_xpbutton m_btok idb_ok idb_ok newgui_xpbutton m_btcancel idb_cancel idb_cancel newgui_xpbutton m_btselfont idb_document_small idb_document_small newgui_xpbutton m_btncreateassoc idb_file idb_file newgui_xpbutton m_btndeleteassoc idb_cancel idb_cancel newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_options kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_banner setcaption keepass m_wndgrp addwindow getdlgitem idc_static_newlinetext optgrp_files m_wndgrp addwindow getdlgitem idc_radio_newline_0 optgrp_files m_wndgrp addwindow getdlgitem idc_radio_newline_1 optgrp_files m_wndgrp addwindow optgrp_files m_wndgrp addwindow getdlgitem idc_check_saveonlatmod optgrp_files m_wndgrp addwindow getdlgitem idc_static_clipboardmethod optgrp_memory m_wndgrp addwindow getdlgitem idc_radio_clipmethod_timed optgrp_memory m_wndgrp addwindow getdlgitem idc_radio_clipmethod_secure optgrp_memory m_wndgrp addwindow optgrp_memory m_wndgrp addwindow getdlgitem idc_static_clipcleartxt optgrp_memory m_wndgrp addwindow getdlgitem idc_edit_clipboardtime optgrp_memory m_wndgrp addwindow getdlgitem idc_check_imgbuttons optgrp_gui m_wndgrp addwindow getdlgitem idc_check_entrygrid optgrp_gui m_wndgrp addwindow getdlgitem idc_check_colautosize optgrp_gui m_wndgrp addwindow optgrp_gui m_wndgrp addwindow getdlgitem idc_check_mintray optgrp_gui m_wndgrp addwindow getdlgitem idc_check_closemin optgrp_gui m_wndgrp addwindow optgrp_gui m_wndgrp addwindow getdlgitem idc_static_selfonttxt optgrp_gui m_wndgrp addwindow getdlgitem idc_btn_selfont optgrp_gui m_wndgrp addwindow optgrp_gui m_wndgrp addwindow getdlgitem idc_static_selrowhighlight optgrp_gui m_wndgrp addwindow getdlgitem idc_btn_rowhighlightsel optgrp_gui m_wndgrp addwindow getdlgitem idc_check_lockmin optgrp_security m_wndgrp addwindow optgrp_security m_wndgrp addwindow getdlgitem idc_check_lockaftertime optgrp_security m_wndgrp addwindow getdlgitem idc_edit_lockseconds optgrp_security m_wndgrp addwindow optgrp_security m_wndgrp addwindow optgrp_security m_wndgrp addwindow getdlgitem idc_check_disableunsafe optgrp_security m_wndgrp addwindow getdlgitem idc_check_secureedits optgrp_security m_wndgrp addwindow optgrp_security m_wndgrp addwindow getdlgitem idc_check_defaultexpire optgrp_security m_wndgrp addwindow getdlgitem idc_edit_defaultexpire optgrp_security m_wndgrp addwindow getdlgitem idc_static_assoc optgrp_setup m_wndgrp addwindow optgrp_setup m_wndgrp addwindow getdlgitem idc_btn_createassoc optgrp_setup m_wndgrp addwindow optgrp_setup m_wndgrp addwindow getdlgitem idc_btn_deleteassoc optgrp_setup m_wndgrp addwindow optgrp_setup m_wndgrp addwindow optgrp_setup m_wndgrp addwindow getdlgitem idc_check_puttyurls optgrp_setup m_wndgrp addwindow optgrp_setup m_wndgrp addwindow optgrp_setup m_wndgrp addwindow getdlgitem idc_static_autotypehk optgrp_setup m_wndgrp addwindow getdlgitem idc_hotkey_autotype optgrp_setup m_wndgrp addwindow getdlgitem idc_list_advanced optgrp_advanced m_wndgrp hideallexcept optgrp_security m_wndgrp arrangewindows m_ilicons cpwsafeapp getclienticonsresourceid cpwsafeapp createhicolorimagelist m_ilicons idb_clienticons_ex m_tabmenu setimagelist m_ilicons m_iloptionicons idr_optionicons cpwsafeapp createhicolorimagelist m_iloptionicons idb_optionicons_ex m_oladvanced initoptionlistex m_iloptionicons m_oladvanced addgrouptext m_oladvanced addcheckitem keepass m_bstartwithwindows ol_link_null m_oladvanced addcheckitem m_bsingleclicktrayicon ol_link_null m_oladvanced addcheckitem m_bminimizebeforeat ol_link_null m_oladvanced addcheckitem m_bdisableautotype ol_link_null m_oladvanced addcheckitem urls urls m_bcopyurls ol_link_null m_oladvanced addgrouptext _t m_oladvanced addgrouptext m_oladvanced addcheckitem m_brememberlast m_bopenlastdb ol_link_same_trigger_false m_oladvanced addcheckitem m_bopenlastdb m_brememberlast ol_link_same_trigger_true m_oladvanced addcheckitem m_bstartminimized ol_link_null m_oladvanced addcheckitem m_bautosave ol_link_null m_oladvanced addcheckitem m_bsingleinstance ol_link_null m_oladvanced addgrouptext _t m_oladvanced addgrouptext m_oladvanced addcheckitem m_bautoshowexpired ol_link_null m_oladvanced addcheckitem m_bautoshowexpiredsoon ol_link_null m_oladvanced addgrouptext _t m_oladvanced addgrouptext m_oladvanced addcheckitem m_bbackupentries ol_link_null m_oladvanced addcheckitem m_bdeletebackupsonsave ol_link_null m_oladvanced addgrouptext _t m_oladvanced addgrouptext m_oladvanced addcheckitem m_bautopwgen ol_link_null m_oladvanced addcheckitem m_bquickfindincbackup ol_link_null m_oladvanced addcheckitem m_bshowfullpath ol_link_null m_oladvanced addcheckitem m_bexitinsteadoflockat ol_link_null zeromemory tcif_text tcif_image cchtextmax _tcslen optsz_security psztext optsz_security iimage m_tabmenu insertitem m_tabmenu getitemcount cchtextmax _tcslen optsz_gui psztext optsz_gui iimage m_tabmenu insertitem m_tabmenu getitemcount cchtextmax _tcslen optsz_files psztext optsz_files iimage m_tabmenu insertitem m_tabmenu getitemcount cchtextmax _tcslen optsz_memory psztext optsz_memory iimage m_tabmenu insertitem m_tabmenu getitemcount cchtextmax _tcslen optsz_setup psztext optsz_setup iimage m_tabmenu insertitem m_tabmenu getitemcount cchtextmax _tcslen optsz_advanced psztext optsz_advanced iimage m_tabmenu insertitem m_tabmenu getitemcount m_tabmenu setcursel m_hkautotype setrules hkcomb_none hkcomb_s hotkeyf_control hotkeyf_alt m_hkautotype sethotkey m_dwathotkey m_dwathotkey m_btncolorrowhighlight setdefaultcolor m_btncolorrowhighlight setcolor m_rgbrowhighlight m_btncolorrowhighlight setcustomtext m_btncolorrowhighlight setdefaulttext m_dwdefaultexpire m_bdefaultexpire getdlgitem idc_edit_defaultexpire enablewindow m_bdefaultexpire updatedata onchecklockaftertime void c options dlg onok update data true word wvk 0 w mod 0 m hkautotype get hot key wvk w mod dword dw new hot key dword w mod 16 dword wvk if dw new hot key m dwathotkey if m pparentdlg register global hot key hotkeyid autotype dw new hot key m dwathotkey 0 true false true false return m dwathotkey dw new hot key m rgbrowhighlight m btncolorrowhighlight get color if m blockaftertime true m nlockafter 5 m nlockafter 5 if m bdefaultexpire false m dwdefaultexpire 0 m ilicons delete image list m iloptionicons delete image list c dialog onok coptionsdlg updatedata wmod m_hkautotype gethotkey wmod dwnewhotkey wmod dwnewhotkey m_dwathotkey m_pparentdlg registerglobalhotkey hotkeyid_autotype dwnewhotkey m_dwathotkey m_dwathotkey dwnewhotkey m_rgbrowhighlight m_btncolorrowhighlight getcolor m_blockaftertime m_nlockafter m_nlockafter m_bdefaultexpire m_dwdefaultexpire m_ilicons deleteimagelist m_iloptionicons deleteimagelist cdialog void c options dlg on cancel m ilicons delete image list m iloptionicons delete image list c dialog on cancel coptionsdlg oncancel m_ilicons deleteimagelist m_iloptionicons deleteimagelist cdialog oncancel void c options dlg on btn sel font c string str font spec m strfontspec c string str face str size str flags int n chars str font spec reverse find t int n size end str font spec reverse find t str face str font spec left n chars str size str font spec mid n chars 1 n size end n chars 1 str flags str font spec right 4 int n size ttoi lpctstr str size int n weight fw normal if str flags get at 0 t 1 n weight fw bold byte b italic byte str flags get at 1 t 1 true false byte b underlined byte str flags get at 2 t 1 true false byte b strike out byte str flags get at 3 t 1 true false logfont lf cdc pdc getdc hdc hdc pdc m hdc assert hdc null if hdc null lf lf height mul div n size get device caps hdc logpixelsy 72 else assert false lf lf height n size releasedc pdc pdc null lf lf width 0 lf lf escapement 0 lf lf orientation 0 lf lf weight n weight lf lf italic b italic lf lf underline b underlined lf lf strike out b strike out lf lf char set default charset lf lf out precision out default precis lf lf clip precision clip default precis lf lf quality default quality lf lf pitch and family default pitch ff dontcare tcscpy lf lf face name str face c font dialog dlg lf c string str temp if dlg do modal idok int d size dlg get size d size d size 0 d size d size m strfontspec dlg get face name m strfontspec t str temp format t d d size 10 m strfontspec str temp m strfontspec t m strfontspec dlg is bold true t 1 t 0 m strfontspec dlg is italic true t 1 t 0 m strfontspec dlg is underline true t 1 t 0 m strfontspec dlg is strike out true t 1 t 0 coptionsdlg onbtnselfont cstring strfontspec m_strfontspec cstring strface strsize strflags nchars strfontspec reversefind _t nsizeend strfontspec reversefind _t strface strfontspec nchars strsize strfontspec nchars nsizeend nchars strflags strfontspec nsize _ttoi strsize nweight fw_normal strflags getat _t nweight fw_bold bitalic strflags getat _t bunderlined strflags getat _t bstrikeout strflags getat _t m_hdc lfheight muldiv nsize getdevicecaps lfheight nsize lfwidth lfescapement lforientation lfweight nweight lfitalic bitalic lfunderline bunderlined lfstrikeout bstrikeout lfcharset default_charset lfoutprecision out_default_precis lfclipprecision clip_default_precis lfquality default_quality lfpitchandfamily default_pitch ff_dontcare _tcscpy lffacename strface cfontdialog cstring strtemp domodal dsize getsize dsize dsize dsize dsize m_strfontspec getfacename m_strfontspec _t strtemp _t dsize m_strfontspec strtemp m_strfontspec _t m_strfontspec isbold _t _t m_strfontspec isitalic _t _t m_strfontspec isunderline _t _t m_strfontspec isstrikeout _t _t void c options dlg on sel change tab menu nmhdr pnmhdr lresult p result int n cur sel m tabmenu get cur sel unreferenced parameter pnmhdr update data true switch n cur sel case optgrp security m wndgrp hide all except optgrp security if m blockaftertime false get dlg item idc edit lockseconds enable window false if m bdefaultexpire false get dlg item idc edit defaultexpire enable window false break case optgrp gui m wndgrp hide all except optgrp gui break case optgrp files m wndgrp hide all except optgrp files break case optgrp memory m wndgrp hide all except optgrp memory if m nclipboardmethod cm timed get dlg item idc edit clipboardtime enable window false break case optgrp setup m wndgrp hide all except optgrp setup if m bdisableautotype true m hkautotype enable window false break case optgrp advanced m wndgrp hide all except optgrp advanced break default assert false break p result 0 coptionsdlg onselchangetabmenu presult ncursel m_tabmenu getcursel unreferenced_parameter updatedata ncursel optgrp_security m_wndgrp hideallexcept optgrp_security m_blockaftertime getdlgitem idc_edit_lockseconds enablewindow m_bdefaultexpire getdlgitem idc_edit_defaultexpire enablewindow optgrp_gui m_wndgrp hideallexcept optgrp_gui optgrp_files m_wndgrp hideallexcept optgrp_files optgrp_memory m_wndgrp hideallexcept optgrp_memory m_nclipboardmethod cm_timed getdlgitem idc_edit_clipboardtime enablewindow optgrp_setup m_wndgrp hideallexcept optgrp_setup m_bdisableautotype m_hkautotype enablewindow optgrp_advanced m_wndgrp hideallexcept optgrp_advanced presult void c options dlg on btn create assoc if c pw safe app register shell association true notify assoc changed message box trl successfully associated kee pass with kdb files a double click on a kdb file will now start kee pass automatically trl password safe mb ok mb iconinformation else message box trl failed to change the kdb file association make sure you have the rights to write to the registry and change file associations trl password safe mb ok mb iconwarning coptionsdlg onbtncreateassoc cpwsafeapp registershellassociation notifyassocchanged messagebox keepass keepass mb_ok mb_iconinformation messagebox mb_ok mb_iconwarning void c options dlg on btn delete assoc if c pw safe app unregister shell association true notify assoc changed message box trl successfully removed association kee pass won t be started any more when double clicking on a kdb file trl password safe mb ok mb iconinformation else message box trl failed to change the kdb file association make sure you have the rights to write to the registry and change file associations trl password safe mb ok mb iconwarning coptionsdlg onbtndeleteassoc cpwsafeapp unregistershellassociation notifyassocchanged messagebox keepass mb_ok mb_iconinformation messagebox mb_ok mb_iconwarning void c options dlg on radio clip method secure c string str trl warning it s possible that this option won t work correctly on your system especially if you are using any clipboard enhancing tools or something like this str t r n r n str trl if you notice any problems with this enhanced method just switch back to the timed clipboard clearing method message box lpctstr str trl password safe mb iconinformation mb ok update data true if m nclipboardmethod cm timed get dlg item idc edit clipboardtime enable window true else get dlg item idc edit clipboardtime enable window false coptionsdlg onradioclipmethodsecure cstring _t messagebox mb_iconinformation mb_ok updatedata m_nclipboardmethod cm_timed getdlgitem idc_edit_clipboardtime enablewindow getdlgitem idc_edit_clipboardtime enablewindow void c options dlg on radio clip method timed update data true if m nclipboardmethod cm timed get dlg item idc edit clipboardtime enable window true else get dlg item idc edit clipboardtime enable window false coptionsdlg onradioclipmethodtimed updatedata m_nclipboardmethod cm_timed getdlgitem idc_edit_clipboardtime enablewindow getdlgitem idc_edit_clipboardtime enablewindow void c options dlg on check default expire update data true if m bdefaultexpire true get dlg item idc edit defaultexpire enable window true else get dlg item idc edit defaultexpire enable window false coptionsdlg oncheckdefaultexpire updatedata m_bdefaultexpire getdlgitem idc_edit_defaultexpire enablewindow getdlgitem idc_edit_defaultexpire enablewindow void c options dlg on check lock after time update data true if m blockaftertime false get dlg item idc edit lockseconds enable window false else get dlg item idc edit lockseconds enable window true coptionsdlg onchecklockaftertime updatedata m_blockaftertime getdlgitem idc_edit_lockseconds enablewindow getdlgitem idc_edit_lockseconds enablewindow c dialog c get random dlg idd p parent afx data init c get random dlg m strrandom t afx data init cdialog cgetrandomdlg pparent afx_data_init cgetrandomdlg m_strrandom _t afx_data_init void c get random dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c get random dlg ddx control pdx idcancel m btcancel ddx control pdx idok m btok ddx control pdx idc begin mouseinput m btmouseinput ddx control pdx idc progress mouse m cmouseprogress ddx text pdx idc edit randomstring m strrandom afx data map cgetrandomdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map cgetrandomdlg ddx_control m_btcancel ddx_control m_btok ddx_control idc_begin_mouseinput m_btmouseinput ddx_control idc_progress_mouse m_cmouseprogress ddx_text idc_edit_randomstring m_strrandom afx_data_map bool c get random dlg on init dialog c dialog on init dialog m cmouseprogress set range 0 100 m cmouseprogress set pos 0 m dwcurpoint 0 m bmouseactive false newgui translatecwnd this enum child windows this m hwnd newgui translatewindowcb 0 newgui xpbutton m btok idb ok idb ok newgui xpbutton m btcancel idb cancel idb cancel newgui xpbutton m btmouseinput idb mouse small idb mouse small newgui configsidebanner m banner this m banner set icon afx get app load icon idi key kcsb icon left kcsb icon vcenter m banner set title trl get random data for key generation m banner set caption trl move the mouse and type some random text to generate random values c new random c rand c rand initialize c rand get random buffer m pfinalrandom 32 c rand get random buffer byte m points sizeof point 100 return true cgetrandomdlg oninitdialog cdialog oninitdialog m_cmouseprogress setrange m_cmouseprogress setpos m_dwcurpoint m_bmouseactive newgui_translatecwnd enumchildwindows m_hwnd newgui_translatewindowcb newgui_xpbutton m_btok idb_ok idb_ok newgui_xpbutton m_btcancel idb_cancel idb_cancel newgui_xpbutton m_btmouseinput idb_mouse_small idb_mouse_small newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_key kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_banner setcaption cnewrandom crand crand crand getrandombuffer m_pfinalrandom crand getrandombuffer m_points void c get random dlg onok sha256 ctx ctx int n string len update data true if m dwcurpoint 0 m strrandom get length 0 message box trl you must generate some random values using the random mouse input box or the edit field before you can close this dialog trl no random input mb ok mb iconwarning return sha256 begin ctx sha256 hash m pfinalrandom 32 ctx sha256 hash unsigned char m points sizeof point 100 ctx n string len m strrandom get length if n string len 0 sha256 hash byte lpctstr m strrandom unsigned long n string len ctx sha256 end unsigned char m pfinalrandom ctx c dialog onok cgetrandomdlg sha256_ctx nstringlen updatedata m_dwcurpoint m_strrandom getlength messagebox mb_ok mb_iconwarning sha256_begin sha256_hash m_pfinalrandom sha256_hash m_points nstringlen m_strrandom getlength nstringlen sha256_hash m_strrandom nstringlen sha256_end m_pfinalrandom cdialog void c get random dlg on mouse move uint n flags c point point if m bmouseactive true if pt in rect m rect point if m dwcurpoint 100 if rand 5 0 m points m dwcurpoint point point m dwcurpoint m cmouseprogress set pos m dwcurpoint else m bmouseactive false get dlg item idc begin mouseinput enable window true get dlg item idc begin mouseinput set focus c dialog on mouse move n flags point cgetrandomdlg onmousemove nflags cpoint m_bmouseactive ptinrect m_rect m_dwcurpoint m_points m_dwcurpoint m_dwcurpoint m_cmouseprogress setpos m_dwcurpoint m_bmouseactive getdlgitem idc_begin_mouseinput enablewindow getdlgitem idc_begin_mouseinput setfocus cdialog onmousemove nflags void c get random dlg on begin mouse input int x y get dlg item idc static random get window rect m rect x m rect left m rect right m rect left 2 y m rect top m rect bottom m rect top 2 set cursor pos x y screen to client m rect m cmouseprogress set pos 0 get dlg item idc begin mouseinput enable window false m dwcurpoint 0 m bmouseactive true cgetrandomdlg onbeginmouseinput getdlgitem idc_static_random getwindowrect m_rect m_rect m_rect m_rect m_rect m_rect m_rect setcursorpos screentoclient m_rect m_cmouseprogress setpos getdlgitem idc_begin_mouseinput enablewindow m_dwcurpoint m_bmouseactive void c get random dlg on cancel c dialog on cancel cgetrandomdlg oncancel cdialog oncancel c dialog c entry properties dlg idd p parent afx data init c entry properties dlg m bmodexpire false m bmodgroup false m bmodicon false afx data init m pmgr null m pparenticons null m dwdefaultexpire 0 m niconid 0 cdialog centrypropertiesdlg pparent afx_data_init centrypropertiesdlg m_bmodexpire m_bmodgroup m_bmodicon afx_data_init m_pmgr m_pparenticons m_dwdefaultexpire m_niconid void c entry properties dlg set expire days dword dw days bool b set time update data true m bmodexpire true c time t c time get current time t c time span long dw days 0 0 0 m editdate set date t beware of daylight saving if b set time true m edittime set time t update data false on check mod expire centrypropertiesdlg setexpiredays dwdays bsettime updatedata m_bmodexpire ctime ctime getcurrenttime ctimespan dwdays m_editdate setdate bsettime m_edittime settime updatedata oncheckmodexpire void c entry properties dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c entry properties dlg ddx control pdx idc setdefaultexpire btn m btsettodefaultexpire ddx control pdx idc seldefexpires btn m btseldefexpires ddx control pdx idc combo groups m cbgroups ddx control pdx idc button select icon m btselecticon ddx control pdx idcancel m btcancel ddx control pdx idok m btok ddx control pdx idc edit expire time m edittime ddx control pdx idc edit expire date m editdate ddx check pdx idc check modexpire m bmodexpire ddx check pdx idc check modgroup m bmodgroup ddx check pdx idc check modicon m bmodicon afx data map centrypropertiesdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map centrypropertiesdlg ddx_control idc_setdefaultexpire_btn m_btsettodefaultexpire ddx_control idc_seldefexpires_btn m_btseldefexpires ddx_control idc_combo_groups m_cbgroups ddx_control idc_button_select_icon m_btselecticon ddx_control m_btcancel ddx_control m_btok ddx_control idc_edit_expire_time m_edittime ddx_control idc_edit_expire_date m_editdate ddx_check idc_check_modexpire m_bmodexpire ddx_check idc_check_modgroup m_bmodgroup ddx_check idc_check_modicon m_bmodicon afx_data_map bool c entry properties dlg on init dialog c dialog on init dialog assert m pmgr null you must set the manager before using this class assert m pparenticons null you must set the image list first translate all windows enum child windows this m hwnd newgui translatewindowcb 0 newgui xpbutton m btok idb ok idb ok newgui xpbutton m btcancel idb cancel idb cancel newgui xpbutton m btselecticon 1 1 newgui xpbutton m btsettodefaultexpire idb tb defaultexpire idb tb defaultexpire true newgui xpbutton m btseldefexpires idb clock idb clock true c string strtt trl change expiration time strtt remove t m btseldefexpires set tooltip text strtt m btseldefexpires set menu idr expiresmenu this m hwnd true null c size 16 15 strtt trl pick one strtt remove t m btselecticon set tooltip text strtt true if m niconid 0 m pparenticons null m btselecticon set icon m pparenticons extract icon m niconid if m dwdefaultexpire 0 c string str str temp str format trl click to expire the entry in u days m dwdefaultexpire c time t c time get current time t c time span long m dwdefaultexpire 0 0 0 str temp format t 04d 02d 02d t get year t get month t get day str str temp m btsettodefaultexpire set tooltip text str set the imagelist for the group selector combo box m cbgroups set image list m pparenticons assert m pmgr null must have been initialized by parent unsigned int i pw group p comboboxexitem cbi for i 0 i m pmgr get number of groups i add groups to combo box p m pmgr get group i assert p null zero memory cbi sizeof comboboxexitem cbi mask cbeif image cbeif text cbeif indent cbeif selectedimage cbi i item int i cbi psz text lptstr p psz group name cbi cch text max int tcslen p psz group name cbi i image cbi i selected image int p u image id cbi i indent int p us level m cbgroups insert item cbi m cbgroups set cur sel 0 configure banner control newgui configsidebanner m banner this m banner set icon afx get app load icon idi key kcsb icon left kcsb icon vcenter m banner set title trl mass modify m banner set caption trl change fields of all selected entries set window text trl mass modify c ole date time ole min ams min oledatetime c ole date time ole max 2999 12 28 23 59 59 m editdate set range ole min ole max m edittime set range ole min ole max m editdate set date ole max m edittime setampm true m edittime show24 hour format true m edittime show seconds true m edittime set time ole max m bmodgroup false m cbgroups enable window false m bmodicon false get dlg item idc button select icon enable window false m bmodexpire false m edittime enable window false m editdate enable window false update data false if m dwdefaultexpire 0 m btsettodefaultexpire enable window false unchangable else m btsettodefaultexpire enable window true return true return true unless you set the focus to a control centrypropertiesdlg oninitdialog cdialog oninitdialog m_pmgr m_pparenticons enumchildwindows m_hwnd newgui_translatewindowcb newgui_xpbutton m_btok idb_ok idb_ok newgui_xpbutton m_btcancel idb_cancel idb_cancel newgui_xpbutton m_btselecticon newgui_xpbutton m_btsettodefaultexpire idb_tb_defaultexpire idb_tb_defaultexpire newgui_xpbutton m_btseldefexpires idb_clock idb_clock cstring _t m_btseldefexpires settooltiptext m_btseldefexpires setmenu idr_expiresmenu m_hwnd csize _t m_btselecticon settooltiptext m_niconid m_pparenticons m_btselecticon seticon m_pparenticons extracticon m_niconid m_dwdefaultexpire cstring strtemp m_dwdefaultexpire ctime ctime getcurrenttime ctimespan m_dwdefaultexpire strtemp _t getyear getmonth getday strtemp m_btsettodefaultexpire settooltiptext m_cbgroups setimagelist m_pparenticons m_pmgr pw_group m_pmgr getnumberofgroups m_pmgr getgroup zeromemory cbeif_image cbeif_text cbeif_indent cbeif_selectedimage iitem psztext pszgroupname cchtextmax _tcslen pszgroupname iimage iselectedimage uimageid iindent uslevel m_cbgroups insertitem m_cbgroups setcursel newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_key kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_banner setcaption setwindowtext coledatetime olemin ams_min_oledatetime coledatetime olemax m_editdate setrange olemin olemax m_edittime setrange olemin olemax m_editdate setdate olemax m_edittime m_edittime show24hourformat m_edittime showseconds m_edittime settime olemax m_bmodgroup m_cbgroups enablewindow m_bmodicon getdlgitem idc_button_select_icon enablewindow m_bmodexpire m_edittime enablewindow m_editdate enablewindow updatedata m_dwdefaultexpire m_btsettodefaultexpire enablewindow m_btsettodefaultexpire enablewindow void c entry properties dlg onok update data true if m bmodgroup true c string str group test m cbgroups getlb text m cbgroups get cur sel str group test if c pw manager is allowed store group lpctstr str group test pws searchgroup false message box trl the group you selected cannot store entries please select an other group trl stop mb iconwarning mb ok return if m editdate get window text length 0 m editdate set date 2999 12 28 if m edittime get window text length 0 m edittime set time 23 59 59 m texpire sh year ushort m editdate get year m texpire bt month byte m editdate get month m texpire bt day byte m editdate get day m texpire bt hour byte m edittime get hour m texpire bt minute byte m edittime get minute m texpire bt second byte m edittime get second m ngroupinx m cbgroups get cur sel c dialog onok centrypropertiesdlg updatedata m_bmodgroup cstring strgrouptest m_cbgroups getlbtext m_cbgroups getcursel strgrouptest cpwmanager isallowedstoregroup strgrouptest pws_searchgroup messagebox mb_iconwarning mb_ok m_editdate getwindowtextlength m_editdate setdate m_edittime getwindowtextlength m_edittime settime m_texpire shyear m_editdate getyear m_texpire btmonth m_editdate getmonth m_texpire btday m_editdate getday m_texpire bthour m_edittime gethour m_texpire btminute m_edittime getminute m_texpire btsecond m_edittime getsecond m_ngroupinx m_cbgroups getcursel cdialog void c entry properties dlg on cancel c dialog on cancel centrypropertiesdlg oncancel cdialog oncancel void c entry properties dlg on button select icon c icon picker dlg dlg dlg m pimagelist m pparenticons dlg m unumicons uint m pparenticons get image count if dlg do modal idok m niconid dlg m nselectedicon if m niconid 0 m pparenticons null m btselecticon set icon m pparenticons extract icon m niconid centrypropertiesdlg onbuttonselecticon ciconpickerdlg m_pimagelist m_pparenticons m_unumicons m_pparenticons getimagecount domodal m_niconid m_nselectedicon m_niconid m_pparenticons m_btselecticon seticon m_pparenticons extracticon m_niconid void c entry properties dlg on check mod expire update data true if m bmodexpire true m edittime enable window true m editdate enable window true else m edittime enable window false m editdate enable window false centrypropertiesdlg oncheckmodexpire updatedata m_bmodexpire m_edittime enablewindow m_editdate enablewindow m_edittime enablewindow m_editdate enablewindow void c entry properties dlg on check mod group update data true if m bmodgroup true m cbgroups enable window true else m cbgroups enable window false centrypropertiesdlg oncheckmodgroup updatedata m_bmodgroup m_cbgroups enablewindow m_cbgroups enablewindow void c entry properties dlg on check mod icon update data true if m bmodicon true get dlg item idc button select icon enable window true else get dlg item idc button select icon enable window false centrypropertiesdlg oncheckmodicon updatedata m_bmodicon getdlgitem idc_button_select_icon enablewindow getdlgitem idc_button_select_icon enablewindow void c entry properties dlg on set default expire btn if m dwdefaultexpire 0 return set expire days m dwdefaultexpire false centrypropertiesdlg onsetdefaultexpirebtn m_dwdefaultexpire setexpiredays m_dwdefaultexpire void c entry properties dlg on expires1 week set expire days 7 false centrypropertiesdlg onexpires1week setexpiredays void c entry properties dlg on expires2 weeks set expire days 14 false centrypropertiesdlg onexpires2weeks setexpiredays void c entry properties dlg on expires1 month set expire days 30 false centrypropertiesdlg onexpires1month setexpiredays void c entry properties dlg on expires3 months set expire days 91 false centrypropertiesdlg onexpires3months setexpiredays void c entry properties dlg on expires6 months set expire days 182 false centrypropertiesdlg onexpires6months setexpiredays void c entry properties dlg on expires12 months set expire days 365 false centrypropertiesdlg onexpires12months setexpiredays void c entry properties dlg on expires now set expire days 0 true centrypropertiesdlg onexpiresnow setexpiredays c dialog c entry list dlg idd p parent afx data init c entry list dlg afx data init m ndisplaymode eldmode unknown m pmgr null zero memory m auuid 16 m bpasswordstars true m buserstars false m ventrylist clear cdialog centrylistdlg pparent afx_data_init centrylistdlg afx_data_init m_ndisplaymode eldmode_unknown m_pmgr zeromemory m_auuid m_bpasswordstars m_buserstars m_ventrylist void c entry list dlg save selected entry dword i uint u state bool b found false lv item lvi tchar tsz temp 40 zero memory m auuid 16 for i 0 i dword m clist get item count i u state m clist get item state int i lvis selected if u state lvis selected b found true break if b found false return zero memory lvi sizeof lv item lvi i item int i lvi i sub item 5 lvi mask lvif text lvi psz text tsz temp lvi cch text max 40 if m clist get item lvi false assert false return c string str temp lvi psz text stringtouuid lpctstr str temp m auuid centrylistdlg saveselectedentry ustate bfound lv_item tsztemp zeromemory m_auuid m_clist getitemcount ustate m_clist getitemstate lvis_selected ustate lvis_selected bfound bfound zeromemory lv_item iitem isubitem lvif_text psztext tsztemp cchtextmax m_clist getitem cstring strtemp psztext _stringtouuid strtemp m_auuid void c entry list dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c entry list dlg ddx control pdx idc static productname m stcproductname ddx control pdx idcancel m btclose ddx control pdx idc entrylist m clist afx data map centrylistdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map centrylistdlg ddx_control idc_static_productname m_stcproductname ddx_control m_btclose ddx_control idc_entrylist m_clist afx_data_map void c entry list dlg addentrytolist pw entry p bool b expired icon lv item lvi c string str temp pw entry pwe p pw group pwg assert pwe null dword dw insert pos dword m clist get item count zero memory lvi sizeof lv item lvi i item int dw insert pos lvi i sub item 0 lvi i image b expired icon true 45 p u image id lvi mask lvif text lvif image pwg m pmgr get group by id pwe u group id assert pwg null if pwg null return lvi psz text pwg psz group name m clist insert item lvi add lvi mask lvif text lvi i sub item 1 lvi psz text pwe psz title lvi i image 0 m clist set item lvi lvi i sub item 2 hide usernames behind if the user has selected this option if m buserstars true lvi psz text pwm password string m clist set item lvi else don t hide display them lvi psz text pwe psz user name m clist set item lvi lvi i sub item 3 hide passwords behind if the user has selected this option if m bpasswordstars true lvi psz text pwm password string m clist set item lvi else don t hide display them m pmgr unlock entry password pwe lvi psz text pwe psz password m clist set item lvi m pmgr lock entry password pwe lvi i sub item 4 pwtimetostring pwe t expire str temp lvi psz text lptstr lpctstr str temp m clist set item lvi ignore m bshowuuid the uuid field is needed in all cases lvi i sub item 5 uuidtostring pwe uuid str temp lvi psz text lptstr lpctstr str temp m clist set item lvi centrylistdlg _addentrytolist pw_entry bexpiredicon lv_item cstring strtemp pw_entry pw_group dwinsertpos m_clist getitemcount zeromemory lv_item iitem dwinsertpos isubitem iimage bexpiredicon uimageid lvif_text lvif_image m_pmgr getgroupbyid ugroupid psztext pszgroupname m_clist insertitem lvif_text isubitem psztext psztitle iimage m_clist setitem isubitem m_buserstars psztext pwm_password_string m_clist setitem psztext pszusername m_clist setitem isubitem m_bpasswordstars psztext pwm_password_string m_clist setitem m_pmgr unlockentrypassword psztext pszpassword m_clist setitem m_pmgr lockentrypassword isubitem _pwtimetostring texpire strtemp psztext strtemp m_clist setitem m_bshowuuid isubitem _uuidtostring strtemp psztext strtemp m_clist setitem bool c entry list dlg on init dialog c dialog on init dialog assert m pmgr null assert m ndisplaymode eldmode unknown assert m pimglist null translate all windows enum child windows this m hwnd newgui translatewindowcb 0 newgui xpbutton m btclose idb cancel idb cancel configure banner control newgui configsidebanner m banner this m banner set icon afx get app load icon idi key kcsb icon left kcsb icon vcenter m banner set title m strbannertitle trl expired entries m banner set caption m strbannercaption trl this is a list of all expired entries c string str window text m strbannertitle if m ndisplaymode eldmode list str window text pwm product name set window text str window text m stcproductname set window text pwm product name m clist set image list m pimglist lvsil small int n col width 160 int a col widths 5 if m ndisplaymode eldmode list a col widths 0 n col width 2 20 a col widths 1 n col width 8 a col widths 2 n col width 8 a col widths 3 n col width 2 a col widths 4 n col width 2 else a col widths 0 n col width 2 25 a col widths 1 n col width 8 50 a col widths 2 n col width 8 35 a col widths 3 0 a col widths 4 0 m clist insert column 0 trl password groups lvcfmt left a col widths 0 0 m clist insert column 1 trl title lvcfmt left a col widths 1 1 m clist insert column 2 trl user name lvcfmt left a col widths 2 2 m clist insert column 3 trl password lvcfmt left a col widths 3 3 m clist insert column 4 trl expires lvcfmt left a col widths 4 4 m clist insert column 5 trl uuid lvcfmt left 0 5 lparam dw 0 dw lvs ex si report lvs ex fullrowselect lvs ex oneclickactivate lvs ex underlinehot dw lvs ex headerdragdrop lvs ex infotip lvs ex gridlines m clist post message lvm setextendedlistviewstyle 0 dw pw entry p dword i if m ndisplaymode eldmode list get dlg item idc static listtext set window text trl click on an entry to auto type it m btclose set window text trl cancel m buserstars false rect rect m clist get window rect rect screen to client rect rect bottom 200 rect right 80 m clist move window rect m btclose get window rect rect screen to client rect rect top 200 rect bottom 200 rect left 80 rect right 80 m btclose move window rect m stcproductname get window rect rect screen to client rect rect top 200 rect bottom 200 m stcproductname move window rect get window rect rect rect bottom 200 rect right 80 move window rect for i 0 i dword m ventrylist size i p m pmgr get entry by uuid m ventrylist i uuid if p null continue addentrytolist p false else expired entries mode dword dw date now dw date pw time t now bool b added dword dw invalid1 dw invalid2 dw invalid1 m pmgr get group id pws backupgroup src dw invalid2 m pmgr get group id pws backupgroup getcurrentpwtime t now dw date now dword t now sh year 16 dword t now bt month 8 dword t now bt day 0xff for i 0 i m pmgr get number of entries i p m pmgr get entry i assert p null if p null continue if p u group id dw invalid1 p u group id dw invalid2 continue b added false if m ndisplaymode eldmode expired m ndisplaymode eldmode expsoonexp if pwtimecmp t now p t expire 0 addentrytolist p true b added true if b added false if m ndisplaymode eldmode soontoexp m ndisplaymode eldmode expsoonexp dw date dword p t expire sh year 16 dword p t expire bt month 8 dword p t expire bt day 0xff if dw date dw date now dw date dw date now pwv soontoexpire days addentrytolist p false if m ndisplaymode eldmode list if m clist get item count 0 m clist set item state 0 lvis selected lvis focused lvis selected lvis focused m clist set focus else m btclose set focus return false return true unless you set the focus to a control centrylistdlg oninitdialog cdialog oninitdialog m_pmgr m_ndisplaymode eldmode_unknown m_pimglist enumchildwindows m_hwnd newgui_translatewindowcb newgui_xpbutton m_btclose idb_cancel idb_cancel newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_key kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_strbannertitle m_banner setcaption m_strbannercaption cstring strwindowtext m_strbannertitle m_ndisplaymode eldmode_list strwindowtext pwm_product_name setwindowtext strwindowtext m_stcproductname setwindowtext pwm_product_name m_clist setimagelist m_pimglist lvsil_small ncolwidth acolwidths m_ndisplaymode eldmode_list acolwidths ncolwidth acolwidths ncolwidth acolwidths ncolwidth acolwidths ncolwidth acolwidths ncolwidth acolwidths ncolwidth acolwidths ncolwidth acolwidths ncolwidth acolwidths acolwidths m_clist insertcolumn lvcfmt_left acolwidths m_clist insertcolumn lvcfmt_left acolwidths m_clist insertcolumn lvcfmt_left acolwidths m_clist insertcolumn lvcfmt_left acolwidths m_clist insertcolumn lvcfmt_left acolwidths m_clist insertcolumn lvcfmt_left lvs_ex_si_report lvs_ex_fullrowselect lvs_ex_oneclickactivate lvs_ex_underlinehot lvs_ex_headerdragdrop lvs_ex_infotip lvs_ex_gridlines m_clist postmessage lvm_setextendedlistviewstyle pw_entry m_ndisplaymode eldmode_list getdlgitem idc_static_listtext setwindowtext m_btclose setwindowtext m_buserstars m_clist getwindowrect screentoclient m_clist movewindow m_btclose getwindowrect screentoclient m_btclose movewindow m_stcproductname getwindowrect screentoclient m_stcproductname movewindow getwindowrect movewindow m_ventrylist m_pmgr getentrybyuuid m_ventrylist _addentrytolist dwdatenow dwdate pw_time tnow badded dwinvalid1 dwinvalid2 dwinvalid1 m_pmgr getgroupid pws_backupgroup_src dwinvalid2 m_pmgr getgroupid pws_backupgroup _getcurrentpwtime tnow dwdatenow tnow shyear tnow btmonth tnow btday m_pmgr getnumberofentries m_pmgr getentry ugroupid dwinvalid1 ugroupid dwinvalid2 badded m_ndisplaymode eldmode_expired m_ndisplaymode eldmode_expsoonexp _pwtimecmp tnow texpire _addentrytolist badded badded m_ndisplaymode eldmode_soontoexp m_ndisplaymode eldmode_expsoonexp dwdate texpire shyear texpire btmonth texpire btday dwdate dwdatenow dwdate dwdatenow pwv_soontoexpire_days _addentrytolist m_ndisplaymode eldmode_list m_clist getitemcount m_clist setitemstate lvis_selected lvis_focused lvis_selected lvis_focused m_clist setfocus m_btclose setfocus void c entry list dlg onok save selected entry c dialog onok centrylistdlg saveselectedentry cdialog void c entry list dlg on cancel c dialog on cancel centrylistdlg oncancel cdialog oncancel void c entry list dlg on click entry list nmhdr pnmhdr lresult p result p result 0 unreferenced parameter pnmhdr onok saves the selected entry and closes the dialog centrylistdlg onclickentrylist presult presult unreferenced_parameter void c entry list dlg on return entry list nmhdr pnmhdr lresult p result unreferenced parameter pnmhdr p result 0 onok centrylistdlg onreturnentrylist presult unreferenced_parameter presult c dialog c db settings dlg idd p parent afx data init c db settings dlg m nalgorithm 1 m dwnumkeyenc 0 afx data init cdialog cdbsettingsdlg pparent afx_data_init cdbsettingsdlg m_nalgorithm m_dwnumkeyenc afx_data_init void c db settings dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c db settings dlg ddx control pdx idc hlink helpfile m hlhelp ddx control pdx idc btn calcrounds m btcalcrounds ddx control pdx idc combo encalgos m cencalgos ddx control pdx idcancel m btcancel ddx control pdx idok m btok ddx cbindex pdx idc combo encalgos m nalgorithm ddx text pdx idc edit keyenc m dwnumkeyenc afx data map cdbsettingsdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map cdbsettingsdlg ddx_control idc_hlink_helpfile m_hlhelp ddx_control idc_btn_calcrounds m_btcalcrounds ddx_control idc_combo_encalgos m_cencalgos ddx_control m_btcancel ddx_control m_btok ddx_cbindex idc_combo_encalgos m_nalgorithm ddx_text idc_edit_keyenc m_dwnumkeyenc afx_data_map bool c db settings dlg on init dialog c dialog on init dialog newgui translatecwnd this enum child windows this m hwnd newgui translatewindowcb 0 newgui xpbutton m btok idb ok idb ok newgui xpbutton m btcancel idb cancel idb cancel newgui xpbutton m btcalcrounds idb tb defaultexpire idb tb defaultexpire c string str m btcalcrounds get window text str m btcalcrounds set tooltip text str m btcalcrounds set window text t str trl open help file str remove t m hlhelp set window text str newgui makehyperlink m hlhelp m hlhelp enable tooltip false m hlhelp set notify parent true m hlhelp enableurl false newgui configsidebanner m banner this m banner set icon afx get app load icon idi options kcsb icon left kcsb icon vcenter m banner set title trl database settings m banner set caption trl here you can configure the current database m cencalgos reset content m cencalgos add string trl advanced encryption standard aes 128 bit block cipher using 256 bit key m cencalgos add string trl twofish 128 bit block cipher using 256 bit key m cencalgos set cur sel m nalgorithm update data false return true return true unless you set the focus to a control cdbsettingsdlg oninitdialog cdialog oninitdialog newgui_translatecwnd enumchildwindows m_hwnd newgui_translatewindowcb newgui_xpbutton m_btok idb_ok idb_ok newgui_xpbutton m_btcancel idb_cancel idb_cancel newgui_xpbutton m_btcalcrounds idb_tb_defaultexpire idb_tb_defaultexpire cstring m_btcalcrounds getwindowtext m_btcalcrounds settooltiptext m_btcalcrounds setwindowtext _t _t m_hlhelp setwindowtext newgui_makehyperlink m_hlhelp m_hlhelp enabletooltip m_hlhelp setnotifyparent m_hlhelp newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_options kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_banner setcaption m_cencalgos resetcontent m_cencalgos addstring m_cencalgos addstring m_cencalgos setcursel m_nalgorithm updatedata void c db settings dlg onok update data true check if the user has entered something valid otherwise fix it c string str get dlg item idc edit keyenc get window text str str trim left str trim right if str get length 10 m dwnumkeyenc 0xfffffffe set to max else if str get length 10 if str get at 0 t 4 m dwnumkeyenc 0xfffffffe set to max update data false c dialog onok cdbsettingsdlg updatedata cstring getdlgitem idc_edit_keyenc getwindowtext trimleft trimright getlength m_dwnumkeyenc getlength getat _t m_dwnumkeyenc updatedata cdialog void c db settings dlg on cancel update data true c dialog on cancel cdbsettingsdlg oncancel updatedata cdialog oncancel void c db settings dlg on btn calc rounds rijndael rijndael rd uint8 a key seed 32 rd uint8 a test 32 dword dw start time dword i rounds 0 update data true memset a key seed 0x4b 32 memset a test 0x8e 32 if rijndael init rijndael ecb rijndael encrypt a key seed rijndael key32 bytes 0 rijndael success message box trl internal error trl password safe mb iconstop mb ok return dw start time time get time while 1 rijndael block encrypt a test 256 a test rijndael block encrypt a test 256 a test rijndael block encrypt a test 256 a test rijndael block encrypt a test 256 a test rijndael block encrypt a test 256 a test rijndael block encrypt a test 256 a test rijndael block encrypt a test 256 a test rijndael block encrypt a test 256 a test i rounds 8 if i rounds 8 i rounds dword max 8 break overflow if time get time dw start time 1000 break m dwnumkeyenc i rounds update data false cdbsettingsdlg onbtncalcrounds rd_uint8 akeyseed rd_uint8 atest dwstarttime irounds updatedata akeyseed atest akeyseed key32bytes rijndael_success messagebox mb_iconstop mb_ok dwstarttime timegettime blockencrypt atest atest blockencrypt atest atest blockencrypt atest atest blockencrypt atest atest blockencrypt atest atest blockencrypt atest atest blockencrypt atest atest blockencrypt atest atest irounds irounds irounds dword_max timegettime dwstarttime m_dwnumkeyenc irounds updatedata lresult c db settings dlg onx hyper link clicked wparam w param lparam l param unreferenced parameter l param if w param idc hlink helpfile wu openapphelp t security html return 0 cdbsettingsdlg onxhyperlinkclicked wparam lparam unreferenced_parameter lparam wparam idc_hlink_helpfile wu_openapphelp _t c dialog c plugins dlg idd p parent afx data init c plugins dlg afx data init m ppimgr null m pimglist null cdialog cpluginsdlg pparent afx_data_init cpluginsdlg afx_data_init m_ppimgr m_pimglist void c plugins dlg updategui lv item lvi m clist delete all items zero memory lvi sizeof lv item unsigned int i kp plugin instance p c string str strt for i 0 i m ppimgr m plugins size i p m ppimgr m plugins i assert p null if p null continue lvi i item int i lvi i sub item 0 lvi mask lvif text lvif image lvi i image p b enabled true 20 45 strt p tsz file str cs file only strt lvi psz text tchar lpctstr str m clist insert item lvi lvi mask lvif text if p hinstdll null p b enabled false lvi psz text lptstr trl this plugin will be disabled after you restart kee pass else if p hinstdll null p b enabled true lvi psz text lptstr trl enabled loaded else if p hinstdll null p b enabled false lvi psz text lptstr trl disabled not loaded else if p hinstdll null p b enabled true lvi psz text lptstr trl this plugin will be enabled after you restart kee pass else assert false lvi psz text t lvi i sub item 1 m clist set item lvi lvi i sub item 2 strt format t u p dw pluginid lvi psz text lptstr lpctstr strt m clist set item lvi cpluginsdlg lv_item m_clist deleteallitems zeromemory lv_item kp_plugin_instance cstring m_ppimgr m_plugins m_ppimgr m_plugins iitem isubitem lvif_text lvif_image iimage benabled tszfile csfileonly psztext m_clist insertitem lvif_text benabled psztext keepass benabled psztext benabled psztext benabled psztext keepass psztext _t isubitem m_clist setitem isubitem _t dwpluginid psztext m_clist setitem dword c plugins dlg get selected pluginid dword i uint u state lv item lvi tchar tsz buf 13 tsz buf 12 0 zero memory lvi sizeof lv item for i 0 i dword m clist get item count i u state m clist get item state int i lvis selected if u state lvis selected lvi i item int i lvi i sub item 2 lvi mask lvif text lvi psz text tsz buf lvi cch text max 12 m clist get item lvi return dword ttoi lvi psz text return dword max cpluginsdlg getselectedpluginid ustate lv_item tszbuf tszbuf zeromemory lv_item m_clist getitemcount ustate m_clist getitemstate lvis_selected ustate lvis_selected iitem isubitem lvif_text psztext tszbuf cchtextmax m_clist getitem _ttoi psztext dword_max void c plugins dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c plugins dlg ddx control pdx idc static hl help m hlhelp ddx control pdx idc static hl getplugins m hlgetplugins ddx control pdx idok m btclose ddx control pdx idc plugins list m clist afx data map cpluginsdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map cpluginsdlg ddx_control idc_static_hl_help m_hlhelp ddx_control idc_static_hl_getplugins m_hlgetplugins ddx_control m_btclose ddx_control idc_plugins_list m_clist afx_data_map bool c plugins dlg on init dialog c dialog on init dialog newgui translatecwnd this enum child windows this m hwnd newgui translatewindowcb 0 assert m ppimgr null assert m pimglist null newgui xpbutton m btclose idb ok idb ok newgui configsidebanner m banner this m banner set icon afx get app load icon idi plugins kcsb icon left kcsb icon vcenter m banner set title trl plugin manager m banner set caption trl here you can configure all installed kee pass plugins newgui makehyperlink m hlgetplugins m hlgetplugins enable tooltip false m hlgetplugins set notify parent true m hlgetplugins enableurl false newgui makehyperlink m hlhelp m hlhelp enable tooltip false m hlhelp set notify parent true m hlhelp enableurl false m clist set image list m pimglist lvsil small m clist post message lvm setextendedlistviewstyle 0 lvs ex si report lvs ex fullrowselect lvs ex gridlines lvs ex oneclickactivate lvs ex underlinehot rect rect m clist get window rect rect int n width rect right rect left get system metrics sm cxvscroll 8 6 m clist insert column 0 trl files lvcfmt left n width 2 0 m clist insert column 1 trl status lvcfmt left n width 4 1 m clist insert column 2 trl id lvcfmt left 0 2 tchar tsz base max path tsz base 0 0 tsz base 1 0 get module file name null tsz base max path 2 int jj for jj int tcslen tsz base 1 jj 0 jj if tsz base jj t tsz base jj 1 0 break verify m ppimgr add all plugins tsz base t dll true updategui return true cpluginsdlg oninitdialog cdialog oninitdialog newgui_translatecwnd enumchildwindows m_hwnd newgui_translatewindowcb m_ppimgr m_pimglist newgui_xpbutton m_btclose idb_ok idb_ok newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_plugins kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_banner setcaption keepass newgui_makehyperlink m_hlgetplugins m_hlgetplugins enabletooltip m_hlgetplugins setnotifyparent m_hlgetplugins newgui_makehyperlink m_hlhelp m_hlhelp enabletooltip m_hlhelp setnotifyparent m_hlhelp m_clist setimagelist m_pimglist lvsil_small m_clist postmessage lvm_setextendedlistviewstyle lvs_ex_si_report lvs_ex_fullrowselect lvs_ex_gridlines lvs_ex_oneclickactivate lvs_ex_underlinehot m_clist getwindowrect nwidth getsystemmetrics sm_cxvscroll m_clist insertcolumn lvcfmt_left nwidth m_clist insertcolumn lvcfmt_left nwidth m_clist insertcolumn lvcfmt_left tszbase max_path tszbase tszbase getmodulefilename tszbase max_path _tcslen tszbase tszbase _t tszbase m_ppimgr addallplugins tszbase _t void c plugins dlg onok c dialog onok cpluginsdlg cdialog void c plugins dlg on cancel c dialog on cancel cpluginsdlg oncancel cdialog oncancel void c plugins dlg onr click plugins list nmhdr pnmhdr lresult p result dword dwid get selected pluginid kp plugin instance p m ppimgr get plugin byid dwid unreferenced parameter pnmhdr p result 0 point pt get cursor pos pt m popmenu load menu idr plugins menu m popmenu set menu draw mode bcmenu drawmode xp bcmenu drawmode original m popmenu set select disable mode false m popmenu setxp bitmap3d true m popmenu set bitmap background rgb 255 0 255 m popmenu set icon size 16 16 m popmenu load toolbar idr infoicons idb infoicons ex bc menu psub bc menu m popmenu get sub menu 0 psub modifyod menu null uint id plugin enable m pimglist 2 psub modifyod menu null uint id plugin disable m pimglist 45 psub modifyod menu null uint id plugin config m pimglist 21 psub modifyod menu null uint id plugin about m pimglist 22 c pw safe dlg translatemenu psub false null if p null if p b enabled false psub enable menu item id plugin disable mf bycommand mf grayed psub enable menu item id plugin config mf bycommand mf grayed psub enable menu item id plugin about mf bycommand mf grayed else psub enable menu item id plugin enable mf bycommand mf grayed if p hinstdll null else if p hinstdll null psub enable menu item id plugin config mf bycommand mf grayed psub enable menu item id plugin about mf bycommand mf grayed else psub enable menu item id plugin enable mf bycommand mf grayed psub enable menu item id plugin disable mf bycommand mf grayed psub enable menu item id plugin config mf bycommand mf grayed psub enable menu item id plugin about mf bycommand mf grayed psub track popup menu tpm leftalign tpm rightbutton pt x pt y this m popmenu destroy menu cpluginsdlg onrclickpluginslist presult getselectedpluginid kp_plugin_instance m_ppimgr getpluginbyid unreferenced_parameter presult getcursorpos m_popmenu loadmenu idr_plugins_menu m_popmenu setmenudrawmode bcmenu_drawmode_xp bcmenu_drawmode_original m_popmenu setselectdisablemode m_popmenu setxpbitmap3d m_popmenu setbitmapbackground m_popmenu seticonsize m_popmenu loadtoolbar idr_infoicons idb_infoicons_ex bcmenu bcmenu m_popmenu getsubmenu modifyodmenu id_plugin_enable m_pimglist modifyodmenu id_plugin_disable m_pimglist modifyodmenu id_plugin_config m_pimglist modifyodmenu id_plugin_about m_pimglist cpwsafedlg _translatemenu benabled enablemenuitem id_plugin_disable mf_bycommand mf_grayed enablemenuitem id_plugin_config mf_bycommand mf_grayed enablemenuitem id_plugin_about mf_bycommand mf_grayed enablemenuitem id_plugin_enable mf_bycommand mf_grayed enablemenuitem id_plugin_config mf_bycommand mf_grayed enablemenuitem id_plugin_about mf_bycommand mf_grayed enablemenuitem id_plugin_enable mf_bycommand mf_grayed enablemenuitem id_plugin_disable mf_bycommand mf_grayed enablemenuitem id_plugin_config mf_bycommand mf_grayed enablemenuitem id_plugin_about mf_bycommand mf_grayed trackpopupmenu tpm_leftalign tpm_rightbutton m_popmenu destroymenu void c plugins dlg on plugin enable dword dwid get selected pluginid if dwid dword max return m ppimgr enable plugin byid dwid true updategui cpluginsdlg onpluginenable getselectedpluginid dword_max m_ppimgr enablepluginbyid void c plugins dlg on plugin disable dword dwid get selected pluginid if dwid dword max return m ppimgr enable plugin byid dwid false updategui cpluginsdlg onplugindisable getselectedpluginid dword_max m_ppimgr enablepluginbyid void c plugins dlg on plugin config dword dwid get selected pluginid assert dwid dword max if dwid dword max return m ppimgr call single plugin dwid kpm direct config 0 0 cpluginsdlg onpluginconfig getselectedpluginid dword_max dword_max m_ppimgr callsingleplugin kpm_direct_config void c plugins dlg on plugin about dword dwid get selected pluginid assert dwid dword max if dwid dword max return m ppimgr call single plugin dwid kpm plugin info 0 0 cpluginsdlg onpluginabout getselectedpluginid dword_max dword_max m_ppimgr callsingleplugin kpm_plugin_info lresult c plugins dlg onx hyper link clicked wparam w param lparam l param unreferenced parameter l param if w param idc static hl getplugins shell execute null t open pwm url plugins null null sw show else if w param idc static hl help wu openapphelp t plugins html return 0 cpluginsdlg onxhyperlinkclicked wparam lparam unreferenced_parameter lparam wparam idc_static_hl_getplugins shellexecute _t pwm_url_plugins sw_show wparam idc_static_hl_help wu_openapphelp _t c dialog c import options dlg idd p parent afx data init c import options dlg m nimportmethod 0 afx data init cdialog cimportoptionsdlg pparent afx_data_init cimportoptionsdlg m_nimportmethod afx_data_init void c import options dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c import options dlg ddx control pdx idcancel m btcancel ddx control pdx idok m btok ddx radio pdx idc radio createnew m nimportmethod afx data map cimportoptionsdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map cimportoptionsdlg ddx_control m_btcancel ddx_control m_btok ddx_radio idc_radio_createnew m_nimportmethod afx_data_map bool c import options dlg on init dialog c dialog on init dialog newgui translatecwnd this enum child windows this m hwnd newgui translatewindowcb 0 newgui xpbutton m btok idb ok idb ok newgui xpbutton m btcancel idb cancel idb cancel newgui configsidebanner m banner this m banner set icon afx get app load icon idi iconpic kcsb icon left kcsb icon vcenter m banner set title trl options m banner set caption t m fbold create font 10 0 0 0 fw bold false false 0 default charset out default precis clip default precis default quality default pitch ff modern t ms shell dlg get dlg item idc radio createnew set font m fbold get dlg item idc radio overwrite always set font m fbold get dlg item idc radio overwrite timebased set font m fbold return true cimportoptionsdlg oninitdialog cdialog oninitdialog newgui_translatecwnd enumchildwindows m_hwnd newgui_translatewindowcb newgui_xpbutton m_btok idb_ok idb_ok newgui_xpbutton m_btcancel idb_cancel idb_cancel newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idi_iconpic kcsb_icon_left kcsb_icon_vcenter m_banner settitle m_banner setcaption _t m_fbold createfont fw_bold default_charset out_default_precis clip_default_precis default_quality default_pitch ff_modern _t getdlgitem idc_radio_createnew setfont m_fbold getdlgitem idc_radio_overwrite_always setfont m_fbold getdlgitem idc_radio_overwrite_timebased setfont m_fbold void c import options dlg onok update data true verify m fbold delete object c dialog onok cimportoptionsdlg updatedata m_fbold deleteobject cdialog void c import options dlg on cancel update data true verify m fbold delete object c dialog on cancel cimportoptionsdlg oncancel updatedata m_fbold deleteobject cdialog oncancel c about dlg c about dlg c dialog c about dlg idd afx data init c about dlg afx data init caboutdlg caboutdlg cdialog caboutdlg afx_data_init caboutdlg afx_data_init void c about dlg do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c about dlg ddx control pdx idc hlink donate m hldonate ddx control pdx idc hlink credits m hlcredits ddx control pdx idc hlink licensefile m hllicense ddx control pdx idc hlink helpfile m hlhelp ddx control pdx idc hlink homepage m hlhomepage ddx control pdx idok m btok afx data map caboutdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map caboutdlg ddx_control idc_hlink_donate m_hldonate ddx_control idc_hlink_credits m_hlcredits ddx_control idc_hlink_licensefile m_hllicense ddx_control idc_hlink_helpfile m_hlhelp ddx_control idc_hlink_homepage m_hlhomepage ddx_control m_btok afx_data_map bool c about dlg on init dialog c dialog on init dialog c string str newgui translatecwnd this enum child windows this m hwnd newgui translatewindowcb 0 newgui xpbutton m btok idb ok idb ok newgui configsidebanner m banner this m banner set icon afx get app load icon idr mainframe kcsb icon left kcsb icon vcenter str trl version str pwm version str m banner set title pwm product name m banner set caption str m hwindowicon afx get app load icon makeintresource idr mainframe set icon m hwindowicon true set icon m hwindowicon false newgui makehyperlink m hlhomepage m hlhomepage seturl c string pwm homepage str trl open help file remove accelerator tip str m hlhelp set window text str newgui makehyperlink m hlhelp m hlhelp enable tooltip false m hlhelp set notify parent true m hlhelp enableurl false str trl open license file remove accelerator tip str m hllicense set window text str newgui makehyperlink m hllicense m hllicense enable tooltip false m hllicense set notify parent true m hllicense enableurl false str trl acknowledgements m hlcredits set window text str newgui makehyperlink m hlcredits m hlcredits enable tooltip false m hlcredits set notify parent true m hlcredits enableurl false str trl donate remove accelerator tip str str remove t m hldonate set window text str newgui makehyperlink m hldonate m hldonate enable tooltip false m hldonate set notify parent true m hldonate enableurl false update data false return true caboutdlg oninitdialog cdialog oninitdialog cstring newgui_translatecwnd enumchildwindows m_hwnd newgui_translatewindowcb newgui_xpbutton m_btok idb_ok idb_ok newgui_configsidebanner m_banner m_banner seticon afxgetapp loadicon idr_mainframe kcsb_icon_left kcsb_icon_vcenter pwm_version_str m_banner settitle pwm_product_name m_banner setcaption m_hwindowicon afxgetapp loadicon idr_mainframe seticon m_hwindowicon seticon m_hwindowicon newgui_makehyperlink m_hlhomepage m_hlhomepage cstring pwm_homepage removeacceleratortip m_hlhelp setwindowtext newgui_makehyperlink m_hlhelp m_hlhelp enabletooltip m_hlhelp setnotifyparent m_hlhelp removeacceleratortip m_hllicense setwindowtext newgui_makehyperlink m_hllicense m_hllicense enabletooltip m_hllicense setnotifyparent m_hllicense m_hlcredits setwindowtext newgui_makehyperlink m_hlcredits m_hlcredits enabletooltip m_hlcredits setnotifyparent m_hlcredits removeacceleratortip _t m_hldonate setwindowtext newgui_makehyperlink m_hldonate m_hldonate enabletooltip m_hldonate setnotifyparent m_hldonate updatedata lresult c about dlg onx hyper link clicked wparam w param lparam l param unreferenced parameter l param if w param idc hlink helpfile openlocalfile pwm readme file olf open else if w param idc hlink licensefile openlocalfile pwm license file olf open else if w param idc hlink credits wu openapphelp pwm help credits else if w param idc hlink donate shell execute null t open pwm url donate null null sw show return 0 caboutdlg onxhyperlinkclicked wparam lparam unreferenced_parameter lparam wparam idc_hlink_helpfile _openlocalfile pwm_readme_file olf_open wparam idc_hlink_licensefile _openlocalfile pwm_license_file olf_open wparam idc_hlink_credits wu_openapphelp pwm_help_credits wparam idc_hlink_donate shellexecute _t pwm_url_donate sw_show bool c pw safe appri generate random sequence unsigned long u random seq size unsigned char p buffer const assert u random seq size 32 only up to 32 byte long random sequence is supported for now if u random seq size 32 u random seq size 32 c get random dlg dlg if dlg do modal idcancel return false memcpy p buffer dlg m pfinalrandom u random seq size return true cpwsafeappri generaterandomsequence urandomseqsize pbuffer urandomseqsize urandomseqsize urandomseqsize cgetrandomdlg domodal pbuffer m_pfinalrandom urandomseqsize c pw manager c pw manager m pentries null m dwnumentries 0 m dwmaxentries 0 m pgroups null m dwnumgroups 0 m dwmaxgroups 0 m plasteditedentry null m nalgorithm algo aes m dwkeyencrounds pwm std keyencrounds memset m pmasterkey 0 32 allocgroups pwm num initial groups allocentries pwm num initial entries m random initialize m random get random buffer m psessionkey pwm session key size cpwmanager cpwmanager m_pentries m_dwnumentries m_dwmaxentries m_pgroups m_dwnumgroups m_dwmaxgroups m_plasteditedentry m_nalgorithm algo_aes m_dwkeyencrounds pwm_std_keyencrounds m_pmasterkey _allocgroups pwm_num_initial_groups _allocentries pwm_num_initial_entries m_random m_random getrandombuffer m_psessionkey pwm_session_key_size c pw manager c pw manager clean up cpwmanager cpwmanager cleanup void c pw manager init primary instance assert m plasteditedentry null memcmp m pmasterkey g pnullstring 4 0 assert m nalgorithm algo aes m dwkeyencrounds pwm std keyencrounds dword dw init xor shift 4 m random get random buffer byte dw init xor shift 16 srand xor shift dw init xor shift assert sizeof byte 1 cpwmanager initprimaryinstance m_plasteditedentry m_pmasterkey g_pnullstring m_nalgorithm algo_aes m_dwkeyencrounds pwm_std_keyencrounds dwinitxorshift m_random getrandombuffer dwinitxorshift srandxorshift dwinitxorshift void c pw manager clean up if m pentries null deleteentrylist true m dwnumentries 0 m dwmaxentries 0 if m pgroups null deletegrouplist true m dwnumgroups 0 m dwmaxgroups 0 m plasteditedentry null mem erase m pmasterkey 32 m random reset cpwmanager cleanup m_pentries _deleteentrylist m_dwnumentries m_dwmaxentries m_pgroups _deletegrouplist m_dwnumgroups m_dwmaxgroups m_plasteditedentry mem_erase m_pmasterkey m_random int c pw manager set master key const tchar psz master key bool b disk drive const tchar psz second key const c new random interface pari bool b overwrite unsigned long u key len u key len2 0 u file size u read tchar sz file 2048 sha256 ctx sha32 char pa key null char pa key2 null unsigned char a file key 32 unsigned char a password key 32 bool b read normal assert psz master key null if psz master key null return pwe invalid param ifdef unicode assert sizeof tchar 2 pa key stringtoansi psz master key else assert sizeof tchar 1 pa key new char tcslen psz master key 1 assert pa key null if pa key null return pwe no mem strcpy pa key psz master key endif assert pa key null if pa key null return pwe no mem if psz second key null ifdef unicode assert sizeof tchar 2 pa key2 stringtoansi psz second key else assert sizeof tchar 1 pa key2 new char tcslen psz second key 1 assert pa key2 null if pa key2 null return pwe no mem strcpy pa key2 psz second key endif assert pa key2 null if pa key2 null return pwe no mem u key len2 strlen pa key2 assert u key len2 0 u key len strlen pa key assert u key len 0 if u key len 0 safe delete array pa key return pwe invalid key if b disk drive false sha256 begin sha32 sha256 hash unsigned char pa key u key len sha32 sha256 end unsigned char m pmasterkey sha32 mem erase unsigned char pa key u key len safe delete array pa key return pwe success else if psz second key null mem erase unsigned char pa key u key len safe delete array pa key don t need ascii key any more from on now tcscpy sz file psz master key if sz file tcslen sz file 1 t tcscat sz file pws default key filename if pari null if pari is null load key from disk file fp fp tfopen sz file t rb if fp null return pwe nofileaccess read key fseek fp 0 seek end u file size unsigned long ftell fp fseek fp 0 seek set b read normal true if u file size 32 if fread m pmasterkey 1 32 fp 32 fclose fp fp null return pwe fileerror read b read normal false else if u file size 64 if load hex key32 fp m pmasterkey false fseek fp 0 seek set else b read normal false if b read normal true sha256 begin sha32 while 1 u read unsigned long fread unsigned char sz file 1 2048 fp if u read 0 break sha256 hash unsigned char sz file u read sha32 if u read 2048 break sha256 end unsigned char m pmasterkey sha32 fclose fp fp null return pwe success else pari is not null save key to disk file fp unsigned char a random bytes 32 fp tfopen sz file t rb does the file exist already if fp null b overwrite false fclose fp fp null return pwe nofileaccess read key if fp null fclose fp fp null we must close it before opening for write if pari generate random sequence 32 a random bytes false return pwe invalid randomsource fp tfopen sz file t wb if fp null return pwe nofileaccess write if save hex key32 fp a random bytes false fclose fp fp null return pwe fileerror write fclose fp fp null memcpy m pmasterkey a random bytes 32 return pwe success else psz second key null mem erase unsigned char pa key u key len safe delete array pa key don t need ascii key any more from on now tcscpy sz file psz master key if sz file tcslen sz file 1 t tcscat sz file pws default key filename if pari null if pari is null load key from disk file fp fp tfopen sz file t rb if fp null return pwe nofileaccess read key fseek fp 0 seek end u file size unsigned long ftell fp fseek fp 0 seek set b read normal true if u file size 32 if fread a file key 1 32 fp 32 fclose fp fp null return pwe fileerror read b read normal false else if u file size 64 if load hex key32 fp a file key false fseek fp 0 seek set else b read normal false if b read normal true sha256 begin sha32 while 1 u read unsigned long fread unsigned char sz file 1 2048 fp if u read 0 break sha256 hash unsigned char sz file u read sha32 if u read 2048 break sha256 end unsigned char a file key sha32 fclose fp fp null sha256 begin sha32 sha256 hash unsigned char pa key2 u key len2 sha32 sha256 end unsigned char a password key sha32 mem erase unsigned char pa key2 u key len2 safe delete array pa key sha256 begin sha32 sha256 hash a password key 32 sha32 sha256 hash a file key 32 sha32 sha256 end unsigned char m pmasterkey sha32 mem erase unsigned char a password key 32 mem erase unsigned char a file key 32 return pwe success else pari is not null save key to disk file fp unsigned char a random bytes 32 fp tfopen sz file t rb does the file exist already if fp null b overwrite false fclose fp fp null return pwe nofileaccess read key if fp null fclose fp fp null we must close it before opening for write if pari generate random sequence 32 a random bytes false return pwe invalid randomsource fp tfopen sz file t wb if fp null return pwe nofileaccess write if save hex key32 fp a random bytes false fclose fp fp null return pwe fileerror write fclose fp fp null assert u key len2 0 sha256 begin sha32 sha256 hash unsigned char pa key2 u key len2 sha32 sha256 end unsigned char a password key sha32 mem erase unsigned char pa key2 u key len2 safe delete array pa key sha256 begin sha32 sha256 hash a password key 32 sha32 sha256 hash a random bytes 32 sha32 sha256 end unsigned char m pmasterkey sha32 mem erase unsigned char a password key 32 mem erase unsigned char a file key 32 return pwe success return pwe unknown unreachable anyway cpwmanager setmasterkey pszmasterkey bdiskdrive pszsecondkey cnewrandominterface boverwrite ukeylen ukeylen2 ufilesize uread szfile sha256_ctx pakey pakey2 afilekey apasswordkey breadnormal pszmasterkey pszmasterkey pwe_invalid_param _unicode pakey _stringtoansi pszmasterkey pakey _tcslen pszmasterkey pakey pakey pwe_no_mem pakey pszmasterkey pakey pakey pwe_no_mem pszsecondkey _unicode pakey2 _stringtoansi pszsecondkey pakey2 _tcslen pszsecondkey pakey2 pakey2 pwe_no_mem pakey2 pszsecondkey pakey2 pakey2 pwe_no_mem ukeylen2 pakey2 ukeylen2 ukeylen pakey ukeylen ukeylen safe_delete_array pakey pwe_invalid_key bdiskdrive sha256_begin sha256_hash pakey ukeylen sha256_end m_pmasterkey mem_erase pakey ukeylen safe_delete_array pakey pwe_success pszsecondkey mem_erase pakey ukeylen safe_delete_array pakey _tcscpy szfile pszmasterkey szfile _tcslen szfile _t _tcscat szfile pws_default_key_filename _tfopen szfile _t pwe_nofileaccess_read_key seek_end ufilesize seek_set breadnormal ufilesize m_pmasterkey pwe_fileerror_read breadnormal ufilesize loadhexkey32 m_pmasterkey seek_set breadnormal breadnormal sha256_begin uread szfile uread sha256_hash szfile uread uread sha256_end m_pmasterkey pwe_success arandombytes _tfopen szfile _t boverwrite pwe_nofileaccess_read_key generaterandomsequence arandombytes pwe_invalid_randomsource _tfopen szfile _t pwe_nofileaccess_write savehexkey32 arandombytes pwe_fileerror_write m_pmasterkey arandombytes pwe_success pszsecondkey mem_erase pakey ukeylen safe_delete_array pakey _tcscpy szfile pszmasterkey szfile _tcslen szfile _t _tcscat szfile pws_default_key_filename _tfopen szfile _t pwe_nofileaccess_read_key seek_end ufilesize seek_set breadnormal ufilesize afilekey pwe_fileerror_read breadnormal ufilesize loadhexkey32 afilekey seek_set breadnormal breadnormal sha256_begin uread szfile uread sha256_hash szfile uread uread sha256_end afilekey sha256_begin sha256_hash pakey2 ukeylen2 sha256_end apasswordkey mem_erase pakey2 ukeylen2 safe_delete_array pakey sha256_begin sha256_hash apasswordkey sha256_hash afilekey sha256_end m_pmasterkey mem_erase apasswordkey mem_erase afilekey pwe_success arandombytes _tfopen szfile _t boverwrite pwe_nofileaccess_read_key generaterandomsequence arandombytes pwe_invalid_randomsource _tfopen szfile _t pwe_nofileaccess_write savehexkey32 arandombytes pwe_fileerror_write ukeylen2 sha256_begin sha256_hash pakey2 ukeylen2 sha256_end apasswordkey mem_erase pakey2 ukeylen2 safe_delete_array pakey sha256_begin sha256_hash apasswordkey sha256_hash arandombytes sha256_end m_pmasterkey mem_erase apasswordkey mem_erase afilekey pwe_success pwe_unknown dword c pw manager get number of entries return m dwnumentries cpwmanager getnumberofentries m_dwnumentries dword c pw manager get number of groups return m dwnumgroups cpwmanager getnumberofgroups m_dwnumgroups dword c pw manager get number of items in group const tchar psz group assert psz group null if psz group null return 0 return get number of items in groupn get group id psz group cpwmanager getnumberofitemsingroup pszgroup pszgroup pszgroup getnumberofitemsingroupn getgroupid pszgroup dword c pw manager get number of items in groupn dword id group dword i dword n assert id group dword max if id group dword max return 0 n 0 for i 0 i m dwnumentries i if m pentries i u group id id group n return n cpwmanager getnumberofitemsingroupn idgroup idgroup dword_max idgroup dword_max m_dwnumentries m_pentries ugroupid idgroup pw entry c pw manager get entry dword dw index assert dw index m dwnumentries if dw index m dwnumentries return null return m pentries dw index pw_entry cpwmanager getentry dwindex dwindex m_dwnumentries dwindex m_dwnumentries m_pentries dwindex pw entry c pw manager get entry by group dword id group dword dw index dword dw pos assert id group dword max if id group dword max return null assert dw index m dwnumentries if dw index m dwnumentries return null dw pos get entry by groupn id group dw index if dw pos dword max return m pentries dw pos assert false return null pw_entry cpwmanager getentrybygroup idgroup dwindex dwpos idgroup dword_max idgroup dword_max dwindex m_dwnumentries dwindex m_dwnumentries dwpos getentrybygroupn idgroup dwindex dwpos dword_max m_pentries dwpos dword c pw manager get entry by groupn dword id group dword dw index dword u current entry u entry in group counter 0 assert id group dword max if id group dword max return dword max assert dw index m dwnumentries if dw index m dwnumentries return dword max for u current entry 0 u current entry m dwnumentries u current entry if id group m pentries u current entry u group id if dw index u entry in group counter return u current entry u entry in group counter return dword max cpwmanager getentrybygroupn idgroup dwindex ucurrententry uentryingroupcounter idgroup dword_max idgroup dword_max dword_max dwindex m_dwnumentries dwindex m_dwnumentries dword_max ucurrententry ucurrententry m_dwnumentries ucurrententry idgroup m_pentries ucurrententry ugroupid dwindex uentryingroupcounter ucurrententry uentryingroupcounter dword_max pw entry c pw manager get entry by uuid const byte p uuid assert p uuid null if p uuid null return null dword dw entry index get entry by uuidn p uuid assert dw entry index dword max if dw entry index dword max return null return m pentries dw entry index pw_entry cpwmanager getentrybyuuid puuid puuid puuid dwentryindex getentrybyuuidn puuid dwentryindex dword_max dwentryindex dword_max m_pentries dwentryindex dword c pw manager get entry by uuidn const byte p uuid assert p uuid null if p uuid null return dword max for dword dw 0 dw m dwnumentries dw if memcmp m pentries dw uuid p uuid 16 0 return dw don t assert here just return dword max return dword max cpwmanager getentrybyuuidn puuid puuid puuid dword_max m_dwnumentries m_pentries puuid dword_max dword_max dword c pw manager get entry pos in group const pw entry p entry dword u current entry pos 0 assert p entry null if p entry null return dword max for u current entry 0 u current entry m dwnumentries u current entry if m pentries u current entry u group id p entry u group id if memcmp m pentries u current entry uuid p entry uuid 16 0 return pos pos return dword max cpwmanager getentryposingroup pw_entry pentry ucurrententry pentry pentry dword_max ucurrententry ucurrententry m_dwnumentries ucurrententry m_pentries ucurrententry ugroupid pentry ugroupid m_pentries ucurrententry pentry dword_max pw entry c pw manager get last edited entry return m plasteditedentry pw_entry cpwmanager getlasteditedentry m_plasteditedentry pw group c pw manager get group dword dw index assert dw index m dwnumgroups if dw index m dwnumgroups return null return m pgroups dw index pw_group cpwmanager getgroup dwindex dwindex m_dwnumgroups dwindex m_dwnumgroups m_pgroups dwindex pw group c pw manager get group by id dword id group dword dw index get group by idn id group if dw index dword max return null return m pgroups dw index pw_group cpwmanager getgroupbyid idgroup dwindex getgroupbyidn idgroup dwindex dword_max m_pgroups dwindex dword c pw manager get group by idn dword id group dword u current entry for u current entry 0 u current entry m dwnumgroups u current entry if m pgroups u current entry u group id id group return u current entry return dword max cpwmanager getgroupbyidn idgroup ucurrententry ucurrententry ucurrententry m_dwnumgroups ucurrententry m_pgroups ucurrententry ugroupid idgroup ucurrententry dword_max dword c pw manager get group id const tchar psz group name dword i assert psz group name null if psz group name null return dword max for i 0 i m dwnumgroups i if tcsicmp m pgroups i psz group name psz group name 0 return m pgroups i u group id return dword max cpwmanager getgroupid pszgroupname pszgroupname pszgroupname dword_max m_dwnumgroups _tcsicmp m_pgroups pszgroupname pszgroupname m_pgroups ugroupid dword_max dword c pw manager get group id by index dword u group index if u group index m dwnumgroups return dword max return m pgroups u group index u group id cpwmanager getgroupidbyindex ugroupindex ugroupindex m_dwnumgroups dword_max m_pgroups ugroupindex ugroupid dword c pw manager get last child group dword dw parent group index dword i ushort us parent level ushort us level ushort us last level if m dwnumgroups 1 return 0 assert dw parent group index m dwnumgroups if dw parent group index m dwnumgroups 1 return m dwnumgroups 1 else if dw parent group index dword m dwnumgroups 1 return dword max us parent level m pgroups dw parent group index us level i dw parent group index 1 us level us parent level while 1 us last level us level us level m pgroups i us level if us level us parent level return i 1 i if i m dwnumgroups break return dword max cpwmanager getlastchildgroup dwparentgroupindex usparentlevel uslevel uslastlevel m_dwnumgroups dwparentgroupindex m_dwnumgroups dwparentgroupindex m_dwnumgroups m_dwnumgroups dwparentgroupindex m_dwnumgroups dword_max usparentlevel m_pgroups dwparentgroupindex uslevel dwparentgroupindex uslevel usparentlevel uslastlevel uslevel uslevel m_pgroups uslevel uslevel usparentlevel m_dwnumgroups dword_max bool c pw manager get group tree dword id group dword p group indexes dword i dw group pos ushort us level assert p group indexes null if p group indexes null return false dw group pos get group by idn id group assert dw group pos dword max if dw group pos dword max return false i dw group pos us level ushort m pgroups i us level 1 while 1 if m pgroups i us level us level 1 us level p group indexes us level i if us level 0 break if i 0 assert false return false i return true cpwmanager getgrouptree idgroup pgroupindexes dwgrouppos uslevel pgroupindexes pgroupindexes dwgrouppos getgroupbyidn idgroup dwgrouppos dword_max dwgrouppos dword_max dwgrouppos uslevel m_pgroups uslevel m_pgroups uslevel uslevel uslevel pgroupindexes uslevel uslevel bool c pw manager add group const pw group p template pw group pt dword i t 0 b assert p template null if p template null return false pt p template copy parameter to local temporary variable if pt u group id 0 pt u group id dword max while 1 generate a new group id that doesn t exist already b 0 t rand xor shift if t 0 t dword max continue for i 0 i m dwnumgroups i if m pgroups i u group id t b 1 if b 0 break else t pt u group id pt u group id t if m dwnumgroups m dwmaxgroups allocgroups m dwmaxgroups 8 m dwnumgroups return set group m dwnumgroups 1 pt cpwmanager addgroup pw_group ptemplate pw_group ptemplate ptemplate ptemplate ugroupid ugroupid dword_max randxorshift dword_max m_dwnumgroups m_pgroups ugroupid ugroupid ugroupid m_dwnumgroups m_dwmaxgroups _allocgroups m_dwmaxgroups m_dwnumgroups setgroup m_dwnumgroups bool c pw manager add entry const pw entry p template pw entry pt don t assert entry the p template assert p template null if p template null return false assert p template u group id 0 p template u group id dword max if p template u group id 0 p template u group id dword max return false if we don t have enough allocated entries allocate 32 more if m dwnumentries m dwmaxentries allocentries m dwmaxentries 32 pt p template copy parameter to local temporary variable if memcmp pt uuid g uuidzero 16 0 shall we create a new uuid rand createuuid pt uuid m random create it assert get entry by uuidn pt uuid dword max map null pointers to valid pointers to a zero length string if pt psz title null pt psz title tchar g pnullstring if pt psz user name null pt psz user name tchar g pnullstring if pt pszurl null pt pszurl tchar g pnullstring if pt psz password null pt psz password tchar g pnullstring if pt psz additional null pt psz additional tchar g pnullstring if pt psz binary desc null pt psz binary desc tchar g pnullstring m dwnumentries return set entry m dwnumentries 1 pt cpwmanager addentry pw_entry ptemplate pw_entry assert_entry ptemplate ptemplate ptemplate ptemplate ugroupid ptemplate ugroupid dword_max ptemplate ugroupid ptemplate ugroupid dword_max m_dwnumentries m_dwmaxentries _allocentries m_dwmaxentries ptemplate g_uuidzero randcreateuuid m_random getentrybyuuidn dword_max psztitle psztitle g_pnullstring pszusername pszusername g_pnullstring g_pnullstring pszpassword pszpassword g_pnullstring pszadditional pszadditional g_pnullstring pszbinarydesc pszbinarydesc g_pnullstring m_dwnumentries setentry m_dwnumentries bool c pw manager backup entry const pw entry pe bool pb group created pw entry pwe pw group pwg dword dw group id assert entry pe if pe null return false if pb group created null pb group created false dw group id get group id pws backupgroup if dw group id dword max zero memory pwg sizeof pw group pwg psz group name tchar pws backupgroup getcurrentpwtime pwg t creation pwg t last access pwg t creation pwg t last mod pwg t creation getneverexpiretime pwg t expire pwg u image id 4 if add group pwg false return false if pb group created null pb group created true dw group id get group id pws backupgroup if dw group id dword max return false pwe pe getcurrentpwtime pwe t last mod pwe u group id dw group id zero memory pwe uuid 16 create new uuid for the backup entry return add entry pwe cpwmanager backupentry pw_entry pbgroupcreated pw_entry pw_group dwgroupid assert_entry pbgroupcreated pbgroupcreated dwgroupid getgroupid pws_backupgroup dwgroupid dword_max zeromemory pw_group pszgroupname pws_backupgroup _getcurrentpwtime tcreation tlastaccess tcreation tlastmod tcreation _getneverexpiretime texpire uimageid addgroup pbgroupcreated pbgroupcreated dwgroupid getgroupid pws_backupgroup dwgroupid dword_max _getcurrentpwtime tlastmod ugroupid dwgroupid zeromemory addentry bool c pw manager delete entry dword dw index dword i assert dw index m dwnumentries if dw index m dwnumentries return false assert entry m pentries dw index safe delete array m pentries dw index psz title safe delete array m pentries dw index pszurl safe delete array m pentries dw index psz user name safe delete array m pentries dw index psz password safe delete array m pentries dw index psz additional safe delete array m pentries dw index psz binary desc safe delete array m pentries dw index p binary data if dw index m dwnumentries 1 for i dw index i m dwnumentries 1 i m pentries i m pentries i 1 mem erase unsigned char m pentries m dwnumentries 1 sizeof pw entry m dwnumentries return true cpwmanager deleteentry dwindex dwindex m_dwnumentries dwindex m_dwnumentries assert_entry m_pentries dwindex safe_delete_array m_pentries dwindex psztitle safe_delete_array m_pentries dwindex safe_delete_array m_pentries dwindex pszusername safe_delete_array m_pentries dwindex pszpassword safe_delete_array m_pentries dwindex pszadditional safe_delete_array m_pentries dwindex pszbinarydesc safe_delete_array m_pentries dwindex pbinarydata dwindex m_dwnumentries dwindex m_dwnumentries m_pentries m_pentries mem_erase m_pentries m_dwnumentries pw_entry m_dwnumentries bool c pw manager delete group by id dword u group id dword i 0 inx pw entry p assert get group by id u group id null if m dwnumentries 0 while 1 remove all items in that group p m pentries i if p u group id u group id verify delete entry i i i if i m dwnumentries break inx get group by idn u group id safe delete array m pgroups inx psz group name if inx m dwnumgroups 1 for i inx i m dwnumgroups 1 i m pgroups i m pgroups i 1 mem erase unsigned char m pgroups m dwnumgroups 1 sizeof pw group m dwnumgroups fix group tree return true cpwmanager deletegroupbyid ugroupid pw_entry getgroupbyid ugroupid m_dwnumentries m_pentries ugroupid ugroupid deleteentry m_dwnumentries getgroupbyidn ugroupid safe_delete_array m_pgroups pszgroupname m_dwnumgroups m_dwnumgroups m_pgroups m_pgroups mem_erase m_pgroups m_dwnumgroups pw_group m_dwnumgroups fixgrouptree bool c pw manager set group dword dw index const pw group p template assert dw index m dwnumgroups assert p template null assert p template u group id 0 p template u group id dword max if p template u group id 0 p template u group id dword max return false safe delete array m pgroups dw index psz group name m pgroups dw index psz group name tcssafedupalloc p template psz group name m pgroups dw index u group id p template u group id m pgroups dw index u image id p template u image id m pgroups dw index us level p template us level m pgroups dw index dw flags p template dw flags m pgroups dw index t creation p template t creation m pgroups dw index t last mod p template t last mod m pgroups dw index t last access p template t last access m pgroups dw index t expire p template t expire return true cpwmanager setgroup dwindex pw_group ptemplate dwindex m_dwnumgroups ptemplate ptemplate ugroupid ptemplate ugroupid dword_max ptemplate ugroupid ptemplate ugroupid dword_max safe_delete_array m_pgroups dwindex pszgroupname m_pgroups dwindex pszgroupname _tcssafedupalloc ptemplate pszgroupname m_pgroups dwindex ugroupid ptemplate ugroupid m_pgroups dwindex uimageid ptemplate uimageid m_pgroups dwindex uslevel ptemplate uslevel m_pgroups dwindex dwflags ptemplate dwflags m_pgroups dwindex tcreation ptemplate tcreation m_pgroups dwindex tlastmod ptemplate tlastmod m_pgroups dwindex tlastaccess ptemplate tlastaccess m_pgroups dwindex texpire ptemplate texpire bool c pw manager set entry dword dw index const pw entry p template dword slen assert dw index m dwnumentries if dw index m dwnumentries return false assert entry p template if p template null return false assert p template u group id 0 p template u group id dword max if p template u group id 0 p template u group id dword max return false if p template psz title null return false if p template psz user name null return false if p template pszurl null return false if p template psz password null return false if p template psz additional null return false memcpy m pentries dw index uuid p template uuid 16 m pentries dw index u group id p template u group id m pentries dw index u image id p template u image id safe delete array m pentries dw index psz title m pentries dw index psz title tcssafedupalloc p template psz title safe delete array m pentries dw index psz user name m pentries dw index psz user name tcssafedupalloc p template psz user name safe delete array m pentries dw index pszurl m pentries dw index pszurl tcssafedupalloc p template pszurl safe delete array m pentries dw index psz password m pentries dw index psz password tcssafedupalloc p template psz password safe delete array m pentries dw index psz additional m pentries dw index psz additional tcssafedupalloc p template psz additional if m pentries dw index p binary data p template p binary data m pentries dw index psz binary desc p template psz binary desc safe delete array m pentries dw index psz binary desc m pentries dw index psz binary desc tcssafedupalloc p template psz binary desc safe delete array m pentries dw index p binary data slen p template u binary data len if p template p binary data null slen 0 m pentries dw index p binary data new byte slen memcpy m pentries dw index p binary data p template p binary data slen else m pentries dw index p binary data null m pentries dw index u binary data len p template u binary data len if m pentries dw index p binary data null m pentries dw index u binary data len 0 m pentries dw index u password len tcslen m pentries dw index psz password lock entry password m pentries dw index m pentries dw index t creation p template t creation m pentries dw index t last mod p template t last mod m pentries dw index t last access p template t last access m pentries dw index t expire p template t expire if m pentries dw index psz binary desc null assert false m pentries dw index psz binary desc tcssafedupalloc null assert entry m pentries dw index m plasteditedentry m pentries dw index return true cpwmanager setentry dwindex pw_entry ptemplate dwindex m_dwnumentries dwindex m_dwnumentries assert_entry ptemplate ptemplate ptemplate ugroupid ptemplate ugroupid dword_max ptemplate ugroupid ptemplate ugroupid dword_max ptemplate psztitle ptemplate pszusername ptemplate ptemplate pszpassword ptemplate pszadditional m_pentries dwindex ptemplate m_pentries dwindex ugroupid ptemplate ugroupid m_pentries dwindex uimageid ptemplate uimageid safe_delete_array m_pentries dwindex psztitle m_pentries dwindex psztitle _tcssafedupalloc ptemplate psztitle safe_delete_array m_pentries dwindex pszusername m_pentries dwindex pszusername _tcssafedupalloc ptemplate pszusername safe_delete_array m_pentries dwindex m_pentries dwindex _tcssafedupalloc ptemplate safe_delete_array m_pentries dwindex pszpassword m_pentries dwindex pszpassword _tcssafedupalloc ptemplate pszpassword safe_delete_array m_pentries dwindex pszadditional m_pentries dwindex pszadditional _tcssafedupalloc ptemplate pszadditional m_pentries dwindex pbinarydata ptemplate pbinarydata m_pentries dwindex pszbinarydesc ptemplate pszbinarydesc safe_delete_array m_pentries dwindex pszbinarydesc m_pentries dwindex pszbinarydesc _tcssafedupalloc ptemplate pszbinarydesc safe_delete_array m_pentries dwindex pbinarydata ptemplate ubinarydatalen ptemplate pbinarydata m_pentries dwindex pbinarydata m_pentries dwindex pbinarydata ptemplate pbinarydata m_pentries dwindex pbinarydata m_pentries dwindex ubinarydatalen ptemplate ubinarydatalen m_pentries dwindex pbinarydata m_pentries dwindex ubinarydatalen m_pentries dwindex upasswordlen _tcslen m_pentries dwindex pszpassword lockentrypassword m_pentries dwindex m_pentries dwindex tcreation ptemplate tcreation m_pentries dwindex tlastmod ptemplate tlastmod m_pentries dwindex tlastaccess ptemplate tlastaccess m_pentries dwindex texpire ptemplate texpire m_pentries dwindex pszbinarydesc m_pentries dwindex pszbinarydesc _tcssafedupalloc assert_entry m_pentries dwindex m_plasteditedentry m_pentries dwindex void c pw manager lock entry password pw entry p entry assert entry p entry if p entry null return assert p entry psz password null if p entry psz password null return if p entry u password len 0 arcfour crypt byte p entry psz password p entry u password len sizeof tchar m psessionkey pwm session key size assert p entry psz password p entry u password len 0 cpwmanager lockentrypassword pw_entry pentry assert_entry pentry pentry pentry pszpassword pentry pszpassword pentry upasswordlen arcfourcrypt pentry pszpassword pentry upasswordlen m_psessionkey pwm_session_key_size pentry pszpassword pentry upasswordlen void c pw manager unlock entry password pw entry p entry assert entry p entry lock entry password p entry ofb encryption mode ifdef debug unsigned int i for i 0 i p entry u password len i assert p entry psz password i 0 endif cpwmanager unlockentrypassword pw_entry pentry assert_entry pentry lockentrypassword pentry _debug pentry upasswordlen pentry pszpassword void c pw manager new database deleteentrylist true delete really everything the strings too deletegrouplist true allocgroups pwm num initial groups allocate some space for the new items allocentries pwm num initial entries cpwmanager newdatabase _deleteentrylist _deletegrouplist _allocgroups pwm_num_initial_groups _allocentries pwm_num_initial_entries int c pw manager open database const tchar psz file pwdb repair info p repair file fp char p virtual file unsigned long u file size u allocated u encrypted part size unsigned long pos pw dbheader hdr sha256 ctx sha32 rd uint8 u final key 32 char p char p start ushort us field type dword dw field size pw group pw group template pw entry pw entry template assert sizeof char 1 assert psz file null if psz file null return pwe invalid param assert psz file 0 0 if psz file 0 0 return pwe invalid param length 0 reset pwg template pw group template reset pwe template pw entry template if p repair null zero memory p repair sizeof pwdb repair info fp tfopen psz file t rb if fp null return pwe nofileaccess read get file size fseek fp 0 seek end u file size ftell fp fseek fp 0 seek set if u file size sizeof pw dbheader fclose fp return pwe invalid fileheader allocate enough memory to hold the complete file u allocated u file size 16 1 8 4 16 encryption buffer space 1 8 string terminating null utf 8 4 unused p virtual file new char u allocated if p virtual file null fclose fp return pwe no mem memset p virtual file u file size 17 1 0 1 8 fread p virtual file 1 u file size fp fclose fp extract header structure from memory file memcpy hdr p virtual file sizeof pw dbheader check if we can open this if hdr dw signature1 pwm dbsig 1 hdr dw signature2 pwm dbsig 2 opendb fail light return pwe invalid filesignature if hdr dw version 0xffffff00 pwm dbver dw 0xffffff00 if hdr dw version 0x00020000 hdr dw version 0x00020001 hdr dw version 0x00020002 if p virtual file null mem erase unsigned char p virtual file u allocated safe delete array p virtual file return opendatabasev2 psz file false pwe success pwe unknown else if hdr dw version 0x00010002 if p virtual file null mem erase unsigned char p virtual file u allocated safe delete array p virtual file return opendatabasev1 psz file false pwe success pwe unknown else assert false opendb fail select algorithm if hdr dw flags pwm flag rijndael 0 m nalgorithm algo aes else if hdr dw flags pwm flag twofish 0 m nalgorithm algo twofish else assert false opendb fail m dwkeyencrounds hdr dw key enc rounds generate m ptransformedmasterkey from m pmasterkey if transformmasterkey hdr a master seed2 false assert false opendb fail hash the master password with the salt in the file sha256 begin sha32 sha256 hash hdr a master seed 16 sha32 sha256 hash m ptransformedmasterkey 32 sha32 sha256 end unsigned char u final key sha32 if p repair null assert u file size sizeof pw dbheader 16 0 if u file size sizeof pw dbheader 16 0 opendb fail light return pwe invalid filesize else repair the database if u file size sizeof pw dbheader 16 0 u file size sizeof pw dbheader assert u file size 0xf 0 u file size 0xf u file size sizeof pw dbheader assert u file size sizeof pw dbheader 16 0 p repair dw original group count hdr dw groups p repair dw original entry count hdr dw entries if m nalgorithm algo aes rijndael aes initialize rijndael algorithm if aes init rijndael cbc rijndael decrypt u final key rijndael key32 bytes hdr a encryptioniv rijndael success opendb fail light return pwe crypt error decrypt the first bytes aren t encrypted that s the header u encrypted part size unsigned long aes pad decrypt rd uint8 p virtual file sizeof pw dbheader u file size sizeof pw dbheader rd uint8 p virtual file sizeof pw dbheader else if m nalgorithm algo twofish c twofish twofish if twofish init u final key 32 hdr a encryptioniv true opendb fail u encrypted part size unsigned long twofish pad decrypt rd uint8 p virtual file sizeof pw dbheader u file size sizeof pw dbheader rd uint8 p virtual file sizeof pw dbheader else assert false opendb fail this should never happen check for success if p repair null if u encrypted part size 2147483446 u encrypted part size 0 opendb fail light return pwe invalid key check if key is correct with very high probability if p repair null sha256 begin sha32 sha256 hash unsigned char p virtual file sizeof pw dbheader u encrypted part size sha32 sha256 end unsigned char u final key sha32 if memcmp hdr a contents hash u final key 32 0 opendb fail light return pwe invalid key new database create a new database and initialize internal structures add groups from the memory file to the internal structures unsigned long u cur group bool b ret pos sizeof pw dbheader p start p virtual file pos for u cur group 0 u cur group hdr dw groups p p virtual file pos if p repair null if is bad read ptr p 2 false opendb fail memcpy us field type p 2 p 2 pos 2 if pos u file size opendb fail if p repair null if is bad read ptr p 4 false opendb fail memcpy dw field size p 4 p 4 pos 4 if pos u file size dw field size opendb fail if p repair null if is bad read ptr p dw field size false opendb fail b ret read group field us field type dw field size byte p pw group template if us field type 0xffff b ret true u cur group now and only now the counter gets increased p dw field size if p p start opendb fail pos dw field size if pos u file size opendb fail safe delete array pw group template psz group name get the entries unsigned long u cur entry for u cur entry 0 u cur entry hdr dw entries p p virtual file pos if p repair null if is bad read ptr p 2 false opendb fail memcpy us field type p 2 p 2 pos 2 if pos u file size opendb fail if p repair null if is bad read ptr p 4 false opendb fail memcpy dw field size p 4 p 4 pos 4 if pos u file size dw field size opendb fail if p repair null if is bad read ptr p dw field size false opendb fail b ret read entry field us field type dw field size byte p pw entry template if us field type 0xffff b ret true u cur entry now and only now the counter gets increased p dw field size if p p start opendb fail pos dw field size if pos u file size opendb fail safe delete array pw entry template psz title safe delete array pw entry template pszurl safe delete array pw entry template psz user name safe delete array pw entry template psz password safe delete array pw entry template psz additional safe delete array pw entry template psz binary desc safe delete array pw entry template p binary data erase and delete memory file mem erase unsigned char p virtual file u allocated safe delete array p virtual file dword dw removed streams loadandremoveallmetastreams if p repair null p repair dw recognized meta stream count dw removed streams verify delete lost entries 0 fix group tree return pwe success cpwmanager opendatabase pszfile pwdb_repair_info prepair pvirtualfile ufilesize uallocated uencryptedpartsize pw_dbheader sha256_ctx rd_uint8 ufinalkey pstart usfieldtype dwfieldsize pw_group pwgrouptemplate pw_entry pwentrytemplate pszfile pszfile pwe_invalid_param pszfile pszfile pwe_invalid_param reset_pwg_template pwgrouptemplate reset_pwe_template pwentrytemplate prepair zeromemory prepair pwdb_repair_info _tfopen pszfile _t pwe_nofileaccess_read seek_end ufilesize seek_set ufilesize pw_dbheader pwe_invalid_fileheader uallocated ufilesize pvirtualfile uallocated pvirtualfile pwe_no_mem pvirtualfile ufilesize pvirtualfile ufilesize pvirtualfile pw_dbheader dwsignature1 pwm_dbsig_1 dwsignature2 pwm_dbsig_2 _opendb_fail_light pwe_invalid_filesignature dwversion pwm_dbver_dw dwversion dwversion dwversion pvirtualfile mem_erase pvirtualfile uallocated safe_delete_array pvirtualfile _opendatabasev2 pszfile pwe_success pwe_unknown dwversion pvirtualfile mem_erase pvirtualfile uallocated safe_delete_array pvirtualfile _opendatabasev1 pszfile pwe_success pwe_unknown _opendb_fail dwflags pwm_flag_rijndael m_nalgorithm algo_aes dwflags pwm_flag_twofish m_nalgorithm algo_twofish _opendb_fail m_dwkeyencrounds dwkeyencrounds m_ptransformedmasterkey m_pmasterkey _transformmasterkey amasterseed2 _opendb_fail sha256_begin sha256_hash amasterseed sha256_hash m_ptransformedmasterkey sha256_end ufinalkey prepair ufilesize pw_dbheader ufilesize pw_dbheader _opendb_fail_light pwe_invalid_filesize ufilesize pw_dbheader ufilesize pw_dbheader ufilesize ufilesize ufilesize pw_dbheader ufilesize pw_dbheader prepair dworiginalgroupcount dwgroups prepair dworiginalentrycount dwentries m_nalgorithm algo_aes ufinalkey key32bytes aencryptioniv rijndael_success _opendb_fail_light pwe_crypt_error uencryptedpartsize paddecrypt rd_uint8 pvirtualfile pw_dbheader ufilesize pw_dbheader rd_uint8 pvirtualfile pw_dbheader m_nalgorithm algo_twofish ctwofish ufinalkey aencryptioniv _opendb_fail uencryptedpartsize paddecrypt rd_uint8 pvirtualfile pw_dbheader ufilesize pw_dbheader rd_uint8 pvirtualfile pw_dbheader _opendb_fail prepair uencryptedpartsize uencryptedpartsize _opendb_fail_light pwe_invalid_key prepair sha256_begin sha256_hash pvirtualfile pw_dbheader uencryptedpartsize sha256_end ufinalkey acontentshash ufinalkey _opendb_fail_light pwe_invalid_key newdatabase ucurgroup bret pw_dbheader pstart pvirtualfile ucurgroup ucurgroup dwgroups pvirtualfile prepair isbadreadptr _opendb_fail usfieldtype ufilesize _opendb_fail prepair isbadreadptr _opendb_fail dwfieldsize ufilesize dwfieldsize _opendb_fail prepair isbadreadptr dwfieldsize _opendb_fail bret readgroupfield usfieldtype dwfieldsize pwgrouptemplate usfieldtype bret ucurgroup dwfieldsize pstart _opendb_fail dwfieldsize ufilesize _opendb_fail safe_delete_array pwgrouptemplate pszgroupname ucurentry ucurentry ucurentry dwentries pvirtualfile prepair isbadreadptr _opendb_fail usfieldtype ufilesize _opendb_fail prepair isbadreadptr _opendb_fail dwfieldsize ufilesize dwfieldsize _opendb_fail prepair isbadreadptr dwfieldsize _opendb_fail bret readentryfield usfieldtype dwfieldsize pwentrytemplate usfieldtype bret ucurentry dwfieldsize pstart _opendb_fail dwfieldsize ufilesize _opendb_fail safe_delete_array pwentrytemplate psztitle safe_delete_array pwentrytemplate safe_delete_array pwentrytemplate pszusername safe_delete_array pwentrytemplate pszpassword safe_delete_array pwentrytemplate pszadditional safe_delete_array pwentrytemplate pszbinarydesc safe_delete_array pwentrytemplate pbinarydata mem_erase pvirtualfile uallocated safe_delete_array pvirtualfile dwremovedstreams _loadandremoveallmetastreams prepair prepair dwrecognizedmetastreamcount dwremovedstreams deletelostentries fixgrouptree pwe_success int c pw manager save database const tchar psz file file fp char p virtual file unsigned long u file size u encrypted part size u allocated unsigned long i pos pw dbheader hdr rd uint8 u final key 32 sha256 ctx sha32 ushort us field type dword dw field size byte a compressed time 5 assert psz file null if psz file null return pwe invalid param assert tcslen psz file 0 if tcslen psz file 0 return pwe invalid param addallmetastreams u file size sizeof pw dbheader byte pbt assert sizeof tchar sizeof dword get the size of all groups for i 0 i m dwnumgroups i u file size 94 6 4 6 6 5 6 5 6 5 6 5 6 4 6 6 2 6 4 94 pbt stringtoutf8 m pgroups i psz group name u file size szlen char pbt 1 safe delete array pbt get the size of all entries together for i 0 i m dwnumentries i assert entry m pentries i unlock entry password m pentries i u file size 134 6 16 6 4 6 4 6 6 6 6 6 6 5 6 5 6 5 6 5 6 122 pbt stringtoutf8 m pentries i psz title u file size szlen char pbt 1 safe delete array pbt pbt stringtoutf8 m pentries i psz user name u file size szlen char pbt 1 safe delete array pbt pbt stringtoutf8 m pentries i pszurl u file size szlen char pbt 1 safe delete array pbt pbt stringtoutf8 m pentries i psz password u file size szlen char pbt 1 safe delete array pbt pbt stringtoutf8 m pentries i psz additional u file size szlen char pbt 1 safe delete array pbt pbt stringtoutf8 m pentries i psz binary desc u file size szlen char pbt 1 safe delete array pbt u file size m pentries i u binary data len lock entry password m pentries i round up filesize to 16 byte boundary for rijndael twofish u file size u file size 16 u file size 16 allocate enough memory u allocated u file size 16 p virtual file new char u allocated assert p virtual file null if p virtual file null loadandremoveallmetastreams return pwe no mem build header structure hdr dw signature1 pwm dbsig 1 hdr dw signature2 pwm dbsig 2 hdr dw flags pwm flag sha2 the one and only hash algorithm available currently if m nalgorithm algo aes hdr dw flags pwm flag rijndael else if m nalgorithm algo twofish hdr dw flags pwm flag twofish else assert false loadandremoveallmetastreams return pwe invalid param hdr dw version pwm dbver dw hdr dw groups m dwnumgroups hdr dw entries m dwnumentries hdr dw key enc rounds m dwkeyencrounds make up the master key hash seed and the encryption iv m random get random buffer hdr a master seed 16 m random get random buffer byte hdr a encryptioniv 16 m random get random buffer hdr a master seed2 32 skip the header it will be written later pos sizeof pw dbheader byte pb store all groups to memory file for i 0 i m dwnumgroups i us field type 0x0001 dw field size 4 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 memcpy p virtual file pos m pgroups i u group id 4 pos 4 pb stringtoutf8 m pgroups i psz group name us field type 0x0002 dw field size szlen char pb 1 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 assert pb null szlen char pb dw field size 1 pos dw field size u allocated szcpy p virtual file pos char pb pos dw field size safe delete array pb us field type 0x0003 dw field size 5 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 pwtimetotime m pgroups i t creation a compressed time memcpy p virtual file pos a compressed time 5 pos 5 us field type 0x0004 dw field size 5 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 pwtimetotime m pgroups i t last mod a compressed time memcpy p virtual file pos a compressed time 5 pos 5 us field type 0x0005 dw field size 5 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 pwtimetotime m pgroups i t last access a compressed time memcpy p virtual file pos a compressed time 5 pos 5 us field type 0x0006 dw field size 5 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 pwtimetotime m pgroups i t expire a compressed time memcpy p virtual file pos a compressed time 5 pos 5 us field type 0x0007 dw field size 4 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 memcpy p virtual file pos m pgroups i u image id 4 pos 4 us field type 0x0008 dw field size 2 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 memcpy p virtual file pos m pgroups i us level 2 pos 2 us field type 0x0009 dw field size 4 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 memcpy p virtual file pos m pgroups i dw flags 4 pos 4 us field type 0xffff dw field size 0 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 store all entries to memory file for i 0 i m dwnumentries i unlock entry password m pentries i us field type 0x0001 dw field size 16 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 memcpy p virtual file pos m pentries i uuid 16 pos 16 us field type 0x0002 dw field size 4 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 memcpy p virtual file pos m pentries i u group id 4 pos 4 us field type 0x0003 dw field size 4 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 memcpy p virtual file pos m pentries i u image id 4 pos 4 pb stringtoutf8 m pentries i psz title us field type 0x0004 dw field size szlen char pb 1 add terminating null character space memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 assert pb null szlen char pb dw field size 1 pos dw field size u allocated szcpy p virtual file pos char pb pos dw field size safe delete array pb pb stringtoutf8 m pentries i pszurl us field type 0x0005 dw field size szlen char pb 1 add terminating null character space memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 assert pb null szlen char pb dw field size 1 pos dw field size u allocated szcpy p virtual file pos char pb pos dw field size safe delete array pb pb stringtoutf8 m pentries i psz user name us field type 0x0006 dw field size szlen char pb 1 add terminating null character space memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 assert pb null szlen char pb dw field size 1 pos dw field size u allocated szcpy p virtual file pos char pb pos dw field size safe delete array pb pb stringtoutf8 m pentries i psz password us field type 0x0007 dw field size szlen char pb 1 add terminating null character space memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 assert pb null szlen char pb dw field size 1 pos dw field size u allocated szcpy p virtual file pos char pb pos dw field size if pb null mem erase unsigned char pb szlen char pb safe delete array pb pb stringtoutf8 m pentries i psz additional us field type 0x0008 dw field size szlen char pb 1 add terminating null character space memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 assert pb null szlen char pb dw field size 1 pos dw field size u allocated szcpy p virtual file pos char pb pos dw field size safe delete array pb us field type 0x0009 dw field size 5 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 pwtimetotime m pentries i t creation a compressed time memcpy p virtual file pos a compressed time 5 pos 5 us field type 0x000a dw field size 5 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 pwtimetotime m pentries i t last mod a compressed time memcpy p virtual file pos a compressed time 5 pos 5 us field type 0x000b dw field size 5 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 pwtimetotime m pentries i t last access a compressed time memcpy p virtual file pos a compressed time 5 pos 5 us field type 0x000c dw field size 5 memcpy p virtual file pos us field type 2 pos 2 memcpy p virtual file pos dw field size 4 pos 4 pwtimetotime m pentries i t expire a compressed time memcpy p virtual file pos a compressed time 5 pos 5 pb stringtoutf8 m pentries i psz binary desc us field type 0x000d dw field size szlen char pb 1 me cpwmanager savedatabase pszfile pvirtualfile ufilesize uencryptedpartsize uallocated pw_dbheader rd_uint8 ufinalkey sha256_ctx usfieldtype dwfieldsize acompressedtime pszfile pszfile pwe_invalid_param _tcslen pszfile _tcslen pszfile pwe_invalid_param _addallmetastreams ufilesize pw_dbheader m_dwnumgroups ufilesize _stringtoutf8 m_pgroups pszgroupname ufilesize safe_delete_array m_dwnumentries assert_entry m_pentries unlockentrypassword m_pentries ufilesize _stringtoutf8 m_pentries psztitle ufilesize safe_delete_array _stringtoutf8 m_pentries pszusername ufilesize safe_delete_array _stringtoutf8 m_pentries ufilesize safe_delete_array _stringtoutf8 m_pentries pszpassword ufilesize safe_delete_array _stringtoutf8 m_pentries pszadditional ufilesize safe_delete_array _stringtoutf8 m_pentries pszbinarydesc ufilesize safe_delete_array ufilesize m_pentries ubinarydatalen lockentrypassword m_pentries ufilesize ufilesize ufilesize uallocated ufilesize pvirtualfile uallocated pvirtualfile pvirtualfile _loadandremoveallmetastreams pwe_no_mem dwsignature1 pwm_dbsig_1 dwsignature2 pwm_dbsig_2 dwflags pwm_flag_sha2 m_nalgorithm algo_aes dwflags pwm_flag_rijndael m_nalgorithm algo_twofish dwflags pwm_flag_twofish _loadandremoveallmetastreams pwe_invalid_param dwversion pwm_dbver_dw dwgroups m_dwnumgroups dwentries m_dwnumentries dwkeyencrounds m_dwkeyencrounds m_random getrandombuffer amasterseed m_random getrandombuffer aencryptioniv m_random getrandombuffer amasterseed2 pw_dbheader m_dwnumgroups usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize pvirtualfile m_pgroups ugroupid _stringtoutf8 m_pgroups pszgroupname usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize dwfieldsize dwfieldsize uallocated pvirtualfile dwfieldsize safe_delete_array usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize _pwtimetotime m_pgroups tcreation acompressedtime pvirtualfile acompressedtime usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize _pwtimetotime m_pgroups tlastmod acompressedtime pvirtualfile acompressedtime usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize _pwtimetotime m_pgroups tlastaccess acompressedtime pvirtualfile acompressedtime usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize _pwtimetotime m_pgroups texpire acompressedtime pvirtualfile acompressedtime usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize pvirtualfile m_pgroups uimageid usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize pvirtualfile m_pgroups uslevel usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize pvirtualfile m_pgroups dwflags usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize m_dwnumentries unlockentrypassword m_pentries usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize pvirtualfile m_pentries usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize pvirtualfile m_pentries ugroupid usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize pvirtualfile m_pentries uimageid _stringtoutf8 m_pentries psztitle usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize dwfieldsize dwfieldsize uallocated pvirtualfile dwfieldsize safe_delete_array _stringtoutf8 m_pentries usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize dwfieldsize dwfieldsize uallocated pvirtualfile dwfieldsize safe_delete_array _stringtoutf8 m_pentries pszusername usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize dwfieldsize dwfieldsize uallocated pvirtualfile dwfieldsize safe_delete_array _stringtoutf8 m_pentries pszpassword usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize dwfieldsize dwfieldsize uallocated pvirtualfile dwfieldsize mem_erase safe_delete_array _stringtoutf8 m_pentries pszadditional usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize dwfieldsize dwfieldsize uallocated pvirtualfile dwfieldsize safe_delete_array usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize _pwtimetotime m_pentries tcreation acompressedtime pvirtualfile acompressedtime usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize _pwtimetotime m_pentries tlastmod acompressedtime pvirtualfile acompressedtime usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize _pwtimetotime m_pentries tlastaccess acompressedtime pvirtualfile acompressedtime usfieldtype dwfieldsize pvirtualfile usfieldtype pvirtualfile dwfieldsize _pwtimetotime m_pentries texpire acompressedtime pvirtualfile acompressedtime _stringtoutf8 m_pentries pszbinarydesc usfieldtype dwfieldsize void c pw manager move internal dword n from dword n to long i long dir pw entry pe if n from n to return if n from m dwnumentries return if n to m dwnumentries return set moving direction if n from n to dir 1 else dir 1 i long n from while 1 if i long n to break pe m pentries i m pentries i m pentries i dir m pentries i dir pe i dir cpwmanager moveinternal nfrom nto pw_entry nfrom nto nfrom m_dwnumentries nto m_dwnumentries nfrom nto nfrom nto m_pentries m_pentries m_pentries m_pentries void c pw manager move in group dword id group dword n from dword n to if n from m dwnumentries n from dword max return if n to m dwnumentries n to dword max return if n from n to return dword dw from ex get entry by groupn id group n from dword dw to ex get entry by groupn id group n to if dw from ex dword max dw to ex dword max return move internal dw from ex dw to ex cpwmanager moveingroup idgroup nfrom nto nfrom m_dwnumentries nfrom dword_max nto m_dwnumentries nto dword_max nfrom nto dwfromex getentrybygroupn idgroup nfrom dwtoex getentrybygroupn idgroup nto dwfromex dword_max dwtoex dword_max moveinternal dwfromex dwtoex bool c pw manager move group dword n from dword n to long i long dir pw group pg assert n from dword max n to dword max if n from n to true if n from m dwnumgroups return false if n to m dwnumgroups return false set moving direction if n from n to dir 1 else dir 1 i long n from while 1 if i long n to break pg m pgroups i m pgroups i m pgroups i dir m pgroups i dir pg i dir fix group tree return true cpwmanager movegroup nfrom nto pw_group nfrom dword_max nto dword_max nfrom nto nfrom m_dwnumgroups nto m_dwnumgroups nfrom nto nfrom nto m_pgroups m_pgroups m_pgroups m_pgroups fixgrouptree void c pw manager sort group dword id group dword dw sort by field ppw entry p pw entry v dword i j n 0 min t if m dwnumentries 1 return nothing to sort p new ppw entry m dwnumentries if p null return build pointer array that contains pointers to the elements to sort for i 0 i m dwnumentries i if m pentries i u group id id group p n m pentries i n if n 1 safe delete array p return something to sort sort the array using a simple selection sort for i 0 i n 1 i min i for j i 1 j n j switch dw sort by field case 0 if tcsicmp p j psz title p min psz title 0 min j break case 1 if tcsicmp p j psz user name p min psz user name 0 min j break case 2 if tcsicmp p j pszurl p min pszurl 0 min j break case 3 t min unlock entry password p j unlock entry password p t if tcsicmp p j psz password p min psz password 0 min j lock entry password p j lock entry password p t break case 4 if tcsicmp p j psz additional p min psz additional 0 min j break case 5 if pwtimecmp p j t creation p min t creation 0 min j break case 6 if pwtimecmp p j t last mod p min t last mod 0 min j break case 7 if pwtimecmp p j t last access p min t last access 0 min j break case 8 if pwtimecmp p j t expire p min t expire 0 min j break case 9 cannot sort by uuid break default assert false if tcsicmp p j psz title p min psz title 0 min j break v p min p min p i p i v safe delete array p cpwmanager sortgroup idgroup dwsortbyfield ppw_entry pw_entry m_dwnumentries ppw_entry m_dwnumentries m_dwnumentries m_pentries ugroupid idgroup m_pentries safe_delete_array dwsortbyfield _tcsicmp psztitle psztitle _tcsicmp pszusername pszusername _tcsicmp unlockentrypassword unlockentrypassword _tcsicmp pszpassword pszpassword lockentrypassword lockentrypassword _tcsicmp pszadditional pszadditional _pwtimecmp tcreation tcreation _pwtimecmp tlastmod tlastmod _pwtimecmp tlastaccess tlastaccess _pwtimecmp texpire texpire _tcsicmp psztitle psztitle safe_delete_array void c pw manager sort group list dword i j bool b swapped true ppw group p null lptstr p list null lptstr p parents null lptstr lp temp null lptstr lp null dword dw max string 0 ushort us max level 0 tchar tsz temp 16 dword dw pw group pwt if m dwnumgroups 1 return nothing to sort search list for longest group name and maximum level for i 0 i m dwnumgroups i j dword tcslen m pgroups i psz group name if j dw max string dw max string j if m pgroups i us level us max level us max level m pgroups i us level allocate pointer list to parent items p parents new lptstr us max level 2 assert p parents null if p parents null return calculate maximum length of the biggest fqgn fully qualified group name numchars base10 0xffffffff 10 char null char n char n 13 dw max string dw max string 1 us max level 1 13 p list new lptstr m dwnumgroups allocate fqgn list array of pointers assert p list null lp temp new tchar dw max string assert lp temp null build fqgn list for i 0 i m dwnumgroups i p list i new tchar dw max string assert p list i null if p list i null for j 0 j i j safe delete array p list j safe delete array p list safe delete array p parents safe delete array lp temp return failed too few memory available p list i 0 p m pgroups i assert p null if p us level 0 for j 0 j p us level j tcscat p list i p parents j tcscat p list i t n p parents p us level p psz group name tcscat p list i p psz group name tcscat p list i t n n ltot long p u group id tsz temp 10 tcscat p list i tsz temp assert tcslen p list i dw max string while b swapped true stable bubble sort on the group list b swapped false for i 0 i m dwnumgroups 1 i if tcsicmp p list i p list i 1 0 tcscpy lp temp p list i swap strings tcscpy p list i p list i 1 tcscpy p list i 1 lp temp b swapped true for i 0 i m dwnumgroups 1 i lp p list i tcslen p list i 1 while 1 if lp t n break lp lp dw dword ttol lp assert get group by id dw null for j i j m dwnumgroups j if m pgroups j u group id dw break pwt m pgroups i m pgroups i m pgroups j m pgroups j pwt for i 0 i m dwnumgroups i safe delete array p list i safe delete array p list safe delete array p parents safe delete array lp temp fix group tree cpwmanager sortgrouplist bswapped ppw_group plist pparents lptemp dwmaxstring usmaxlevel tsztemp pw_group m_dwnumgroups m_dwnumgroups _tcslen m_pgroups pszgroupname dwmaxstring dwmaxstring m_pgroups uslevel usmaxlevel usmaxlevel m_pgroups uslevel pparents usmaxlevel pparents pparents dwmaxstring dwmaxstring usmaxlevel plist m_dwnumgroups plist lptemp dwmaxstring lptemp m_dwnumgroups plist dwmaxstring plist plist safe_delete_array plist safe_delete_array plist safe_delete_array pparents safe_delete_array lptemp plist m_pgroups uslevel uslevel _tcscat plist pparents _tcscat plist _t pparents uslevel pszgroupname _tcscat plist pszgroupname _tcscat plist _t _ltot ugroupid tsztemp _tcscat plist tsztemp _tcslen plist dwmaxstring bswapped bswapped m_dwnumgroups _tcsicmp plist plist _tcscpy lptemp plist _tcscpy plist plist _tcscpy plist lptemp bswapped m_dwnumgroups plist _tcslen plist _t _ttol getgroupbyid m_dwnumgroups m_pgroups ugroupid m_pgroups m_pgroups m_pgroups m_pgroups m_dwnumgroups safe_delete_array plist safe_delete_array plist safe_delete_array pparents safe_delete_array lptemp fixgrouptree bool c pw manager mem alloc copy entry const pw entry p existing pw entry p destination assert entry p existing assert p destination null if p existing null p destination null return false zero memory p destination sizeof pw entry p destination u binary data len p existing u binary data len if p existing p binary data null p destination p binary data new byte p existing u binary data len 1 assert p destination p binary data null if p destination p binary data null return false p destination p binary data p existing u binary data len 0 memcpy p destination p binary data p existing p binary data p existing u binary data len p destination psz additional tcssafedupalloc p existing psz additional p destination psz binary desc tcssafedupalloc p existing psz binary desc p destination psz password tcssafedupalloc p existing psz password p destination psz title tcssafedupalloc p existing psz title p destination pszurl tcssafedupalloc p existing pszurl p destination psz user name tcssafedupalloc p existing psz user name p destination t creation p existing t creation p destination t expire p existing t expire p destination t last access p existing t last access p destination t last mod p existing t last mod p destination u group id p existing u group id p destination u image id p existing u image id p destination u password len p existing u password len memcpy p destination uuid p existing uuid 16 return true cpwmanager memalloccopyentry pw_entry pexisting pw_entry pdestination assert_entry pexisting pdestination pexisting pdestination zeromemory pdestination pw_entry pdestination ubinarydatalen pexisting ubinarydatalen pexisting pbinarydata pdestination pbinarydata pexisting ubinarydatalen pdestination pbinarydata pdestination pbinarydata pdestination pbinarydata pexisting ubinarydatalen pdestination pbinarydata pexisting pbinarydata pexisting ubinarydatalen pdestination pszadditional _tcssafedupalloc pexisting pszadditional pdestination pszbinarydesc _tcssafedupalloc pexisting pszbinarydesc pdestination pszpassword _tcssafedupalloc pexisting pszpassword pdestination psztitle _tcssafedupalloc pexisting psztitle pdestination _tcssafedupalloc pexisting pdestination pszusername _tcssafedupalloc pexisting pszusername pdestination tcreation pexisting tcreation pdestination texpire pexisting texpire pdestination tlastaccess pexisting tlastaccess pdestination tlastmod pexisting tlastmod pdestination ugroupid pexisting ugroupid pdestination uimageid pexisting uimageid pdestination upasswordlen pexisting upasswordlen pdestination pexisting void c pw manager mem free entry pw entry p entry assert entry p entry if p entry null return safe delete array p entry p binary data safe delete array p entry psz additional safe delete array p entry psz binary desc safe delete array p entry psz password safe delete array p entry psz title safe delete array p entry pszurl safe delete array p entry psz user name zero memory p entry sizeof pw entry cpwmanager memfreeentry pw_entry pentry assert_entry pentry pentry safe_delete_array pentry pbinarydata safe_delete_array pentry pszadditional safe_delete_array pentry pszbinarydesc safe_delete_array pentry pszpassword safe_delete_array pentry psztitle safe_delete_array pentry safe_delete_array pentry pszusername zeromemory pentry pw_entry void c pw manager merge in vpa modify c pw manager p data source bool b create newuui ds bool b compare times assert p data source null if p data source null return dword i dw modify index dw old id dw new id pw group pg this pg source pw entry pe this pe source pw time t now bool b do replace getcurrentpwtime t now for i 0 i p data source get number of groups i pg source p data source get group i assert pg source null if pg source null continue if b create newuui ds true while 1 dw old id pg source u group id pg source u group id 0 create new id verify add group pg source true dw new id get group get number of groups 1 u group id if p data source get group by id dw new id null p data source subst entry group ids dw old id dw new id break pg source u group id dw old id verify delete group by id dw new id true else b create newuui ds false dw modify index get group by idn pg source u group id if dw modify index dword max pg this get group dw modify index else pg this null if pg this null add group pg source group doesn t exist already else b do replace true if b compare times true if pwtimecmp pg this t last mod pg source t last mod 0 b do replace false if b do replace true verify set group dw modify index pg source true pg this get group dw modify index if pg this null pg this t last access t now fix group tree for i 0 i p data source get number of entries i pe source p data source get entry i assert pe source null if pe source null continue don t import meta streams if ismetastream pe source true continue p data source unlock entry password pe source if b create newuui ds true memset pe source uuid 0 16 verify add entry pe source true else dw modify index get entry by uuidn pe source uuid if dw modify index dword max pe this get entry dw modify index else pe this null if pe this null add entry pe source entry doesn t exist already else b do replace true if b compare times true if pwtimecmp pe this t last mod pe source t last mod 0 b do replace false if b do replace true verify set entry dw modify index pe source pe this get entry dw modify index if pe this null pe this t last access t now p data source lock entry password pe source verify delete lost entries 0 cpwmanager mergein vpa_modify cpwmanager pdatasource bcreatenewuuids bcomparetimes pdatasource pdatasource dwmodifyindex dwoldid dwnewid pw_group pgthis pgsource pw_entry pethis pesource pw_time tnow bdoreplace _getcurrentpwtime tnow pdatasource getnumberofgroups pgsource pdatasource getgroup pgsource pgsource bcreatenewuuids dwoldid pgsource ugroupid pgsource ugroupid addgroup pgsource dwnewid getgroup getnumberofgroups ugroupid pdatasource getgroupbyid dwnewid pdatasource substentrygroupids dwoldid dwnewid pgsource ugroupid dwoldid deletegroupbyid dwnewid bcreatenewuuids dwmodifyindex getgroupbyidn pgsource ugroupid dwmodifyindex dword_max pgthis getgroup dwmodifyindex pgthis pgthis addgroup pgsource bdoreplace bcomparetimes _pwtimecmp pgthis tlastmod pgsource tlastmod bdoreplace bdoreplace setgroup dwmodifyindex pgsource pgthis getgroup dwmodifyindex pgthis pgthis tlastaccess tnow fixgrouptree pdatasource getnumberofentries pesource pdatasource getentry pesource pesource _ismetastream pesource pdatasource unlockentrypassword pesource bcreatenewuuids pesource addentry pesource dwmodifyindex getentrybyuuidn pesource dwmodifyindex dword_max pethis getentry dwmodifyindex pethis pethis addentry pesource bdoreplace bcomparetimes _pwtimecmp pethis tlastmod pesource tlastmod bdoreplace bdoreplace setentry dwmodifyindex pesource pethis getentry dwmodifyindex pethis pethis tlastaccess tnow pdatasource lockentrypassword pesource deletelostentries dword c pw manager find const tchar psz find string bool b case sensitive dword field flags dword n start dword i c string str find c string str entry if n start int m dwnumentries return dword max assert psz find string null if psz find string null return dword max str find psz find string if b case sensitive false str find make lower if str find get length 0 str find t return n start for i n start i int m dwnumentries i if field flags pwmf title str entry m pentries i psz title if b case sensitive false str entry make lower if str entry find str find 1 return i if field flags pwmf user str entry m pentries i psz user name if b case sensitive false str entry make lower if str entry find str find 1 return i if field flags pwmf url str entry m pentries i pszurl if b case sensitive false str entry make lower if str entry find str find 1 return i if field flags pwmf password unlock entry password m pentries i str entry m pentries i psz password lock entry password m pentries i if b case sensitive false str entry make lower if str entry find str find 1 return i if field flags pwmf additional str entry m pentries i psz additional if b case sensitive false str entry make lower if str entry find str find 1 return i if field flags pwmf groupname dword dw group index get group by idn m pentries i u group id assert dw group index dword max str entry get group dw group index psz group name if b case sensitive false str entry make lower if str entry find str find 1 return i return dword max cpwmanager pszfindstring bcasesensitive fieldflags nstart cstring strfind cstring strentry nstart m_dwnumentries dword_max pszfindstring pszfindstring dword_max strfind pszfindstring bcasesensitive strfind makelower strfind getlength strfind _t nstart nstart m_dwnumentries fieldflags pwmf_title strentry m_pentries psztitle bcasesensitive strentry makelower strentry strfind fieldflags pwmf_user strentry m_pentries pszusername bcasesensitive strentry makelower strentry strfind fieldflags pwmf_url strentry m_pentries bcasesensitive strentry makelower strentry strfind fieldflags pwmf_password unlockentrypassword m_pentries strentry m_pentries pszpassword lockentrypassword m_pentries bcasesensitive strentry makelower strentry strfind fieldflags pwmf_additional strentry m_pentries pszadditional bcasesensitive strentry makelower strentry strfind fieldflags pwmf_groupname dwgroupindex getgroupbyidn m_pentries ugroupid dwgroupindex dword_max strentry getgroup dwgroupindex pszgroupname bcasesensitive strentry makelower strentry strfind dword_max bool c pw manager set algorithm int n algorithm assert n algorithm algo aes n algorithm algo twofish if n algorithm algo aes n algorithm algo twofish return false m nalgorithm n algorithm return true cpwmanager setalgorithm nalgorithm nalgorithm algo_aes nalgorithm algo_twofish nalgorithm algo_aes nalgorithm algo_twofish m_nalgorithm nalgorithm int c pw manager get algorithm return m nalgorithm cpwmanager getalgorithm m_nalgorithm dword c pw manager get key enc rounds return m dwkeyencrounds cpwmanager getkeyencrounds m_dwkeyencrounds void c pw manager set key enc rounds dword dw rounds all allowed except dword max if dw rounds dword max m dwkeyencrounds dword max 1 else m dwkeyencrounds dw rounds cpwmanager setkeyencrounds dwrounds dword_max dwrounds dword_max m_dwkeyencrounds dword_max m_dwkeyencrounds dwrounds void c pw manager timetopwtime const byte p compressed time pw time p pw time dword dw year dw month dw day dw hour dw minute dw second assert p compressed time null p pw time null if p pw time null return unpackstructtotime p compressed time dw year dw month dw day dw hour dw minute dw second p pw time sh year ushort dw year p pw time bt month byte dw month p pw time bt day byte dw day p pw time bt hour byte dw hour p pw time bt minute byte dw minute p pw time bt second byte dw second cpwmanager _timetopwtime pcompressedtime pw_time ppwtime dwyear dwmonth dwday dwhour dwminute dwsecond pcompressedtime ppwtime ppwtime _unpackstructtotime pcompressedtime dwyear dwmonth dwday dwhour dwminute dwsecond ppwtime shyear dwyear ppwtime btmonth dwmonth ppwtime btday dwday ppwtime bthour dwhour ppwtime btminute dwminute ppwtime btsecond dwsecond void c pw manager pwtimetotime const pw time p pw time byte p compressed time assert p pw time null p compressed time null if p pw time null return packtimetostruct p compressed time dword p pw time sh year dword p pw time bt month dword p pw time bt day dword p pw time bt hour dword p pw time bt minute dword p pw time bt second cpwmanager _pwtimetotime pw_time ppwtime pcompressedtime ppwtime pcompressedtime ppwtime _packtimetostruct pcompressedtime ppwtime shyear ppwtime btmonth ppwtime btday ppwtime bthour ppwtime btminute ppwtime btsecond void c pw manager getneverexpiretime pw time p pw time assert p pw time null if p pw time null return memcpy p pw time g pwtimenever sizeof pw time cpwmanager _getneverexpiretime pw_time ppwtime ppwtime ppwtime ppwtime g_pwtimenever pw_time void c pw manager fix group tree dword i ushort us last level 0 m pgroups 0 us level 0 first group must be root for i 0 i m dwnumgroups i if m pgroups i us level ushort us last level 1 m pgroups i us level ushort us last level 1 us last level m pgroups i us level cpwmanager fixgrouptree uslastlevel m_pgroups uslevel m_dwnumgroups m_pgroups uslevel uslastlevel m_pgroups uslevel uslastlevel uslastlevel m_pgroups uslevel int c pw manager delete lost entries dword i dw entry count bool b fixed true pw entry pe pw group pg int i deleted count 0 dw entry count get number of entries if dw entry count 0 return 0 while b fixed true b fixed false for i 0 i dw entry count i pe get entry i assert pe null if pe null break pg get group by id pe u group id if pg null delete entry i dw entry count b fixed true i deleted count break return i deleted count cpwmanager deletelostentries dwentrycount bfixed pw_entry pw_group ideletedcount dwentrycount getnumberofentries dwentrycount bfixed bfixed dwentrycount getentry getgroupbyid ugroupid deleteentry dwentrycount bfixed ideletedcount ideletedcount void c pw manager subst entry group ids dword dw existing id dword dw new id dword i assert dw existing id dword max assert dw new id dword max if dw existing id dw new id return nothing to do for i 0 i m dwnumentries i if m pentries i u group id dw existing id m pentries i u group id dw new id cpwmanager substentrygroupids dwexistingid dwnewid dwexistingid dword_max dwnewid dword_max dwexistingid dwnewid m_dwnumentries m_pentries ugroupid dwexistingid m_pentries ugroupid dwnewid bool c pw manager attach file as binary data pw entry p entry const tchar lp file file fp dword dw file len dword dw path len lptstr p binary desc dword i assert entry p entry if p entry null return false assert lp file null if lp file null return false fp tfopen lp file t rb if fp null return false fseek fp 0 seek end dw file len dword ftell fp fseek fp 0 seek set if dw file len 0 fclose fp fp null return false assert dw file len 0 safe delete array p entry psz binary desc safe delete array p entry p binary data i dword tcslen lp file 1 while 1 if i dword 1 break if lp file i lp file i break i p binary desc lptstr lp file i 1 dw path len dword tcslen p binary desc p entry psz binary desc new tchar dw path len 1 tcscpy p entry psz binary desc p binary desc p entry p binary data new byte dw file len fread p entry p binary data 1 dw file len fp p entry u binary data len dw file len fclose fp fp null return true cpwmanager attachfileasbinarydata pw_entry pentry lpfile dwfilelen dwpathlen pbinarydesc assert_entry pentry pentry lpfile lpfile _tfopen lpfile _t seek_end dwfilelen seek_set dwfilelen dwfilelen safe_delete_array pentry pszbinarydesc safe_delete_array pentry pbinarydata _tcslen lpfile lpfile lpfile pbinarydesc lpfile dwpathlen _tcslen pbinarydesc pentry pszbinarydesc dwpathlen _tcscpy pentry pszbinarydesc pbinarydesc pentry pbinarydata dwfilelen pentry pbinarydata dwfilelen pentry ubinarydatalen dwfilelen bool c pw manager save binary data const pw entry p entry const tchar lp file file fp assert entry p entry if p entry null return false assert lp file null if lp file null return false if tcslen p entry psz binary desc 0 return false fp tfopen lp file t wb if fp null return false if p entry u binary data len 0 fwrite p entry p binary data 1 p entry u binary data len fp fclose fp fp null return true cpwmanager savebinarydata pw_entry pentry lpfile assert_entry pentry pentry lpfile lpfile _tcslen pentry pszbinarydesc _tfopen lpfile _t pentry ubinarydatalen pentry pbinarydata pentry ubinarydatalen bool c pw manager remove binary data pw entry p entry assert entry p entry if p entry null return false safe delete array p entry p binary data safe delete array p entry psz binary desc p entry psz binary desc new tchar 1 p entry psz binary desc 0 0 p entry u binary data len 0 return true cpwmanager removebinarydata pw_entry pentry assert_entry pentry pentry safe_delete_array pentry pbinarydata safe_delete_array pentry pszbinarydesc pentry pszbinarydesc pentry pszbinarydesc pentry ubinarydatalen bool c pw manager is allowed store group lpctstr lp group name lpctstr lp search group name assert lp group name null if lp group name null return false if tcscmp lp group name lp search group name 0 return false return true cpwmanager isallowedstoregroup lpgroupname lpsearchgroupname lpgroupname lpgroupname _tcscmp lpgroupname lpsearchgroupname void c pw manager get raw master key byte p storage assert p storage null if p storage null return memcpy p storage m pmasterkey 32 cpwmanager getrawmasterkey pstorage pstorage pstorage pstorage m_pmasterkey void c pw manager set raw master key const byte p new key if p new key null memcpy m pmasterkey p new key 32 else memset m pmasterkey 0 32 cpwmanager setrawmasterkey pnewkey pnewkey m_pmasterkey pnewkey m_pmasterkey bool c pw manager is zerouuid const byte puuid if puuid null return true return memcmp puuid g uuidzero 16 0 true false cpwmanager iszerouuid g_uuidzero bool c pw manager read group field ushort us field type dword dw field size const byte p data pw group p group byte a compressed time 5 switch us field type case 0x0000 ignore field break case 0x0001 memcpy p group u group id p data 4 break case 0x0002 assert dw field size 0 safe delete array p group psz group name p group psz group name utf8tostring utf8 byte p data break case 0x0003 memcpy a compressed time p data 5 timetopwtime a compressed time p group t creation break case 0x0004 memcpy a compressed time p data 5 timetopwtime a compressed time p group t last mod break case 0x0005 memcpy a compressed time p data 5 timetopwtime a compressed time p group t last access break case 0x0006 memcpy a compressed time p data 5 timetopwtime a compressed time p group t expire break case 0x0007 memcpy p group u image id p data 4 break case 0x0008 memcpy p group us level p data 2 break case 0x0009 memcpy p group dw flags p data 4 break case 0xffff add group p group safe delete array p group psz group name reset pwg template p group break default return false field unsupported return true field supported cpwmanager readgroupfield usfieldtype dwfieldsize pdata pw_group pgroup acompressedtime usfieldtype pgroup ugroupid pdata dwfieldsize safe_delete_array pgroup pszgroupname pgroup pszgroupname _utf8tostring utf8_byte pdata acompressedtime pdata _timetopwtime acompressedtime pgroup tcreation acompressedtime pdata _timetopwtime acompressedtime pgroup tlastmod acompressedtime pdata _timetopwtime acompressedtime pgroup tlastaccess acompressedtime pdata _timetopwtime acompressedtime pgroup texpire pgroup uimageid pdata pgroup uslevel pdata pgroup dwflags pdata addgroup pgroup safe_delete_array pgroup pszgroupname reset_pwg_template pgroup bool c pw manager read entry field ushort us field type dword dw field size const byte p data pw entry p entry byte a compressed time 5 switch us field type case 0x0000 ignore field break case 0x0001 memcpy p entry uuid p data 16 break case 0x0002 memcpy p entry u group id p data 4 break case 0x0003 memcpy p entry u image id p data 4 break case 0x0004 assert dw field size 0 safe delete array p entry psz title p entry psz title utf8tostring utf8 byte p data break case 0x0005 assert dw field size 0 safe delete array p entry pszurl p entry pszurl utf8tostring utf8 byte p data break case 0x0006 assert dw field size 0 safe delete array p entry psz user name p entry psz user name utf8tostring utf8 byte p data break case 0x0007 assert dw field size 0 if p entry psz password null mem erase unsigned char p entry psz password tcslen p entry psz password sizeof tchar safe delete array p entry psz password p entry psz password utf8tostring utf8 byte p data break case 0x0008 assert dw field size 0 safe delete array p entry psz additional p entry psz additional utf8tostring utf8 byte p data break case 0x0009 assert dw field size 5 memcpy a compressed time p data 5 timetopwtime a compressed time p entry t creation break case 0x000a assert dw field size 5 memcpy a compressed time p data 5 timetopwtime a compressed time p entry t last mod break case 0x000b assert dw field size 5 memcpy a compressed time p data 5 timetopwtime a compressed time p entry t last access break case 0x000c assert dw field size 5 memcpy a compressed time p data 5 timetopwtime a compressed time p entry t expire break case 0x000d assert dw field size 0 safe delete array p entry psz binary desc p entry psz binary desc utf8tostring utf8 byte p data break case 0x000e safe delete array p entry p binary data if dw field size 0 p entry p binary data new byte dw field size memcpy p entry p binary data p data dw field size p entry u binary data len dw field size break case 0xffff assert dw field size 0 add entry p entry safe delete array p entry psz title safe delete array p entry pszurl safe delete array p entry psz user name if p entry psz password null mem erase unsigned char p entry psz password tcslen p entry psz password sizeof tchar safe delete array p entry psz password safe delete array p entry psz additional safe delete array p entry psz binary desc safe delete array p entry p binary data reset pwe template p entry break default return false field unsupported return true field processed cpwmanager readentryfield usfieldtype dwfieldsize pdata pw_entry pentry acompressedtime usfieldtype pentry pdata pentry ugroupid pdata pentry uimageid pdata dwfieldsize safe_delete_array pentry psztitle pentry psztitle _utf8tostring utf8_byte pdata dwfieldsize safe_delete_array pentry pentry _utf8tostring utf8_byte pdata dwfieldsize safe_delete_array pentry pszusername pentry pszusername _utf8tostring utf8_byte pdata dwfieldsize pentry pszpassword mem_erase pentry pszpassword _tcslen pentry pszpassword safe_delete_array pentry pszpassword pentry pszpassword _utf8tostring utf8_byte pdata dwfieldsize safe_delete_array pentry pszadditional pentry pszadditional _utf8tostring utf8_byte pdata dwfieldsize acompressedtime pdata _timetopwtime acompressedtime pentry tcreation dwfieldsize acompressedtime pdata _timetopwtime acompressedtime pentry tlastmod dwfieldsize acompressedtime pdata _timetopwtime acompressedtime pentry tlastaccess dwfieldsize acompressedtime pdata _timetopwtime acompressedtime pentry texpire dwfieldsize safe_delete_array pentry pszbinarydesc pentry pszbinarydesc _utf8tostring utf8_byte pdata safe_delete_array pentry pbinarydata dwfieldsize pentry pbinarydata dwfieldsize pentry pbinarydata pdata dwfieldsize pentry ubinarydatalen dwfieldsize dwfieldsize addentry pentry safe_delete_array pentry psztitle safe_delete_array pentry safe_delete_array pentry pszusername pentry pszpassword mem_erase pentry pszpassword _tcslen pentry pszpassword safe_delete_array pentry pszpassword safe_delete_array pentry pszadditional safe_delete_array pentry pszbinarydesc safe_delete_array pentry pbinarydata reset_pwe_template pentry void c pw manager allocentries dword u entries pw entry p dword dw entries assert u entries 0 u entries dword max if u entries 0 return dw entries m dwnumentries if we already have allocated enough entries just return if u entries m dwmaxentries return p new pw entry u entries if p null assert false return memset p 0 sizeof pw entry u entries if m dwnumentries 0 m pentries null memcpy p m pentries sizeof pw entry m dwnumentries deleteentrylist false m dwnumentries dw entries m dwmaxentries u entries m pentries p cpwmanager _allocentries uentries pw_entry dwentries uentries uentries dword_max uentries dwentries m_dwnumentries uentries m_dwmaxentries pw_entry uentries pw_entry uentries m_dwnumentries m_pentries m_pentries pw_entry m_dwnumentries _deleteentrylist m_dwnumentries dwentries m_dwmaxentries uentries m_pentries void c pw manager deleteentrylist bool b free strings unsigned long u current entry if m pentries null return nothing to delete if b free strings true for u current entry 0 u current entry m dwnumentries u current entry safe delete array m pentries u current entry psz title safe delete array m pentries u current entry pszurl safe delete array m pentries u current entry psz user name safe delete array m pentries u current entry psz password safe delete array m pentries u current entry psz additional safe delete array m pentries u current entry psz binary desc safe delete array m pentries u current entry p binary data if m dwnumentries 0 erase all data mem erase unsigned char m pentries sizeof pw entry m dwnumentries safe delete array m pentries m dwnumentries 0 m dwmaxentries 0 cpwmanager _deleteentrylist bfreestrings ucurrententry m_pentries bfreestrings ucurrententry ucurrententry m_dwnumentries ucurrententry safe_delete_array m_pentries ucurrententry psztitle safe_delete_array m_pentries ucurrententry safe_delete_array m_pentries ucurrententry pszusername safe_delete_array m_pentries ucurrententry pszpassword safe_delete_array m_pentries ucurrententry pszadditional safe_delete_array m_pentries ucurrententry pszbinarydesc safe_delete_array m_pentries ucurrententry pbinarydata m_dwnumentries mem_erase m_pentries pw_entry m_dwnumentries safe_delete_array m_pentries m_dwnumentries m_dwmaxentries void c pw manager allocgroups dword u groups pw group p dword dw groups assert u groups 0 u groups dword max if u groups 0 u groups dword max return dw groups m dwnumgroups if we already have allocated enough entries just return if u groups m dwmaxgroups return p new pw group u groups if p null assert false return memset p 0 sizeof pw group u groups if m dwnumgroups 0 m pgroups null memcpy p m pgroups sizeof pw group m dwnumgroups deletegrouplist false m dwnumgroups dw groups m dwmaxgroups u groups m pgroups p cpwmanager _allocgroups ugroups pw_group dwgroups ugroups ugroups dword_max ugroups ugroups dword_max dwgroups m_dwnumgroups ugroups m_dwmaxgroups pw_group ugroups pw_group ugroups m_dwnumgroups m_pgroups m_pgroups pw_group m_dwnumgroups _deletegrouplist m_dwnumgroups dwgroups m_dwmaxgroups ugroups m_pgroups void c pw manager deletegrouplist bool b free strings unsigned long u current group if m pgroups null return nothing to delete if b free strings true for u current group 0 u current group m dwnumgroups u current group safe delete array m pgroups u current group psz group name if m dwnumgroups 0 mem erase unsigned char m pgroups sizeof pw group m dwnumgroups safe delete array m pgroups m dwnumgroups 0 m dwmaxgroups 0 cpwmanager _deletegrouplist bfreestrings ucurrentgroup m_pgroups bfreestrings ucurrentgroup ucurrentgroup m_dwnumgroups ucurrentgroup safe_delete_array m_pgroups ucurrentgroup pszgroupname m_dwnumgroups mem_erase m_pgroups pw_group m_dwnumgroups safe_delete_array m_pgroups m_dwnumgroups m_dwmaxgroups bool c pw manager addallmetastreams pms simple ui state simp state bool b true memset simp state 0 sizeof pms simple ui state simp state u last selected group id m dwlastselectedgroupid simp state u last top visible group id m dwlasttopvisiblegroupid memcpy simp state a last selected entry uuid m alastselectedentryuuid 16 memcpy simp state a last top visible entry uuid m alasttopvisibleentryuuid 16 b addmetastream pms stream simplestate byte simp state sizeof pms simple ui state assert b true return b cpwmanager _addallmetastreams pms_simple_ui_state simpstate simpstate pms_simple_ui_state simpstate ulastselectedgroupid m_dwlastselectedgroupid simpstate ulasttopvisiblegroupid m_dwlasttopvisiblegroupid simpstate alastselectedentryuuid m_alastselectedentryuuid simpstate alasttopvisibleentryuuid m_alasttopvisibleentryuuid _addmetastream pms_stream_simplestate simpstate pms_simple_ui_state dword c pw manager loadandremoveallmetastreams bool b change true dword i dword dw entry count pw entry p dword dw meta stream count 0 if m pentries null return 0 if m pgroups null return 0 if get number of entries 0 return 0 if get number of groups 0 return 0 while b change true b change false dw entry count get number of entries if dw entry count 0 break i dw entry count 1 while 1 p get entry i if ismetastream p true parsemetastream p verify delete entry i dw meta stream count b change true break if i 0 break i return dw meta stream count cpwmanager _loadandremoveallmetastreams bchange dwentrycount pw_entry dwmetastreamcount m_pentries m_pgroups getnumberofentries getnumberofgroups bchange bchange dwentrycount getnumberofentries dwentrycount dwentrycount getentry _ismetastream _parsemetastream deleteentry dwmetastreamcount bchange dwmetastreamcount bool c pw manager addmetastream lpctstr lp meta data desc byte p data dword dw length pw entry pe assert lp meta data desc null assert tcslen lp meta data desc 0 assert p data null if p data null return false assert dw length 0 if dw length 0 return true memset pe 0 sizeof pw entry pe p binary data p data pe psz additional tchar lp meta data desc pe psz binary desc pms id bindesc pe psz password t pe psz title pms id title pe pszurl pms id url pe psz user name pms id user pe t creation g pwtimenever pe t expire g pwtimenever pe t last access g pwtimenever pe t last mod g pwtimenever pe u binary data len dw length if get number of groups 0 pe u group id m pgroups 0 u group id return add entry pe cpwmanager _addmetastream lpmetadatadesc pdata dwlength pw_entry lpmetadatadesc _tcslen lpmetadatadesc pdata pdata dwlength dwlength pw_entry pbinarydata pdata pszadditional lpmetadatadesc pszbinarydesc pms_id_bindesc pszpassword _t psztitle pms_id_title pms_id_url pszusername pms_id_user tcreation g_pwtimenever texpire g_pwtimenever tlastaccess g_pwtimenever tlastmod g_pwtimenever ubinarydatalen dwlength getnumberofgroups ugroupid m_pgroups ugroupid addentry bool c pw manager ismetastream const pw entry p assert entry p if p null return false if p p binary data null return false if p psz additional null return false if p psz binary desc null return false if tcscmp p psz binary desc pms id bindesc 0 return false if p psz title null return false if tcscmp p psz title pms id title 0 return false if p psz user name null return false if tcscmp p psz user name pms id user 0 return false if p pszurl null return false if tcscmp p pszurl pms id url 0 return false if p u image id 0 return false return true cpwmanager _ismetastream pw_entry assert_entry pbinarydata pszadditional pszbinarydesc _tcscmp pszbinarydesc pms_id_bindesc psztitle _tcscmp psztitle pms_id_title pszusername _tcscmp pszusername pms_id_user _tcscmp pms_id_url uimageid void c pw manager parsemetastream pw entry p pms simple ui state p state assert ismetastream p true if tcscmp p psz additional pms stream simplestate 0 p state pms simple ui state p p binary data if p u binary data len 4 length checks for backwards compatibility m dwlastselectedgroupid p state u last selected group id if p u binary data len 8 m dwlasttopvisiblegroupid p state u last top visible group id if p u binary data len 24 memcpy m alastselectedentryuuid p state a last selected entry uuid 16 if p u binary data len 40 memcpy m alasttopvisibleentryuuid p state a last top visible entry uuid 16 cpwmanager _parsemetastream pw_entry pms_simple_ui_state pstate _ismetastream _tcscmp pszadditional pms_stream_simplestate pstate pms_simple_ui_state pbinarydata ubinarydatalen m_dwlastselectedgroupid pstate ulastselectedgroupid ubinarydatalen m_dwlasttopvisiblegroupid pstate ulasttopvisiblegroupid ubinarydatalen m_alastselectedentryuuid pstate alastselectedentryuuid ubinarydatalen m_alasttopvisibleentryuuid pstate alasttopvisibleentryuuid bool c pw manager transformmasterkey const byte p key seed rijndael rijndael rd uint8 a key 32 rd uint8 a test 16 rd uint8 a ref 16 the rijndael class will be tested that s the expected ciphertext 0x8e 0xa2 0xb7 0xca 0x51 0x67 0x45 0xbf 0xea 0xfc 0x49 0x90 0x4b 0x49 0x60 0x89 dword i sha256 ctx sha2 assert p key seed null if p key seed null return false if rijndael init rijndael ecb rijndael encrypt const rd uint8 p key seed rijndael key32 bytes 0 rijndael success return false memcpy m ptransformedmasterkey m pmasterkey 32 for i 0 i m dwkeyencrounds i rijndael block encrypt const rd uint8 m ptransformedmasterkey 256 rd uint8 m ptransformedmasterkey do a quick test if the rijndael class worked correctly for i 0 i 32 i a key i rd uint8 i for i 0 i 16 i a test i rd uint8 rd uint8 i 4 rd uint8 i if rijndael init rijndael ecb rijndael encrypt a key rijndael key32 bytes null rijndael success assert false return false if rijndael block encrypt a test 128 a test 128 assert false if memcmp a test a ref 16 0 assert false return false hash once with sha 256 sha256 begin sha2 sha256 hash m ptransformedmasterkey 32 sha2 sha256 end m ptransformedmasterkey sha2 return true cpwmanager _transformmasterkey pkeyseed rd_uint8 akey rd_uint8 atest rd_uint8 aref sha256_ctx pkeyseed pkeyseed rd_uint8 pkeyseed key32bytes rijndael_success m_ptransformedmasterkey m_pmasterkey m_dwkeyencrounds blockencrypt rd_uint8 m_ptransformedmasterkey rd_uint8 m_ptransformedmasterkey akey rd_uint8 atest rd_uint8 rd_uint8 rd_uint8 akey key32bytes rijndael_success blockencrypt atest atest atest aref sha256_begin sha256_hash m_ptransformedmasterkey sha256_end m_ptransformedmasterkey bool c pw manager opendatabasev1 const tchar psz file file fp char p virtual file unsigned long u file size u allocated u encrypted part size unsigned long i j pos pw dbheader v1 hdr sha256 ctx sha32 rd uint8 u final key 32 dword dw dw2 char ptr temp char ptr title char ptr user name char ptrurl char ptr password char ptr additional pw time t now pw group pwtg pw entry pwte getcurrentpwtime t now memset pwtg 0 sizeof pw group memset pwte 0 sizeof pw entry pwtg t creation t now pwtg t expire g pwtimenever pwtg t last access t now pwtg t last mod t now pwte t creation t now pwte t expire g pwtimenever pwte t last access t now pwte t last mod t now assert sizeof char 1 assert psz file null if psz file null return false assert tcslen psz file 0 if tcslen psz file 0 return false fp tfopen psz file t rb if fp null return false get file size fseek fp 0 seek end u file size ftell fp fseek fp 0 seek set if u file size sizeof pw dbheader v1 fclose fp return false allocate enough memory to hold the complete file u allocated u file size 17 p virtual file new char u allocated if p virtual file null fclose fp return false p virtual file u file size 17 1 0 fread p virtual file 1 u file size fp fclose fp extract header structure from memory file memcpy hdr p virtual file sizeof pw dbheader v1 check if we can open this if hdr dw signature1 pwm dbsig 1 hdr dw signature2 pwm dbsig 2 opendb fail if hdr dw flags pwm flag rijndael m nalgorithm algo aes else if hdr dw flags pwm flag twofish m nalgorithm algo twofish else assert false opendb fail hash the master password with the salt in the file sha256 begin sha32 sha256 hash hdr a master seed 16 sha32 sha256 hash m pmasterkey 32 sha32 sha256 end unsigned char u final key sha32 if m nalgorithm algo aes rijndael aes initialize rijndael algorithm if aes init rijndael cbc rijndael decrypt u final key rijndael key32 bytes hdr a encryptioniv rijndael success opendb fail decrypt the first 48 bytes aren t encrypted that s the header u encrypted part size unsigned long aes pad decrypt rd uint8 p virtual file 48 u file size 48 rd uint8 p virtual file 48 else if m nalgorithm algo twofish c twofish twofish if twofish init u final key 32 hdr a encryptioniv true opendb fail u encrypted part size unsigned long twofish pad decrypt rd uint8 p virtual file 48 u file size 48 rd uint8 p virtual file 48 else assert false opendb fail check for success if u encrypted part size 2147483446 u encrypted part size 0 opendb fail update header information it was partially encrypted memcpy hdr p virtual file sizeof pw dbheader v1 new database create a new database and initialize internal structures add groups from the memory file to the internal structures j 0 pos sizeof pw dbheader v1 for i 0 i hdr dw groups i ptr temp p virtual file pos j strlen ptr temp pos j 1 if pos u file size opendb fail memcpy dw p virtual file pos sizeof dword pos 4 if pos u file size opendb fail pwtg u group id i 1 pwtg u image id dw ifdef unicode lptstr lpptr stringtounicode ptr temp pwtg psz group name lpptr pwtg us level 0 add group pwtg safe delete array lpptr else pwtg psz group name ptr temp add group pwtg endif get the entries for i 0 i hdr dw entries i if pos u file size opendb fail ptr title p virtual file pos j strlen ptr title pos j 1 if pos u file size opendb fail ptr user name p virtual file pos j strlen ptr user name pos j 1 if pos u file size opendb fail ptrurl p virtual file pos j strlen ptrurl pos j 1 if pos u file size opendb fail ptr password p virtual file pos j strlen ptr password pos j 1 if pos u file size opendb fail ptr additional p virtual file pos j strlen ptr additional pos j 1 if pos u file size opendb fail memcpy dw p virtual file pos sizeof dword pos 4 if pos u file size opendb fail memcpy dw2 p virtual file pos sizeof dword pos 4 if pos u file size opendb fail dw increase group id to be compatible with i 1 group id importing zero memory pwte uuid 16 0 create new uuid ifdef unicode lptstr lpt title stringtounicode ptr title lptstr lpturl stringtounicode ptrurl lptstr lpt user name stringtounicode ptr user name lptstr lpt password stringtounicode ptr password lptstr lpt additional stringtounicode ptr additional pwte psz additional lpt additional pwte psz password lpt password pwte psz title lpt title pwte pszurl lpturl pwte psz user name lpt user name pwte u group id dw pwte u image id dw2 add entry pwte safe delete array lpt title safe delete array lpturl safe delete array lpt user name safe delete array lpt password safe delete array lpt additional else pwte psz additional ptr additional pwte psz password ptr password pwte psz title ptr title pwte pszurl ptrurl pwte psz user name ptr user name pwte u group id dw pwte u image id dw2 add entry pwte endif erase and delete memory file mem erase unsigned char p virtual file u allocated safe delete array p virtual file return true cpwmanager _opendatabasev1 pszfile pvirtualfile ufilesize uallocated uencryptedpartsize pw_dbheader_v1 sha256_ctx rd_uint8 ufinalkey ptrtemp ptrtitle ptrusername ptrpassword ptradditional pw_time tnow pw_group pw_entry _getcurrentpwtime tnow pw_group pw_entry tcreation tnow texpire g_pwtimenever tlastaccess tnow tlastmod tnow tcreation tnow texpire g_pwtimenever tlastaccess tnow tlastmod tnow pszfile pszfile _tcslen pszfile _tcslen pszfile _tfopen pszfile _t seek_end ufilesize seek_set ufilesize pw_dbheader_v1 uallocated ufilesize pvirtualfile uallocated pvirtualfile pvirtualfile ufilesize pvirtualfile ufilesize pvirtualfile pw_dbheader_v1 dwsignature1 pwm_dbsig_1 dwsignature2 pwm_dbsig_2 _opendb_fail dwflags pwm_flag_rijndael m_nalgorithm algo_aes dwflags pwm_flag_twofish m_nalgorithm algo_twofish _opendb_fail sha256_begin sha256_hash amasterseed sha256_hash m_pmasterkey sha256_end ufinalkey m_nalgorithm algo_aes ufinalkey key32bytes aencryptioniv rijndael_success _opendb_fail uencryptedpartsize paddecrypt rd_uint8 pvirtualfile ufilesize rd_uint8 pvirtualfile m_nalgorithm algo_twofish ctwofish ufinalkey aencryptioniv _opendb_fail uencryptedpartsize paddecrypt rd_uint8 pvirtualfile ufilesize rd_uint8 pvirtualfile _opendb_fail uencryptedpartsize uencryptedpartsize _opendb_fail pvirtualfile pw_dbheader_v1 newdatabase pw_dbheader_v1 dwgroups ptrtemp pvirtualfile ptrtemp ufilesize _opendb_fail pvirtualfile ufilesize _opendb_fail ugroupid uimageid _unicode _stringtounicode ptrtemp pszgroupname uslevel addgroup safe_delete_array pszgroupname ptrtemp addgroup dwentries ufilesize _opendb_fail ptrtitle pvirtualfile ptrtitle ufilesize _opendb_fail ptrusername pvirtualfile ptrusername ufilesize _opendb_fail pvirtualfile ufilesize _opendb_fail ptrpassword pvirtualfile ptrpassword ufilesize _opendb_fail ptradditional pvirtualfile ptradditional ufilesize _opendb_fail pvirtualfile ufilesize _opendb_fail pvirtualfile ufilesize _opendb_fail zeromemory _unicode lpttitle _stringtounicode ptrtitle _stringtounicode lptusername _stringtounicode ptrusername lptpassword _stringtounicode ptrpassword lptadditional _stringtounicode ptradditional pszadditional lptadditional pszpassword lptpassword psztitle lpttitle pszusername lptusername ugroupid uimageid addentry safe_delete_array lpttitle safe_delete_array safe_delete_array lptusername safe_delete_array lptpassword safe_delete_array lptadditional pszadditional ptradditional pszpassword ptrpassword psztitle ptrtitle pszusername ptrusername ugroupid uimageid addentry mem_erase pvirtualfile uallocated safe_delete_array pvirtualfile bool c pw manager opendatabasev2 const tchar psz file file fp char p virtual file unsigned long u file size u allocated u encrypted part size unsigned long pos pw dbheader v2 hdr sha256 ctx sha32 rd uint8 u final key 32 c string str title str user name strurl str password str notes char p ushort us field type dword dw field size pw group pw group template pw entry pw entry template assert sizeof char 1 assert psz file null if psz file null return false assert tcslen psz file 0 if tcslen psz file 0 return false fp tfopen psz file t rb if fp null return false get file size fseek fp 0 seek end u file size ftell fp fseek fp 0 seek set if u file size sizeof pw dbheader v2 fclose fp return false allocate enough memory to hold the complete file u allocated u file size 17 p virtual file new char u allocated if p virtual file null fclose fp return false p virtual file u file size 17 1 0 fread p virtual file 1 u file size fp fclose fp extract header structure from memory file memcpy hdr p virtual file sizeof pw dbheader v2 check if we can open this if hdr dw signature1 pwm dbsig 1 hdr dw signature2 pwm dbsig 2 opendb fail if hdr dw flags pwm flag rijndael m nalgorithm algo aes else if hdr dw flags pwm flag twofish m nalgorithm algo twofish else assert false opendb fail hash the master password with the salt in the file sha256 begin sha32 sha256 hash hdr a master seed 16 sha32 sha256 hash m pmasterkey 32 sha32 sha256 end unsigned char u final key sha32 assert u file size sizeof pw dbheader v2 16 0 if m nalgorithm algo aes rijndael aes initialize rijndael algorithm if aes init rijndael cbc rijndael decrypt u final key rijndael key32 bytes hdr a encryptioniv rijndael success opendb fail decrypt the first bytes aren t encrypted that s the header u encrypted part size unsigned long aes pad decrypt rd uint8 p virtual file sizeof pw dbheader v2 u file size sizeof pw dbheader v2 rd uint8 p virtual file sizeof pw dbheader v2 else if m nalgorithm algo twofish c twofish twofish if twofish init u final key 32 hdr a encryptioniv true opendb fail u encrypted part size unsigned long twofish pad decrypt rd uint8 p virtual file sizeof pw dbheader v2 u file size sizeof pw dbheader v2 rd uint8 p virtual file sizeof pw dbheader v2 else assert false opendb fail this should never happen check for success if u encrypted part size 2147483446 u encrypted part size 0 opendb fail check if key is correct with high probability sha256 begin sha32 sha256 hash unsigned char p virtual file sizeof pw dbheader v2 u encrypted part size sha32 sha256 end unsigned char u final key sha32 if memcmp hdr a contents hash u final key 32 0 opendb fail new database create a new database and initialize internal structures memset pw group template 0 16 reset pwg template pw group template add groups from the memory file to the internal structures unsigned long u cur group bool b ret pos sizeof pw dbheader v2 for u cur group 0 u cur group hdr dw groups p p virtual file pos memcpy us field type p 2 p 2 pos 2 if pos u file size opendb fail memcpy dw field size p 4 p 4 pos 4 if pos u file size dw field size opendb fail b ret readgroupfieldv2 us field type dw field size byte p pw group template if us field type 0xffff b ret true u cur group now and only now the counter gets increased p dw field size pos dw field size if pos u file size opendb fail safe delete array pw group template psz group name reset pwe template pw entry template get the entries unsigned long u cur entry for u cur entry 0 u cur entry hdr dw entries p p virtual file pos memcpy us field type p 2 p 2 pos 2 if pos u file size opendb fail memcpy dw field size p 4 p 4 pos 4 if pos u file size dw field size opendb fail b ret readentryfieldv2 us field type dw field size byte p pw entry template if us field type 0xffff b ret true u cur entry now and only now the counter gets increased p dw field size pos dw field size if pos u file size opendb fail safe delete array pw entry template psz title safe delete array pw entry template pszurl safe delete array pw entry template psz user name safe delete array pw entry template psz password safe delete array pw entry template psz additional safe delete array pw entry template psz binary desc safe delete array pw entry template p binary data erase and delete memory file mem erase unsigned char p virtual file u allocated safe delete array p virtual file return true cpwmanager _opendatabasev2 pszfile pvirtualfile ufilesize uallocated uencryptedpartsize pw_dbheader_v2 sha256_ctx rd_uint8 ufinalkey cstring strtitle strusername strpassword strnotes usfieldtype dwfieldsize pw_group pwgrouptemplate pw_entry pwentrytemplate pszfile pszfile _tcslen pszfile _tcslen pszfile _tfopen pszfile _t seek_end ufilesize seek_set ufilesize pw_dbheader_v2 uallocated ufilesize pvirtualfile uallocated pvirtualfile pvirtualfile ufilesize pvirtualfile ufilesize pvirtualfile pw_dbheader_v2 dwsignature1 pwm_dbsig_1 dwsignature2 pwm_dbsig_2 _opendb_fail dwflags pwm_flag_rijndael m_nalgorithm algo_aes dwflags pwm_flag_twofish m_nalgorithm algo_twofish _opendb_fail sha256_begin sha256_hash amasterseed sha256_hash m_pmasterkey sha256_end ufinalkey ufilesize pw_dbheader_v2 m_nalgorithm algo_aes ufinalkey key32bytes aencryptioniv rijndael_success _opendb_fail uencryptedpartsize paddecrypt rd_uint8 pvirtualfile pw_dbheader_v2 ufilesize pw_dbheader_v2 rd_uint8 pvirtualfile pw_dbheader_v2 m_nalgorithm algo_twofish ctwofish ufinalkey aencryptioniv _opendb_fail uencryptedpartsize paddecrypt rd_uint8 pvirtualfile pw_dbheader_v2 ufilesize pw_dbheader_v2 rd_uint8 pvirtualfile pw_dbheader_v2 _opendb_fail uencryptedpartsize uencryptedpartsize _opendb_fail sha256_begin sha256_hash pvirtualfile pw_dbheader_v2 uencryptedpartsize sha256_end ufinalkey acontentshash ufinalkey _opendb_fail newdatabase pwgrouptemplate reset_pwg_template pwgrouptemplate ucurgroup bret pw_dbheader_v2 ucurgroup ucurgroup dwgroups pvirtualfile usfieldtype ufilesize _opendb_fail dwfieldsize ufilesize dwfieldsize _opendb_fail bret _readgroupfieldv2 usfieldtype dwfieldsize pwgrouptemplate usfieldtype bret ucurgroup dwfieldsize dwfieldsize ufilesize _opendb_fail safe_delete_array pwgrouptemplate pszgroupname reset_pwe_template pwentrytemplate ucurentry ucurentry ucurentry dwentries pvirtualfile usfieldtype ufilesize _opendb_fail dwfieldsize ufilesize dwfieldsize _opendb_fail bret _readentryfieldv2 usfieldtype dwfieldsize pwentrytemplate usfieldtype bret ucurentry dwfieldsize dwfieldsize ufilesize _opendb_fail safe_delete_array pwentrytemplate psztitle safe_delete_array pwentrytemplate safe_delete_array pwentrytemplate pszusername safe_delete_array pwentrytemplate pszpassword safe_delete_array pwentrytemplate pszadditional safe_delete_array pwentrytemplate pszbinarydesc safe_delete_array pwentrytemplate pbinarydata mem_erase pvirtualfile uallocated safe_delete_array pvirtualfile bool c pw manager readgroupfieldv2 ushort us field type dword dw field size byte p data pw group p group byte a compressed time 5 switch us field type case 0x0000 ignore field break case 0x0001 memcpy p group u group id p data 4 break case 0x0002 assert dw field size 0 safe delete array p group psz group name p group psz group name utf8tostringv2 utf8 byte p data break case 0x0003 memcpy a compressed time p data 5 timetopwtime a compressed time p group t creation break case 0x0004 memcpy a compressed time p data 5 timetopwtime a compressed time p group t last mod break case 0x0005 memcpy a compressed time p data 5 timetopwtime a compressed time p group t last access break case 0x0006 memcpy a compressed time p data 5 timetopwtime a compressed time p group t expire break case 0x0007 memcpy p group u image id p data 4 break case 0x0008 memcpy p group us level p data 2 break case 0x0009 memcpy p group dw flags p data 4 break case 0xffff add group p group safe delete array p group psz group name reset pwg template p group break default return false field unsupported return true field supported cpwmanager _readgroupfieldv2 usfieldtype dwfieldsize pdata pw_group pgroup acompressedtime usfieldtype pgroup ugroupid pdata dwfieldsize safe_delete_array pgroup pszgroupname pgroup pszgroupname _utf8tostringv2 utf8_byte pdata acompressedtime pdata _timetopwtime acompressedtime pgroup tcreation acompressedtime pdata _timetopwtime acompressedtime pgroup tlastmod acompressedtime pdata _timetopwtime acompressedtime pgroup tlastaccess acompressedtime pdata _timetopwtime acompressedtime pgroup texpire pgroup uimageid pdata pgroup uslevel pdata pgroup dwflags pdata addgroup pgroup safe_delete_array pgroup pszgroupname reset_pwg_template pgroup bool c pw manager readentryfieldv2 ushort us field type dword dw field size byte p data pw entry p entry byte a compressed time 5 switch us field type case 0x0000 ignore field break case 0x0001 memcpy p entry uuid p data 16 break case 0x0002 memcpy p entry u group id p data 4 break case 0x0003 memcpy p entry u image id p data 4 break case 0x0004 assert dw field size 0 safe delete array p entry psz title p entry psz title utf8tostringv2 utf8 byte p data break case 0x0005 assert dw field size 0 safe delete array p entry pszurl p entry pszurl utf8tostringv2 utf8 byte p data break case 0x0006 assert dw field size 0 safe delete array p entry psz user name p entry psz user name utf8tostringv2 utf8 byte p data break case 0x0007 assert dw field size 0 safe delete array p entry psz password p entry psz password utf8tostringv2 utf8 byte p data break case 0x0008 assert dw field size 0 safe delete array p entry psz additional p entry psz additional utf8tostringv2 utf8 byte p data break case 0x0009 assert dw field size 5 memcpy a compressed time p data 5 timetopwtime a compressed time p entry t creation break case 0x000a assert dw field size 5 memcpy a compressed time p data 5 timetopwtime a compressed time p entry t last mod break case 0x000b assert dw field size 5 memcpy a compressed time p data 5 timetopwtime a compressed time p entry t last access break case 0x000c assert dw field size 5 memcpy a compressed time p data 5 timetopwtime a compressed time p entry t expire break case 0x000d assert dw field size 0 safe delete array p entry psz binary desc p entry psz binary desc utf8tostringv2 utf8 byte p data break case 0x000e safe delete array p entry p binary data if dw field size 0 p entry p binary data new byte dw field size memcpy p entry p binary data p data dw field size p entry u binary data len dw field size break case 0xffff assert dw field size 0 add entry p entry safe delete array p entry psz title safe delete array p entry pszurl safe delete array p entry psz user name safe delete array p entry psz password safe delete array p entry psz additional safe delete array p entry psz binary desc safe delete array p entry p binary data reset pwe template p entry break default return false field unsupported return true field processed cpwmanager _readentryfieldv2 usfieldtype dwfieldsize pdata pw_entry pentry acompressedtime usfieldtype pentry pdata pentry ugroupid pdata pentry uimageid pdata dwfieldsize safe_delete_array pentry psztitle pentry psztitle _utf8tostringv2 utf8_byte pdata dwfieldsize safe_delete_array pentry pentry _utf8tostringv2 utf8_byte pdata dwfieldsize safe_delete_array pentry pszusername pentry pszusername _utf8tostringv2 utf8_byte pdata dwfieldsize safe_delete_array pentry pszpassword pentry pszpassword _utf8tostringv2 utf8_byte pdata dwfieldsize safe_delete_array pentry pszadditional pentry pszadditional _utf8tostringv2 utf8_byte pdata dwfieldsize acompressedtime pdata _timetopwtime acompressedtime pentry tcreation dwfieldsize acompressedtime pdata _timetopwtime acompressedtime pentry tlastmod dwfieldsize acompressedtime pdata _timetopwtime acompressedtime pentry tlastaccess dwfieldsize acompressedtime pdata _timetopwtime acompressedtime pentry texpire dwfieldsize safe_delete_array pentry pszbinarydesc pentry pszbinarydesc _utf8tostringv2 utf8_byte pdata safe_delete_array pentry pbinarydata dwfieldsize pentry pbinarydata dwfieldsize pentry pbinarydata pdata dwfieldsize pentry ubinarydatalen dwfieldsize dwfieldsize addentry pentry safe_delete_array pentry psztitle safe_delete_array pentry safe_delete_array pentry pszusername safe_delete_array pentry pszpassword safe_delete_array pentry pszadditional safe_delete_array pentry pszbinarydesc safe_delete_array pentry pbinarydata reset_pwe_template pentry c pw import c pw import cpwimport cpwimport c pw import c pw import cpwimport cpwimport dword c pw import import csv to db const tchar psz file c pw manager p mgr dword dw group id unsigned long u file size i j 0 char p data char p processed char ch bool b in field false bool butf8 false dword dw field counter 0 assert psz file null if psz file null return 0 assert p mgr null if p mgr null return 0 if dw group id dword max dw group id 0 return 0 p data filetomemory psz file u file size if p data null return false p processed new char u file size 2 if p processed null safe delete array p data return 0 last character mustn t be an escape character if p data u file size 1 p data u file size 1 0 if u file size 3 if p data 0 0xef p data 1 0xbb p data 2 0xbf j 3 skip utf 8 initialization characters butf8 true if butf8 false butf8 isutf8string const utf8 byte p data for i j i u file size i ch p data i if b in field false ch n if dw field counter 5 0 safe delete array p processed safe delete array p data return dw field counter 5 if ch 0 continue else if ch p data i 1 0 i skip escape character p processed j p data i write escaped symbol j increase write counter else if b in field false ch p data i 1 p processed j 0 j dw field counter else if b in field false ch p data i 1 r p processed j 0 j dw field counter else if b in field false ch p data i 1 n p processed j 0 j dw field counter else if ch if b in field true p processed j 0 j dw field counter b in field false else b in field true else if b in field true p processed j ch j if b in field true safe delete array p data safe delete array p processed return dword max 1 m plastmgr p mgr m dwlastgroupid dw group id addstringstreamtodb p processed j butf8 safe delete array p processed safe delete array p data return dword max cpwimport importcsvtodb pszfile cpwmanager pmgr dwgroupid ufilesize pdata pprocessed binfield dwfieldcounter pszfile pszfile pmgr pmgr dwgroupid dword_max dwgroupid pdata _filetomemory pszfile ufilesize pdata pprocessed ufilesize pprocessed safe_delete_array pdata pdata ufilesize pdata ufilesize ufilesize pdata pdata pdata _isutf8string utf8_byte pdata ufilesize pdata binfield dwfieldcounter safe_delete_array pprocessed safe_delete_array pdata dwfieldcounter pdata pprocessed pdata binfield pdata pprocessed dwfieldcounter binfield pdata pprocessed dwfieldcounter binfield pdata pprocessed dwfieldcounter binfield pprocessed dwfieldcounter binfield binfield binfield pprocessed binfield safe_delete_array pdata safe_delete_array pprocessed dword_max m_plastmgr pmgr m_dwlastgroupid dwgroupid _addstringstreamtodb pprocessed safe_delete_array pprocessed safe_delete_array pdata dword_max bool c pw import importc wallet to db const tchar psz file c pw manager p mgr char p data c string str title strurl str user name str password str notes dword u file size i b c string str c string str last category t general dword dw last group id 0 bool b in notes false assert p mgr null p data filetomemory psz file u file size if p data null return false str title empty strurl empty str user name empty str password empty str notes empty i dword max if u file size 3 if p data 0 0xef p data 1 0xbb p data 2 0xbf i 3 skip utf 8 initialization characters while 1 processing the file str empty while 1 loading one line to c string i if i u file size break if p data i n break if p data i r str p data i add the entry if str left 1 t str right 1 t str def cw category i u file size if str title is empty false str user name is empty false strurl is empty false str password is empty false str title trim left str title trim right strurl trim left strurl trim right str user name trim left str user name trim right str password trim left str password trim right str notes trim left str notes trim right pw entry pw template pw time t now getcurrentpwtime t now memset pw template 0 sizeof pw entry pw template psz additional tchar lpctstr str notes pw template psz password tchar lpctstr str password pw template psz title tchar lpctstr str title pw template pszurl tchar lpctstr strurl pw template psz user name tchar lpctstr str user name pw template t creation t now c pw manager getneverexpiretime pw template t expire pw template t last access t now pw template t last mod t now pw template u group id dw last group id pw template u image id getpreferredicon lpctstr str title pw template u password len str password get length p mgr add entry pw template str title empty strurl empty str user name empty str password empty str notes empty b in notes false if i u file size break if str left 1 t str right 1 t str title str str title str title left str title get length 1 str title str title right str title get length 1 continue if b in notes true if str notes get length 0 str notes t r n str notes str if str left 10 t category str last category str right str get length 10 str last category trim left str last category trim right while 1 str last category str last category left str last category get length 1 if str last category get length 0 break if str last category right 1 t str last category str last category left str last category get length 2 break if str last category get length 0 break if str last category get length 0 str last category trl general dw last group id p mgr get group id lpctstr str last category if dw last group id dword max pw group pwt pw time t now getcurrentpwtime t now memset pwt 0 sizeof pw group pwt psz group name tchar lpctstr str last category pwt t creation t now c pw manager getneverexpiretime pwt t expire pwt t last access t now pwt t last mod t now pwt u group id 0 0 create new group id pwt u image id getpreferredicon lpctstr str last category p mgr add group pwt dw last group id p mgr get group id lpctstr str last category assert dw last group id dword max if str left 6 t notes b in notes false b in notes true str str right str get length 6 if str get length 0 str notes str continue b 0 if str left 9 t user id str user name str right str get length 9 b 1 if str left 7 t login str user name str right str get length 7 b 1 if str left 10 t access str user name str right str get length 10 b 1 if str left 8 t system str user name str right str get length 8 b 1 if str left 9 t content str user name str right str get length 9 b 1 if str user name get length 0 if str left 6 t date str user name str right str get length 6 b 1 if str left 8 t issuer str user name str right str get length 8 b 1 if str left 8 t number str user name str right str get length 8 b 1 if str left 9 t network str user name str right str get length 9 b 1 if str left 11 t ftp login str user name str right str get length 11 b 1 if str left 5 t url strurl str right str get length 5 b 1 if str left 10 t web site strurl str right str get length 10 b 1 if strurl get length 0 if str left 19 t registered e mail strurl str right str get length 19 b 1 if str left 10 t password str password str right str get length 10 b 1 if str password get length 0 if str left 5 t pin str password str right str get length 5 b 1 if b 0 b in notes false if str notes get length 0 str notes t r n str notes str safe delete array p data return true cpwimport importcwallettodb pszfile cpwmanager pmgr pdata cstring strtitle strusername strpassword strnotes ufilesize cstring cstring strlastcategory _t dwlastgroupid binnotes pmgr pdata _filetomemory pszfile ufilesize pdata strtitle strusername strpassword strnotes dword_max ufilesize pdata pdata pdata cstring ufilesize pdata pdata pdata _t _t def_cw_category ufilesize strtitle isempty strusername isempty isempty strpassword isempty strtitle trimleft strtitle trimright trimleft trimright strusername trimleft strusername trimright strpassword trimleft strpassword trimright strnotes trimleft strnotes trimright pw_entry pwtemplate pw_time tnow _getcurrentpwtime tnow pwtemplate pw_entry pwtemplate pszadditional strnotes pwtemplate pszpassword strpassword pwtemplate psztitle strtitle pwtemplate pwtemplate pszusername strusername pwtemplate tcreation tnow cpwmanager _getneverexpiretime pwtemplate texpire pwtemplate tlastaccess tnow pwtemplate tlastmod tnow pwtemplate ugroupid dwlastgroupid pwtemplate uimageid _getpreferredicon strtitle pwtemplate upasswordlen strpassword getlength pmgr addentry pwtemplate strtitle strusername strpassword strnotes binnotes ufilesize _t _t strtitle strtitle strtitle strtitle getlength strtitle strtitle strtitle getlength binnotes strnotes getlength strnotes _t strnotes _t strlastcategory getlength strlastcategory trimleft strlastcategory trimright strlastcategory strlastcategory strlastcategory getlength strlastcategory getlength strlastcategory _t strlastcategory strlastcategory strlastcategory getlength strlastcategory getlength strlastcategory getlength strlastcategory dwlastgroupid pmgr getgroupid strlastcategory dwlastgroupid dword_max pw_group pw_time tnow _getcurrentpwtime tnow pw_group pszgroupname strlastcategory tcreation tnow cpwmanager _getneverexpiretime texpire tlastaccess tnow tlastmod tnow ugroupid uimageid _getpreferredicon strlastcategory pmgr addgroup dwlastgroupid pmgr getgroupid strlastcategory dwlastgroupid dword_max _t binnotes binnotes getlength getlength strnotes _t strusername getlength _t strusername getlength _t strusername getlength _t strusername getlength _t strusername getlength strusername getlength _t strusername getlength _t strusername getlength _t strusername getlength _t strusername getlength _t strusername getlength _t getlength _t getlength getlength _t getlength _t strpassword getlength strpassword getlength _t strpassword getlength binnotes strnotes getlength strnotes _t strnotes safe_delete_array pdata bool c pw import import pw safe to db const tchar psz file c pw manager p mgr char p data unsigned long u file size i int n field j c string str group str title str user name str password str notes dword dw group id bool b in notes false c string str3 str4 str5 str6 assert psz file null if psz file null return false assert p mgr null if p mgr null return false p data filetomemory psz file u file size if p data null return false n field 0 i 0 j 0 str group empty str title empty str user name empty str password empty str notes empty if u file size 3 if p data 0 0xef p data 1 0xbb p data 2 0xbf i 3 skip utf 8 initialization characters while 1 if p data i t b in notes false n field if n field 1 j str group reverse find t thanks to andrew d bond for the following improvement slightly enhanced by d reichl to detect some more ur ls andrew d bond introduction the password safe export format is rather flawed since it uses the character as the group title separator however is not likely to appear in the context of titles that include com org edu etc domain names or even zip password protected zip files slightly smarter import if the we just found is followed by com org edu etc domain names or even zip password protected zip files then figure this is part of the title and try the group title splitting again example str group websites some site com j 17 incorrect overall these fixes do make things much better however they will still not be able to handle entries where the title has other s in it for example when the title is subdomain domain com my software version 8 5 domain tv replace tv with any domain suffix not included below if str group get length 4 j 1 str3 str group right 3 else str3 t if str group get length 5 j 1 str4 str group right 4 else str4 t if str group get length 6 j 1 str5 str group right 5 else str5 t if str group get length 7 j 1 str6 str group right 6 else str6 t str3 make lower str4 make lower str5 make lower str6 make lower if str4 t com str4 t org str4 t edu str4 t net str4 t zip str3 t uk str3 t de str3 t ch str3 t at str3 t it fix for double point ur ls like co uk if str6 t co uk j 3 str title str group right str group get length j str group str group left j j str group reverse find t if j 1 str title str group right str group get length j 1 str title str group str group left j else no was found or it is part of a com in the title since password safe requires a title but not a group name this means that a group name was not specified a common occurrence we should assign a logical group name and store the title we just identified str title str group str title str group trl imported from password safe else if p data i b in notes false n field 3 b in notes true else if p data i b in notes true n field 3 b in notes false if str notes get length 0 if str notes get at 0 t str notes str notes right str notes get length 1 if str notes right 1 t str notes str notes left str notes get length 1 else if p data i r b in notes false ignore all r else if p data i n b in notes false dw group id p mgr get group id lpctstr str group if dw group id dword max pw group pwt pw time t now getcurrentpwtime t now memset pwt 0 sizeof pw group pwt psz group name tchar lpctstr str group pwt t creation t now c pw manager getneverexpiretime pwt t expire pwt t last access t now pwt t last mod t now pwt u group id 0 0 create new group id pwt u image id getpreferredicon lpctstr str group p mgr add group pwt dw group id p mgr get group id lpctstr str group assert dw group id dword max pw entry pw template pw time t now memset pw template 0 sizeof pw entry getcurrentpwtime t now pw template psz additional tchar lpctstr str notes pw template psz password tchar lpctstr str password pw template psz title tchar lpctstr str title pw template pszurl g pnullstring pw template psz user name tchar lpctstr str user name pw template t creation t now c pw manager getneverexpiretime pw template t expire pw template t last access t now pw template t last mod t now pw template u image id getpreferredicon lpctstr str title pw template u password len str password get length pw template u group id dw group id uuid is zero create new uuid p mgr add entry pw template str group empty str title empty str user name empty str password empty str notes empty n field 0 else if n field 0 str group p data i else if n field 1 str user name p data i else if n field 2 str password p data i else if n field 3 str notes p data i i if i u file size break erasec string str group erasec string str title erasec string str user name erasec string str password erasec string str notes safe delete array p data return true cpwimport importpwsafetodb pszfile cpwmanager pmgr pdata ufilesize nfield cstring strgroup strtitle strusername strpassword strnotes dwgroupid binnotes cstring pszfile pszfile pmgr pmgr pdata _filetomemory pszfile ufilesize pdata nfield strgroup strtitle strusername strpassword strnotes ufilesize pdata pdata pdata pdata binnotes nfield nfield strgroup reversefind _t urls strgroup somesite _other_ mysoftware strgroup getlength strgroup _t strgroup getlength strgroup _t strgroup getlength strgroup _t strgroup getlength strgroup _t makelower makelower makelower makelower _t _t _t _t _t _t _t _t _t _t urls _t strtitle strgroup strgroup getlength strgroup strgroup strgroup reversefind _t strtitle strgroup strgroup getlength strtitle strgroup strgroup strtitle strgroup strtitle strgroup pdata binnotes nfield binnotes pdata binnotes nfield binnotes strnotes getlength strnotes getat _t strnotes strnotes strnotes getlength strnotes _t strnotes strnotes strnotes getlength pdata binnotes pdata binnotes dwgroupid pmgr getgroupid strgroup dwgroupid dword_max pw_group pw_time tnow _getcurrentpwtime tnow pw_group pszgroupname strgroup tcreation tnow cpwmanager _getneverexpiretime texpire tlastaccess tnow tlastmod tnow ugroupid uimageid _getpreferredicon strgroup pmgr addgroup dwgroupid pmgr getgroupid strgroup dwgroupid dword_max pw_entry pwtemplate pw_time tnow pwtemplate pw_entry _getcurrentpwtime tnow pwtemplate pszadditional strnotes pwtemplate pszpassword strpassword pwtemplate psztitle strtitle pwtemplate g_pnullstring pwtemplate pszusername strusername pwtemplate tcreation tnow cpwmanager _getneverexpiretime pwtemplate texpire pwtemplate tlastaccess tnow pwtemplate tlastmod tnow pwtemplate uimageid _getpreferredicon strtitle pwtemplate upasswordlen strpassword getlength pwtemplate ugroupid dwgroupid pmgr addentry pwtemplate strgroup strtitle strusername strpassword strnotes nfield nfield strgroup pdata nfield strusername pdata nfield strpassword pdata nfield strnotes pdata ufilesize erasecstring strgroup erasecstring strtitle erasecstring strusername erasecstring strpassword erasecstring strnotes safe_delete_array pdata bool c pw import importp vault to db const tchar psz file c pw manager p mgr char p data c string str title strurl str user name str password str notes dword u file size i b c string str c string str last category t general dword dw last group id 0 bool b in notes false assert p mgr null p data filetomemory psz file u file size if p data null return false str title empty strurl empty str user name empty str password empty str notes empty i dword max if u file size 3 if p data 0 0xef p data 1 0xbb p data 2 0xbf i 3 skip utf 8 initialization characters while 1 processing the file str empty while 1 loading one line to c string i if i u file size break if p data i n break if p data i r str p data i add the entry if str def pv sepentry i u file size str left 12 def pv category if str title is empty false str user name is empty false strurl is empty false str password is empty false str title trim left str title trim right strurl trim left strurl trim right str user name trim left str user name trim right str password trim left str password trim right str notes trim left str notes trim right pw entry pw template pw time t now getcurrentpwtime t now memset pw template 0 sizeof pw entry pw template psz additional tchar lpctstr str notes pw template psz password tchar lpctstr str password pw template psz title tchar lpctstr str title pw template pszurl tchar lpctstr strurl pw template psz user name tchar lpctstr str user name pw template t creation t now c pw manager getneverexpiretime pw template t expire pw template t last access t now pw template t last mod t now pw template u group id dw last group id pw template u image id getpreferredicon lpctstr str title pw template u password len str password get length p mgr add entry pw template str title empty strurl empty str user name empty str password empty str notes empty b in notes false if i u file size break if b in notes true if str notes get length 0 str notes t r n str notes str right str get length 14 if str left 12 def pv category str right 12 def pv category str last category str right str get length 12 str last category str last category left str last category get length 12 str last category trim left str last category trim right if str last category get length 0 str last category trl general dw last group id p mgr get group id lpctstr str last category if dw last group id dword max pw group pwt pw time t now getcurrentpwtime t now memset pwt 0 sizeof pw group pwt psz group name tchar lpctstr str last category pwt t creation t now c pw manager getneverexpiretime pwt t expire pwt t last access t now pwt t last mod t now pwt u group id 0 0 create new group id pwt u image id getpreferredicon lpctstr str last category p mgr add group pwt dw last group id p mgr get group id lpctstr str last category assert dw last group id dword max if str left 9 t comments b in notes false b in notes true str str right str get length 9 if str get length 0 str notes str continue if str left 9 t account str title str right str get length 9 b 1 b 0 if str left 11 t user name str user name str right str get length 11 b 1 if str left 11 t hyperlink strurl str right str get length 11 b 1 if str left 10 t password str password str right str get length 10 b 1 if b 0 b in notes false if str notes get length 0 str notes t r n str notes str safe delete array p data return true cpwimport importpvaulttodb pszfile cpwmanager pmgr pdata cstring strtitle strusername strpassword strnotes ufilesize cstring cstring strlastcategory _t dwlastgroupid binnotes pmgr pdata _filetomemory pszfile ufilesize pdata strtitle strusername strpassword strnotes dword_max ufilesize pdata pdata pdata cstring ufilesize pdata pdata pdata def_pv_sepentry ufilesize def_pv_category strtitle isempty strusername isempty isempty strpassword isempty strtitle trimleft strtitle trimright trimleft trimright strusername trimleft strusername trimright strpassword trimleft strpassword trimright strnotes trimleft strnotes trimright pw_entry pwtemplate pw_time tnow _getcurrentpwtime tnow pwtemplate pw_entry pwtemplate pszadditional strnotes pwtemplate pszpassword strpassword pwtemplate psztitle strtitle pwtemplate pwtemplate pszusername strusername pwtemplate tcreation tnow cpwmanager _getneverexpiretime pwtemplate texpire pwtemplate tlastaccess tnow pwtemplate tlastmod tnow pwtemplate ugroupid dwlastgroupid pwtemplate uimageid _getpreferredicon strtitle pwtemplate upasswordlen strpassword getlength pmgr addentry pwtemplate strtitle strusername strpassword strnotes binnotes ufilesize binnotes strnotes getlength strnotes _t strnotes getlength def_pv_category def_pv_category strlastcategory getlength strlastcategory strlastcategory strlastcategory getlength strlastcategory trimleft strlastcategory trimright strlastcategory getlength strlastcategory dwlastgroupid pmgr getgroupid strlastcategory dwlastgroupid dword_max pw_group pw_time tnow _getcurrentpwtime tnow pw_group pszgroupname strlastcategory tcreation tnow cpwmanager _getneverexpiretime texpire tlastaccess tnow tlastmod tnow ugroupid uimageid _getpreferredicon strlastcategory pmgr addgroup dwlastgroupid pmgr getgroupid strlastcategory dwlastgroupid dword_max _t binnotes binnotes getlength getlength strnotes _t strtitle getlength _t strusername getlength _t getlength _t strpassword getlength binnotes strnotes getlength strnotes _t strnotes safe_delete_array pdata void c pw import addstringstreamtodb const char p stream unsigned long u stream size bool butf8 unsigned long s char p title null p user name null p password null purl null p notes null char p char p stream char p end char p stream u stream size tchar tsz title null tsz user name null tsz password null tszurl null tsz notes null assert p stream null while 1 if p p end break p title p s szlen p p s 1 if p p end break p user name p s szlen p p s 1 if p p end break p password p s szlen p p s 1 if p p end break purl p s szlen p p s 1 if p p end break p notes p s szlen p p s 1 if strcmp p title account 0 strcmp p password password 0 pw entry pw template pw time t now if butf8 true tsz title utf8tostring utf8 byte p title tsz user name utf8tostring utf8 byte p user name tsz password utf8tostring utf8 byte p password tszurl utf8tostring utf8 byte purl tsz notes utf8tostring utf8 byte p notes else tsz title tchar p title tsz user name tchar p user name tsz password tchar p password tszurl tchar purl tsz notes tchar p notes memset pw template 0 sizeof pw entry getcurrentpwtime t now pw template psz additional tsz notes pw template psz password tsz password pw template psz title tsz title pw template pszurl tszurl pw template psz user name tsz user name pw template t creation t now c pw manager getneverexpiretime pw template t expire pw template t last access t now pw template t last mod t now pw template u group id m dwlastgroupid pw template u image id getpreferredicon tsz title pw template u password len tcslen tsz password uuid is zero create new uuid m plastmgr add entry pw template if butf8 true safe delete array tsz title safe delete array tsz user name safe delete array tsz password safe delete array tszurl safe delete array tsz notes cpwimport _addstringstreamtodb pstream ustreamsize ptitle pusername ppassword pnotes pstream pend pstream ustreamsize tsztitle tszusername tszpassword tsznotes pstream pend ptitle pend pusername pend ppassword pend pend pnotes ptitle ppassword pw_entry pwtemplate pw_time tnow tsztitle _utf8tostring utf8_byte ptitle tszusername _utf8tostring utf8_byte pusername tszpassword _utf8tostring utf8_byte ppassword _utf8tostring utf8_byte tsznotes _utf8tostring utf8_byte pnotes tsztitle ptitle tszusername pusername tszpassword ppassword tsznotes pnotes pwtemplate pw_entry _getcurrentpwtime tnow pwtemplate pszadditional tsznotes pwtemplate pszpassword tszpassword pwtemplate psztitle tsztitle pwtemplate pwtemplate pszusername tszusername pwtemplate tcreation tnow cpwmanager _getneverexpiretime pwtemplate texpire pwtemplate tlastaccess tnow pwtemplate tlastmod tnow pwtemplate ugroupid m_dwlastgroupid pwtemplate uimageid _getpreferredicon tsztitle pwtemplate upasswordlen _tcslen tszpassword m_plastmgr addentry pwtemplate safe_delete_array tsztitle safe_delete_array tszusername safe_delete_array tszpassword safe_delete_array safe_delete_array tsznotes char c pw import filetomemory const tchar psz file unsigned long p file size file fp unsigned long u file size char p data assert psz file null if psz file null return null if tcslen psz file 0 return null fp tfopen psz file t rb if fp null return null fseek fp 0 seek end u file size ftell fp fseek fp 0 seek set p data new char u file size 3 if p data null fclose fp fp null return null p data u file size 0 terminate buffer p data u file size 1 0 p data u file size 2 0 fread p data 1 u file size fp fclose fp fp null if p file size null p file size u file size store file size return p data cpwimport _filetomemory pszfile pfilesize ufilesize pdata pszfile pszfile _tcslen pszfile _tfopen pszfile _t seek_end ufilesize seek_set pdata ufilesize pdata pdata ufilesize pdata ufilesize pdata ufilesize pdata ufilesize pfilesize pfilesize ufilesize pdata unsigned long c pw import getpreferredicon lpctstr psz group c string str psz group if str find t windows 1 return 38 if str find t system 1 return 38 if str find t network 1 return 3 if str find t connection 1 return 3 if str find t vpn 1 return 3 if str find t lan 1 return 3 if str find t internet 1 return 1 if str find t internet 1 return 1 if str find t web 1 return 1 if str find t www 1 return 1 if str find t www 1 return 1 if str find t http 1 return 1 if str find t http 1 return 1 if str find t ftp 1 return 1 if str find t ftp 1 return 1 if str find t e mail 1 return 19 if str find t mail 1 return 19 if str find t post 1 return 19 if str find t 1 return 19 if str find t homebanking 1 return 37 if str find t banking 1 return 37 if str find t archive 1 return 37 if str find t collection 1 return 37 if str find t cash 1 return 37 if str find t explorer 1 return 9 if str find t netscape 1 return 9 if str find t mozilla 1 return 9 if str find t opera 1 return 9 return 0 cpwimport _getpreferredicon pszgroup cstring pszgroup _t _t _t _t _t _t _t _t _t _t _t _t _t _t _t _t email _t _t _t _t _t _t _t _t _t _t _t _t c pw export c pw export m pmgr null m nformat 0 m fp null set new line seq false zero memory m adefaults pwexp txt sizeof pwexport options m adefaults pwexp txt b group true m adefaults pwexp txt b title true m adefaults pwexp txt b user name true m adefaults pwexp txt burl true m adefaults pwexp txt b password true m adefaults pwexp txt b notes true zero memory m adefaults pwexp html sizeof pwexport options m adefaults pwexp html b group true m adefaults pwexp html b title true m adefaults pwexp html b user name true m adefaults pwexp html burl true m adefaults pwexp html b password true m adefaults pwexp html b notes true zero memory m adefaults pwexp xml sizeof pwexport options m adefaults pwexp xml b group true m adefaults pwexp xml b group tree true m adefaults pwexp xml b title true m adefaults pwexp xml b user name true m adefaults pwexp xml burl true m adefaults pwexp xml b password true m adefaults pwexp xml b notes true m adefaults pwexp xml buuid true m adefaults pwexp xml b image true m adefaults pwexp xml b creation time true m adefaults pwexp xml b last acc time true m adefaults pwexp xml b last mod time true m adefaults pwexp xml b expire time true m adefaults pwexp xml b attachment true zero memory m adefaults pwexp csv sizeof pwexport options m adefaults pwexp csv b title true m adefaults pwexp csv b user name true m adefaults pwexp csv burl true m adefaults pwexp csv b password true m adefaults pwexp csv b notes true zero memory m adefaults pwexp keepass sizeof pwexport options m adefaults pwexp keepass b group true m adefaults pwexp keepass b group tree true m adefaults pwexp keepass b title true m adefaults pwexp keepass b user name true m adefaults pwexp keepass burl true m adefaults pwexp keepass b password true m adefaults pwexp keepass b notes true m adefaults pwexp keepass buuid true m adefaults pwexp keepass b image true m adefaults pwexp keepass b creation time true m adefaults pwexp keepass b last acc time true m adefaults pwexp keepass b last mod time true m adefaults pwexp keepass b expire time true m adefaults pwexp keepass b attachment true m adefaults pwexp keepass b export backups true cpwexport cpwexport m_pmgr m_nformat m_fp setnewlineseq zeromemory m_adefaults pwexp_txt pwexport_options m_adefaults pwexp_txt bgroup m_adefaults pwexp_txt btitle m_adefaults pwexp_txt busername m_adefaults pwexp_txt m_adefaults pwexp_txt bpassword m_adefaults pwexp_txt bnotes zeromemory m_adefaults pwexp_html pwexport_options m_adefaults pwexp_html bgroup m_adefaults pwexp_html btitle m_adefaults pwexp_html busername m_adefaults pwexp_html m_adefaults pwexp_html bpassword m_adefaults pwexp_html bnotes zeromemory m_adefaults pwexp_xml pwexport_options m_adefaults pwexp_xml bgroup m_adefaults pwexp_xml bgrouptree m_adefaults pwexp_xml btitle m_adefaults pwexp_xml busername m_adefaults pwexp_xml m_adefaults pwexp_xml bpassword m_adefaults pwexp_xml bnotes m_adefaults pwexp_xml m_adefaults pwexp_xml bimage m_adefaults pwexp_xml bcreationtime m_adefaults pwexp_xml blastacctime m_adefaults pwexp_xml blastmodtime m_adefaults pwexp_xml bexpiretime m_adefaults pwexp_xml battachment zeromemory m_adefaults pwexp_csv pwexport_options m_adefaults pwexp_csv btitle m_adefaults pwexp_csv busername m_adefaults pwexp_csv m_adefaults pwexp_csv bpassword m_adefaults pwexp_csv bnotes zeromemory m_adefaults pwexp_keepass pwexport_options m_adefaults pwexp_keepass bgroup m_adefaults pwexp_keepass bgrouptree m_adefaults pwexp_keepass btitle m_adefaults pwexp_keepass busername m_adefaults pwexp_keepass m_adefaults pwexp_keepass bpassword m_adefaults pwexp_keepass bnotes m_adefaults pwexp_keepass m_adefaults pwexp_keepass bimage m_adefaults pwexp_keepass bcreationtime m_adefaults pwexp_keepass blastacctime m_adefaults pwexp_keepass blastmodtime m_adefaults pwexp_keepass bexpiretime m_adefaults pwexp_keepass battachment m_adefaults pwexp_keepass bexportbackups c pw export c pw export m pmgr null m nformat 0 m fp null cpwexport cpwexport m_pmgr m_nformat m_fp void c pw export set manager c pw manager p mgr assert p mgr null m pmgr p mgr cpwexport setmanager cpwmanager pmgr pmgr m_pmgr pmgr void c pw export set format int n format assert n format pwexp null n format pwexp last if n format pwexp null n format pwexp last m nformat n format cpwexport setformat nformat nformat pwexp_null nformat pwexp_last nformat pwexp_null nformat pwexp_last m_nformat nformat void c pw export set new line seq bool b windows if b windows true m psznewline t r n else m psznewline t n cpwexport setnewlineseq bwindows bwindows m_psznewline _t m_psznewline _t bool c pw export export all const tchar psz file const pwexport options p options c pw manager p store mgr assert psz file null return export group psz file dword max p options p store mgr cpwexport exportall pszfile pwexport_options poptions cpwmanager pstoremgr pszfile exportgroup pszfile dword_max poptions pstoremgr bool c pw export export group const tchar psz file dword dw group id const pwexport options p options c pw manager p store mgr file fp null dword i j dw this id dw number of groups dw invalid id1 dw invalid id2 pw entry p pw group pg byte a initutf8 3 0xef 0xbb 0xbf c string str struuid str image str creation time str last acc time str last mod time c string str expire time str group tree byte pb encoded attachment null c base64 codec base64 pw time t never std vector dword a group ids ushort us level 0 bool b return true assert m pmgr null if m pmgr null return false m pmgr getneverexpiretime t never assert psz file null if psz file null return false if m nformat pwexp keepass assert p store mgr null if p store mgr null return false if p options null if m nformat pwexp txt p options m adefaults pwexp txt else if m nformat pwexp html p options m adefaults pwexp html else if m nformat pwexp xml p options m adefaults pwexp xml else if m nformat pwexp csv p options m adefaults pwexp csv else if m nformat pwexp keepass p options m adefaults pwexp keepass else assert false return false m poptions p options dw number of groups m pmgr get number of groups dw invalid id1 m pmgr get group id pws backupgroup src dw invalid id2 m pmgr get group id pws backupgroup if dw group id dword max i m pmgr get group by idn dw group id assert i dword max if i dword max return false us level m pmgr get group i us level while 1 pg m pmgr get group i assert pg null if pg null break if pg u group id dw group id pg us level us level break a group ids push back pg u group id i if i dw number of groups break else for i 0 i dw number of groups i pg m pmgr get group i assert pg null if pg null continue a group ids push back pg u group id if m nformat pwexp keepass fp tfopen psz file t wb if fp null a group ids clear return false m fp fp fwrite a initutf8 1 3 fp if m nformat pwexp txt else if m nformat pwexp html expstr t doctype html public w3c dtd html 4 0 transitional en expstr m psznewline expstr t html head expstr t meta http equiv content type content text html charset utf 8 expstr t title expstr trl password list expstr t title head body expstr m psznewline expstr t h1 expstr trl password list expstr t h1 expstr m psznewline expstr t table width 100 border 1px cellspacing 0 cellpadding 1 tr th expsetsep t th th expresetskip expstrif p options b group trl password groups expstrif p options b group tree trl group tree expstrif p options b title trl title expstrif p options b user name trl user name expstrif p options burl trl url expstrif p options b password trl password expstrif p options b notes trl notes expstrif p options buuid trl uuid expstrif p options b image trl icon expstrif p options b creation time trl creation time expstrif p options b last acc time trl last access expstrif p options b last mod time trl last modification expstrif p options b expire time trl expires expstrif p options b attachment trl attachment expstrif p options b attachment trl attachment expstr t th tr expstr m psznewline else if m nformat pwexp xml expstr t xml version 1 0 encoding utf 8 expstr m psznewline expstr t pwlist expstr m psznewline else if m nformat pwexp csv expstr t expsetsep t expresetskip expstrif p options b group t password groups expstrif p options b group tree t group tree expstrif p options b title t account expstrif p options b user name t login name expstrif p options b password t password expstrif p options burl t web site expstrif p options b notes t comments expstrif p options buuid t uuid expstrif p options b image t icon expstrif p options b creation time t creation time expstrif p options b last acc time t last access expstrif p options b last mod time t last modification expstrif p options b expire time t expires expstrif p options b attachment t attachment expstrif p options b attachment t attachment expstr t expstr m psznewline else if m nformat pwexp keepass dword dw group enum pw group pwg template for dw group enum 0 dw group enum dword a group ids size dw group enum pw group pg copy m pmgr get group by id a group ids dw group enum assert pg copy null if pg copy null return false pwg template pg copy pwg template us level us level p store mgr add group pwg template else assert false dword u num entries m pmgr get number of entries for j 0 j dword a group ids size j dw this id a group ids j if m poptions b export backups false if dw this id dw invalid id1 continue else if dw this id dw invalid id2 continue for i 0 i u num entries i p m pmgr get entry i assert entry p are we exporting this group if p u group id dw this id continue pg m pmgr get group by id p u group id assert pg null if pg null continue m pmgr unlock entry password p uuidtostring p uuid struuid str image format t u p u image id if m nformat pwexp csv m nformat pwexp xml pwtimetoxmltime p t creation str creation time pwtimetoxmltime p t last access str last acc time pwtimetoxmltime p t last mod str last mod time pwtimetoxmltime p t expire str expire time else pwtimetostring p t creation str creation time pwtimetostring p t last access str last acc time pwtimetostring p t last mod str last mod time pwtimetostring p t expire str expire time str group tree make group tree string pg u group id assert p psz binary desc null if p options b attachment true p u binary data len 0 p p binary data null dword dw buf size p u binary data len 2 3 2 1 pb encoded attachment new byte dw buf size 1 assert pb encoded attachment null if pb encoded attachment null if base64 encode p p binary data p u binary data len pb encoded attachment dw buf size false safe delete array pb encoded attachment else pb encoded attachment null if m nformat pwexp txt expsetsep null expstrif p options b title t expstrif p options b title p psz title expstrif p options b title t if p options b title true expstr m psznewline expstrif p options b group trl group expstrif p options b group t expstrif p options b group pg psz group name if p options b group true expstr m psznewline expstrif p options b group tree trl group tree expstrif p options b group tree t expstrif p options b group tree str group tree if p options b group tree true expstr m psznewline expstrif p options b user name trl user name expstrif p options b user name t expstrif p options b user name p psz user name if p options b user name true expstr m psznewline expstrif p options burl trl url expstrif p options burl t expstrif p options burl p pszurl if p options burl true expstr m psznewline expstrif p options b password trl password expstrif p options b password t expstrif p options b password p psz password if p options b password true expstr m psznewline expstrif p options b notes trl notes expstrif p options b notes t expstrif p options b notes p psz additional if p options b notes true expstr m psznewline expstrif p options buuid trl uuid expstrif p options buuid t expstrif p options buuid struuid if p options buuid true expstr m psznewline expstrif p options b image trl icon expstrif p options b image t expstrif p options b image str image if p options b image true expstr m psznewline expstrif p options b creation time trl creation time expstrif p options b creation time t expstrif p options b creation time str creation time if p options b creation time true expstr m psznewline expstrif p options b last acc time trl last access expstrif p options b last acc time t expstrif p options b last acc time str last acc time if p options b last acc time true expstr m psznewline expstrif p options b last mod time trl last modification expstrif p options b last mod time t expstrif p options b last mod time str last mod time if p options b last mod time true expstr m psznewline expstrif p options b expire time trl expires expstrif p options b expire time t expstrif p options b expire time str expire time if p options b expire time true expstr m psznewline if p psz binary desc 0 0 expstrif p options b attachment trl attachment expstrif p options b attachment t expstrif p options b attachment trl title expstrif p options b attachment t expstrif p options b attachme cpwexport exportgroup pszfile dwgroupid pwexport_options poptions cpwmanager pstoremgr dwthisid dwnumberofgroups dwinvalidid1 dwinvalidid2 pw_entry pw_group ainitutf8 cstring strimage strcreationtime strlastacctime strlastmodtime cstring strexpiretime strgrouptree pbencodedattachment cbase64codec pw_time tnever agroupids uslevel breturn m_pmgr m_pmgr m_pmgr _getneverexpiretime tnever pszfile pszfile m_nformat pwexp_keepass pstoremgr pstoremgr poptions m_nformat pwexp_txt poptions m_adefaults pwexp_txt m_nformat pwexp_html poptions m_adefaults pwexp_html m_nformat pwexp_xml poptions m_adefaults pwexp_xml m_nformat pwexp_csv poptions m_adefaults pwexp_csv m_nformat pwexp_keepass poptions m_adefaults pwexp_keepass m_poptions poptions dwnumberofgroups m_pmgr getnumberofgroups dwinvalidid1 m_pmgr getgroupid pws_backupgroup_src dwinvalidid2 m_pmgr getgroupid pws_backupgroup dwgroupid dword_max m_pmgr getgroupbyidn dwgroupid dword_max dword_max uslevel m_pmgr getgroup uslevel m_pmgr getgroup ugroupid dwgroupid uslevel uslevel agroupids push_back ugroupid dwnumberofgroups dwnumberofgroups m_pmgr getgroup agroupids push_back ugroupid m_nformat pwexp_keepass _tfopen pszfile _t agroupids m_fp ainitutf8 m_nformat pwexp_txt m_nformat pwexp_html _expstr _t _expstr m_psznewline _expstr _t _expstr _t _expstr _t _expstr _expstr _t _expstr m_psznewline _expstr _t _expstr _expstr _t _expstr m_psznewline _expstr _t _expsetsep _t _expresetskip _expstrif poptions bgroup _expstrif poptions bgrouptree _expstrif poptions btitle _expstrif poptions busername username _expstrif poptions _expstrif poptions bpassword _expstrif poptions bnotes _expstrif poptions _expstrif poptions bimage _expstrif poptions bcreationtime _expstrif poptions blastacctime _expstrif poptions blastmodtime _expstrif poptions bexpiretime _expstrif poptions battachment _expstrif poptions battachment _expstr _t _expstr m_psznewline m_nformat pwexp_xml _expstr _t _expstr m_psznewline _expstr _t _expstr m_psznewline m_nformat pwexp_csv _expstr _t _expsetsep _t _expresetskip _expstrif poptions bgroup _t _expstrif poptions bgrouptree _t _expstrif poptions btitle _t _expstrif poptions busername _t _expstrif poptions bpassword _t _expstrif poptions _t _expstrif poptions bnotes _t _expstrif poptions _t _expstrif poptions bimage _t _expstrif poptions bcreationtime _t _expstrif poptions blastacctime _t _expstrif poptions blastmodtime _t _expstrif poptions bexpiretime _t _expstrif poptions battachment _t _expstrif poptions battachment _t _expstr _t _expstr m_psznewline m_nformat pwexp_keepass dwgroupenum pw_group pwgtemplate dwgroupenum dwgroupenum agroupids dwgroupenum pw_group pgcopy m_pmgr getgroupbyid agroupids dwgroupenum pgcopy pgcopy pwgtemplate pgcopy pwgtemplate uslevel uslevel pstoremgr addgroup pwgtemplate unumentries m_pmgr getnumberofentries agroupids dwthisid agroupids m_poptions bexportbackups dwthisid dwinvalidid1 dwthisid dwinvalidid2 unumentries m_pmgr getentry assert_entry ugroupid dwthisid m_pmgr getgroupbyid ugroupid m_pmgr unlockentrypassword _uuidtostring strimage _t uimageid m_nformat pwexp_csv m_nformat pwexp_xml _pwtimetoxmltime tcreation strcreationtime _pwtimetoxmltime tlastaccess strlastacctime _pwtimetoxmltime tlastmod strlastmodtime _pwtimetoxmltime texpire strexpiretime _pwtimetostring tcreation strcreationtime _pwtimetostring tlastaccess strlastacctime _pwtimetostring tlastmod strlastmodtime _pwtimetostring texpire strexpiretime strgrouptree makegrouptreestring ugroupid pszbinarydesc poptions battachment ubinarydatalen pbinarydata dwbufsize ubinarydatalen pbencodedattachment dwbufsize pbencodedattachment pbencodedattachment pbinarydata ubinarydatalen pbencodedattachment dwbufsize safe_delete_array pbencodedattachment pbencodedattachment m_nformat pwexp_txt _expsetsep _expstrif poptions btitle _t _expstrif poptions btitle psztitle _expstrif poptions btitle _t poptions btitle _expstr m_psznewline _expstrif poptions bgroup _expstrif poptions bgroup _t _expstrif poptions bgroup pszgroupname poptions bgroup _expstr m_psznewline _expstrif poptions bgrouptree _expstrif poptions bgrouptree _t _expstrif poptions bgrouptree strgrouptree poptions bgrouptree _expstr m_psznewline _expstrif poptions busername username _expstrif poptions busername _t _expstrif poptions busername pszusername poptions busername _expstr m_psznewline _expstrif poptions _expstrif poptions _t _expstrif poptions poptions _expstr m_psznewline _expstrif poptions bpassword _expstrif poptions bpassword _t _expstrif poptions bpassword pszpassword poptions bpassword _expstr m_psznewline _expstrif poptions bnotes _expstrif poptions bnotes _t _expstrif poptions bnotes pszadditional poptions bnotes _expstr m_psznewline _expstrif poptions _expstrif poptions _t _expstrif poptions poptions _expstr m_psznewline _expstrif poptions bimage _expstrif poptions bimage _t _expstrif poptions bimage strimage poptions bimage _expstr m_psznewline _expstrif poptions bcreationtime _expstrif poptions bcreationtime _t _expstrif poptions bcreationtime strcreationtime poptions bcreationtime _expstr m_psznewline _expstrif poptions blastacctime _expstrif poptions blastacctime _t _expstrif poptions blastacctime strlastacctime poptions blastacctime _expstr m_psznewline _expstrif poptions blastmodtime _expstrif poptions blastmodtime _t _expstrif poptions blastmodtime strlastmodtime poptions blastmodtime _expstr m_psznewline _expstrif poptions bexpiretime _expstrif poptions bexpiretime _t _expstrif poptions bexpiretime strexpiretime poptions bexpiretime _expstr m_psznewline pszbinarydesc _expstrif poptions battachment _expstrif poptions battachment _t _expstrif poptions battachment _expstrif poptions battachment _t _expstrif poptions battachme c string c pw export make group tree string dword dw group id dword pdw indexes dword i ushort us level pw group pg c string str str temp pg m pmgr get group by id dw group id assert pg null if pg null return str us level pg us level assert us level 0xffff if us level 0xffff return str if us level 0 return str pdw indexes new dword us level 2 assert pdw indexes null if pdw indexes null return str if m pmgr get group tree dw group id pdw indexes true for i 0 i dword us level i pg m pmgr get group pdw indexes i if pg null if i 0 str t str temp pg psz group name str temp replace t t str temp replace t t str str temp safe delete array pdw indexes return str cstring cpwexport makegrouptreestring dwgroupid pdwindexes uslevel pw_group cstring strtemp m_pmgr getgroupbyid dwgroupid uslevel uslevel uslevel uslevel uslevel pdwindexes uslevel pdwindexes pdwindexes m_pmgr getgrouptree dwgroupid pdwindexes uslevel m_pmgr getgroup pdwindexes _t strtemp pszgroupname strtemp _t _t strtemp _t _t strtemp safe_delete_array pdwindexes void c pw export expstr lpctstr lp string if tcslen lp string 0 utf8 byte p utf8 string stringtoutf8 lp string assert p utf8 string null if p utf8 string null fwrite p utf8 string 1 strlen char p utf8 string m fp safe delete array p utf8 string cpwexport _expstr lpstring _tcslen lpstring utf8_byte putf8string _stringtoutf8 lpstring putf8string putf8string putf8string putf8string m_fp safe_delete_array putf8string void c pw export expxmlstr lpctstr lp string if tcslen lp string 0 tchar p xml string make safe xml string lp string assert p xml string null if p xml string null utf8 byte p utf8 string stringtoutf8 p xml string fwrite p utf8 string 1 strlen char p utf8 string m fp safe delete array p utf8 string safe delete array p xml string cpwexport _expxmlstr lpstring _tcslen lpstring pxmlstring makesafexmlstring lpstring pxmlstring pxmlstring utf8_byte putf8string _stringtoutf8 pxmlstring putf8string putf8string m_fp safe_delete_array putf8string safe_delete_array pxmlstring void c pw export exphtmlstr lpctstr lp string if lp string 0 0 expstr t nbsp else expxmlstr lp string cpwexport _exphtmlstr lpstring lpstring _expstr _t _expxmlstr lpstring void c pw export expresetskip m boneskipped false cpwexport _expresetskip m_boneskipped void c pw export expsetsep lpctstr lp sep if lp sep null m lpsep t else m lpsep lp sep cpwexport _expsetsep lpsep lpsep m_lpsep _t m_lpsep lpsep void c pw export expstrif bool b condition lpctstr lp string if b condition true if m boneskipped true expstr m lpsep else m boneskipped true if m poptions b encode newlines true c string str lp string str replace t r t r str replace t n t n expstr str else expstr lp string cpwexport _expstrif bcondition lpstring bcondition m_boneskipped _expstr m_lpsep m_boneskipped m_poptions bencodenewlines cstring lpstring _t _t _t _t _expstr _expstr lpstring void c pw export expxmlstrif bool b condition lpctstr lp string if b condition true if m boneskipped true expstr m lpsep else m boneskipped true if m poptions b encode newlines true c string str lp string str replace t r t r str replace t n t n expxmlstr str else expxmlstr lp string cpwexport _expxmlstrif bcondition lpstring bcondition m_boneskipped _expstr m_lpsep m_boneskipped m_poptions bencodenewlines cstring lpstring _t _t _t _t _expxmlstr _expxmlstr lpstring void c pw export exphtmlstrif bool b condition lpctstr lp string if b condition true if m boneskipped true expstr m lpsep else m boneskipped true if m poptions b encode newlines true c string str lp string str replace t r t r str replace t n t n exphtmlstr str else exphtmlstr lp string cpwexport _exphtmlstrif bcondition lpstring bcondition m_boneskipped _expstr m_lpsep m_boneskipped m_poptions bencodenewlines cstring lpstring _t _t _t _t _exphtmlstr _exphtmlstr lpstring void c pw export expcsvstrif bool b condition lpctstr lp string if b condition true if m boneskipped true expstr m lpsep else m boneskipped true c string str lp string str replace t t str replace t t if m poptions b encode newlines true str replace t r t r str replace t n t n expstr str else expstr str cpwexport _expcsvstrif bcondition lpstring bcondition m_boneskipped _expstr m_lpsep m_boneskipped cstring lpstring _t _t _t _t m_poptions bencodenewlines _t _t _t _t _expstr _expstr c buttonst c buttonst m bispressed false m bisfocused false m bisdisabled false m bmouseonbutton false free resources false default type is flat button m bisflat true button will be tracked also if when the window is inactive like internet explorer m balwaystrack true by default draw border in flat button m bdrawborder true by default icon is aligned horizontally m byalign st align horiz by default use usual pressed style set pressed style btnst pressed leftright false by default for flat button don t draw the focus rect m bdrawflatfocus false by default the button is not the default button m bisdefault false invalid value since type still unknown m ntypestyle bs typemask by default the button is not a checkbox m bischeckbox false m ncheck 0 initially use the system colors for int i 0 i btnst max colors i m busesystemcolor i true set default colors set default colors false no tooltip created m tooltip m hwnd null m dwtooltipstyle 0 do not draw as a transparent button m bdrawtransparent false m pbmpoldbk null no url defined seturl null no cursor defined m hcursor null no associated menu ifndef btnst use bcmenu m hmenu null endif m hparentwndmenu null m bmenudisplayed false m bshowdisabledbitmap true m ptimageorg x 3 m ptimageorg y 3 no defined callbacks zero memory m cscallbacks sizeof m cscallbacks ifdef btnst use sound no defined sounds zero memory m cssounds sizeof m cssounds endif cbuttonst cbuttonst m_bispressed m_bisfocused m_bisdisabled m_bmouseonbutton freeresources m_bisflat m_balwaystrack m_bdrawborder m_byalign st_align_horiz setpressedstyle btnst_pressed_leftright m_bdrawflatfocus m_bisdefault m_ntypestyle bs_typemask m_bischeckbox m_ncheck btnst_max_colors m_busesystemcolor setdefaultcolors m_tooltip m_hwnd m_dwtooltipstyle m_bdrawtransparent m_pbmpoldbk m_hcursor btnst_use_bcmenu m_hmenu m_hparentwndmenu m_bmenudisplayed m_bshowdisabledbitmap m_ptimageorg m_ptimageorg zeromemory m_cscallbacks m_cscallbacks btnst_use_sound zeromemory m_cssounds m_cssounds c buttonst c buttonst restore old bitmap if any if m dcbk m hdc m pbmpoldbk m dcbk select object m pbmpoldbk select object m dcbk m pbmpoldbk if free resources destroy the cursor if any if m hcursor destroy cursor m hcursor destroy the menu if any ifdef btnst use bcmenu if m menupopup m hmenu m menupopup destroy menu else if m hmenu destroy menu m hmenu endif cbuttonst cbuttonst m_dcbk m_hdc m_pbmpoldbk m_dcbk selectobject m_pbmpoldbk selectobject m_dcbk m_pbmpoldbk freeresources m_hcursor destroycursor m_hcursor btnst_use_bcmenu m_menupopup m_hmenu m_menupopup destroymenu m_hmenu destroymenu m_hmenu void c buttonst draw item lpdrawitemstruct lpdis cdc pdc cdc from handle lpdis hdc checkbox if m bischeckbox m bispressed lpdis item state ods selected m ncheck 0 if else normal button or other button style m bispressed lpdis item state ods selected if there is a menu and it s displayed draw the button as pressed if ifdef btnst use bcmenu m menupopup m hmenu else m hmenu endif m bmenudisplayed m bispressed true else m bisfocused lpdis item state ods focus m bisdisabled lpdis item state ods disabled c rect item rect lpdis rc item pdc set bk mode transparent prepare draw paint button background draw transparent if m bdrawtransparent paint bk pdc else on draw background pdc item rect draw button border on draw border pdc item rect read the button s title c string s title get window text s title c rect caption rect lpdis rc item draw the icon if m csicons 0 h icon draw the icon pdc s title is empty lpdis rc item caption rect m bispressed m bisdisabled if if m csbitmaps 0 h bitmap pdc set bk color rgb 255 255 255 draw the bitmap pdc s title is empty lpdis rc item caption rect m bispressed m bisdisabled if write the button title if any if s title is empty false draw the text pdc lpctstr s title lpdis rc item caption rect m bispressed m bisdisabled if if m bisflat false m bisflat m bdrawflatfocus draw the focus rect if m bisfocused c rect focus rect item rect focus rect deflate rect 3 3 pdc draw focus rect focus rect if if cbuttonst drawitem fromhandle m_bischeckbox m_bispressed itemstate ods_selected m_ncheck m_bispressed itemstate ods_selected btnst_use_bcmenu m_menupopup m_hmenu m_hmenu m_bmenudisplayed m_bispressed m_bisfocused itemstate ods_focus m_bisdisabled itemstate ods_disabled crect itemrect rcitem setbkmode m_bdrawtransparent paintbk ondrawbackground itemrect ondrawborder itemrect cstring stitle getwindowtext stitle crect captionrect rcitem m_csicons hicon drawtheicon stitle isempty rcitem captionrect m_bispressed m_bisdisabled m_csbitmaps hbitmap setbkcolor drawthebitmap stitle isempty rcitem captionrect m_bispressed m_bisdisabled stitle isempty drawthetext stitle rcitem captionrect m_bispressed m_bisdisabled m_bisflat m_bisflat m_bdrawflatfocus m_bisfocused crect focusrect itemrect focusrect deflaterect drawfocusrect focusrect bool c buttonst pre translate message msg p msg init tool tip m tooltip relay event p msg if p msg message wm lbuttondblclk p msg message wm lbuttondown return c button pre translate message p msg cbuttonst pretranslatemessage pmsg inittooltip m_tooltip relayevent pmsg pmsg wm_lbuttondblclk pmsg wm_lbuttondown cbutton pretranslatemessage pmsg void c buttonst pre subclass window uint nbs nbs get button style set initial control type m ntypestyle nbs bs typemask check if this is a checkbox if nbs bs checkbox m bischeckbox true set initial default state flag if m ntypestyle bs defpushbutton set default state for a default button m bisdefault true adjust style for default button m ntypestyle bs pushbutton if you should not set the owner draw before this call don t use the resource editor owner draw or modify style 0 bs ownerdraw before calling pre subclass window assert m ntypestyle bs ownerdraw switch to owner draw modify style bs typemask bs ownerdraw swp framechanged c button pre subclass window cbuttonst presubclasswindow getbuttonstyle m_ntypestyle bs_typemask bs_checkbox m_bischeckbox m_ntypestyle bs_defpushbutton m_bisdefault m_ntypestyle bs_pushbutton modifystyle bs_ownerdraw presubclasswindow m_ntypestyle bs_ownerdraw modifystyle bs_typemask bs_ownerdraw swp_framechanged cbutton presubclasswindow dword c buttonst set default colors bool b repaint if m busesystemcolor btnst color bk in m crcolors btnst color bk in get sys color color btnface if m busesystemcolor btnst color fg in m crcolors btnst color fg in get sys color color btntext if m busesystemcolor btnst color bk out m crcolors btnst color bk out get sys color color btnface if m busesystemcolor btnst color fg out m crcolors btnst color fg out get sys color color btntext if m busesystemcolor btnst color bk focus m crcolors btnst color bk focus get sys color color btnface if m busesystemcolor btnst color fg focus m crcolors btnst color fg focus get sys color color btntext if b repaint invalidate return btnst ok cbuttonst setdefaultcolors brepaint m_busesystemcolor btnst_color_bk_in m_crcolors btnst_color_bk_in getsyscolor color_btnface m_busesystemcolor btnst_color_fg_in m_crcolors btnst_color_fg_in getsyscolor color_btntext m_busesystemcolor btnst_color_bk_out m_crcolors btnst_color_bk_out getsyscolor color_btnface m_busesystemcolor btnst_color_fg_out m_crcolors btnst_color_fg_out getsyscolor color_btntext m_busesystemcolor btnst_color_bk_focus m_crcolors btnst_color_bk_focus getsyscolor color_btnface m_busesystemcolor btnst_color_fg_focus m_crcolors btnst_color_fg_focus getsyscolor color_btntext brepaint btnst_ok dword c buttonst set color byte by color index colorref cr color bool b repaint if by color index btnst max colors return btnst invalidindex set new color m crcolors by color index cr color use the custom color not the system color m busesystemcolor by color index false if b repaint invalidate return btnst ok cbuttonst setcolor bycolorindex crcolor brepaint bycolorindex btnst_max_colors btnst_invalidindex m_crcolors bycolorindex crcolor m_busesystemcolor bycolorindex brepaint btnst_ok dword c buttonst get color byte by color index colorref crp color if by color index btnst max colors return btnst invalidindex get color crp color m crcolors by color index return btnst ok cbuttonst getcolor bycolorindex crpcolor bycolorindex btnst_max_colors btnst_invalidindex crpcolor m_crcolors bycolorindex btnst_ok dword c buttonst offset color byte by color index short sh offset bool b repaint byte by red 0 byte by green 0 byte by blue 0 short sh offsetr sh offset short sh offsetg sh offset short sh offsetb sh offset if by color index btnst max colors return btnst invalidindex if sh offset 255 sh offset 255 return btnst badparam get rgb components of specified color by red getr value m crcolors by color index by green getg value m crcolors by color index by blue getb value m crcolors by color index calculate max allowed real offset if sh offset 0 if by red sh offset 255 sh offsetr short 255 by red if by green sh offset 255 sh offsetg short 255 by green if by blue sh offset 255 sh offsetb short 255 by blue sh offset min min sh offsetr sh offsetg sh offsetb if else if by red sh offset 0 sh offsetr short by red if by green sh offset 0 sh offsetg short by green if by blue sh offset 0 sh offsetb short by blue sh offset max max sh offsetr sh offsetg sh offsetb else set new color m crcolors by color index rgb by red sh offset by green sh offset by blue sh offset use the custom color not the system color m busesystemcolor by color index false if b repaint invalidate return btnst ok cbuttonst offsetcolor bycolorindex shoffset brepaint byred bygreen byblue shoffsetr shoffset shoffsetg shoffset shoffsetb shoffset bycolorindex btnst_max_colors btnst_invalidindex shoffset shoffset btnst_badparam byred getrvalue m_crcolors bycolorindex bygreen getgvalue m_crcolors bycolorindex byblue getbvalue m_crcolors bycolorindex shoffset byred shoffset shoffsetr byred bygreen shoffset shoffsetg bygreen byblue shoffset shoffsetb byblue shoffset shoffsetr shoffsetg shoffsetb byred shoffset shoffsetr byred bygreen shoffset shoffsetg bygreen byblue shoffset shoffsetb byblue shoffset shoffsetr shoffsetg shoffsetb m_crcolors bycolorindex byred shoffset bygreen shoffset byblue shoffset m_busesystemcolor bycolorindex brepaint btnst_ok dword c buttonst set check int n check bool b repaint if m bischeckbox if n check 0 m ncheck 0 else m ncheck 1 if b repaint invalidate if return btnst ok cbuttonst setcheck ncheck brepaint m_bischeckbox ncheck m_ncheck m_ncheck brepaint btnst_ok int c buttonst get check return m ncheck cbuttonst getcheck m_ncheck dword c buttonst seturl lpctstr lpszurl remove any existing url memset m szurl 0 sizeof m szurl if lpszurl store the url tcsncpy m szurl lpszurl max path if return btnst ok cbuttonst m_szurl m_szurl _tcsncpy m_szurl _max_path btnst_ok void c buttonst draw transparent bool b repaint m bdrawtransparent true restore old bitmap if any if m dcbk m hdc null m pbmpoldbk null m dcbk select object m pbmpoldbk select object m dcbk m pbmpoldbk if m bmpbk delete object m dcbk deletedc repaint the button if b repaint invalidate cbuttonst drawtransparent brepaint m_bdrawtransparent m_dcbk m_hdc m_pbmpoldbk m_dcbk selectobject m_pbmpoldbk selectobject m_dcbk m_pbmpoldbk m_bmpbk deleteobject m_dcbk brepaint dword c buttonst set bk cdc pdc if m bdrawtransparent pdc restore old bitmap if any if m dcbk m hdc null m pbmpoldbk null m dcbk select object m pbmpoldbk select object m dcbk m pbmpoldbk if m bmpbk delete object m dcbk deletedc c rect rect c rect rect1 get client rect rect get window rect rect1 get parent screen to client rect1 m dcbk create compatibledc pdc m bmpbk create compatible bitmap pdc rect width rect height m pbmpoldbk m dcbk select object m bmpbk m pbmpoldbk hbitmap select object m dcbk hbitmap m bmpbk m dcbk bit blt 0 0 rect width rect height pdc rect1 left rect1 top srccopy return btnst ok if return btnst badparam cbuttonst setbk m_bdrawtransparent m_dcbk m_hdc m_pbmpoldbk m_dcbk selectobject m_pbmpoldbk selectobject m_dcbk m_pbmpoldbk m_bmpbk deleteobject m_dcbk crect crect getclientrect getwindowrect getparent screentoclient m_dcbk createcompatibledc m_bmpbk createcompatiblebitmap m_pbmpoldbk m_dcbk selectobject m_bmpbk m_pbmpoldbk selectobject m_dcbk m_bmpbk m_dcbk bitblt btnst_ok btnst_badparam bool c buttonst get default return m bisdefault cbuttonst getdefault m_bisdefault dword c buttonst set always track bool b always track m balwaystrack b always track return btnst ok cbuttonst setalwaystrack balwaystrack m_balwaystrack balwaystrack btnst_ok void c buttonst set tooltip text int n text bool b activate c string s text load string resource s text load string n text if string resource is not empty if s text is empty false set tooltip text lpctstr s text b activate cbuttonst settooltiptext ntext bactivate cstring stext stext loadstring ntext stext isempty settooltiptext stext bactivate void c buttonst set tooltip text lpctstr lpsz text bool b activate we cannot accept null pointer if lpsz text null return initialize tool tip init tool tip if there is no tooltip defined then add it if m tooltip get tool count 0 c rect rect btn get client rect rect btn m tooltip add tool this lpsz text rect btn 1 if set text for tooltip m tooltip update tip text lpsz text this 1 m tooltip activate b activate cbuttonst settooltiptext lpsztext bactivate lpsztext tooltip inittooltip m_tooltip gettoolcount crect rectbtn getclientrect rectbtn m_tooltip addtool lpsztext rectbtn m_tooltip updatetiptext lpsztext m_tooltip bactivate void c buttonst activate tooltip bool b activate if there is no tooltip then do nothing if m tooltip get tool count 0 return activate tooltip m tooltip activate b activate cbuttonst activatetooltip bactivate m_tooltip gettoolcount m_tooltip bactivate dword c buttonst enable balloon tooltip m dwtooltipstyle tts balloon return btnst ok cbuttonst enableballoontooltip m_dwtooltipstyle tts_balloon btnst_ok dword c buttonst set btn cursor int n cursor id bool b repaint hinstance h inst resource null destroy any previous cursor if m hcursor destroy cursor m hcursor m hcursor null if load cursor if n cursor id h inst resource afx find resource handle makeintresource n cursor id rt group cursor load cursor resource m hcursor hcursor load image h inst resource makeintresource n cursor id image cursor 0 0 0 repaint the button if b repaint invalidate if something wrong if m hcursor null return btnst invalidresource if return btnst ok cbuttonst setbtncursor ncursorid brepaint hinstresource m_hcursor destroycursor m_hcursor m_hcursor ncursorid hinstresource afxfindresourcehandle ncursorid rt_group_cursor m_hcursor loadimage hinstresource ncursorid image_cursor brepaint m_hcursor btnst_invalidresource btnst_ok dword c buttonst set flat bool b flat bool b repaint m bisflat b flat if b repaint invalidate return btnst ok cbuttonst setflat bflat brepaint m_bisflat bflat brepaint btnst_ok dword c buttonst set align byte by align bool b repaint switch by align case st align horiz case st align horiz right case st align vert case st align overlap m byalign by align if b repaint invalidate return btnst ok break switch return btnst invalidalign cbuttonst setalign byalign brepaint byalign st_align_horiz st_align_horiz_right st_align_vert st_align_overlap m_byalign byalign brepaint btnst_ok btnst_invalidalign dword c buttonst set pressed style byte by style bool b repaint switch by style case btnst pressed leftright m ptpressedoffset x 1 m ptpressedoffset y 1 break case btnst pressed topbottom m ptpressedoffset x 0 m ptpressedoffset y 2 break default return btnst invalidpressedstyle switch if b repaint invalidate return btnst ok cbuttonst setpressedstyle bystyle brepaint bystyle btnst_pressed_leftright m_ptpressedoffset m_ptpressedoffset btnst_pressed_topbottom m_ptpressedoffset m_ptpressedoffset btnst_invalidpressedstyle brepaint btnst_ok dword c buttonst draw border bool b draw border bool b repaint m bdrawborder b draw border repaint the button if b repaint invalidate return btnst ok cbuttonst drawborder bdrawborder brepaint m_bdrawborder bdrawborder brepaint btnst_ok dword c buttonst draw flat focus bool b draw flat focus bool b repaint m bdrawflatfocus b draw flat focus repaint the button if b repaint invalidate return btnst ok cbuttonst drawflatfocus bdrawflatfocus brepaint m_bdrawflatfocus bdrawflatfocus brepaint btnst_ok dword c buttonst set icon int n icon in int n cx desired in int n cy desired in int n icon out int n cx desired out int n cy desired out hicon h icon in null hicon h icon out null hinstance h inst resource null find correct resource handle h inst resource afx find resource handle makeintresource n icon in rt group icon set icon when the mouse is in the button h icon in hicon load image h inst resource makeintresource n icon in image icon n cx desired in n cy desired in 0 set icon when the mouse is out the button switch n icon out case null break case int btnst auto gray h icon out btnst auto gray break case int btnst auto darker h icon out btnst auto darker break default h icon out hicon load image h inst resource makeintresource n icon out image icon n cx desired out n cy desired out 0 break switch return set icon h icon in h icon out cbuttonst seticon niconin ncxdesiredin ncydesiredin niconout ncxdesiredout ncydesiredout hiconin hiconout hinstresource hinstresource afxfindresourcehandle niconin rt_group_icon hiconin loadimage hinstresource niconin image_icon ncxdesiredin ncydesiredin niconout btnst_auto_gray hiconout btnst_auto_gray btnst_auto_darker hiconout btnst_auto_darker hiconout loadimage hinstresource niconout image_icon ncxdesiredout ncydesiredout seticon hiconin hiconout dword c buttonst set icon int n icon in int n icon out return set icon n icon in 0 0 n icon out 0 0 cbuttonst seticon niconin niconout seticon niconin niconout dword c buttonst set icon hicon h icon in hicon h icon out bool b ret value iconinfo ii free any loaded resource free resources if h icon in icon when mouse over button m csicons 0 h icon h icon in get icon dimension zero memory ii sizeof iconinfo b ret value get icon info h icon in ii if b ret value false free resources return btnst invalidresource if m csicons 0 dw width dword ii x hotspot 2 m csicons 0 dw height dword ii y hotspot 2 delete object ii hbm mask delete object ii hbm color icon when mouse outside button if h icon out switch int h icon out case int btnst auto gray h icon out create grayscale icon h icon in break case int btnst auto darker h icon out create darker icon h icon in break switch m csicons 1 h icon h icon out get icon dimension zero memory ii sizeof iconinfo b ret value get icon info h icon out ii if b ret value false free resources return btnst invalidresource if m csicons 1 dw width dword ii x hotspot 2 m csicons 1 dw height dword ii y hotspot 2 delete object ii hbm mask delete object ii hbm color if if invalidate return btnst ok cbuttonst seticon hiconin hiconout bretvalue freeresources hiconin m_csicons hicon hiconin zeromemory bretvalue geticoninfo hiconin bretvalue freeresources btnst_invalidresource m_csicons dwwidth xhotspot m_csicons dwheight yhotspot deleteobject hbmmask deleteobject hbmcolor hiconout hiconout btnst_auto_gray hiconout creategrayscaleicon hiconin btnst_auto_darker hiconout createdarkericon hiconin m_csicons hicon hiconout zeromemory bretvalue geticoninfo hiconout bretvalue freeresources btnst_invalidresource m_csicons dwwidth xhotspot m_csicons dwheight yhotspot deleteobject hbmmask deleteobject hbmcolor btnst_ok dword c buttonst set bitmaps int n bitmap in colorref cr trans color in int n bitmap out colorref cr trans color out hbitmap h bitmap in null hbitmap h bitmap out null hinstance h inst resource null find correct resource handle h inst resource afx find resource handle makeintresource n bitmap in rt bitmap load bitmap in h bitmap in hbitmap load image h inst resource makeintresource n bitmap in image bitmap 0 0 0 load bitmap out switch n bitmap out case null break case int btnst auto gray h bitmap out hbitmap btnst auto gray break case int btnst auto darker h bitmap out hbitmap btnst auto darker break default h bitmap out hbitmap load image h inst resource makeintresource n bitmap out image bitmap 0 0 0 break if return set bitmaps h bitmap in cr trans color in h bitmap out cr trans color out cbuttonst setbitmaps nbitmapin crtranscolorin nbitmapout crtranscolorout hbitmapin hbitmapout hinstresource hinstresource afxfindresourcehandle nbitmapin rt_bitmap hbitmapin loadimage hinstresource nbitmapin image_bitmap nbitmapout btnst_auto_gray hbitmapout btnst_auto_gray btnst_auto_darker hbitmapout btnst_auto_darker hbitmapout loadimage hinstresource nbitmapout image_bitmap setbitmaps hbitmapin crtranscolorin hbitmapout crtranscolorout dword c buttonst set bitmaps hbitmap h bitmap in colorref cr trans color in hbitmap h bitmap out colorref cr trans color out int n ret value 0 bitmap cs bitmap size free any loaded resource free resources if h bitmap in m csbitmaps 0 h bitmap h bitmap in m csbitmaps 0 cr transparent cr trans color in get bitmap size n ret value get object h bitmap in sizeof cs bitmap size cs bitmap size if n ret value 0 free resources return btnst invalidresource if m csbitmaps 0 dw width dword cs bitmap size bm width m csbitmaps 0 dw height dword cs bitmap size bm height create grayscale darker bitmap before mask of h bitmap in switch int h bitmap out case int btnst auto gray h bitmap out create grayscale bitmap h bitmap in m csbitmaps 0 dw width m csbitmaps 0 dw height cr trans color in m csbitmaps 1 h bitmap h bitmap out cr trans color out cr trans color in break case int btnst auto darker h bitmap out create darker bitmap h bitmap in m csbitmaps 0 dw width m csbitmaps 0 dw height cr trans color in m csbitmaps 1 h bitmap h bitmap out cr trans color out cr trans color in break switch create mask for bitmap in m csbitmaps 0 h mask create bitmap mask h bitmap in m csbitmaps 0 dw width m csbitmaps 0 dw height cr trans color in if m csbitmaps 0 h mask null free resources return btnst failedmask if if h bitmap out m csbitmaps 1 h bitmap h bitmap out m csbitmaps 1 cr transparent cr trans color out get bitmap size n ret value get object h bitmap out sizeof cs bitmap size cs bitmap size if n ret value 0 free resources return btnst invalidresource if m csbitmaps 1 dw width dword cs bitmap size bm width m csbitmaps 1 dw height dword cs bitmap size bm height create mask for bitmap out m csbitmaps 1 h mask create bitmap mask h bitmap out m csbitmaps 1 dw width m csbitmaps 1 dw height cr trans color out if m csbitmaps 1 h mask null free resources return btnst failedmask if if if invalidate return btnst ok cbuttonst setbitmaps hbitmapin crtranscolorin hbitmapout crtranscolorout nretvalue csbitmapsize freeresources hbitmapin m_csbitmaps hbitmap hbitmapin m_csbitmaps crtransparent crtranscolorin nretvalue getobject hbitmapin csbitmapsize csbitmapsize nretvalue freeresources btnst_invalidresource m_csbitmaps dwwidth csbitmapsize bmwidth m_csbitmaps dwheight csbitmapsize bmheight hbitmapin hbitmapout btnst_auto_gray hbitmapout creategrayscalebitmap hbitmapin m_csbitmaps dwwidth m_csbitmaps dwheight crtranscolorin m_csbitmaps hbitmap hbitmapout crtranscolorout crtranscolorin btnst_auto_darker hbitmapout createdarkerbitmap hbitmapin m_csbitmaps dwwidth m_csbitmaps dwheight crtranscolorin m_csbitmaps hbitmap hbitmapout crtranscolorout crtranscolorin m_csbitmaps hmask createbitmapmask hbitmapin m_csbitmaps dwwidth m_csbitmaps dwheight crtranscolorin m_csbitmaps hmask freeresources btnst_failedmask hbitmapout m_csbitmaps hbitmap hbitmapout m_csbitmaps crtransparent crtranscolorout nretvalue getobject hbitmapout csbitmapsize csbitmapsize nretvalue freeresources btnst_invalidresource m_csbitmaps dwwidth csbitmapsize bmwidth m_csbitmaps dwheight csbitmapsize bmheight m_csbitmaps hmask createbitmapmask hbitmapout m_csbitmaps dwwidth m_csbitmaps dwheight crtranscolorout m_csbitmaps hmask freeresources btnst_failedmask btnst_ok void c buttonst size to content if m csicons 0 h icon m ptimageorg x 0 m ptimageorg y 0 set window pos null 1 1 m csicons 0 dw width m csicons 0 dw height swp nomove swp nozorder swp noredraw swp noactivate if else if m csbitmaps 0 h bitmap m ptimageorg x 0 m ptimageorg y 0 set window pos null 1 1 m csbitmaps 0 dw width m csbitmaps 0 dw height swp nomove swp nozorder swp noredraw swp noactivate if cbuttonst sizetocontent m_csicons hicon m_ptimageorg m_ptimageorg setwindowpos m_csicons dwwidth m_csicons dwheight swp_nomove swp_nozorder swp_noredraw swp_noactivate m_csbitmaps hbitmap m_ptimageorg m_ptimageorg setwindowpos m_csbitmaps dwwidth m_csbitmaps dwheight swp_nomove swp_nozorder swp_noredraw swp_noactivate dword c buttonst set menu uint n menu hwnd h parent wnd bool b winxp style uint n toolbarid c size size toolbar icon colorref cr toolbar bk bool b repaint bool b ret value false destroy any previous menu if m menupopup m hmenu m menupopup destroy menu m hparentwndmenu null m bmenudisplayed false if load menu if n menu m menupopup set menu draw mode b winxp style load menu b ret value m menupopup load menu n menu if something wrong if b ret value false return btnst invalidresource load toolbar if n toolbarid m menupopup set bitmap background cr toolbar bk m menupopup set icon size size toolbar icon cx size toolbar icon cy b ret value m menupopup load toolbar n toolbarid n toolbarid if something wrong if b ret value false m menupopup destroy menu return btnst invalidresource if if m hparentwndmenu h parent wnd if repaint the button if b repaint invalidate return btnst ok cbuttonst setmenu nmenu hparentwnd bwinxpstyle ntoolbarid csize sizetoolbaricon crtoolbarbk brepaint bretvalue m_menupopup m_hmenu m_menupopup destroymenu m_hparentwndmenu m_bmenudisplayed nmenu m_menupopup setmenudrawmode bwinxpstyle bretvalue m_menupopup loadmenu nmenu bretvalue btnst_invalidresource ntoolbarid m_menupopup setbitmapbackground crtoolbarbk m_menupopup seticonsize sizetoolbaricon sizetoolbaricon bretvalue m_menupopup loadtoolbar ntoolbarid ntoolbarid bretvalue m_menupopup destroymenu btnst_invalidresource m_hparentwndmenu hparentwnd brepaint btnst_ok dword c buttonst set menu callback hwnd h wnd uint n message lparam l param m cscallbacks h wnd h wnd m cscallbacks n message n message m cscallbacks l param l param return btnst ok cbuttonst setmenucallback hwnd nmessage lparam m_cscallbacks hwnd hwnd m_cscallbacks nmessage nmessage m_cscallbacks lparam lparam btnst_ok bool c buttonst on set cursor c wnd p wnd uint n hit test uint message if a cursor was specified then use it if m hcursor null set cursor m hcursor return true if return c button on set cursor p wnd n hit test message cbuttonst onsetcursor cwnd pwnd nhittest m_hcursor setcursor m_hcursor cbutton onsetcursor pwnd nhittest void c buttonst on kill focus c wnd p new wnd c button on kill focus p new wnd cancel hover cbuttonst onkillfocus cwnd pnewwnd cbutton onkillfocus pnewwnd cancelhover void c buttonst on mouse move uint n flags c point point c wnd wnd under mouse null c wnd wnd active this trackmouseevent cstme c button on mouse move n flags point client to screen point wnd under mouse window from point point if the mouse enter the button with the left button pressed then do nothing if n flags mk lbutton m bmouseonbutton false return if our button is not flat then do nothing if m bisflat false return if m balwaystrack false wnd active get active window if wnd under mouse wnd under mouse m hwnd m hwnd wnd active if m bmouseonbutton m bmouseonbutton true invalidate ifdef btnst use sound play sound if m cssounds 0 lpsz sound play sound m cssounds 0 lpsz sound m cssounds 0 h mod m cssounds 0 dw flags endif cstme cb size sizeof cstme cstme dw flags tme leave cstme hwnd track m hwnd trackmouseevent cstme if else cancel hover cbuttonst onmousemove nflags cpoint cwnd wndundermouse cwnd wndactive cbutton onmousemove nflags clienttoscreen wndundermouse windowfrompoint nflags mk_lbutton m_bmouseonbutton m_bisflat m_balwaystrack wndactive getactivewindow wndundermouse wndundermouse m_hwnd m_hwnd wndactive m_bmouseonbutton m_bmouseonbutton btnst_use_sound m_cssounds lpszsound playsound m_cssounds lpszsound m_cssounds hmod m_cssounds dwflags cbsize dwflags tme_leave hwndtrack m_hwnd _trackmouseevent cancelhover void c buttonst on sys color change c button on sys color change m dcbk deletedc m bmpbk delete object set default colors cbuttonst onsyscolorchange cbutton onsyscolorchange m_dcbk m_bmpbk deleteobject setdefaultcolors bool c buttonst on clicked set focus ifdef btnst use sound play sound if m cssounds 1 lpsz sound play sound m cssounds 1 lpsz sound m cssounds 1 h mod m cssounds 1 dw flags endif if m bischeckbox m ncheck m ncheck invalidate if else handle the menu if any ifdef btnst use bcmenu if m menupopup m hmenu else if m hmenu endif c rect r wnd get window rect r wnd m bmenudisplayed true invalidate ifdef btnst use bcmenu bc menu psub bc menu m menupopup get sub menu 0 if m cscallbacks h wnd send message m cscallbacks h wnd m cscallbacks n message wparam psub m cscallbacks l param c pw safe dlg translatemenu psub false null dword dw ret value psub track popup menu tpm leftalign tpm leftbutton tpm rightbutton tpm nonotify tpm returncmd r wnd left r wnd bottom this null else hmenu h sub menu get sub menu m hmenu 0 if m cscallbacks h wnd send message m cscallbacks h wnd m cscallbacks n message wparam h sub menu m cscallbacks l param dword dw ret value track popup menu ex h sub menu tpm leftalign tpm leftbutton tpm rightbutton tpm nonotify tpm returncmd r wnd left r wnd bottom m hparentwndmenu null endif m bmenudisplayed false invalidate if dw ret value post message m hparentwndmenu wm command makewparam dw ret value 0 lparam null if else handle the url if any if tcslen m szurl 0 shellexecuteinfo cssei memset cssei 0 sizeof cssei cssei cb size sizeof shellexecuteinfo cssei f mask see mask flag no ui cssei lp verb t open cssei lp file m szurl cssei n show sw showmaximized shell execute ex cssei if else else return false cbuttonst onclicked setfocus btnst_use_sound m_cssounds lpszsound playsound m_cssounds lpszsound m_cssounds hmod m_cssounds dwflags m_bischeckbox m_ncheck m_ncheck btnst_use_bcmenu m_menupopup m_hmenu m_hmenu crect rwnd getwindowrect rwnd m_bmenudisplayed btnst_use_bcmenu bcmenu bcmenu m_menupopup getsubmenu m_cscallbacks hwnd sendmessage m_cscallbacks hwnd m_cscallbacks nmessage m_cscallbacks lparam cpwsafedlg _translatemenu dwretvalue trackpopupmenu tpm_leftalign tpm_leftbutton tpm_rightbutton tpm_nonotify tpm_returncmd rwnd rwnd hsubmenu getsubmenu m_hmenu m_cscallbacks hwnd sendmessage m_cscallbacks hwnd m_cscallbacks nmessage hsubmenu m_cscallbacks lparam dwretvalue trackpopupmenuex hsubmenu tpm_leftalign tpm_leftbutton tpm_rightbutton tpm_nonotify tpm_returncmd rwnd rwnd m_hparentwndmenu m_bmenudisplayed dwretvalue postmessage m_hparentwndmenu wm_command dwretvalue _tcslen m_szurl cbsize fmask see_mask_flag_no_ui lpverb _t lpfile m_szurl nshow sw_showmaximized shellexecuteex void c buttonst on activate uint n state c wnd p wnd other bool b minimized c button on activate n state p wnd other b minimized if n state wa inactive cancel hover cbuttonst onactivate nstate cwnd pwndother bminimized cbutton onactivate nstate pwndother bminimized nstate wa_inactive cancelhover void c buttonst on enable bool b enable c button on enable b enable if b enable false cancel hover if cbuttonst onenable benable cbutton onenable benable benable cancelhover void c buttonst on cancel mode c button on cancel mode cancel hover cbuttonst oncancelmode cbutton oncancelmode cancelhover uint c buttonst on get dlg code uint n code c button on get dlg code tell the system if we want default state handling losing default state always allowed n code m bisdefault dlgc defpushbutton dlgc undefpushbutton return n code cbuttonst ongetdlgcode ncode cbutton ongetdlgcode ncode m_bisdefault dlgc_defpushbutton dlgc_undefpushbutton ncode bool c buttonst on erase bkgnd cdc pdc unreferenced parameter pdc do nothing return false cbuttonst onerasebkgnd unreferenced_parameter lresult c buttonst on menu char uint n char uint n flags c menu p menu lresult l result if bc menu is menu p menu l result bc menu find keyboard shortcut n char n flags p menu else l result c button on menu char n char n flags p menu return l result cbuttonst onmenuchar nchar nflags cmenu pmenu lresult bcmenu ismenu pmenu lresult bcmenu findkeyboardshortcut nchar nflags pmenu lresult cbutton onmenuchar nchar nflags pmenu lresult void c buttonst on measure item int nid ctl lpmeasureitemstruct lp measure item struct bool b set flag false if lp measure item struct ctl type odt menu if is menu hmenu lp measure item struct itemid bc menu is menu hmenu lp measure item struct itemid m menupopup measure item lp measure item struct b set flag true if if if b set flag c button on measure item nid ctl lp measure item struct cbuttonst onmeasureitem nidctl lpmeasureitemstruct bsetflag lpmeasureitemstruct ctltype odt_menu ismenu lpmeasureitemstruct bcmenu ismenu lpmeasureitemstruct m_menupopup measureitem lpmeasureitemstruct bsetflag bsetflag cbutton onmeasureitem nidctl lpmeasureitemstruct hbrush c buttonst ctl color cdc pdc uint n ctl color unreferenced parameter pdc unreferenced parameter n ctl color return hbrush get stock object null brush cbuttonst ctlcolor nctlcolor unreferenced_parameter unreferenced_parameter nctlcolor getstockobject null_brush hicon c buttonst create grayscale icon hicon h icon hicon h gray icon null hdc h maindc null h memdc1 null h memdc2 null bitmap bmp hbitmap h old bmp1 null h old bmp2 null iconinfo csii cs grayii bool b ret value false b ret value get icon info h icon csii if b ret value false return null h maindc getdc null h memdc1 create compatibledc h maindc h memdc2 create compatibledc h maindc if h maindc null h memdc1 null h memdc2 null return null if get object csii hbm color sizeof bitmap bmp dword dw width csii x hotspot 2 dword dw height csii y hotspot 2 cs grayii hbm color create bitmap dw width dw height bmp bm planes bmp bm bits pixel null if cs grayii hbm color h old bmp1 hbitmap select object h memdc1 csii hbm color h old bmp2 hbitmap select object h memdc2 cs grayii hbm color bit blt h memdc2 0 0 dw width dw height h memdc1 0 0 srccopy dword dw loopy 0 dw loopx 0 colorref cr pixel 0 byte by new pixel 0 for dw loopy 0 dw loopy dw height dw loopy for dw loopx 0 dw loopx dw width dw loopx cr pixel get pixel h memdc1 dw loopx dw loopy by new pixel byte getr value cr pixel 0 299 getg value cr pixel 0 587 getb value cr pixel 0 114 if cr pixel set pixel h memdc2 dw loopx dw loopy rgb by new pixel by new pixel by new pixel else set pixel h memdc2 dw loopx dw loopy cr pixel for for select object h memdc1 h old bmp1 select object h memdc2 h old bmp2 cs grayii hbm mask csii hbm mask cs grayii f icon true h gray icon create icon indirect cs grayii if delete object cs grayii hbm color delete object cs grayii hbm mask if delete object csii hbm color delete object csii hbm mask deletedc h memdc1 deletedc h memdc2 releasedc null h maindc return h gray icon cbuttonst creategrayscaleicon hicon hgrayicon hmaindc hmemdc1 hmemdc2 holdbmp1 holdbmp2 csgrayii bretvalue bretvalue geticoninfo hicon bretvalue hmaindc hmemdc1 createcompatibledc hmaindc hmemdc2 createcompatibledc hmaindc hmaindc hmemdc1 hmemdc2 getobject hbmcolor dwwidth xhotspot dwheight yhotspot csgrayii hbmcolor createbitmap dwwidth dwheight bmplanes bmbitspixel csgrayii hbmcolor holdbmp1 selectobject hmemdc1 hbmcolor holdbmp2 selectobject hmemdc2 csgrayii hbmcolor bitblt hmemdc2 dwwidth dwheight hmemdc1 dwloopy dwloopx crpixel bynewpixel dwloopy dwloopy dwheight dwloopy dwloopx dwloopx dwwidth dwloopx crpixel getpixel hmemdc1 dwloopx dwloopy bynewpixel getrvalue crpixel getgvalue crpixel getbvalue crpixel crpixel setpixel hmemdc2 dwloopx dwloopy bynewpixel bynewpixel bynewpixel setpixel hmemdc2 dwloopx dwloopy crpixel selectobject hmemdc1 holdbmp1 selectobject hmemdc2 holdbmp2 csgrayii hbmmask hbmmask csgrayii ficon hgrayicon createiconindirect csgrayii deleteobject csgrayii hbmcolor deleteobject csgrayii hbmmask deleteobject hbmcolor deleteobject hbmmask hmemdc1 hmemdc2 hmaindc hgrayicon hicon c buttonst create darker icon hicon h icon hicon h gray icon null hdc h maindc null h memdc1 null h memdc2 null bitmap bmp hbitmap h old bmp1 null h old bmp2 null iconinfo csii cs grayii bool b ret value false b ret value get icon info h icon csii if b ret value false return null h maindc getdc null h memdc1 create compatibledc h maindc h memdc2 create compatibledc h maindc if h maindc null h memdc1 null h memdc2 null return null if get object csii hbm color sizeof bitmap bmp dword dw width csii x hotspot 2 dword dw height csii y hotspot 2 cs grayii hbm color create bitmap dw width dw height bmp bm planes bmp bm bits pixel null if cs grayii hbm color h old bmp1 hbitmap select object h memdc1 csii hbm color h old bmp2 hbitmap select object h memdc2 cs grayii hbm color bit blt h memdc2 0 0 dw width dw height h memdc1 0 0 srccopy dword dw loopy 0 dw loopx 0 colorref cr pixel 0 for dw loopy 0 dw loopy dw height dw loopy for dw loopx 0 dw loopx dw width dw loopx cr pixel get pixel h memdc1 dw loopx dw loopy if cr pixel set pixel h memdc2 dw loopx dw loopy darken color cr pixel 0 25 else set pixel h memdc2 dw loopx dw loopy cr pixel for for select object h memdc1 h old bmp1 select object h memdc2 h old bmp2 cs grayii hbm mask csii hbm mask cs grayii f icon true h gray icon create icon indirect cs grayii if delete object cs grayii hbm color delete object cs grayii hbm mask if delete object csii hbm color delete object csii hbm mask deletedc h memdc1 deletedc h memdc2 releasedc null h maindc return h gray icon cbuttonst createdarkericon hicon hgrayicon hmaindc hmemdc1 hmemdc2 holdbmp1 holdbmp2 csgrayii bretvalue bretvalue geticoninfo hicon bretvalue hmaindc hmemdc1 createcompatibledc hmaindc hmemdc2 createcompatibledc hmaindc hmaindc hmemdc1 hmemdc2 getobject hbmcolor dwwidth xhotspot dwheight yhotspot csgrayii hbmcolor createbitmap dwwidth dwheight bmplanes bmbitspixel csgrayii hbmcolor holdbmp1 selectobject hmemdc1 hbmcolor holdbmp2 selectobject hmemdc2 csgrayii hbmcolor bitblt hmemdc2 dwwidth dwheight hmemdc1 dwloopy dwloopx crpixel dwloopy dwloopy dwheight dwloopy dwloopx dwloopx dwwidth dwloopx crpixel getpixel hmemdc1 dwloopx dwloopy crpixel setpixel hmemdc2 dwloopx dwloopy darkencolor crpixel setpixel hmemdc2 dwloopx dwloopy crpixel selectobject hmemdc1 holdbmp1 selectobject hmemdc2 holdbmp2 csgrayii hbmmask hbmmask csgrayii ficon hgrayicon createiconindirect csgrayii deleteobject csgrayii hbmcolor deleteobject csgrayii hbmmask deleteobject hbmcolor deleteobject hbmmask hmemdc1 hmemdc2 hmaindc hgrayicon hbitmap c buttonst create grayscale bitmap hbitmap h bitmap dword dw width dword dw height colorref cr trans hbitmap h gray bitmap null hdc h maindc null h memdc1 null h memdc2 null hbitmap h old bmp1 null h old bmp2 null h maindc getdc null if h maindc null return null h memdc1 create compatibledc h maindc if h memdc1 null releasedc null h maindc return null if h memdc2 create compatibledc h maindc if h memdc2 null deletedc h memdc1 releasedc null h maindc return null if h gray bitmap create compatible bitmap h maindc dw width dw height if h gray bitmap h old bmp1 hbitmap select object h memdc1 h gray bitmap h old bmp2 hbitmap select object h memdc2 h bitmap bit blt h memdc1 0 0 dw width dw height h memdc2 0 0 srccopy dword dw loopy 0 dw loopx 0 colorref cr pixel 0 byte by new pixel 0 for dw loopy 0 dw loopy dw height dw loopy for dw loopx 0 dw loopx dw width dw loopx cr pixel get pixel h memdc2 dw loopx dw loopy by new pixel byte getr value cr pixel 0 299 getg value cr pixel 0 587 getb value cr pixel 0 114 if cr pixel cr trans set pixel h memdc1 dw loopx dw loopy rgb by new pixel by new pixel by new pixel else set pixel h memdc1 dw loopx dw loopy cr pixel for for select object h memdc1 h old bmp1 select object h memdc2 h old bmp2 if deletedc h memdc1 deletedc h memdc2 releasedc null h maindc return h gray bitmap cbuttonst creategrayscalebitmap hbitmap dwwidth dwheight crtrans hgraybitmap hmaindc hmemdc1 hmemdc2 holdbmp1 holdbmp2 hmaindc hmaindc hmemdc1 createcompatibledc hmaindc hmemdc1 hmaindc hmemdc2 createcompatibledc hmaindc hmemdc2 hmemdc1 hmaindc hgraybitmap createcompatiblebitmap hmaindc dwwidth dwheight hgraybitmap holdbmp1 selectobject hmemdc1 hgraybitmap holdbmp2 selectobject hmemdc2 hbitmap bitblt hmemdc1 dwwidth dwheight hmemdc2 dwloopy dwloopx crpixel bynewpixel dwloopy dwloopy dwheight dwloopy dwloopx dwloopx dwwidth dwloopx crpixel getpixel hmemdc2 dwloopx dwloopy bynewpixel getrvalue crpixel getgvalue crpixel getbvalue crpixel crpixel crtrans setpixel hmemdc1 dwloopx dwloopy bynewpixel bynewpixel bynewpixel setpixel hmemdc1 dwloopx dwloopy crpixel selectobject hmemdc1 holdbmp1 selectobject hmemdc2 holdbmp2 hmemdc1 hmemdc2 hmaindc hgraybitmap hbitmap c buttonst create darker bitmap hbitmap h bitmap dword dw width dword dw height colorref cr trans hbitmap h gray bitmap null hdc h maindc null h memdc1 null h memdc2 null hbitmap h old bmp1 null h old bmp2 null h maindc getdc null if h maindc null return null h memdc1 create compatibledc h maindc if h memdc1 null releasedc null h maindc return null if h memdc2 create compatibledc h maindc if h memdc2 null deletedc h memdc1 releasedc null h maindc return null if h gray bitmap create compatible bitmap h maindc dw width dw height if h gray bitmap h old bmp1 hbitmap select object h memdc1 h gray bitmap h old bmp2 hbitmap select object h memdc2 h bitmap bit blt h memdc1 0 0 dw width dw height h memdc2 0 0 srccopy dword dw loopy 0 dw loopx 0 colorref cr pixel 0 for dw loopy 0 dw loopy dw height dw loopy for dw loopx 0 dw loopx dw width dw loopx cr pixel get pixel h memdc2 dw loopx dw loopy if cr pixel cr trans set pixel h memdc1 dw loopx dw loopy darken color cr pixel 0 25 else set pixel h memdc1 dw loopx dw loopy cr pixel for for select object h memdc1 h old bmp1 select object h memdc2 h old bmp2 if deletedc h memdc1 deletedc h memdc2 releasedc null h maindc return h gray bitmap cbuttonst createdarkerbitmap hbitmap dwwidth dwheight crtrans hgraybitmap hmaindc hmemdc1 hmemdc2 holdbmp1 holdbmp2 hmaindc hmaindc hmemdc1 createcompatibledc hmaindc hmemdc1 hmaindc hmemdc2 createcompatibledc hmaindc hmemdc2 hmemdc1 hmaindc hgraybitmap createcompatiblebitmap hmaindc dwwidth dwheight hgraybitmap holdbmp1 selectobject hmemdc1 hgraybitmap holdbmp2 selectobject hmemdc2 hbitmap bitblt hmemdc1 dwwidth dwheight hmemdc2 dwloopy dwloopx crpixel dwloopy dwloopy dwheight dwloopy dwloopx dwloopx dwwidth dwloopx crpixel getpixel hmemdc2 dwloopx dwloopy crpixel crtrans setpixel hmemdc1 dwloopx dwloopy darkencolor crpixel setpixel hmemdc1 dwloopx dwloopy crpixel selectobject hmemdc1 holdbmp1 selectobject hmemdc2 holdbmp2 hmemdc1 hmemdc2 hmaindc hgraybitmap colorref c buttonst darken color colorref cr color double d factor if d factor 0 0 d factor 1 0 byte red green blue lightred lightgreen lightblue red getr value cr color green getg value cr color blue getb value cr color lightred byte red d factor red lightgreen byte green d factor green lightblue byte blue d factor blue cr color rgb lightred lightgreen lightblue if return cr color cbuttonst darkencolor crcolor dfactor dfactor dfactor getrvalue crcolor getgvalue crcolor getbvalue crcolor dfactor dfactor dfactor crcolor crcolor dword c buttonst on draw background cdc pdc c rect p rect colorref cr color if m bisflat false if m bisfocused m bisdefault c brush br rgb 0 0 0 pdc frame rect p rect br p rect deflate rect 1 1 if if if m bmouseonbutton m bispressed cr color m crcolors btnst color bk in else if m bisfocused cr color m crcolors btnst color bk focus else cr color m crcolors btnst color bk out else c brush br background cr color pdc fill rect p rect br background return btnst ok cbuttonst ondrawbackground crect prect crcolor m_bisflat m_bisfocused m_bisdefault cbrush framerect prect prect deflaterect m_bmouseonbutton m_bispressed crcolor m_crcolors btnst_color_bk_in m_bisfocused crcolor m_crcolors btnst_color_bk_focus crcolor m_crcolors btnst_color_bk_out cbrush brbackground crcolor fillrect prect brbackground btnst_ok dword c buttonst on draw border cdc pdc c rect p rect draw pressed button if m bispressed if m bisflat if m bdrawborder pdc draw3d rect p rect get sys color color btnshadow get sys color color btnhilight else c brush br btn shadow get sys color color btnshadow pdc frame rect p rect br btn shadow else else draw non pressed button c pen pen btn hi light ps solid 0 get sys color color btnhilight white c pen pen3d light ps solid 0 get sys color color 3dlight light gray c pen pen btn shadow ps solid 0 get sys color color btnshadow dark gray c pen pen3ddk shadow ps solid 0 get sys color color 3ddkshadow black if m bisflat if m bmouseonbutton m bdrawborder pdc draw3d rect p rect get sys color color btnhilight get sys color color btnshadow else draw top left borders white line c pen p old pen pdc select object pen btn hi light pdc move to p rect left p rect bottom 1 pdc line to p rect left p rect top pdc line to p rect right p rect top light gray line pdc select object pen3d light pdc move to p rect left 1 p rect bottom 1 pdc line to p rect left 1 p rect top 1 pdc line to p rect right p rect top 1 draw bottom right borders black line pdc select object pen3ddk shadow pdc move to p rect left p rect bottom 1 pdc line to p rect right 1 p rect bottom 1 pdc line to p rect right 1 p rect top 1 dark gray line pdc select object pen btn shadow pdc move to p rect left 1 p rect bottom 2 pdc line to p rect right 2 p rect bottom 2 pdc line to p rect right 2 p rect top pdc select object p old pen else else return btnst ok cbuttonst ondrawborder crect prect m_bispressed m_bisflat m_bdrawborder draw3drect prect getsyscolor color_btnshadow getsyscolor color_btnhilight cbrush brbtnshadow getsyscolor color_btnshadow framerect prect brbtnshadow cpen penbtnhilight ps_solid getsyscolor color_btnhilight cpen pen3dlight ps_solid getsyscolor color_3dlight cpen penbtnshadow ps_solid getsyscolor color_btnshadow cpen pen3ddkshadow ps_solid getsyscolor color_3ddkshadow m_bisflat m_bmouseonbutton m_bdrawborder draw3drect prect getsyscolor color_btnhilight getsyscolor color_btnshadow cpen poldpen selectobject penbtnhilight moveto prect prect lineto prect prect lineto prect prect selectobject pen3dlight moveto prect prect lineto prect prect lineto prect prect selectobject pen3ddkshadow moveto prect prect lineto prect prect lineto prect prect selectobject penbtnshadow moveto prect prect lineto prect prect lineto prect prect selectobject poldpen btnst_ok lresult c buttonst on set check wparam w param lparam l param assert m bischeckbox unreferenced parameter l param switch w param case bst checked case bst indeterminate indeterminate state is handled like checked state set check 1 break default set check 0 break switch return 0 cbuttonst onsetcheck wparam lparam m_bischeckbox unreferenced_parameter lparam wparam bst_checked bst_indeterminate setcheck setcheck lresult c buttonst on get check wparam w param lparam l param unreferenced parameter w param unreferenced parameter l param assert m bischeckbox return get check cbuttonst ongetcheck wparam lparam unreferenced_parameter wparam unreferenced_parameter lparam m_bischeckbox getcheck lresult c buttonst on set style wparam w param lparam l param uint n new type w param bs typemask update default state flag if n new type bs defpushbutton m bisdefault true if else if n new type bs pushbutton losing default state always allowed m bisdefault false if can t change control type after owner draw is set let the system process changes to other style bits and redrawing while keeping owner draw style return def window proc bm setstyle w param bs typemask bs ownerdraw l param cbuttonst onsetstyle wparam lparam nnewtype wparam bs_typemask nnewtype bs_defpushbutton m_bisdefault nnewtype bs_pushbutton m_bisdefault defwindowproc bm_setstyle wparam bs_typemask bs_ownerdraw lparam lresult c buttonst on mouse leave wparam w param lparam l param unreferenced parameter w param unreferenced parameter l param cancel hover return 0 cbuttonst onmouseleave wparam lparam unreferenced_parameter wparam unreferenced_parameter lparam cancelhover void c buttonst cancel hover only for flat buttons if m bisflat if m bmouseonbutton m bmouseonbutton false invalidate if if cbuttonst cancelhover m_bisflat m_bmouseonbutton m_bmouseonbutton void c buttonst free resources bool b check fornull if b check fornull destroy icons note the following two lines must be here even if bound checker says they are unnecessary if m csicons 0 h icon destroy icon m csicons 0 h icon if m csicons 1 h icon destroy icon m csicons 1 h icon destroy bitmaps if m csbitmaps 0 h bitmap delete object m csbitmaps 0 h bitmap if m csbitmaps 1 h bitmap delete object m csbitmaps 1 h bitmap destroy mask bitmaps if m csbitmaps 0 h mask delete object m csbitmaps 0 h mask if m csbitmaps 1 h mask delete object m csbitmaps 1 h mask if zero memory m csicons sizeof m csicons zero memory m csbitmaps sizeof m csbitmaps cbuttonst freeresources bcheckfornull bcheckfornull boundchecker m_csicons hicon destroyicon m_csicons hicon m_csicons hicon destroyicon m_csicons hicon m_csbitmaps hbitmap deleteobject m_csbitmaps hbitmap m_csbitmaps hbitmap deleteobject m_csbitmaps hbitmap m_csbitmaps hmask deleteobject m_csbitmaps hmask m_csbitmaps hmask deleteobject m_csbitmaps hmask zeromemory m_csicons m_csicons zeromemory m_csbitmaps m_csbitmaps void c buttonst prepare image rect bool b has title rect rp item c rect rp title bool b is pressed dword dw width dword dw height c rect rp image c rect r btn rp image copy rect rp item switch m byalign case st align horiz if b has title false center image horizontally rp image left rp image width long dw width 2 else image must be placed just inside the focus rect rp image left m ptimageorg x rp title left dw width m ptimageorg x center image vertically rp image top rp image height long dw height 2 break case st align horiz right get client rect r btn if b has title false center image horizontally rp image left rp image width long dw width 2 else image must be placed just inside the focus rect rp title right rp title width dw width m ptimageorg x rp title left m ptimageorg x rp image left r btn right dw width m ptimageorg x center image vertically rp image top rp image height long dw height 2 break case st align vert center image horizontally rp image left rp image width long dw width 2 if b has title false center image vertically rp image top rp image height long dw height 2 else rp image top m ptimageorg y rp title top dw height break case st align overlap break switch if button is pressed then press image also if b is pressed m bischeckbox false rp image offset rect m ptpressedoffset x m ptpressedoffset y cbuttonst prepareimagerect bhastitle rpitem crect rptitle bispressed dwwidth dwheight crect rpimage crect rbtn rpimage copyrect rpitem m_byalign st_align_horiz bhastitle rpimage rpimage dwwidth rpimage m_ptimageorg rptitle dwwidth m_ptimageorg rpimage rpimage dwheight st_align_horiz_right getclientrect rbtn bhastitle rpimage rpimage dwwidth rptitle rptitle dwwidth m_ptimageorg rptitle m_ptimageorg rpimage rbtn dwwidth m_ptimageorg rpimage rpimage dwheight st_align_vert rpimage rpimage dwwidth bhastitle rpimage rpimage dwheight rpimage m_ptimageorg rptitle dwheight st_align_overlap bispressed m_bischeckbox rpimage offsetrect m_ptpressedoffset m_ptpressedoffset hbitmap c buttonst create bitmap mask hbitmap h source bitmap dword dw width dword dw height colorref cr trans color hbitmap h mask null hdc hdc src null hdc hdc dest null hbitmap hbm srct null hbitmap hbm destt null colorref cr save bk colorref cr save dest text h mask create bitmap dw width dw height 1 1 null if h mask null return null hdc src create compatibledc null hdc dest create compatibledc null hbm srct hbitmap select object hdc src h source bitmap hbm destt hbitmap select object hdc dest h mask cr save bk set bk color hdc src cr trans color bit blt hdc dest 0 0 dw width dw height hdc src 0 0 srccopy cr save dest text set text color hdc src rgb 255 255 255 set bk color hdc src rgb 0 0 0 bit blt hdc src 0 0 dw width dw height hdc dest 0 0 srcand set text color hdc dest cr save dest text set bk color hdc src cr save bk select object hdc src hbm srct select object hdc dest hbm destt deletedc hdc src deletedc hdc dest return h mask cbuttonst createbitmapmask hsourcebitmap dwwidth dwheight crtranscolor hmask hdcsrc hdcdest hbmsrct hbmdestt crsavebk crsavedesttext hmask createbitmap dwwidth dwheight hmask hdcsrc createcompatibledc hdcdest createcompatibledc hbmsrct selectobject hdcsrc hsourcebitmap hbmdestt selectobject hdcdest hmask crsavebk setbkcolor hdcsrc crtranscolor bitblt hdcdest dwwidth dwheight hdcsrc crsavedesttext settextcolor hdcsrc setbkcolor hdcsrc bitblt hdcsrc dwwidth dwheight hdcdest settextcolor hdcdest crsavedesttext setbkcolor hdcsrc crsavebk selectobject hdcsrc hbmsrct selectobject hdcdest hbmdestt hdcsrc hdcdest hmask void c buttonst draw the icon cdc pdc bool b has title rect rp item c rect rp caption bool b is pressed bool b is disabled byte by index 0 select the icon to use if m bischeckbox b is pressed m bischeckbox b is pressed m bmouseonbutton by index 0 else by index m csicons 1 h icon null byte 0 byte 1 c rect r image prepare image rect b has title rp item rp caption b is pressed m csicons by index dw width m csicons by index dw height r image ole pdc draw state r image top left r image size m csicons by index h icon b is disabled dss disabled dss normal c brush null cbuttonst drawtheicon bhastitle rpitem crect rpcaption bispressed bisdisabled byindex m_bischeckbox bispressed m_bischeckbox bispressed m_bmouseonbutton byindex byindex m_csicons hicon crect rimage prepareimagerect bhastitle rpitem rpcaption bispressed m_csicons byindex dwwidth m_csicons byindex dwheight rimage drawstate rimage topleft rimage m_csicons byindex hicon bisdisabled dss_disabled dss_normal cbrush void c buttonst draw the bitmap cdc pdc bool b has title rect rp item c rect rp caption bool b is pressed bool b is disabled hdc hdc bmp mem null hbitmap hbm old bmp null hdc hdc mem null hbitmap hbmt null byte by index 0 select the bitmap to use if m bischeckbox b is pressed m bischeckbox b is pressed m bmouseonbutton by index 0 else by index byte m csbitmaps 1 h bitmap null byte 0 byte 1 c rect r image prepare image rect b has title rp item rp caption b is pressed m csbitmaps by index dw width m csbitmaps by index dw height r image hdc bmp mem create compatibledc pdc m hdc hbm old bmp hbitmap select object hdc bmp mem m csbitmaps by index h bitmap hdc mem create compatibledc null hbmt hbitmap select object hdc mem m csbitmaps by index h mask if b is disabled m bshowdisabledbitmap hdc hdc null hbitmap h bitmap null hdc create compatibledc pdc m hdc h bitmap create compatible bitmap pdc m hdc m csbitmaps by index dw width m csbitmaps by index dw height hbitmap h old bmp2 hbitmap select object hdc h bitmap rect r rect r rect left 0 r rect top 0 r rect right r image right 1 r rect bottom r image bottom 1 fill rect hdc r rect hbrush rgb 255 255 255 colorref cr old color set bk color hdc rgb 255 255 255 bit blt hdc 0 0 m csbitmaps by index dw width m csbitmaps by index dw height hdc mem 0 0 srcand bit blt hdc 0 0 m csbitmaps by index dw width m csbitmaps by index dw height hdc bmp mem 0 0 srcpaint set bk color hdc cr old color select object hdc h old bmp2 deletedc hdc pdc draw state c point r image left 1 r image top c size m csbitmaps by index dw width m csbitmaps by index dw height h bitmap dst bitmap dss disabled delete object h bitmap if else bit blt pdc m hdc r image left r image top m csbitmaps by index dw width m csbitmaps by index dw height hdc mem 0 0 srcand bit blt pdc m hdc r image left r image top m csbitmaps by index dw width m csbitmaps by index dw height hdc bmp mem 0 0 srcpaint else select object hdc mem hbmt deletedc hdc mem select object hdc bmp mem hbm old bmp deletedc hdc bmp mem cbuttonst drawthebitmap bhastitle rpitem crect rpcaption bispressed bisdisabled hdcbmpmem hbmoldbmp hdcmem byindex m_bischeckbox bispressed m_bischeckbox bispressed m_bmouseonbutton byindex byindex m_csbitmaps hbitmap crect rimage prepareimagerect bhastitle rpitem rpcaption bispressed m_csbitmaps byindex dwwidth m_csbitmaps byindex dwheight rimage hdcbmpmem createcompatibledc m_hdc hbmoldbmp selectobject hdcbmpmem m_csbitmaps byindex hbitmap hdcmem createcompatibledc selectobject hdcmem m_csbitmaps byindex hmask bisdisabled m_bshowdisabledbitmap hbitmap createcompatibledc m_hdc hbitmap createcompatiblebitmap m_hdc m_csbitmaps byindex dwwidth m_csbitmaps byindex dwheight holdbmp2 selectobject hbitmap rrect rrect rrect rrect rimage rrect rimage fillrect rrect croldcolor setbkcolor bitblt m_csbitmaps byindex dwwidth m_csbitmaps byindex dwheight hdcmem bitblt m_csbitmaps byindex dwwidth m_csbitmaps byindex dwheight hdcbmpmem setbkcolor croldcolor selectobject holdbmp2 drawstate cpoint rimage rimage csize m_csbitmaps byindex dwwidth m_csbitmaps byindex dwheight hbitmap dst_bitmap dss_disabled deleteobject hbitmap bitblt m_hdc rimage rimage m_csbitmaps byindex dwwidth m_csbitmaps byindex dwheight hdcmem bitblt m_hdc rimage rimage m_csbitmaps byindex dwwidth m_csbitmaps byindex dwheight hdcbmpmem selectobject hdcmem hdcmem selectobject hdcbmpmem hbmoldbmp hdcbmpmem void c buttonst draw the text cdc pdc lpctstr lpsz text rect rp item c rect rp caption bool b is pressed bool b is disabled unreferenced parameter rp item unreferenced parameter b is pressed unreferenced parameter b is disabled draw the button s title if button is pressed then press title also if m bispressed m bischeckbox false rp caption offset rect m ptpressedoffset x m ptpressedoffset y only for debug c brush br btn shadow rgb 255 0 0 pdc frame rect r caption br btn shadow center text c rect center rect rp caption pdc draw text lpsz text 1 rp caption dt wordbreak dt center dt calcrect rp caption offset rect center rect width rp caption width 2 center rect height rp caption height 2 rfu rp caption offset rect 0 center rect height rp caption height 2 rp caption offset rect center rect width rp caption width 4 center rect height rp caption height 2 pdc set bk mode transparent pdc draw state r caption top left r caption size lpctstr s title b is disabled dss disabled dss normal true 0 c brush null if m bisdisabled rp caption offset rect 1 1 pdc set text color get sys color color 3dhilight pdc draw text lpsz text 1 rp caption dt wordbreak dt center rp caption offset rect 1 1 pdc set text color get sys color color 3dshadow pdc draw text lpsz text 1 rp caption dt wordbreak dt center if else if m bmouseonbutton m bispressed pdc set text color m crcolors btnst color fg in pdc set bk color m crcolors btnst color bk in if else if m bisfocused pdc set text color m crcolors btnst color fg focus pdc set bk color m crcolors btnst color bk focus if else pdc set text color m crcolors btnst color fg out pdc set bk color m crcolors btnst color bk out else else pdc draw text lpsz text 1 rp caption dt wordbreak dt center if cbuttonst drawthetext lpsztext rpitem crect rpcaption bispressed bisdisabled unreferenced_parameter rpitem unreferenced_parameter bispressed unreferenced_parameter bisdisabled m_bispressed m_bischeckbox rpcaption offsetrect m_ptpressedoffset m_ptpressedoffset cbrush brbtnshadow framerect rcaption brbtnshadow crect centerrect rpcaption drawtext lpsztext rpcaption dt_wordbreak dt_center dt_calcrect rpcaption offsetrect centerrect rpcaption centerrect rpcaption rpcaption offsetrect centerrect rpcaption rpcaption offsetrect centerrect rpcaption centerrect rpcaption setbkmode drawstate rcaption topleft rcaption stitle bisdisabled dss_disabled dss_normal cbrush m_bisdisabled rpcaption offsetrect settextcolor getsyscolor color_3dhilight drawtext lpsztext rpcaption dt_wordbreak dt_center rpcaption offsetrect settextcolor getsyscolor color_3dshadow drawtext lpsztext rpcaption dt_wordbreak dt_center m_bmouseonbutton m_bispressed settextcolor m_crcolors btnst_color_fg_in setbkcolor m_crcolors btnst_color_bk_in m_bisfocused settextcolor m_crcolors btnst_color_fg_focus setbkcolor m_crcolors btnst_color_bk_focus settextcolor m_crcolors btnst_color_fg_out setbkcolor m_crcolors btnst_color_bk_out drawtext lpsztext rpcaption dt_wordbreak dt_center void c buttonst paint bk cdc pdc c clientdc cldc get parent c rect rect c rect rect1 get client rect rect get window rect rect1 get parent screen to client rect1 if m dcbk m hdc null m dcbk create compatibledc cldc m bmpbk create compatible bitmap cldc rect width rect height m pbmpoldbk m dcbk select object m bmpbk m pbmpoldbk hbitmap select object m dcbk hbitmap m bmpbk m dcbk bit blt 0 0 rect width rect height cldc rect1 left rect1 top srccopy if pdc bit blt 0 0 rect width rect height m dcbk 0 0 srccopy cbuttonst paintbk cclientdc getparent crect crect getclientrect getwindowrect getparent screentoclient m_dcbk m_hdc m_dcbk createcompatibledc m_bmpbk createcompatiblebitmap m_pbmpoldbk m_dcbk selectobject m_bmpbk m_pbmpoldbk selectobject m_dcbk m_bmpbk m_dcbk bitblt bitblt m_dcbk void c buttonst init tool tip if m tooltip m hwnd null create tool tip control m tooltip create this m dwtooltipstyle create inactive m tooltip activate false enable multiline m tooltip send message ttm setmaxtipwidth 0 400 m tooltip send message ttm settitle tti info lparam t title if cbuttonst inittooltip m_tooltip m_hwnd tooltip m_tooltip m_dwtooltipstyle m_tooltip m_tooltip sendmessage ttm_setmaxtipwidth m_tooltip sendmessage ttm_settitle tti_info _t c theme helperst c theme helperst m hdll load library t ux theme dll if m hdll null pfn open theme data pfnopenthemedata get proc address m hdll open theme data pfn close theme data pfnclosethemedata get proc address m hdll close theme data pfn draw theme parent background pfndrawthemeparentbackground get proc address m hdll draw theme parent background pfn draw theme background pfndrawthemebackground get proc address m hdll draw theme background pfn draw theme text pfndrawthemetext get proc address m hdll draw theme text pfn is app themed pfnisappthemed get proc address m hdll is app themed pfn is theme active pfnisthemeactive get proc address m hdll is theme active else pfn open theme data null pfn close theme data null pfn draw theme parent background null pfn draw theme background null pfn draw theme text null pfn is app themed null pfn is theme active null cthemehelperst cthemehelperst m_hdll loadlibrary _t uxtheme m_hdll pfnopenthemedata getprocaddress m_hdll openthemedata pfnclosethemedata getprocaddress m_hdll closethemedata pfndrawthemeparentbackground getprocaddress m_hdll drawthemeparentbackground pfndrawthemebackground getprocaddress m_hdll drawthemebackground pfndrawthemetext getprocaddress m_hdll drawthemetext pfnisappthemed getprocaddress m_hdll isappthemed pfnisthemeactive getprocaddress m_hdll isthemeactive pfnopenthemedata pfnclosethemedata pfndrawthemeparentbackground pfndrawthemebackground pfndrawthemetext pfnisappthemed pfnisthemeactive c theme helperst c theme helperst pfn open theme data null pfn close theme data null pfn draw theme parent background null pfn draw theme background null pfn draw theme text null pfn is app themed null pfn is theme active null if m hdll null free library m hdll m hdll null cthemehelperst cthemehelperst pfnopenthemedata pfnclosethemedata pfndrawthemeparentbackground pfndrawthemebackground pfndrawthemetext pfnisappthemed pfnisthemeactive m_hdll freelibrary m_hdll m_hdll htheme c theme helperst open theme data hwnd hwnd lpcwstr psz class list if pfn open theme data null return pfn open theme data hwnd psz class list return null cthemehelperst openthemedata pszclasslist pfnopenthemedata pfnopenthemedata pszclasslist hresult c theme helperst close theme data htheme h theme if pfn close theme data null return pfn close theme data h theme return e fail cthemehelperst closethemedata htheme pfnclosethemedata pfnclosethemedata htheme e_fail hresult c theme helperst draw theme background htheme h theme hwnd h wnd hdc hdc int i part id int i state id const rect p rect const rect p clip rect if pfn draw theme parent background null h wnd null pfn draw theme parent background h wnd hdc prect p rect if pfn draw theme background null return pfn draw theme background h theme hdc i part id i state id p rect p clip rect return e fail cthemehelperst drawthemebackground htheme hwnd ipartid istateid prect pcliprect pfndrawthemeparentbackground hwnd pfndrawthemeparentbackground hwnd prect pfndrawthemebackground pfndrawthemebackground htheme ipartid istateid prect pcliprect e_fail hresult c theme helperst draw theme text htheme h theme hdc hdc int i part id int i state id lpcwstr psz text int i char count dword dw text flags dword dw text flags2 const rect p rect if pfn draw theme text null return pfn draw theme text h theme hdc i part id i state id psz text i char count dw text flags dw text flags2 p rect return e fail cthemehelperst drawthemetext htheme ipartid istateid psztext icharcount dwtextflags dwtextflags2 prect pfndrawthemetext pfndrawthemetext htheme ipartid istateid psztext icharcount dwtextflags dwtextflags2 prect e_fail bool c theme helperst is theme active if pfn is theme active null return pfn is theme active return false cthemehelperst isthemeactive pfnisthemeactive pfnisthemeactive bool c theme helperst is app themed if pfn is app themed null return pfn is app themed return false cthemehelperst isappthemed pfnisappthemed pfnisappthemed cxp style buttonst cxp style buttonst no theme helper m ptheme null don t use flat toolbar style m bdrawastoolbar false m bdrawborder false cxpstylebuttonst cxpstylebuttonst m_ptheme m_bdrawastoolbar m_bdrawborder cxp style buttonst cxp style buttonst cxpstylebuttonst cxpstylebuttonst void cxp style buttonst set theme helper c theme helperst p theme m ptheme p theme no theme active if m ptheme null m ptheme is app themed false m bdrawborder true if cxpstylebuttonst setthemehelper cthemehelperst ptheme m_ptheme ptheme m_ptheme m_ptheme isappthemed m_bdrawborder dword cxp style buttonst draw as toolbar bool b draw as toolbar bool b repaint m bdrawastoolbar b draw as toolbar repaint the button if b repaint true invalidate return btnst ok cxpstylebuttonst drawastoolbar bdrawastoolbar brepaint m_bdrawastoolbar bdrawastoolbar brepaint btnst_ok dword cxp style buttonst on draw background cdc pdc c rect p rect bool b default draw false no theme helper passed if m ptheme null m ptheme is app themed false b default draw true else htheme h theme null int i state id 0 h theme m ptheme open theme data get safe hwnd m bdrawastoolbar l toolbar l button if h theme i state id pbs normal normal if m bisdefault m bdrawastoolbar m bisdefault m bdrawastoolbar m bdrawborder i state id pbs defaulted default button if m bmouseonbutton i state id pbs hot hot if m bispressed i state id pbs pressed pressed if m bisdisabled i state id pbs disabled disabled m ptheme draw theme background h theme m hwnd pdc get safe hdc bp pushbutton i state id p rect null m ptheme close theme data h theme if else b default draw true else else if b default draw return c buttonst on draw background pdc p rect if return btnst ok cxpstylebuttonst ondrawbackground crect prect bdefaultdraw m_ptheme m_ptheme isappthemed bdefaultdraw htheme istateid htheme m_ptheme openthemedata getsafehwnd m_bdrawastoolbar htheme istateid pbs_normal m_bisdefault m_bdrawastoolbar m_bisdefault m_bdrawastoolbar m_bdrawborder istateid pbs_defaulted m_bmouseonbutton istateid pbs_hot m_bispressed istateid pbs_pressed m_bisdisabled istateid pbs_disabled m_ptheme drawthemebackground htheme m_hwnd getsafehdc bp_pushbutton istateid prect m_ptheme closethemedata htheme bdefaultdraw bdefaultdraw cbuttonst ondrawbackground prect btnst_ok dword cxp style buttonst on draw border cdc pdc c rect p rect if m ptheme null m ptheme is app themed false return c buttonst on draw border pdc p rect return btnst ok cxpstylebuttonst ondrawborder crect prect m_ptheme m_ptheme isappthemed cbuttonst ondrawborder prect btnst_ok c window groups c window groups m awindows remove all m agroupids remove all m aflags remove all cwindowgroups cwindowgroups m_awindows removeall m_agroupids removeall m_aflags removeall c window groups c window groups m awindows remove all m agroupids remove all m aflags remove all cwindowgroups cwindowgroups m_awindows removeall m_agroupids removeall m_aflags removeall bool c window groups add window c object p window dword dw groupid bool b reposition byte bt 0 m awindows add p window m agroupids add dw groupid if b reposition true bt wgf reposition m aflags add bt return true cwindowgroups addwindow cobject pwindow dwgroupid breposition m_awindows pwindow m_agroupids dwgroupid breposition wgf_reposition m_aflags bool c window groups arrange windows c wnd p parent window c wnd p cd word array a pos int i rect rect 0 0 0 0 unreferenced parameter p parent window a pos remove all for i 0 i m awindows get size i a pos add wg offset top for i 0 i m awindows get size i if m aflags get at i wgf reposition 0 continue p c wnd m awindows get at i if p null p get window rect rect rect right rect right rect left coords to sizes rect bottom rect bottom rect top rect top long a pos get at int m agroupids get at i rect left wg offset left if p null p move window rect left rect top rect right rect bottom true a pos set at int m agroupids get at i dword rect top wg y step a pos remove all return true cwindowgroups arrangewindows cwnd pparentwindow cwnd cdwordarray apos unreferenced_parameter pparentwindow apos removeall m_awindows getsize apos wg_offset_top m_awindows getsize m_aflags getat wgf_reposition cwnd m_awindows getat getwindowrect apos getat m_agroupids getat wg_offset_left movewindow apos setat m_agroupids getat wg_y_step apos removeall bool c window groups hide all except dword dw groupid int i c wnd p assert m awindows get size m agroupids get size for i 0 i m awindows get size i p c wnd m awindows get at i if p null continue if m agroupids get at i dw groupid p show window sw hide p enable window false else p enable window true p show window true return true cwindowgroups hideallexcept dwgroupid cwnd m_awindows getsize m_agroupids getsize m_awindows getsize cwnd m_awindows getat m_agroupids getat dwgroupid showwindow sw_hide enablewindow enablewindow showwindow c system tray c system tray initialise csystemtray csystemtray uint u balloon timeout 10 balloon timeout w2k initialise create p parent u callback message sz tool tip icon uid b hidden sz balloon tip sz balloon title dw balloon icon u balloon timeout uballoontimeout pparent ucallbackmessage sztooltip bhidden szballoontip szballoontitle dwballoonicon uballoontimeout c system tray c system tray remove icon m iconlist remove all destroy window csystemtray csystemtray removeicon m_iconlist removeall destroywindow uint u balloon timeout 10 ifdef win32 wce m benabled true else this is only for windows 95 or higher m benabled get version 0xff 4 if m benabled assert false return false endif m nmaxtooltiplength countof m tnd sz tip make sure we avoid conflict with other messages assert u callback message wm app tray only supports tooltip text up to m nmaxtooltiplength characters assert afx is valid string sz tool tip assert tcslen sz tool tip m nmaxtooltiplength create an invisible window c wnd create ex 0 afx register wnd class 0 t ws popup 0 0 0 0 null 0 load up the notifyicondata structure m tnd cb size sizeof notifyicondata m tnd h wnd p parent get safe hwnd p parent get safe hwnd m hwnd m tnd uid uid m tnd h icon icon m tnd u flags nif message nif icon nif tip m tnd u callback message u callback message tcsncpy m tnd sz tip sz tool tip m nmaxtooltiplength 1 ifdef systemtray usew2k if m bwin2k sz balloon tip the balloon tooltip text can be up to 255 chars long assert afx is valid string sz balloon tip assert lstrlen sz balloon tip 256 the balloon title text can be up to 63 chars long if sz balloon title assert afx is valid string sz balloon title assert lstrlen sz balloon title 64 dw balloon icon must be valid assert niif none dw balloon icon niif info dw balloon icon niif warning dw balloon icon niif error dw balloon icon the timeout must be between 10 and 30 seconds assert u balloon timeout 10 u balloon timeout 30 m tnd u flags nif info tcsncpy m tnd sz info sz balloon tip 255 if sz balloon title tcsncpy m tnd sz info title sz balloon title 63 else m tnd sz info title 0 t 0 m tnd u timeout u balloon timeout 1000 convert time to ms m tnd dw info flags dw balloon icon endif m bhidden b hidden ifdef systemtray usew2k if m bwin2k m bhidden m tnd u flags nif state m tnd dw state nis hidden m tnd dw state mask nis hidden endif m ucreationflags m tnd u flags store in case we need to recreate in on task bar create bool b result true if m bhidden m bwin2k b result shell notifyicon nim add m tnd m bshowiconpending m bhidden m bremoved b result ifdef systemtray usew2k if m bwin2k sz balloon tip zero out the balloon text string so that later operations won t redisplay the balloon m tnd sz info 0 t 0 endif return b result uballoontimeout _win32_wce m_benabled m_benabled getversion m_benabled m_nmaxtooltiplength _countof m_tnd sztip ucallbackmessage wm_app m_nmaxtooltiplength afxisvalidstring sztooltip _tcslen sztooltip m_nmaxtooltiplength cwnd createex afxregisterwndclass _t ws_popup m_tnd cbsize m_tnd hwnd pparent getsafehwnd pparent getsafehwnd m_hwnd m_tnd m_tnd hicon m_tnd uflags nif_message nif_icon nif_tip m_tnd ucallbackmessage ucallbackmessage _tcsncpy m_tnd sztip sztooltip m_nmaxtooltiplength systemtray_usew2k m_bwin2k szballoontip afxisvalidstring szballoontip szballoontip szballoontitle afxisvalidstring szballoontitle szballoontitle dwballoonicon niif_none dwballoonicon niif_info dwballoonicon niif_warning dwballoonicon niif_error dwballoonicon uballoontimeout uballoontimeout m_tnd uflags nif_info _tcsncpy m_tnd szinfo szballoontip szballoontitle _tcsncpy m_tnd szinfotitle szballoontitle m_tnd szinfotitle _t m_tnd utimeout uballoontimeout m_tnd dwinfoflags dwballoonicon m_bhidden bhidden systemtray_usew2k m_bwin2k m_bhidden m_tnd uflags nif_state m_tnd dwstate nis_hidden m_tnd dwstatemask nis_hidden m_ucreationflags m_tnd uflags ontaskbarcreate bresult m_bhidden m_bwin2k bresult shell_notifyicon nim_add m_tnd m_bshowiconpending m_bhidden m_bremoved bresult systemtray_usew2k m_bwin2k szballoontip m_tnd szinfo _t bresult bool c system tray set tooltip text lpctstr psz tip assert afx is valid string psz tip md assert tcslen psz tip m nmaxtooltiplength if m benabled return false m tnd u flags nif tip tcsncpy m tnd sz tip psz tip m nmaxtooltiplength 1 if m bhidden return true else return shell notifyicon nim modify m tnd csystemtray settooltiptext psztip afxisvalidstring psztip _tcslen psztip m_nmaxtooltiplength m_benabled m_tnd uflags nif_tip _tcsncpy m_tnd sztip psztip m_nmaxtooltiplength m_bhidden shell_notifyicon nim_modify m_tnd bool c system tray set tooltip text uint nid c string str text verify str text load string nid return set tooltip text str text csystemtray settooltiptext cstring strtext strtext loadstring settooltiptext strtext c string c system tray get tooltip text const c string str text if m benabled str text m tnd sz tip return str text cstring csystemtray gettooltiptext cstring strtext m_benabled strtext m_tnd sztip strtext bool c system tray set icon hicon h icon if m benabled return false m tnd u flags nif icon m tnd h icon h icon if m bhidden return true else return shell notifyicon nim modify m tnd csystemtray seticon hicon m_benabled m_tnd uflags nif_icon m_tnd hicon hicon m_bhidden shell_notifyicon nim_modify m_tnd bool c system tray set icon lpctstr lpsz icon name hicon h icon hicon load image afx get resource handle lpsz icon name image icon 0 0 lr defaultcolor if h icon return false bool b success set icon h icon destroy icon h icon return b success csystemtray seticon lpsziconname hicon loadimage afxgetresourcehandle lpsziconname image_icon lr_defaultcolor hicon bsuccess seticon hicon destroyicon hicon bsuccess bool c system tray set icon uint nid resource return set icon makeintresource nid resource csystemtray seticon nidresource seticon nidresource bool c system tray set standard icon lpctstr lp icon name hicon h icon load icon null lp icon name return set icon h icon csystemtray setstandardicon lpiconname hicon loadicon lpiconname seticon hicon bool c system tray set standard icon uint nid resource return set standard icon makeintresource nid resource csystemtray setstandardicon nidresource setstandardicon nidresource hicon c system tray get icon const return m benabled m tnd h icon null csystemtray geticon m_benabled m_tnd hicon void c system tray set focus ifdef systemtray usew2k shell notifyicon nim setfocus m tnd endif csystemtray setfocus systemtray_usew2k shell_notifyicon nim_setfocus m_tnd bool c system tray hide icon if m benabled m bremoved m bhidden return true ifdef systemtray usew2k if m bwin2k m tnd u flags nif state m tnd dw state nis hidden m tnd dw state mask nis hidden m bhidden shell notifyicon nim modify m tnd else endif remove icon return m bhidden true csystemtray hideicon m_benabled m_bremoved m_bhidden systemtray_usew2k m_bwin2k m_tnd uflags nif_state m_tnd dwstate nis_hidden m_tnd dwstatemask nis_hidden m_bhidden shell_notifyicon nim_modify m_tnd removeicon m_bhidden bool c system tray show icon if m bremoved return add icon if m bhidden return true ifdef systemtray usew2k if m bwin2k m tnd u flags nif state m tnd dw state 0 m tnd dw state mask nis hidden shell notifyicon nim modify m tnd m bhidden false else endif add icon return m bhidden false csystemtray showicon m_bremoved addicon m_bhidden systemtray_usew2k m_bwin2k m_tnd uflags nif_state m_tnd dwstate m_tnd dwstatemask nis_hidden shell_notifyicon nim_modify m_tnd m_bhidden addicon m_bhidden bool c system tray add icon if m bremoved remove icon if m benabled m tnd u flags nif message nif icon nif tip if shell notifyicon nim add m tnd m bshowiconpending true else m bremoved m bhidden false return m bremoved false csystemtray addicon m_bremoved removeicon m_benabled m_tnd uflags nif_message nif_icon nif_tip shell_notifyicon nim_add m_tnd m_bshowiconpending m_bremoved m_bhidden m_bremoved bool c system tray remove icon m bshowiconpending false if m benabled m bremoved return true m tnd u flags 0 if shell notifyicon nim delete m tnd m bremoved m bhidden true return m bremoved true csystemtray removeicon m_bshowiconpending m_benabled m_bremoved m_tnd uflags shell_notifyicon nim_delete m_tnd m_bremoved m_bhidden m_bremoved bool c system tray move to right remove icon return add icon csystemtray movetoright removeicon addicon uint u timeout 10 ifndef systemtray usew2k return false else bail out if we re not on win 2k if m bwin2k return false verify input parameters the balloon tooltip text can be up to 255 chars long assert afx is valid string sz text assert lstrlen sz text 256 the balloon title text can be up to 63 chars long if sz title assert afx is valid string sz title assert lstrlen sz title 64 dw balloon icon must be valid assert niif none dw icon niif info dw icon niif warning dw icon niif error dw icon the timeout must be between 10 and 30 seconds assert u timeout 10 u timeout 30 m tnd u flags nif info tcsncpy m tnd sz info sz text 256 if sz title tcsncpy m tnd sz info title sz title 64 else m tnd sz info title 0 t 0 m tnd dw info flags dw icon m tnd u timeout u timeout 1000 convert time to ms bool b success shell notifyicon nim modify m tnd zero out the balloon text string so that later operations won t redisplay the balloon m tnd sz info 0 t 0 return b success endif utimeout systemtray_usew2k m_bwin2k afxisvalidstring sztext sztext sztitle afxisvalidstring sztitle sztitle dwballoonicon niif_none dwicon niif_info dwicon niif_warning dwicon niif_error dwicon utimeout utimeout m_tnd uflags nif_info _tcsncpy m_tnd szinfo sztext sztitle _tcsncpy m_tnd szinfotitle sztitle m_tnd szinfotitle _t m_tnd dwinfoflags dwicon m_tnd utimeout utimeout bsuccess shell_notifyicon nim_modify m_tnd m_tnd szinfo _t bsuccess bool c system tray set icon list uint u first iconid uint u last iconid if u first iconid u last iconid return false const c win app p app afx get app if p app assert false return false m iconlist remove all try for uint i u first iconid i u last iconid i m iconlist add p app load icon i catch c memory exception e e report error e delete m iconlist remove all return false end catch return true csystemtray seticonlist ufirsticonid ulasticonid ufirsticonid ulasticonid cwinapp papp afxgetapp papp m_iconlist removeall ufirsticonid ulasticonid m_iconlist papp loadicon cmemoryexception reporterror m_iconlist removeall end_catch bool c system tray set icon list hicon ph icon list uint n num icons m iconlist remove all try for uint i 0 i n num icons i m iconlist add ph icon list i catch c memory exception e e report error e delete m iconlist remove all return false end catch return true csystemtray seticonlist phiconlist nnumicons m_iconlist removeall nnumicons m_iconlist phiconlist cmemoryexception reporterror m_iconlist removeall end_catch bool c system tray animate uint n delay milli seconds int n num seconds 1 if m iconlist get size 0 return false stop animation m ncurrenticon 0 m starttime c ole date time get current time m nanimationperiod n num seconds m hsavedicon get icon setup a timer for the animation m uidtimer set timer m ntimerid n delay milli seconds null return m uidtimer 0 csystemtray ndelaymilliseconds nnumseconds m_iconlist getsize stopanimation m_ncurrenticon m_starttime coledatetime getcurrenttime m_nanimationperiod nnumseconds m_hsavedicon geticon m_uidtimer settimer m_ntimerid ndelaymilliseconds m_uidtimer bool c system tray step animation if m iconlist get size return false m ncurrenticon if m ncurrenticon m iconlist get size m ncurrenticon 0 return set icon m iconlist m ncurrenticon csystemtray stepanimation m_iconlist getsize m_ncurrenticon m_ncurrenticon m_iconlist getsize m_ncurrenticon seticon m_iconlist m_ncurrenticon bool c system tray stop animation bool b result false if m uidtimer b result kill timer m uidtimer m uidtimer 0 if m hsavedicon set icon m hsavedicon m hsavedicon null return b result csystemtray stopanimation bresult m_uidtimer bresult killtimer m_uidtimer m_uidtimer m_hsavedicon seticon m_hsavedicon m_hsavedicon bresult void c system tray get menu default item uint u item bool b by pos u item m defaultmenuitemid b by pos m defaultmenuitembypos csystemtray getmenudefaultitem uitem bbypos uitem m_defaultmenuitemid bbypos m_defaultmenuitembypos bool c system tray set menu default item uint u item bool b by pos ifdef win32 wce return false else if m defaultmenuitemid u item m defaultmenuitembypos b by pos return true m defaultmenuitemid u item m defaultmenuitembypos b by pos c menu menu p sub menu if menu load menu m tnd uid return false p sub menu menu get sub menu 0 if p sub menu return false set menu default item p sub menu m hmenu m defaultmenuitemid m defaultmenuitembypos return true endif csystemtray setmenudefaultitem uitem bbypos _win32_wce m_defaultmenuitemid uitem m_defaultmenuitembypos bbypos m_defaultmenuitemid uitem m_defaultmenuitembypos bbypos cmenu psubmenu loadmenu m_tnd psubmenu getsubmenu psubmenu setmenudefaultitem psubmenu m_hmenu m_defaultmenuitemid m_defaultmenuitembypos bool c system tray set notification wnd c wnd p wnd if m benabled return false make sure notification window is valid if p wnd is window p wnd get safe hwnd assert false return false m tnd h wnd p wnd get safe hwnd m tnd u flags 0 if m bhidden return true else return shell notifyicon nim modify m tnd csystemtray setnotificationwnd cwnd pwnd m_benabled pwnd iswindow pwnd getsafehwnd m_tnd hwnd pwnd getsafehwnd m_tnd uflags m_bhidden shell_notifyicon nim_modify m_tnd c wnd c system tray get notification wnd const return c wnd from handle m tnd h wnd cwnd csystemtray getnotificationwnd cwnd fromhandle m_tnd hwnd bool c system tray set target wnd c wnd p target wnd m ptargetwnd p target wnd return true csystemtray settargetwnd cwnd ptargetwnd m_ptargetwnd ptargetwnd c wnd c system tray get target wnd const if m ptargetwnd return m ptargetwnd else return afx get main wnd cwnd csystemtray gettargetwnd m_ptargetwnd m_ptargetwnd afxgetmainwnd bool c system tray set callback message uint u callback message if m benabled return false make sure we avoid conflict with other messages assert u callback message wm app m tnd u callback message u callback message m tnd u flags nif message if m bhidden return true else return shell notifyicon nim modify m tnd csystemtray setcallbackmessage ucallbackmessage m_benabled ucallbackmessage wm_app m_tnd ucallbackmessage ucallbackmessage m_tnd uflags nif_message m_bhidden shell_notifyicon nim_modify m_tnd uint c system tray get callback message const return m tnd u callback message csystemtray getcallbackmessage m_tnd ucallbackmessage void c system tray minimise to tray c wnd p wnd bool b force animation false ifndef win32 wce if b force animation get do wnd animation c rect rect from rect to p wnd get window rect rect from get tray wnd rect rect to draw animated rects p wnd m hwnd idani caption rect from rect to remove taskbar icon p wnd p wnd modify style ws visible 0 endif csystemtray minimisetotray cwnd pwnd bforceanimation _win32_wce bforceanimation getdowndanimation crect rectfrom rectto pwnd getwindowrect rectfrom gettraywndrect rectto drawanimatedrects pwnd m_hwnd idani_caption rectfrom rectto removetaskbaricon pwnd pwnd modifystyle ws_visible void c system tray maximise from tray c wnd p wnd bool b force animation true ifndef win32 wce if b force animation get do wnd animation c rect rect to p wnd get window rect rect to c rect rect from get tray wnd rect rect from p wnd set parent null draw animated rects p wnd m hwnd idani caption rect from rect to else p wnd set parent null p wnd modify style 0 ws visible p wnd redraw window null null rdw updatenow rdw allchildren rdw frame rdw invalidate rdw erase move focus away and back again to ensure taskbar icon is recreated if is window m wndinvisible m hwnd m wndinvisible set active window p wnd set active window p wnd set foreground window endif csystemtray maximisefromtray cwnd pwnd bforceanimation _win32_wce bforceanimation getdowndanimation crect rectto pwnd getwindowrect rectto crect rectfrom gettraywndrect rectfrom pwnd setparent drawanimatedrects pwnd m_hwnd idani_caption rectfrom rectto pwnd setparent pwnd modifystyle ws_visible pwnd redrawwindow rdw_updatenow rdw_allchildren rdw_frame rdw_invalidate rdw_erase iswindow m_wndinvisible m_hwnd m_wndinvisible setactivewindow pwnd setactivewindow pwnd setforegroundwindow lresult c system tray on tray notification uint w param long l param return quickly if its not for this tray icon if w param m tnd uid return 0l c menu menu p sub menu c wnd p target wnd get target wnd if p target wnd return 0l clicking with right button brings up a context menu if defined win32 wce win32 wce 211 bool b alt pressed get key state vk menu 1 sizeof short 8 1 0 if loword l param wm lbuttonup b alt pressed else if loword l param wm rbuttonup endif if menu load menu m tnd uid return 0 p sub menu menu get sub menu 0 if p sub menu return 0 ifndef win32 wce make chosen menu item the default bold font set menu default item p sub menu m hmenu m defaultmenuitemid m defaultmenuitembypos endif customize menu p sub menu display and track the popup menu c point pos ifdef win32 wce pos c point get message pos else get cursor pos pos endif p target wnd set foreground window ifndef win32 wce track popup menu p sub menu m hmenu 0 pos x pos y 0 p target wnd get safe hwnd null else p sub menu track popup menu tpm leftalign pos x pos y p target wnd null endif bugfix see prb menus for notification icons don t work correctly p target wnd post message wm null 0 0 menu destroy menu if defined win32 wce win32 wce 211 if loword l param wm lbuttondblclk b alt pressed else else if loword l param wm lbuttondblclk endif double click received the default action is to execute default menu item p target wnd set foreground window uint u item if m defaultmenuitembypos if menu load menu m tnd uid return 0 p sub menu menu get sub menu 0 if p sub menu return 0 u item p sub menu get menu itemid m defaultmenuitemid menu destroy menu else u item m defaultmenuitemid p target wnd post message wm command u item 0 return 1 csystemtray ontraynotification wparam lparam wparam m_tnd cmenu psubmenu cwnd ptargetwnd gettargetwnd ptargetwnd _win32_wce _win32_wce baltpressed getkeystate vk_menu lparam wm_lbuttonup baltpressed lparam wm_rbuttonup loadmenu m_tnd psubmenu getsubmenu psubmenu _win32_wce setmenudefaultitem psubmenu m_hmenu m_defaultmenuitemid m_defaultmenuitembypos customizemenu psubmenu cpoint _win32_wce cpoint getmessagepos getcursorpos ptargetwnd setforegroundwindow _win32_wce trackpopupmenu psubmenu m_hmenu ptargetwnd getsafehwnd psubmenu trackpopupmenu tpm_leftalign ptargetwnd ptargetwnd postmessage wm_null destroymenu _win32_wce _win32_wce lparam wm_lbuttondblclk baltpressed lparam wm_lbuttondblclk ptargetwnd setforegroundwindow uitem m_defaultmenuitembypos loadmenu m_tnd psubmenu getsubmenu psubmenu uitem psubmenu getmenuitemid m_defaultmenuitemid destroymenu uitem m_defaultmenuitemid ptargetwnd postmessage wm_command uitem lresult c system tray window proc uint message wparam w param lparam l param if message m tnd u callback message return on tray notification w param l param return c wnd window proc message w param l param csystemtray windowproc wparam lparam m_tnd ucallbackmessage ontraynotification wparam lparam cwnd windowproc wparam lparam void c system tray initialise memset m tnd 0 sizeof m tnd m benabled false m bhidden true m bremoved true m defaultmenuitemid 0 m defaultmenuitembypos true m bshowiconpending false m uidtimer 0 m hsavedicon null m ptargetwnd null m ucreationflags 0 ifdef systemtray usew2k osversioninfo os sizeof os get version ex os m bwin2k ver platform win32 nt os dw platform id os dw major version 5 else m bwin2k false endif csystemtray m_tnd m_tnd m_benabled m_bhidden m_bremoved m_defaultmenuitemid m_defaultmenuitembypos m_bshowiconpending m_uidtimer m_hsavedicon m_ptargetwnd m_ucreationflags systemtray_usew2k getversionex m_bwin2k ver_platform_win32_nt dwplatformid dwmajorversion m_bwin2k void c system tray install icon pending is the icon display pending and it s not been set as hidden if m bshowiconpending m bhidden return reset the flags to what was used at creation m tnd u flags m ucreationflags try and recreate the icon m bhidden shell notifyicon nim add m tnd if it s still hidden then have another go next time m bshowiconpending m bhidden assert m bhidden false csystemtray installiconpending m_bshowiconpending m_bhidden m_tnd uflags m_ucreationflags m_bhidden shell_notifyicon nim_add m_tnd m_bshowiconpending m_bhidden m_bhidden bool c system tray remove taskbar icon c wnd p wnd lpctstr pstr owner class afx register wnd class 0 create static invisible window if is window m wndinvisible m hwnd if m wndinvisible create ex 0 pstr owner class t ws popup cw usedefault cw usedefault cw usedefault cw usedefault null 0 return false p wnd set parent m wndinvisible return true csystemtray removetaskbaricon cwnd pwnd pstrownerclass afxregisterwndclass iswindow m_wndinvisible m_hwnd m_wndinvisible createex pstrownerclass _t ws_popup cw_usedefault cw_usedefault cw_usedefault cw_usedefault pwnd setparent m_wndinvisible void c system tray get tray wnd rect lprect lprect define default rect width 150 define default rect height 30 hwnd h shell tray wnd find window t shell traywnd null if h shell tray wnd get window rect h shell tray wnd lprect enum child windows h shell tray wnd find tray wnd lparam lprect return ok we failed to get the rect from the quick hack either explorer isn t running or it s a new version of the shell with the window class names changed how dare microsoft change these undocumented class names so we try to find out what side of the screen the taskbar is connected to we know that the system tray is either on the right or the bottom of the taskbar so we can make a good guess at where to minimize to appbardata app bar data app bar data cb size sizeof app bar data if sh app bar message abm gettaskbarpos app bar data we know the edge the taskbar is connected to so guess the rect of the system tray use various fudge factor to make it look good switch app bar data u edge case abe left case abe right we want to minimize to the bottom of the taskbar lprect top app bar data rc bottom 100 lprect bottom app bar data rc bottom 16 lprect left app bar data rc left lprect right app bar data rc right break case abe top case abe bottom we want to minimize to the right of the taskbar lprect top app bar data rc top lprect bottom app bar data rc bottom lprect left app bar data rc right 100 lprect right app bar data rc right 16 break return blimey we really aren t in luck it s possible that a third party shell is running instead of explorer this shell might provide support for the system tray by providing a shell traywnd window which receives the messages for the icons so look for a shell traywnd window and work out the rect from that remember that explorer s taskbar is the shell traywnd and stretches either the width or the height of the screen we can t rely on the 3rd party shell s shell traywnd doing the same in fact we can t rely on it being any size the best we can do is just blindly use the window rect perhaps limiting the width and height to say 150 square note that if the 3rd party shell supports the same configuraion as explorer the icons hosted in notify tray wnd which is a child window of shell traywnd we would already have caught it above if h shell tray wnd get window rect h shell tray wnd lprect if lprect right lprect left default rect width lprect left lprect right default rect width if lprect bottom lprect top default rect height lprect top lprect bottom default rect height return ok haven t found a thing provide a default rect based on the current work area system parameters info spi getworkarea 0 lprect 0 lprect left lprect right default rect width lprect top lprect bottom default rect height csystemtray gettraywndrect default_rect_width default_rect_height hshelltraywnd findwindow _t shell_traywnd hshelltraywnd getwindowrect hshelltraywnd enumchildwindows hshelltraywnd findtraywnd appbardata appbardata cbsize appbardata shappbarmessage abm_gettaskbarpos appbardata appbardata uedge abe_left abe_right appbardata appbardata appbardata appbardata abe_top abe_bottom appbardata appbardata appbardata appbardata shell_traywnd shell_traywnd shell_traywnd shell_traywnd notifytraywnd shell_traywnd hshelltraywnd getwindowrect hshelltraywnd default_rect_width default_rect_width default_rect_height default_rect_height systemparametersinfo spi_getworkarea default_rect_width default_rect_height bool c system tray get do wnd animation animationinfo ai ai cb size sizeof ai system parameters info spi getanimation sizeof ai ai 0 return ai i min animate true false csystemtray getdowndanimation cbsize systemparametersinfo spi_getanimation iminanimate void c system tray on timer uint nid event if nid event m uidtimer assert false return c ole date time current time c ole date time get current time c ole date time span period current time m starttime if m nanimationperiod 0 m nanimationperiod period get total seconds stop animation return step animation csystemtray ontimer nidevent nidevent m_uidtimer coledatetime currenttime coledatetime getcurrenttime coledatetimespan currenttime m_starttime m_nanimationperiod m_nanimationperiod gettotalseconds stopanimation stepanimation void c system tray on setting change uint u flags lpctstr lpsz section c wnd on setting change u flags lpsz section if u flags spi setworkarea m bshowiconpending m bhidden install icon pending csystemtray onsettingchange uflags lpszsection cwnd onsettingchange uflags lpszsection uflags spi_setworkarea m_bshowiconpending m_bhidden installiconpending lresult c system tray on taskbar created wparam w param lparam l param m bshowiconpending true m bhidden install icon pending return 0l csystemtray ontaskbarcreated wparam lparam m_bshowiconpending m_bhidden installiconpending void c system tray ex customize menu c menu p menu translate the menu c string str item str new uint n item 0 n itemid 0 for n item 0 n item p menu get menu item count n item n itemid p menu get menu itemid int n item if n itemid 0 continue p menu get menu string n item str item mf byposition str new trl var str item verify p menu modify menu n item mf byposition mf string n itemid str new csystemtrayex customizemenu cmenu pmenu cstring stritem strnew nitem nitemid nitem nitem pmenu getmenuitemcount nitem nitemid pmenu getmenuitemid nitem nitemid pmenu getmenustring nitem stritem mf_byposition strnew trl_var stritem pmenu modifymenu nitem mf_byposition mf_string nitemid strnew c options list c options list m ptrs clear m ptrslinked clear m alinktype clear m pimages null coptionslist coptionslist m_ptrs m_ptrslinked m_alinktype m_pimages c options list c options list m ptrs clear m ptrslinked clear m alinktype clear m pimages null coptionslist coptionslist m_ptrs m_ptrslinked m_alinktype m_pimages void c options list init option list ex c image list p images assert p images null if p images null return m pimages p images post message lvm setextendedlistviewstyle 0 lvs ex si menu lvs ex fullrowselect set image list m pimages lvsil small delete all items rect rect get client rect rect int n width rect right rect left get system metrics sm cxvscroll 8 insert column 0 trl options lvcfmt left n width 0 coptionslist initoptionlistex cimagelist pimages pimages pimages m_pimages pimages postmessage lvm_setextendedlistviewstyle lvs_ex_si_menu lvs_ex_fullrowselect setimagelist m_pimages lvsil_small deleteallitems getclientrect nwidth getsystemmetrics sm_cxvscroll insertcolumn lvcfmt_left nwidth void c options list add group text lpctstr lp item text int n icon lv item lvi assert lp item text null if lp item text null return m ptrs push back null m ptrslinked push back null m alinktype push back ol link null zero memory lvi sizeof lv item lvi mask lvif text lvif image lvif indent lvi i item get item count lvi psz text lptstr lp item text lvi cch text max tcslen lp item text lvi i image n icon insert item lvi coptionslist addgrouptext lpitemtext nicon lv_item lpitemtext lpitemtext m_ptrs push_back m_ptrslinked push_back m_alinktype push_back ol_link_null zeromemory lv_item lvif_text lvif_image lvif_indent iitem getitemcount psztext lpitemtext cchtextmax _tcslen lpitemtext iimage nicon insertitem void c options list add check item lpctstr lp item text bool p value storage bool p linked value int n link type lv item lvi assert lp item text null if lp item text null return m ptrs push back void p value storage m ptrslinked push back void p linked value m alinktype push back n link type zero memory lvi sizeof lv item lvi mask lvif text lvif image lvif indent lvi i item get item count lvi i sub item 0 lvi psz text lptstr lp item text lvi cch text max tcslen lp item text lvi i image p value storage true ol check true ol check false lvi i indent 1 insert item lvi coptionslist addcheckitem lpitemtext pvaluestorage plinkedvalue nlinktype lv_item lpitemtext lpitemtext m_ptrs push_back pvaluestorage m_ptrslinked push_back plinkedvalue m_alinktype push_back nlinktype zeromemory lv_item lvif_text lvif_image lvif_indent iitem getitemcount isubitem psztext lpitemtext cchtextmax _tcslen lpitemtext iimage pvaluestorage ol_check_true ol_check_false iindent insertitem void c options list set list item check int n item bool b check lv item lvi zero memory lvi sizeof lv item lvi mask lvif image lvi i item n item lvi i image b check true ol check true ol check false set item lvi coptionslist setlistitemcheck nitem bcheck lv_item zeromemory lv_item lvif_image iitem nitem iimage bcheck ol_check_true ol_check_false setitem int c options list find item pointer void p int i for i 0 i int m ptrs size i if m ptrs i p return i return 1 coptionslist finditempointer m_ptrs m_ptrs void c options list on click nmhdr pnmhdr lresult p result c point pointm get cursor pos pointm unreferenced parameter pnmhdr screen to client pointm uint n flags 0 int n hit item hit test pointm n flags if n flags lvht onitem n hit item 0 bool pb bool m ptrs n hit item if pb null pb pb true false true set list item check n hit item pb bool pbl bool m ptrslinked n hit item if pbl null int n find item pointer void pbl if n 1 switch m alinktype n hit item case ol link same trigger true if pb true pbl true set list item check n true break case ol link same trigger false if pb false pbl false set list item check n false break case ol link same trigger always pbl pb set list item check n pb break case ol link inv trigger true if pb true pbl false set list item check n false break case ol link inv trigger false if pb false pbl true set list item check n true break case ol link inv trigger always pbl pb true false true set list item check n pbl break default break p result 0 coptionslist onclick presult cpoint getcursorpos unreferenced_parameter screentoclient nflags nhititem hittest nflags nflags lvht_onitem nhititem m_ptrs nhititem setlistitemcheck nhititem m_ptrslinked nhititem finditempointer m_alinktype nhititem ol_link_same_trigger_true setlistitemcheck ol_link_same_trigger_false setlistitemcheck ol_link_same_trigger_always setlistitemcheck ol_link_inv_trigger_true setlistitemcheck ol_link_inv_trigger_false setlistitemcheck ol_link_inv_trigger_always setlistitemcheck presult c gradient progress ctrl c gradient progress ctrl defaults assigned by c progress ctrl m nlower 0 m nupper 100 m ncurrentposition 0 m nstep 10 initial colors m clrstart colorref rgb 255 0 0 m clrend colorref rgb 0 0 255 m clrbkground get sys color color 3dface m clrtext colorref rgb 255 255 255 initial show percent m bshowpercent false cgradientprogressctrl cgradientprogressctrl cprogressctrl m_nlower m_nupper m_ncurrentposition m_nstep m_clrstart m_clrend m_clrbkground getsyscolor color_3dface m_clrtext m_bshowpercent void c gradient progress ctrl set range int n lower int n upper m nlower n lower m nupper n upper m ncurrentposition n lower c progress ctrl set range short n lower short n upper cgradientprogressctrl setrange nlower nupper m_nlower nlower m_nupper nupper m_ncurrentposition nlower cprogressctrl setrange nlower nupper void c gradient progress ctrl set range32 int n lower int n upper m nlower n lower m nupper n upper m ncurrentposition n lower c progress ctrl set range short n lower short n upper cgradientprogressctrl setrange32 nlower nupper m_nlower nlower m_nupper nupper m_ncurrentposition nlower cprogressctrl setrange nlower nupper int c gradient progress ctrl set pos int n pos m ncurrentposition n pos return c progress ctrl set pos n pos cgradientprogressctrl setpos npos m_ncurrentposition npos cprogressctrl setpos npos int c gradient progress ctrl set step int n step m nstep n step return c progress ctrl set step n step cgradientprogressctrl setstep nstep m_nstep nstep cprogressctrl setstep nstep int c gradient progress ctrl step it void m ncurrentposition m nstep return c progress ctrl step it cgradientprogressctrl stepit m_ncurrentposition m_nstep cprogressctrl stepit c gradient progress ctrl c gradient progress ctrl cgradientprogressctrl cgradientprogressctrl void c gradient progress ctrl draw gradient c paintdc pdc const rect rect client const int n max width const bool b vertical rect rect fill rectangle for filling band float f step how wide is each band c brush brush brush to fill in the bar c memdc memdc pdc first find out the largest color distance between the start and end colors this distance will determine how many steps we use to carve up the client region and the size of each gradient rect int r g b first distance then starting value float r step g step b step step size for each color bool b same color false handle case if start color end color get the color differences r getr value m clrend getr value m clrstart g getg value m clrend getg value m clrstart b getb value m clrend getb value m clrstart check to see if colors are same if r 0 g 0 b 0 b same color true added the three lines below to fix the drawing problem which used to occur when both the start and end colors are same r getr value m clrstart g getg value m clrstart b getb value m clrstart int n steps select max possible value for n steps if the colors are equal if b same color m clrstart 0 n steps 255 else make the number of steps equal to the greatest distance n steps max abs r max abs g abs b determine how large each band should be in order to cover the client with n steps bands one for every color intensity level if b vertical f step float rect client bottom float n steps else f step float rect client right float n steps calculate the step size for each color r step r float n steps g step g float n steps b step b float n steps reset the colors to the starting position r getr value m clrstart g getg value m clrstart b getb value m clrstart start filling bands for int i on band 0 i on band n steps i on band fill the vertical control if b vertical set rect rect fill 0 upper left x int i on band f step upper left y rect client right 1 lower right x int i on band 1 f step lower right y cdc fill solid rect is faster but it does not handle 8 bit color depth verify brush create solid brush rgb r r step i on band g g step i on band b b step i on band memdc fill rect rect fill brush verify brush delete object if we are past the maximum for the current position we need to get out of the loop before we leave we repaint the remainder of the client area with the background color if rect fill bottom n max width set rect rect fill 0 rect fill bottom rect client right rect client bottom verify brush create solid brush m clrbkground memdc fill rect rect fill brush verify brush delete object return else fill the horizontal control set rect rect fill int i on band f step upper left x 0 upper left y int i on band 1 f step lower right x rect client bottom 1 lower right y cdc fill solid rect is faster but it does not handle 8 bit color depth verify brush create solid brush rgb r r step i on band g g step i on band b b step i on band memdc fill rect rect fill brush verify brush delete object if we are past the maximum for the current position we need to get out of the loop before we leave we repaint the remainder of the client area with the background color if rect fill right n max width set rect rect fill rect fill right 0 rect client right rect client bottom verify brush create solid brush m clrbkground memdc fill rect rect fill brush verify brush delete object return cgradientprogressctrl drawgradient cpaintdc rectclient nmaxwidth bvertical rectfill fstep cbrush cmemdc rstep gstep bstep bsamecolor getrvalue m_clrend getrvalue m_clrstart getgvalue m_clrend getgvalue m_clrstart getbvalue m_clrend getbvalue m_clrstart bsamecolor getrvalue m_clrstart getgvalue m_clrstart getbvalue m_clrstart nsteps nsteps bsamecolor m_clrstart nsteps nsteps nsteps bvertical fstep rectclient nsteps fstep rectclient nsteps rstep nsteps gstep nsteps bstep nsteps getrvalue m_clrstart getgvalue m_clrstart getbvalue m_clrstart ionband ionband nsteps ionband bvertical setrect rectfill ionband fstep rectclient ionband fstep fillsolidrect createsolidbrush rstep ionband gstep ionband bstep ionband fillrect rectfill deleteobject rectfill nmaxwidth setrect rectfill rectfill rectclient rectclient createsolidbrush m_clrbkground fillrect rectfill deleteobject setrect rectfill ionband fstep ionband fstep rectclient fillsolidrect createsolidbrush rstep ionband gstep ionband bstep ionband fillrect rectfill deleteobject rectfill nmaxwidth setrect rectfill rectfill rectclient rectclient createsolidbrush m_clrbkground fillrect rectfill deleteobject void c gradient progress ctrl on paint c paintdc dc this device context for painting todo add your message handler code here c rect rect client get client rect rect client if the current positionis invalid then we should fade into the background if m ncurrentposition m nlower m ncurrentposition m nupper c rect rect get client rect rect c brush brush brush create solid brush get sys color color 3dface dc fill rect rect brush verify brush delete object return the actions to take depend on whether or not we are a vertical control dword dw styles get style bool b vertical bool dw styles pbs vertical figure out what part should be visible so we can stop the gradient when needed float max width if b vertical max width float m ncurrentposition float m nupper float rect client bottom else max width float m ncurrentposition float m nupper float rect client right draw the gradient draw gradient dc rect client int max width b vertical show percent indicator if needed if m bshowpercent c string str percent float fp 100 0f fp float m ncurrentposition m nlower fp float m nupper m nlower str percent format t 3 0f fp dc set text color m clrtext dc set bk mode transparent dc draw text str percent rect client dt vcenter dt center dt singleline do not call c progress ctrl on paint for painting messages cgradientprogressctrl onpaint cpaintdc crect rectclient getclientrect rectclient m_ncurrentposition m_nlower m_ncurrentposition m_nupper crect getclientrect cbrush createsolidbrush getsyscolor color_3dface fillrect deleteobject dwstyles getstyle bvertical dwstyles pbs_vertical maxwidth bvertical maxwidth m_ncurrentposition m_nupper rectclient maxwidth m_ncurrentposition m_nupper rectclient drawgradient rectclient maxwidth bvertical m_bshowpercent cstring strpercent m_ncurrentposition m_nlower m_nupper m_nlower strpercent _t settextcolor m_clrtext setbkmode drawtext strpercent rectclient dt_vcenter dt_center dt_singleline cprogressctrl onpaint bool c gradient progress ctrl on erase bkgnd cdc pdc todo add your message handler code here and or call default unreferenced parameter pdc return true cgradientprogressctrl onerasebkgnd unreferenced_parameter m hgradmod 0 register wnd class c font font font create point font 110 t tahoma bold font get log font m lftitle font delete object font create point font 85 t tahoma font get log font m lfcaption font delete object try and load the msimg32 lib m hgradmod load library t msimg32 dll if m hgradmod null m pgradfill pfngradfill get proc address m hgradmod gradient fill m_hgradmod registerwndclass cfont createpointfont _t getlogfont m_lftitle deleteobject createpointfont _t getlogfont m_lfcaption deleteobject m_hgradmod loadlibrary _t m_hgradmod m_pgradfill getprocaddress m_hgradmod gradientfill ckc side banner wnd ckc side banner wnd if m hbkgbitmap m bbmpdelete delete object m hbkgbitmap if m hicon m bicondelete delete object m hicon if m hgradmod free library m hgradmod ckcsidebannerwnd ckcsidebannerwnd m_hbkgbitmap m_bbmpdelete deleteobject m_hbkgbitmap m_hicon m_bicondelete deleteobject m_hicon m_hgradmod freelibrary m_hgradmod bool ckc side banner wnd attach c wnd p wnd unsigned int u flags unsigned int uiid assert p wnd if p wnd return false assert p wnd m hwnd if p wnd m hwnd return false c rect rect m powner p wnd m powner get window rect rect m powner client to screen rect m uposflag u flags banner left if u flags kcsb attach left rect left m nsize if rect left 0 rect offset rect rect left 0 banner right else if u flags kcsb attach right rect right m nsize banner top else if u flags kcsb attach top rect top m nsize if rect top 0 rect offset rect 0 rect top banner bottom else if u flags kcsb attach bottom rect bottom m nsize update the size of the owner m powner set window pos null rect left rect top rect right rect left rect bottom rect top swp nomove swp nozorder update the positions of the child controls update layout m nsize attach the banner respective to its positional flag m powner get client rect rect if u flags kcsb attach left rect right rect left m nsize else if u flags kcsb attach right rect left rect right m nsize else if u flags kcsb attach top rect bottom rect top m nsize else if u flags kcsb attach bottom rect top rect bottom m nsize et voila create the banner create ws child ws visible rect m powner uiid return true ckcsidebannerwnd cwnd pwnd uflags pwnd pwnd pwnd m_hwnd pwnd m_hwnd crect m_powner pwnd m_powner getwindowrect m_powner clienttoscreen m_uposflag uflags uflags kcsb_attach_left m_nsize offsetrect uflags kcsb_attach_right m_nsize uflags kcsb_attach_top m_nsize offsetrect uflags kcsb_attach_bottom m_nsize m_powner setwindowpos swp_nomove swp_nozorder updatelayout m_nsize m_powner getclientrect uflags kcsb_attach_left m_nsize uflags kcsb_attach_right m_nsize uflags kcsb_attach_top m_nsize uflags kcsb_attach_bottom m_nsize ws_child ws_visible m_powner void ckc side banner wnd set size int n size if m hwnd c rect rect offset the controls accordingly if m uposflag kcsb attach left m uposflag kcsb attach top update layout n size m nsize size the containing window m powner get window rect rect if m uposflag kcsb attach left rect left n size m nsize if rect left 0 rect offset rect rect left 0 m powner set window pos null rect left rect top rect right rect left rect bottom rect top swp nomove swp nozorder else if m uposflag kcsb attach right rect left n size m nsize m powner set window pos null rect left rect top rect right rect left rect bottom rect top swp nozorder else if m uposflag kcsb attach top rect top n size m nsize if rect top 0 rect offset rect 0 rect top m powner set window pos null rect left rect top rect right rect left rect bottom rect top swp nomove swp nozorder else if m uposflag kcsb attach bottom rect top n size m nsize m powner set window pos null rect left rect top rect right rect left rect bottom rect top swp nozorder size the banner get client rect rect if m uposflag kcsb attach left rect right rect left n size else if m uposflag kcsb attach right rect right rect left n size else if m uposflag kcsb attach top rect bottom rect top n size else if m uposflag kcsb attach bottom rect bottom rect top n size move window rect m powner invalidate m nsize n size ckcsidebannerwnd setsize nsize m_hwnd crect m_uposflag kcsb_attach_left m_uposflag kcsb_attach_top updatelayout nsize m_nsize m_powner getwindowrect m_uposflag kcsb_attach_left nsize m_nsize offsetrect m_powner setwindowpos swp_nomove swp_nozorder m_uposflag kcsb_attach_right nsize m_nsize m_powner setwindowpos swp_nozorder m_uposflag kcsb_attach_top nsize m_nsize offsetrect m_powner setwindowpos swp_nomove swp_nozorder m_uposflag kcsb_attach_bottom nsize m_nsize m_powner setwindowpos swp_nozorder getclientrect m_uposflag kcsb_attach_left nsize m_uposflag kcsb_attach_right nsize m_uposflag kcsb_attach_top nsize m_uposflag kcsb_attach_bottom nsize movewindow m_powner m_nsize nsize void ckc side banner wnd update size if m hwnd return c rect rect m powner get client rect rect if m uposflag kcsb attach left rect right rect left m nsize else if m uposflag kcsb attach right rect left rect right m nsize else if m uposflag kcsb attach top rect bottom rect top m nsize else if m uposflag kcsb attach bottom rect top rect bottom m nsize move window rect true ckcsidebannerwnd updatesize m_hwnd crect m_powner getclientrect m_uposflag kcsb_attach_left m_nsize m_uposflag kcsb_attach_right m_nsize m_uposflag kcsb_attach_top m_nsize m_uposflag kcsb_attach_bottom m_nsize movewindow void ckc side banner wnd set pos flag unsigned int u flags if u flags 0xf m uposflag 0xf return c rect rect int n size m nsize set size 0 m uposflag u flags set size n size m powner get client rect rect if u flags kcsb attach left rect right rect left n size else if u flags kcsb attach right rect left rect right n size else if u flags kcsb attach top rect bottom rect top n size else if u flags kcsb attach bottom rect top rect bottom n size move window rect m powner invalidate ckcsidebannerwnd setposflag uflags uflags m_uposflag crect nsize m_nsize setsize m_uposflag uflags setsize nsize m_powner getclientrect uflags kcsb_attach_left nsize uflags kcsb_attach_right nsize uflags kcsb_attach_top nsize uflags kcsb_attach_bottom nsize movewindow m_powner void ckc side banner wnd set caption font c font p font if p font return p font get log font m lfcaption invalidate ckcsidebannerwnd setcaptionfont cfont pfont pfont pfont getlogfont m_lfcaption void ckc side banner wnd get caption font logfont p font if p font return memcpy p font m lfcaption sizeof logfont ckcsidebannerwnd getcaptionfont pfont pfont pfont m_lfcaption void ckc side banner wnd set title font c font p font if p font return p font get log font m lftitle invalidate ckcsidebannerwnd settitlefont cfont pfont pfont pfont getlogfont m_lftitle void ckc side banner wnd get title font logfont p font if p font return memcpy p font m lftitle sizeof logfont ckcsidebannerwnd gettitlefont pfont pfont pfont m_lftitle bool ckc side banner wnd set icon hicon h icon uint ui icon pos bool b self delete bool b result true if m bicondelete m hicon delete object m hicon m bicondelete b self delete m uiconpos ui icon pos m hicon h icon if m hicon calculate the size of the icon iconinfo ii if get icon info hicon m hicon ii b result false if get object ii hbm color sizeof bitmap m bmpinfo b result false else delete object ii hbm color delete object ii hbm mask if is window m hwnd m hicon invalidate return b result ckcsidebannerwnd seticon hicon uiiconpos bselfdelete bresult m_bicondelete m_hicon deleteobject m_hicon m_bicondelete bselfdelete m_uiconpos uiiconpos m_hicon hicon m_hicon geticoninfo m_hicon bresult getobject hbmcolor m_bmpinfo bresult deleteobject hbmcolor deleteobject hbmmask iswindow m_hwnd m_hicon bresult void ckc side banner wnd set texture hbitmap h bitmap bool b self delete if m hbkgbitmap m bbmpdelete delete object m hbkgbitmap m bbmpdelete b self delete m hbkgbitmap h bitmap ckcsidebannerwnd settexture hbitmap bselfdelete m_hbkgbitmap m_bbmpdelete deleteobject m_hbkgbitmap m_bbmpdelete bselfdelete m_hbkgbitmap hbitmap void ckc side banner wnd gradient fill cdc pdc colorref col1 colorref col2 c rect rect bool b hor bool b flip if rect c rect 0 0 0 0 no rectangle get the clip area of the device context pdc get clip box rect if b flip exhange the 2 colors colorref clr col1 col1 col2 col2 clr if pdc get device caps bitspixel 8 gradient only for true color displays draw the gradient int n lenght b hor rect width rect height 1 for int i 0 i n lenght i c rect rcl rect if b hor rcl left i rcl right i 1 else rcl top i rcl bottom i 1 double dfl double i double n lenght pdc fill solid rect rcl rgb dfl getr value col1 1 0 dfl getr value col2 dfl getg value col1 1 0 dfl getg value col2 dfl getb value col1 1 0 dfl getb value col2 else a solid rectangle pdc fill solid rect rect col1 ckcsidebannerwnd gradientfill crect bhor bflip crect getclipbox bflip getdevicecaps nlenght bhor nlenght crect bhor nlenght fillsolidrect getrvalue getrvalue getgvalue getgvalue getbvalue getbvalue fillsolidrect bool ckc side banner wnd create dword dw style const rect rect c wnd p parent wnd uint nid c create context p context bool b result c wnd create kcsb classname t dw style rect p parent wnd nid p context return b result ckcsidebannerwnd dwstyle cwnd pparentwnd ccreatecontext pcontext bresult cwnd kcsb_classname _t dwstyle pparentwnd pcontext bresult void ckc side banner wnd update layout int n offset st enum data data p banner wnd this data p parent wnd m powner data n offset n offset data u flags m uposflag enum child windows m powner m hwnd child enum proc lparam data ckcsidebannerwnd updatelayout noffset stenum pbannerwnd pparentwnd m_powner noffset noffset uflags m_uposflag enumchildwindows m_powner m_hwnd childenumproc void ckc side banner wnd draw background cdc pdc c rect rect c brush n brush p old brush null c pen n pen flat fill if m ufillflag kcsb fill flat m colbkg m colbkg2 m ufillflag kcsb fill gradient pdc fill solid rect rect m colbkg draw edge pdc rect gradient fill else if m ufillflag kcsb fill gradient my trivertex vert 2 my gradient rect g rect ulong ug flag if m pgradfill can we use the msimg32 dll function if m uposflag kcsb attach left m uposflag kcsb attach right set the gradient fill according to position if m uposflag kcsb attach left vert 0 x 0 vert 0 y rect top vert 0 red ushort getr value m colbkg2 8 vert 0 green ushort getg value m colbkg2 8 vert 0 blue ushort getb value m colbkg2 8 vert 0 alpha 0 vert 1 x rect right vert 1 y rect bottom vert 1 red ushort getr value m colbkg 8 vert 1 green ushort getg value m colbkg 8 vert 1 blue ushort getb value m colbkg 8 vert 1 alpha 0 else vert 0 x rect right vert 0 y rect top vert 0 red ushort getr value m colbkg 8 vert 0 green ushort getg value m colbkg 8 vert 0 blue ushort getb value m colbkg 8 vert 0 alpha 0 vert 1 x 0 vert 1 y rect bottom vert 1 red ushort getr value m colbkg2 8 vert 1 green ushort getg value m colbkg2 8 vert 1 blue ushort getb value m colbkg2 8 vert 1 alpha 0 ug flag gradient fill rect v else vert 0 x 0 vert 0 y rect top vert 0 red ushort getr value m colbkg 8 vert 0 green ushort getg value m colbkg 8 vert 0 blue ushort getb value m colbkg 8 vert 0 alpha 0 vert 1 x rect right vert 1 y rect bottom vert 1 red ushort getr value m colbkg2 8 vert 1 green ushort getg value m colbkg2 8 vert 1 blue ushort getb value m colbkg2 8 vert 1 alpha 0 ug flag gradient fill rect h g rect upper left 0 g rect lower right 1 do the fill m pgradfill pdc m hdc vert 2 g rect 1 ug flag else added 2003 oct 29 bool b flip false b horz false if m uposflag kcsb attach top m uposflag kcsb attach bottom b flip true b horz true else if m uposflag kcsb attach right b flip true gradient fill pdc m colbkg m colbkg2 rect b horz b flip draw edge pdc rect gradient fill else if m ufillflag kcsb fill texture c bitmap bmp bmp attach m hbkgbitmap n brush create pattern brush bmp p old brush pdc select object n brush pdc select stock object null pen rect inflate rect 1 1 1 1 pdc rectangle rect rect deflate rect 1 1 1 1 draw edge pdc rect bmp detach ckcsidebannerwnd drawbackground crect cbrush nbrush poldbrush cpen npen m_ufillflag kcsb_fill_flat m_colbkg m_colbkg2 m_ufillflag kcsb_fill_gradient fillsolidrect m_colbkg drawedge m_ufillflag kcsb_fill_gradient my_trivertex my_gradient_rect grect ugflag m_pgradfill m_uposflag kcsb_attach_left m_uposflag kcsb_attach_right m_uposflag kcsb_attach_left getrvalue m_colbkg2 getgvalue m_colbkg2 getbvalue m_colbkg2 getrvalue m_colbkg getgvalue m_colbkg getbvalue m_colbkg getrvalue m_colbkg getgvalue m_colbkg getbvalue m_colbkg getrvalue m_colbkg2 getgvalue m_colbkg2 getbvalue m_colbkg2 ugflag gradient_fill_rect_v getrvalue m_colbkg getgvalue m_colbkg getbvalue m_colbkg getrvalue m_colbkg2 getgvalue m_colbkg2 getbvalue m_colbkg2 ugflag gradient_fill_rect_h grect upperleft grect lowerright m_pgradfill m_hdc grect ugflag bflip bhorz m_uposflag kcsb_attach_top m_uposflag kcsb_attach_bottom bflip bhorz m_uposflag kcsb_attach_right bflip gradientfill m_colbkg m_colbkg2 bhorz bflip drawedge m_ufillflag kcsb_fill_texture cbitmap m_hbkgbitmap nbrush createpatternbrush poldbrush selectobject nbrush selectstockobject null_pen inflaterect deflaterect drawedge void ckc side banner wnd draw text fields cdc pdc c rect rect c point pt pt2 if m hicon draw banner icon pdc rect configure the font if m uposflag kcsb attach left m lftitle lf escapement m lftitle lf orientation m lfcaption lf escapement m lfcaption lf orientation 900 pt x rect left m szedgeoffset cx pt y rect bottom m szedgeoffset cy pt2 x pt x m lftitle lf height m szcaptionoffset cx pt2 y pt y m szcaptionoffset cy else if m uposflag kcsb attach right m lftitle lf escapement m lftitle lf orientation m lfcaption lf escapement m lfcaption lf orientation 900 pt x rect right m szedgeoffset cx pt y rect top m szedgeoffset cy pt2 x pt x m lftitle lf height m szcaptionoffset cx pt2 y pt y m szcaptionoffset cy else if m uposflag kcsb attach top m uposflag kcsb attach bottom m lftitle lf escapement m lftitle lf orientation m lfcaption lf escapement m lfcaption lf orientation 0 pt x rect left m szedgeoffset cx pt y rect top m szedgeoffset cy pt2 x pt x m szcaptionoffset cx pt2 y pt y m lftitle lf height m szcaptionoffset cy int n old bk mode pdc set bk mode transparent c font n font p old font null colorref old txt col pdc set text color m coltxttitle draw the title n font create font indirect m lftitle p old font pdc select object n font pdc text out pt x pt y m strtitle pdc select object p old font n font delete object draw the caption pdc set text color m coltxtcaption n font create font indirect m lfcaption p old font pdc select object n font int arr widths 256 pdc get char width 0 255 arr widths int i c point pt draw pt2 tchar ch i 0 ch 0 pdc text out pt draw x pt draw y m strcaption edited by dominik reichl kee pass doesn t need multiline drawing currently for i 0 i n count i ch m strcaption get at i if ch r continue if ch n if m uposflag kcsb attach left pt draw pt2 pt draw x m lfcaption lf height n height else if m uposflag kcsb attach top m uposflag kcsb attach bottom pt draw pt2 pt draw y m lfcaption lf height n height else if m uposflag kcsb attach right pt draw pt2 pt draw x m lfcaption lf height n height continue pdc text out pt draw x pt draw y c string char ch if m uposflag kcsb attach left pt draw y arr widths ch if i n count 1 pt draw y arr widths m strcaption get at i 1 rect top pt draw pt2 pt draw x m lfcaption lf height n height else if m uposflag kcsb attach top m uposflag kcsb attach bottom pt draw x arr widths ch if i n count 1 pt draw x arr widths m strcaption get at i 1 rect right pt draw pt2 pt draw y m lfcaption lf height n height else if m uposflag kcsb attach right pt draw y arr widths ch if i n count 1 pt draw y arr widths m strcaption get at i 1 rect bottom pt draw pt2 pt draw x m lfcaption lf height n height pdc select object p old font n font delete object pdc set bk mode n old bk mode pdc set text color old txt col ckcsidebannerwnd drawtextfields crect cpoint m_hicon drawbannericon m_uposflag kcsb_attach_left m_lftitle lfescapement m_lftitle lforientation m_lfcaption lfescapement m_lfcaption lforientation m_szedgeoffset m_szedgeoffset m_lftitle lfheight m_szcaptionoffset m_szcaptionoffset m_uposflag kcsb_attach_right m_lftitle lfescapement m_lftitle lforientation m_lfcaption lfescapement m_lfcaption lforientation m_szedgeoffset m_szedgeoffset m_lftitle lfheight m_szcaptionoffset m_szcaptionoffset m_uposflag kcsb_attach_top m_uposflag kcsb_attach_bottom m_lftitle lfescapement m_lftitle lforientation m_lfcaption lfescapement m_lfcaption lforientation m_szedgeoffset m_szedgeoffset m_szcaptionoffset m_lftitle lfheight m_szcaptionoffset noldbkmode setbkmode cfont nfont poldfont oldtxtcol settextcolor m_coltxttitle nfont createfontindirect m_lftitle poldfont selectobject nfont textout m_strtitle selectobject poldfont nfont deleteobject settextcolor m_coltxtcaption nfont createfontindirect m_lfcaption poldfont selectobject nfont arrwidths getcharwidth arrwidths cpoint ptdraw textout ptdraw ptdraw m_strcaption keepass ncount m_strcaption getat m_uposflag kcsb_attach_left ptdraw ptdraw m_lfcaption lfheight nheight m_uposflag kcsb_attach_top m_uposflag kcsb_attach_bottom ptdraw ptdraw m_lfcaption lfheight nheight m_uposflag kcsb_attach_right ptdraw ptdraw m_lfcaption lfheight nheight textout ptdraw ptdraw cstring m_uposflag kcsb_attach_left ptdraw arrwidths ncount ptdraw arrwidths m_strcaption getat ptdraw ptdraw m_lfcaption lfheight nheight m_uposflag kcsb_attach_top m_uposflag kcsb_attach_bottom ptdraw arrwidths ncount ptdraw arrwidths m_strcaption getat ptdraw ptdraw m_lfcaption lfheight nheight m_uposflag kcsb_attach_right ptdraw arrwidths ncount ptdraw arrwidths m_strcaption getat ptdraw ptdraw m_lfcaption lfheight nheight selectobject poldfont nfont deleteobject setbkmode noldbkmode settextcolor oldtxtcol void ckc side banner wnd draw edge cdc pdc c rect rect c pen n pen p old pen null n pen create pen ps solid 0 m coledge p old pen pdc select object n pen if m uposflag kcsb attach left pdc move to rect right 1 rect top pdc line to rect right 1 rect bottom else if m uposflag kcsb attach right pdc move to rect left rect top pdc line to rect left rect bottom else if m uposflag kcsb attach top pdc move to rect left rect bottom 1 pdc line to rect right rect bottom 1 else if m uposflag kcsb attach bottom pdc move to rect left rect top pdc line to rect right rect top pdc select object p old pen n pen delete object ckcsidebannerwnd drawedge crect cpen npen poldpen npen createpen ps_solid m_coledge poldpen selectobject npen m_uposflag kcsb_attach_left moveto lineto m_uposflag kcsb_attach_right moveto lineto m_uposflag kcsb_attach_top moveto lineto m_uposflag kcsb_attach_bottom moveto lineto selectobject poldpen npen deleteobject void ckc side banner wnd draw banner icon cdc pdc c rect rect if m hicon return c point pt banner on left if m uposflag kcsb attach left icon to left if m uiconpos kcsb icon left rect bottom m szedgeoffset cy m bmpinfo bm height pt y rect bottom icon to right else if m uiconpos kcsb icon right rect top m szedgeoffset cy pt rect top left vtop if m uiconpos kcsb icon top pt x rect left vcenter else if m uiconpos kcsb icon vcenter pt x rect center point x m bmpinfo bm width 2 vbottom else if m uiconpos kcsb icon bottom pt x rect right m bmpinfo bm width 1 banner on right else if m uposflag kcsb attach right icon to left if m uiconpos kcsb icon left rect top m szedgeoffset cy pt y rect top rect top m bmpinfo bm height icon to right else if m uiconpos kcsb icon right rect bottom m szedgeoffset cy m bmpinfo bm height pt x rect left pt y rect bottom vtop if m uiconpos kcsb icon top pt x rect right m bmpinfo bm width vcenter else if m uiconpos kcsb icon vcenter pt x rect center point x m bmpinfo bm width 2 vbottom else if m uiconpos kcsb icon bottom pt x rect left 1 banner on top or bottom else if m uposflag kcsb attach top m uposflag kcsb attach bottom icon to left if m uiconpos kcsb icon left rect left m szedgeoffset cx pt rect top left rect left m bmpinfo bm width icon to right else if m uiconpos kcsb icon right rect right m szedgeoffset cx m bmpinfo bm width pt x rect right pt y rect top vtop if m uiconpos kcsb icon top pt y rect top 1 vcenter else if m uiconpos kcsb icon vcenter pt y rect center point y m bmpinfo bm height 2 vbottom else if m uiconpos kcsb icon bottom pt y rect bottom m bmpinfo bm height 1 pdc draw icon pt x pt y m hicon ckcsidebannerwnd drawbannericon crect m_hicon cpoint m_uposflag kcsb_attach_left m_uiconpos kcsb_icon_left m_szedgeoffset m_bmpinfo bmheight m_uiconpos kcsb_icon_right m_szedgeoffset topleft m_uiconpos kcsb_icon_top m_uiconpos kcsb_icon_vcenter centerpoint m_bmpinfo bmwidth m_uiconpos kcsb_icon_bottom m_bmpinfo bmwidth m_uposflag kcsb_attach_right m_uiconpos kcsb_icon_left m_szedgeoffset m_bmpinfo bmheight m_uiconpos kcsb_icon_right m_szedgeoffset m_bmpinfo bmheight m_uiconpos kcsb_icon_top m_bmpinfo bmwidth m_uiconpos kcsb_icon_vcenter centerpoint m_bmpinfo bmwidth m_uiconpos kcsb_icon_bottom m_uposflag kcsb_attach_top m_uposflag kcsb_attach_bottom m_uiconpos kcsb_icon_left m_szedgeoffset topleft m_bmpinfo bmwidth m_uiconpos kcsb_icon_right m_szedgeoffset m_bmpinfo bmwidth m_uiconpos kcsb_icon_top m_uiconpos kcsb_icon_vcenter centerpoint m_bmpinfo bmheight m_uiconpos kcsb_icon_bottom m_bmpinfo bmheight drawicon m_hicon bool callback ckc side banner wnd child enum proc hwnd h wnd child lparam l param st enum p data st enum l param hwnd h wnd parent 0 c rect rect point top left bottom right check if the hwnd is valid and check that its not the hwnd to the banner if h wnd child h wnd child p data p banner wnd m hwnd now we check if the parent is actually the parent of the banner this check was put it to deal with composite controls like a combobox note for some reason a combobox s edit control appears to be a child of the parent until you query for its parent hwnd h wnd parent get parent h wnd child if h wnd parent p data p parent wnd m hwnd we have a valid child window which we can now reposition get window rect h wnd child rect top left x rect left top left y rect top bottom right x rect right bottom right y rect bottom screen to client p data p parent wnd m hwnd top left screen to client p data p parent wnd m hwnd bottom right if p data u flags kcsb attach left top left x p data n offset bottom right x p data n offset else if p data u flags kcsb attach top top left y p data n offset bottom right y p data n offset move window h wnd child top left x top left y bottom right x top left x bottom right y top left y true return true to continue enumerating return true ckcsidebannerwnd childenumproc hwndchild lparam stenum pdata stenum lparam hwndparent crect topleft bottomright hwndchild hwndchild pdata pbannerwnd m_hwnd hwndparent getparent hwndchild hwndparent pdata pparentwnd m_hwnd getwindowrect hwndchild topleft topleft bottomright bottomright screentoclient pdata pparentwnd m_hwnd topleft screentoclient pdata pparentwnd m_hwnd bottomright pdata uflags kcsb_attach_left topleft pdata noffset bottomright pdata noffset pdata uflags kcsb_attach_top topleft pdata noffset bottomright pdata noffset movewindow hwndchild topleft topleft bottomright topleft bottomright topleft void ckc side banner wnd on paint c paintdc dc this device context for painting cdc memdc c bitmap membmp p old bmp null c rect rect get client rect rect create mem dc memdc create compatibledc dc membmp create compatible bitmap dc rect width rect height p old bmp memdc select object membmp draw the banner draw background memdc rect draw text fields memdc rect render the image dc bit blt 0 0 rect width rect height memdc 0 0 srccopy deselect object memdc select object p old bmp delete objects membmp delete object memdc deletedc ckcsidebannerwnd onpaint cpaintdc cbitmap poldbmp crect getclientrect createcompatibledc createcompatiblebitmap poldbmp selectobject drawbackground drawtextfields bitblt selectobject poldbmp deleteobject bool ckc side banner wnd on erase bkgnd cdc pdc unreferenced parameter pdc return true ckcsidebannerwnd onerasebkgnd unreferenced_parameter c custom list ctrl ex c custom list ctrl ex hdc hdc null int n bits per pixel 0 hdc getdc null n bits per pixel get device caps hdc bitspixel releasedc null hdc if n bits per pixel 8 m bcolorize true else m bcolorize false m rgbrowcolor rgb 238 238 255 m pparenti null m pbshowcolumns null ccustomlistctrlex ccustomlistctrlex nbitsperpixel nbitsperpixel getdevicecaps nbitsperpixel m_bcolorize m_bcolorize m_rgbrowcolor m_pparenti m_pbshowcolumns c custom list ctrl ex c custom list ctrl ex ccustomlistctrlex ccustomlistctrlex colorref c custom list ctrl ex get row color ex return m rgbrowcolor ccustomlistctrlex getrowcolorex m_rgbrowcolor void c custom list ctrl ex set row color ex colorref rgb color m rgbrowcolor rgb color redraw items 0 get item count 1 update window ccustomlistctrlex setrowcolorex rgbcolor m_rgbrowcolor rgbcolor redrawitems getitemcount updatewindow bool c custom list ctrl ex ensure visible int n item bool b partialok return c list ctrl ensure visible n item b partialok ccustomlistctrlex ensurevisible nitem bpartialok clistctrl ensurevisible nitem bpartialok int c custom list ctrl ex get item count return c list ctrl get item count ccustomlistctrlex getitemcount clistctrl getitemcount bool c custom list ctrl ex pre create window createstruct cs cs style lvs typemask cs style lvs showselalways cs style lvs report lvs ownerdrawfixed return c list ctrl pre create window cs ccustomlistctrlex precreatewindow lvs_typemask lvs_showselalways lvs_report lvs_ownerdrawfixed clistctrl precreatewindow bool c custom list ctrl ex on notify wparam w param lparam l param lresult p result hd notify phdn hd notify l param parent must be initialized first assert m pparenti null m pbshowcolumns null if m pparenti null m pbshowcolumns null return c list ctrl on notify w param l param p result if phdn hdr code hdn itemchangedw phdn hdr code hdn itemchangeda assert phdn pitem null track only width changes if phdn pitem mask hdi width c pw safe dlg m pparenti cb onpwlistcolumnwidthchange phdn i item phdn pitem cxy else if phdn hdr code hdn begintrackw phdn hdr code hdn begintracka int n item phdn i item if n item 0 if m pbshowcolumns n item false p result true return true return c list ctrl on notify w param l param p result ccustomlistctrlex onnotify wparam lparam presult hd_notify hd_notify lparam m_pparenti m_pbshowcolumns m_pparenti m_pbshowcolumns clistctrl onnotify wparam lparam presult hdn_itemchangedw hdn_itemchangeda hdi_width cpwsafedlg m_pparenti cb_onpwlistcolumnwidthchange iitem hdn_begintrackw hdn_begintracka nitem iitem nitem m_pbshowcolumns nitem presult clistctrl onnotify wparam lparam presult void c custom list ctrl ex on custom draw nmhdr pnmhdr lresult p result nmlvcustomdrawx plvcd reinterpret cast nmlvcustomdrawx pnmhdr colorref cr text cr bkgnd take the default processing unless we set this to something else below p result cdrf dodefault first thing check the draw stage if it s the control s prepaint stage then tell windows we want messages for every item if plvcd nmcd dw draw stage cdds prepaint p result cdrf notifyitemdraw else if plvcd nmcd dw draw stage cdds itemprepaint this is the prepaint stage for a subitem here s where we set the item s text and background colors our return value will tell windows to draw the subitem itself but it will use the new colors we set here if m bcolorize true colorize the list only if enough colors are available if plvcd nmcd dw item spec 1 uneven item number cr text rgb 0 0 0 cr bkgnd m rgbrowcolor else even item number cr text rgb 0 0 0 cr bkgnd rgb 255 255 255 else cr text rgb 0 0 0 cr bkgnd rgb 255 255 255 store the colors into the nmlvcustomdraw struct plvcd clr text cr text plvcd clr text bk cr bkgnd ccustomlistctrlex oncustomdraw presult reinterpret_cast crtext crbkgnd presult cdrf_dodefault dwdrawstage cdds_prepaint presult cdrf_notifyitemdraw dwdrawstage cdds_itemprepaint m_bcolorize dwitemspec crtext crbkgnd m_rgbrowcolor crtext crbkgnd crtext crbkgnd clrtext crtext clrtextbk crbkgnd void c custom list ctrl ex on sys key down uint n char uint n rep cnt uint n flags parent must be initialized first assert m pparenti null if m pparenti null return c pw safe dlg m pparenti notify user activity if n flags 0x2000 if n char vk up n char vk down n char vk home n char vk end c pw safe dlg m pparenti processlistkey n char true else c list ctrl on sys key down n char n rep cnt n flags else c list ctrl on sys key down n char n rep cnt n flags ccustomlistctrlex onsyskeydown nchar nrepcnt nflags m_pparenti m_pparenti cpwsafedlg m_pparenti notifyuseractivity nflags nchar vk_up nchar vk_down nchar vk_home nchar vk_end cpwsafedlg m_pparenti _processlistkey nchar clistctrl onsyskeydown nchar nrepcnt nflags clistctrl onsyskeydown nchar nrepcnt nflags void c custom list ctrl ex on mouse move uint n flags c point point assert m pparenti null if m pparenti null return c pw safe dlg m pparenti notify user activity c list ctrl on mouse move n flags point ccustomlistctrlex onmousemove nflags cpoint m_pparenti m_pparenti cpwsafedlg m_pparenti notifyuseractivity clistctrl onmousemove nflags void c custom list ctrl ex on key down uint n char uint n rep cnt uint n flags assert m pparenti null if m pparenti null return if n char vk delete n flags 0x2000 0 c pw safe dlg m pparenti processlistkey vk delete false else c pw safe dlg m pparenti notify user activity c list ctrl on key down n char n rep cnt n flags ccustomlistctrlex onkeydown nchar nrepcnt nflags m_pparenti m_pparenti nchar vk_delete nflags cpwsafedlg m_pparenti _processlistkey vk_delete cpwsafedlg m_pparenti notifyuseractivity clistctrl onkeydown nchar nrepcnt nflags m balwaysrgb false osversioninfo osvi osvi dwos version info size sizeof osvi get version ex osvi bool b isxp osvi dw platform id ver platform win32 nt osvi dw major version 5 osvi dw major version 5 osvi dw minor version 1 m bflatmenus false if b isxp system parameters info spi getflatmenu 0 m bflatmenus false m_balwaysrgb dwosversioninfosize getversionex bisxp dwplatformid ver_platform_win32_nt dwmajorversion dwmajorversion dwminorversion m_bflatmenus bisxp systemparametersinfo spi_getflatmenu m_bflatmenus c colour pickerxp c colour pickerxp void ccolourpickerxp ccolourpickerxp colorref c colour pickerxp get color void const return m color ccolourpickerxp getcolor m_color colorref c colour pickerxp get color bool b translate default const return b translate default m color clr default m defaultcolor m color ccolourpickerxp getcolor btranslatedefault btranslatedefault m_color clr_default m_defaultcolor m_color void c colour pickerxp set color colorref color m color color if is window m hwnd invalidate false ccolourpickerxp setcolor m_color iswindow m_hwnd colorref c colour pickerxp get default color void const return m defaultcolor ccolourpickerxp getdefaultcolor m_defaultcolor void c colour pickerxp set default color colorref color m defaultcolor color ccolourpickerxp setdefaultcolor m_defaultcolor void c colour pickerxp set custom text lpctstr tsz text m strcustomtext tsz text ccolourpickerxp setcustomtext tsztext m_strcustomtext tsztext void c colour pickerxp set default text lpctstr tsz text m strdefaulttext tsz text if m bcomboboxstyle m color clr default invalidate false ccolourpickerxp setdefaulttext tsztext m_strdefaulttext tsztext m_bcomboboxstyle m_color clr_default void c colour pickerxp set colours name uint n firstid if n firstid c string sz temp for int i 0 i sizeof c colour popupxp m crcolours sizeof colour table entry i if sz temp load string n firstid i sz temp c colour popupxp m strinitnames i tcscpy c colour popupxp m crcolours i sz name sz temp else for int i 0 i sizeof c colour popupxp m crcolours sizeof colour table entry i tcscpy c colour popupxp m crcolours i sz name c colour popupxp m strinitnames i ccolourpickerxp setcoloursname nfirstid nfirstid cstring sztemp ccolourpopupxp m_crcolours colourtableentry sztemp loadstring nfirstid sztemp ccolourpopupxp m_strinitnames _tcscpy ccolourpopupxp m_crcolours szname sztemp ccolourpopupxp m_crcolours colourtableentry _tcscpy ccolourpopupxp m_crcolours szname ccolourpopupxp m_strinitnames void c colour pickerxp set reg section lpctstr tsz reg section t m strregsection tsz reg section ccolourpickerxp setregsection tszregsection _t m_strregsection tszregsection void c colour pickerxp set reg section static lpctstr tsz reg section t m strregsectionstatic tsz reg section ccolourpickerxp setregsectionstatic tszregsection _t m_strregsectionstatic tszregsection void c colour pickerxp set track selection bool b track m btrackselection b track ccolourpickerxp settrackselection btrack m_btrackselection btrack bool c colour pickerxp get track selection void const return m btrackselection ccolourpickerxp gettrackselection m_btrackselection void c colour pickerxp set style bool b combo box style m bcomboboxstyle b combo box style if b combo box style c rect rc get window rect rc cdc pdc this getdc c font p old font pdc select object get font textmetric tm pdc get text metrics tm pdc select object p old font this releasedc pdc set window pos null 0 0 rc width tm tm height 8 swp noactivate swp nozorder swp nomove swp noredraw invalidate false ccolourpickerxp setstyle bcomboboxstyle m_bcomboboxstyle bcomboboxstyle bcomboboxstyle crect getwindowrect cfont poldfont selectobject getfont gettextmetrics selectobject poldfont setwindowpos tmheight swp_noactivate swp_nozorder swp_nomove swp_noredraw bool c colour pickerxp get style void const return m bcomboboxstyle ccolourpickerxp getstyle m_bcomboboxstyle void c colour pickerxp setrgb text lpctstr tszrgb t rgb m strrgbtext tszrgb while m strrgbtext get length 3 m strrgbtext t if m bcomboboxstyle m color clr default invalidate false ccolourpickerxp setrgbtext _t m_strrgbtext m_strrgbtext getlength m_strrgbtext _t m_bcomboboxstyle m_color clr_default void c colour pickerxp set alwaysrgb bool b show m balwaysrgb b show if m bcomboboxstyle m color clr default invalidate false ccolourpickerxp setalwaysrgb bshow m_balwaysrgb bshow m_bcomboboxstyle m_color clr_default bool c colour pickerxp get alwaysrgb void const return m balwaysrgb ccolourpickerxp getalwaysrgb m_balwaysrgb void c colour pickerxp draw item lpdrawitemstruct lp draw item struct assert lp draw item struct cdc pdc cdc from handle lp draw item struct hdc c memdc dc mem pdc uint state lp draw item struct item state c rect r draw lp draw item struct rc item c rect r arrow bool b focus state ods focus state ods selected 0 send message wm erasebkgnd wparam dc mem get safe hdc if m bpopupactive m bcomboboxstyle state ods selected ods focus if state ods focus state ods default ifdef theme h if m xpbutton m xpbutton open get safe hwnd l button if m xpedit m xpedit open get safe hwnd l edit if m xpcombo m xpcombo open get safe hwnd l combobox endif draw outer edge ifdef theme h if m xpbutton is app themed if state ods disabled 0 m bcomboboxstyle dc mem draw3d rect r draw combobox disabled colour out combobox disabled colour out r draw deflate rect 1 1 else int n frame state 0 if state ods selected 0 m bpopupactive n frame state m bcomboboxstyle ets selected pbs pressed if state ods disabled 0 n frame state m bcomboboxstyle ets disabled pbs disabled if state ods hotlight 0 m bmouseover n frame state m bcomboboxstyle ets hot pbs hot else if state ods default 0 m bcomboboxstyle n frame state pbs defaulted if m bcomboboxstyle m xpedit draw background dc mem get safe hdc ep edittext n frame state r draw null m xpedit get background content rect dc mem get safe hdc ep edittext n frame state r draw r draw else m xpbutton draw background dc mem get safe hdc bp pushbutton n frame state r draw null m xpbutton get background content rect dc mem get safe hdc bp pushbutton n frame state r draw r draw r draw inflate rect 0 0 1 0 else endif if m bcomboboxstyle if state ods disabled 0 dc mem fill solid rect r draw get sys color color window dc mem draw edge r draw edge sunken bf rect r draw deflate rect get system metrics sm cxedge get system metrics sm cyedge else uint u frame state dfcs buttonpush dfcs adjustrect if state ods selected u frame state dfcs pushed if state ods disabled u frame state dfcs inactive dc mem draw frame control r draw dfc button u frame state if state ods selected r draw offset rect 1 1 draw arrow combo box style if m bcomboboxstyle ifdef theme h if m xpcombo is app themed int n frame state 0 if state ods selected 0 m bpopupactive n frame state cbxs pressed if state ods disabled 0 n frame state cbxs disabled if state ods hotlight 0 m bmouseover n frame state cbxs hot r arrow set rect r draw right r draw height 2 r draw top r draw right r draw bottom m xpcombo draw background dc mem get safe hdc cp dropdownbutton n frame state r arrow null r draw deflate rect 0 0 r arrow width 0 else endif r arrow set rect r draw right r draw height r draw top r draw right r draw bottom dc mem draw frame control r arrow dfc scroll dfcs scrolldown state ods selected dfcs flat dfcs pushed 0 state ods disabled dfcs inactive 0 r draw deflate rect 1 1 r arrow width 1 draw inner edge disabled combo box ifdef theme h if m xpbutton is app themed m bcomboboxstyle if state ods disabled 0 dc mem draw3d rect r draw combobox disabled colour in combobox disabled colour in r draw deflate rect 2 2 1 2 endif draw focus if b focus c rect r focus r draw left r draw top r draw right 1 r draw bottom if m bcomboboxstyle colorref cl focus get sys color color highlight colorref cl invert rgb 255 getr value cl focus 255 getg value cl focus 255 getb value cl focus r focus deflate rect 1 1 dc mem fill solid rect r focus cl focus r focus inflate rect 1 1 dc mem draw3d rect r focus cl invert cl invert dc mem draw focus rect r focus r draw deflate rect get system metrics sm cxedge get system metrics sm cyedge r draw deflate rect 0 0 1 0 if m bcomboboxstyle draw arrow button style r arrow left r draw right g ciarrowsizex get system metrics sm cxedge 2 r arrow right r arrow left g ciarrowsizex r arrow top r draw bottom r draw top 2 g ciarrowsizey 2 r arrow bottom r draw bottom r draw top 2 g ciarrowsizey 2 draw arrow dc mem r arrow 0 state ods disabled get sys color color graytext rgb 0 0 0 r draw right r arrow left get system metrics sm cxedge 2 2 draw separator button style dc mem draw edge r draw edge etched bf right m bflatmenus bf flat 0 r draw right get system metrics sm cxedge 2 1 draw color if state ods disabled 0 c rect rc color r draw if m bcomboboxstyle rc color right r draw left r draw height dc mem fill solid rect rc color m color clr default m defaultcolor m color frame rect dc mem m hdc rc color get sys color brush b focus m bcomboboxstyle color highlighttext color windowtext if m bcomboboxstyle r draw deflate rect rc color width 2 1 0 1 c string sz temp if m color clr default sz temp m strdefaulttext else sz temp format t s d s d s d m strrgbtext left 1 getr value m color m strrgbtext mid 1 1 getg value m color m strrgbtext mid 2 1 getb value m color for int i 0 i c colour popupxp m nnumcolours i if c colour popupxp get colour i m color if m balwaysrgb c string szrgb sz temp sz temp format t s s c colour popupxp get colour name i szrgb else sz temp c colour popupxp get colour name i break c font p old font dc mem select object get font dc mem set bk mode transparent if b focus dc mem set text color get sys color color highlighttext dc mem draw text sz temp r draw dt singleline dt vcenter dt end ellipsis dt noprefix dc mem select object p old font ccolourpickerxp drawitem lpdrawitemstruct lpdrawitemstruct fromhandle lpdrawitemstruct cmemdc dcmem lpdrawitemstruct itemstate crect rdraw lpdrawitemstruct rcitem crect rarrow bfocus ods_focus ods_selected sendmessage wm_erasebkgnd dcmem getsafehdc m_bpopupactive m_bcomboboxstyle ods_selected ods_focus ods_focus ods_default _theme_h_ m_xpbutton m_xpbutton getsafehwnd m_xpedit m_xpedit getsafehwnd m_xpcombo m_xpcombo getsafehwnd _theme_h_ m_xpbutton isappthemed ods_disabled m_bcomboboxstyle dcmem draw3drect rdraw combobox_disabled_colour_out combobox_disabled_colour_out rdraw deflaterect nframestate ods_selected m_bpopupactive nframestate m_bcomboboxstyle ets_selected pbs_pressed ods_disabled nframestate m_bcomboboxstyle ets_disabled pbs_disabled ods_hotlight m_bmouseover nframestate m_bcomboboxstyle ets_hot pbs_hot ods_default m_bcomboboxstyle nframestate pbs_defaulted m_bcomboboxstyle m_xpedit drawbackground dcmem getsafehdc ep_edittext nframestate rdraw m_xpedit getbackgroundcontentrect dcmem getsafehdc ep_edittext nframestate rdraw rdraw m_xpbutton drawbackground dcmem getsafehdc bp_pushbutton nframestate rdraw m_xpbutton getbackgroundcontentrect dcmem getsafehdc bp_pushbutton nframestate rdraw rdraw rdraw inflaterect m_bcomboboxstyle ods_disabled dcmem fillsolidrect rdraw getsyscolor color_window dcmem drawedge rdraw edge_sunken bf_rect rdraw deflaterect getsystemmetrics sm_cxedge getsystemmetrics sm_cyedge uframestate dfcs_buttonpush dfcs_adjustrect ods_selected uframestate dfcs_pushed ods_disabled uframestate dfcs_inactive dcmem drawframecontrol rdraw dfc_button uframestate ods_selected rdraw offsetrect combobox m_bcomboboxstyle _theme_h_ m_xpcombo isappthemed nframestate ods_selected m_bpopupactive nframestate cbxs_pressed ods_disabled nframestate cbxs_disabled ods_hotlight m_bmouseover nframestate cbxs_hot rarrow setrect rdraw rdraw rdraw rdraw rdraw m_xpcombo drawbackground dcmem getsafehdc cp_dropdownbutton nframestate rarrow rdraw deflaterect rarrow rarrow setrect rdraw rdraw rdraw rdraw rdraw dcmem drawframecontrol rarrow dfc_scroll dfcs_scrolldown ods_selected dfcs_flat dfcs_pushed ods_disabled dfcs_inactive rdraw deflaterect rarrow _theme_h_ m_xpbutton isappthemed m_bcomboboxstyle ods_disabled dcmem draw3drect rdraw combobox_disabled_colour_in combobox_disabled_colour_in rdraw deflaterect bfocus crect rfocus rdraw rdraw rdraw rdraw m_bcomboboxstyle clfocus getsyscolor color_highlight clinvert getrvalue clfocus getgvalue clfocus getbvalue clfocus rfocus deflaterect dcmem fillsolidrect rfocus clfocus rfocus inflaterect dcmem draw3drect rfocus clinvert clinvert dcmem drawfocusrect rfocus rdraw deflaterect getsystemmetrics sm_cxedge getsystemmetrics sm_cyedge rdraw deflaterect m_bcomboboxstyle rarrow rdraw g_ciarrowsizex getsystemmetrics sm_cxedge rarrow rarrow g_ciarrowsizex rarrow rdraw rdraw g_ciarrowsizey rarrow rdraw rdraw g_ciarrowsizey drawarrow dcmem rarrow ods_disabled getsyscolor color_graytext rdraw rarrow getsystemmetrics sm_cxedge dcmem drawedge rdraw edge_etched bf_right m_bflatmenus bf_flat rdraw getsystemmetrics sm_cxedge ods_disabled crect rccolor rdraw m_bcomboboxstyle rccolor rdraw rdraw dcmem fillsolidrect rccolor m_color clr_default m_defaultcolor m_color framerect dcmem m_hdc rccolor getsyscolorbrush bfocus m_bcomboboxstyle color_highlighttext color_windowtext m_bcomboboxstyle rdraw deflaterect rccolor cstring sztemp m_color clr_default sztemp m_strdefaulttext sztemp _t m_strrgbtext getrvalue m_color m_strrgbtext getgvalue m_color m_strrgbtext getbvalue m_color ccolourpopupxp m_nnumcolours ccolourpopupxp getcolour m_color m_balwaysrgb cstring sztemp sztemp _t ccolourpopupxp getcolourname sztemp ccolourpopupxp getcolourname cfont poldfont dcmem selectobject getfont dcmem setbkmode bfocus dcmem settextcolor getsyscolor color_highlighttext dcmem drawtext sztemp rdraw dt_singleline dt_vcenter dt_end_ellipsis dt_noprefix dcmem selectobject poldfont void c colour pickerxp pre subclass window modify style 0 bs ownerdraw inherited pre subclass window ccolourpickerxp presubclasswindow modifystyle bs_ownerdraw _inherited presubclasswindow bool c colour pickerxp pre translate message msg p msg if p msg message wm keydown switch p msg w param case vk down case vk f4 on clicked activate pop up when f4 key or down arrow is hit return true case vk up return true disable up arrow return inherited pre translate message p msg ccolourpickerxp pretranslatemessage pmsg pmsg wm_keydown pmsg wparam vk_down vk_f4 onclicked vk_up _inherited pretranslatemessage pmsg bool c colour pickerxp on clicked m bpopupactive true c rect r draw get window rect r draw new c colour popupxp c point r draw left r draw bottom point to display popup m color selected colour this parent m strdefaulttext default text area m strcustomtext custom text m strregsection get length m strregsection m strregsectionstatic registry section for custom colours c wnd p parent get parent if p parent p parent send message cpn dropdown lparam m color wparam get dlg ctrlid return true ccolourpickerxp onclicked m_bpopupactive crect rdraw getwindowrect rdraw ccolourpopupxp cpoint rdraw rdraw m_color m_strdefaulttext m_strcustomtext m_strregsection getlength m_strregsection m_strregsectionstatic cwnd pparent getparent pparent pparent sendmessage cpn_dropdown m_color getdlgctrlid int c colour pickerxp on create lpcreatestruct lp create struct if c button on create lp create struct 1 return 1 return 0 ccolourpickerxp oncreate lpcreatestruct cbutton oncreate lpcreatestruct long c colour pickerxp on sel endok uint l param long w param m bpopupactive false colorref old color m color color colorref l param c wnd p parent get parent if p parent p parent send message cpn closeup l param wparam get dlg ctrlid p parent send message cpn selendok l param wparam get dlg ctrlid if old color m color if p parent p parent send message cpn selchange m color wparam get dlg ctrlid return true ccolourpickerxp onselendok lparam wparam m_bpopupactive oldcolor m_color lparam cwnd pparent getparent pparent pparent sendmessage cpn_closeup lparam getdlgctrlid pparent sendmessage cpn_selendok lparam getdlgctrlid oldcolor m_color pparent pparent sendmessage cpn_selchange m_color getdlgctrlid long c colour pickerxp on sel end cancel uint l param long w param m bpopupactive false color colorref l param c wnd p parent get parent if p parent p parent send message cpn closeup l param wparam get dlg ctrlid p parent send message cpn selendcancel l param wparam get dlg ctrlid return true ccolourpickerxp onselendcancel lparam wparam m_bpopupactive lparam cwnd pparent getparent pparent pparent sendmessage cpn_closeup lparam getdlgctrlid pparent sendmessage cpn_selendcancel lparam getdlgctrlid long c colour pickerxp on sel change uint l param long w param if m btrackselection color colorref l param c wnd p parent get parent if p parent p parent send message cpn selchange l param wparam get dlg ctrlid return true ccolourpickerxp onselchange lparam wparam m_btrackselection lparam cwnd pparent getparent pparent pparent sendmessage cpn_selchange lparam getdlgctrlid void c colour pickerxp onnm theme changed nmhdr pnmhdr lresult p result unreferenced parameter pnmhdr this feature requires windows xp or greater the symbol win32 winnt must be 0x0501 todo add your control notification handler code here ifdef theme h m xpbutton open get safe hwnd l button m xpedit open get safe hwnd l edit m xpcombo open get safe hwnd l combobox endif invalidate false p result 0 ccolourpickerxp onnmthemechanged presult unreferenced_parameter _win32_winnt _theme_h_ m_xpbutton getsafehwnd m_xpedit getsafehwnd m_xpcombo getsafehwnd presult void c colour pickerxp on mouse move uint n flags c point point if m bmouseover m bmouseover true trackmouseevent tme tme cb size sizeof tme tme dw flags tme leave tme hwnd track m hwnd trackmouseevent tme if m bcomboboxstyle draw hot arrow true else invalidate false c button on mouse move n flags point ccolourpickerxp onmousemove nflags cpoint m_bmouseover m_bmouseover cbsize dwflags tme_leave hwndtrack m_hwnd _trackmouseevent m_bcomboboxstyle drawhotarrow cbutton onmousemove nflags lresult c colour pickerxp on mouse leave wparam w param lparam l param unreferenced parameter w param unreferenced parameter l param if m bmouseover m bmouseover false if m bcomboboxstyle draw hot arrow false else invalidate false return 0 ccolourpickerxp onmouseleave wparam lparam unreferenced_parameter wparam unreferenced_parameter lparam m_bmouseover m_bmouseover m_bcomboboxstyle drawhotarrow colorref clr arrow rgb 0 0 0 point pts arrow 3 switch i direction case 0 down pts arrow 0 x p rect left pts arrow 0 y p rect top pts arrow 1 x p rect right pts arrow 1 y p rect top pts arrow 2 x p rect left p rect right 2 pts arrow 2 y p rect bottom break case 1 up pts arrow 0 x p rect left pts arrow 0 y p rect bottom pts arrow 1 x p rect right pts arrow 1 y p rect bottom pts arrow 2 x p rect left p rect right 2 pts arrow 2 y p rect top break case 2 left pts arrow 0 x p rect right pts arrow 0 y p rect top pts arrow 1 x p rect right pts arrow 1 y p rect bottom pts arrow 2 x p rect left pts arrow 2 y p rect top p rect bottom 2 break case 3 right pts arrow 0 x p rect left pts arrow 0 y p rect top pts arrow 1 x p rect left pts arrow 1 y p rect bottom pts arrow 2 x p rect right pts arrow 2 y p rect top p rect bottom 2 break c brush brs arrow clr arrow c pen pen arrow ps solid 1 clr arrow c brush p old brush pdc select object brs arrow c pen p old pen pdc select object pen arrow pdc set poly fill mode winding pdc polygon pts arrow 3 pdc select object p old brush pdc select object p old pen clrarrow ptsarrow idirection ptsarrow prect ptsarrow prect ptsarrow prect ptsarrow prect ptsarrow prect prect ptsarrow prect ptsarrow prect ptsarrow prect ptsarrow prect ptsarrow prect ptsarrow prect prect ptsarrow prect ptsarrow prect ptsarrow prect ptsarrow prect ptsarrow prect ptsarrow prect ptsarrow prect prect ptsarrow prect ptsarrow prect ptsarrow prect ptsarrow prect ptsarrow prect ptsarrow prect prect cbrush brsarrow clrarrow cpen penarrow ps_solid clrarrow cbrush poldbrush selectobject brsarrow cpen poldpen selectobject penarrow setpolyfillmode ptsarrow selectobject poldbrush selectobject poldpen void c colour pickerxp draw hot arrow bool b hot ifdef theme h if m xpcombo is app themed c clientdc dc this c rect rc arrow get client rect rc arrow m xpedit get background content rect dc get safe hdc ep edittext ets normal rc arrow rc arrow rc arrow left rc arrow right rc arrow height 2 m xpcombo draw background dc get safe hdc cp dropdownbutton b hot cbxs hot cbxs normal rc arrow null else unreferenced parameter b hot endif ccolourpickerxp drawhotarrow bhot _theme_h_ m_xpcombo isappthemed cclientdc crect rcarrow getclientrect rcarrow m_xpedit getbackgroundcontentrect getsafehdc ep_edittext ets_normal rcarrow rcarrow rcarrow rcarrow rcarrow m_xpcombo drawbackground getsafehdc cp_dropdownbutton bhot cbxs_hot cbxs_normal rcarrow unreferenced_parameter bhot c colour popupxp c colour popupxp initialise ccolourpopupxp ccolourpopupxp lpctstr sz reg section null initialise m crcolour m crinitialcolour cr colour m pparent p parent wnd m strdefaulttext sz default text sz default text t m strcustomtext sz custom text sz custom text t m strregsection sz reg section sz reg section t c colour popupxp create p cr colour p parent wnd sz default text sz custom text szregsection m_crcolour m_crinitialcolour crcolour m_pparent pparentwnd m_strdefaulttext szdefaulttext szdefaulttext _t m_strcustomtext szcustomtext szcustomtext _t m_strregsection szregsection szregsection _t ccolourpopupxp crcolour pparentwnd szdefaulttext szcustomtext void c colour popupxp initialise assert m nnumcolours max colours if m nnumcolours max colours m nnumcolours max colours m nnumcolumns 0 m nnumrows 0 m nboxsize 18 m nmargin get system metrics sm cxedge m ncurrentsel invalid colour m nchosencoloursel invalid colour m pparent null m crcolour m crinitialcolour rgb 0 0 0 m bchildwindowvisible false osversioninfo osvi osvi dwos version info size sizeof osvi get version ex osvi m bisxp osvi dw platform id ver platform win32 nt osvi dw major version 5 osvi dw major version 5 osvi dw minor version 1 m bflatmenus false if m bisxp system parameters info spi getflatmenu 0 m bflatmenus false get all the colors i need int n alpha 48 m clrbackground get sys color color menu m clrhilightborder get sys color color highlight m clrhilight m clrhilightborder if m bisxp m clrhilight get sys color color menuhilight m clrhilighttext get sys color color highlighttext m clrtext get sys color color menutext m clrlolight rgb getr value m clrbackground 255 n alpha getr value m clrhilightborder n alpha 8 getg value m clrbackground 255 n alpha getg value m clrhilightborder n alpha 8 getb value m clrbackground 255 n alpha getb value m clrhilightborder n alpha 8 idiot check make sure the colour square is at least 5 x 5 if m nboxsize 2 m nmargin 2 5 m nboxsize 5 2 m nmargin 2 create the font nonclientmetrics ncm ncm cb size sizeof nonclientmetrics verify system parameters info spi getnonclientmetrics sizeof nonclientmetrics ncm 0 m font create font indirect ncm lf message font create the palette struct logpalette log palette paletteentry pal entry max colours pal logpalette p log palette logpalette pal p log palette pal version 0x300 p log palette pal num entries word m nnumcolours for int i 0 i m nnumcolours i p log palette pal pal entry i pe red getr value m crcolours i cr colour p log palette pal pal entry i pe green getg value m crcolours i cr colour p log palette pal pal entry i pe blue getb value m crcolours i cr colour p log palette pal pal entry i pe flags 0 m palette create palette p log palette ccolourpopupxp m_nnumcolours max_colours m_nnumcolours max_colours m_nnumcolours max_colours m_nnumcolumns m_nnumrows m_nboxsize m_nmargin getsystemmetrics sm_cxedge m_ncurrentsel invalid_colour m_nchosencoloursel invalid_colour m_pparent m_crcolour m_crinitialcolour m_bchildwindowvisible dwosversioninfosize getversionex m_bisxp dwplatformid ver_platform_win32_nt dwmajorversion dwmajorversion dwminorversion m_bflatmenus m_bisxp systemparametersinfo spi_getflatmenu m_bflatmenus nalpha m_clrbackground getsyscolor color_menu m_clrhilightborder getsyscolor color_highlight m_clrhilight m_clrhilightborder m_bisxp m_clrhilight getsyscolor color_menuhilight m_clrhilighttext getsyscolor color_highlighttext m_clrtext getsyscolor color_menutext m_clrlolight getrvalue m_clrbackground nalpha getrvalue m_clrhilightborder nalpha getgvalue m_clrbackground nalpha getgvalue m_clrhilightborder nalpha getbvalue m_clrbackground nalpha getbvalue m_clrhilightborder nalpha m_nboxsize m_nmargin m_nboxsize m_nmargin cbsize systemparametersinfo spi_getnonclientmetrics m_font createfontindirect lfmessagefont logpalette palentry max_colours plogpalette plogpalette palversion plogpalette palnumentries m_nnumcolours m_nnumcolours plogpalette palpalentry pered getrvalue m_crcolours crcolour plogpalette palpalentry pegreen getgvalue m_crcolours crcolour plogpalette palpalentry peblue getbvalue m_crcolours crcolour plogpalette palpalentry peflags m_palette createpalette plogpalette lpctstr sz custom text null assert p parent wnd is window p parent wnd get safe hwnd m pparent p parent wnd m crcolour m crinitialcolour cr colour get the class name and create the window uint n class style cs classdc cs savebits cs hredraw cs vredraw if m bisxp bool b drop shadow system parameters info spi getdropshadow 0 b drop shadow false if b drop shadow n class style cs dropshadow c string sz class name afx register wnd class n class style 0 hbrush color menu 1 0 finding the window s topmost parent c wnd p top parent m pparent get parent owner if p top parent null p top parent set redraw false bool b create c wnd create ex 0 sz class name t ws visible ws popup p x p y 100 100 size updated soon p parent wnd get safe hwnd 0 null if p top parent null p top parent send message wm ncactivate true p top parent set redraw true if b create return false store the custom text if sz custom text null m strcustomtext sz custom text store the default area text if sz default text null m strdefaulttext sz default text set the window size set window size create the tooltips create tool tips find which cell if any corresponds to the initial colour find cell from colour cr colour capture all mouse events for the life of this window set capture return true szcustomtext pparentwnd iswindow pparentwnd getsafehwnd m_pparent pparentwnd m_crcolour m_crinitialcolour crcolour nclassstyle cs_classdc cs_savebits cs_hredraw cs_vredraw m_bisxp bdropshadow systemparametersinfo spi_getdropshadow bdropshadow bdropshadow nclassstyle cs_dropshadow cstring szclassname afxregisterwndclass nclassstyle color_menu cwnd ptopparent m_pparent getparentowner ptopparent ptopparent setredraw bcreate cwnd createex szclassname _t ws_visible ws_popup pparentwnd getsafehwnd ptopparent ptopparent sendmessage wm_ncactivate ptopparent setredraw bcreate szcustomtext m_strcustomtext szcustomtext szdefaulttext m_strdefaulttext szdefaulttext setwindowsize createtooltips findcellfromcolour crcolour setcapture bool c colour popupxp pre translate message msg p msg m tooltip relay event p msg fix adrian roman sometimes if the picker loses focus it is never destroyed if get capture get safe hwnd m hwnd set capture return c wnd pre translate message p msg ccolourpopupxp pretranslatemessage pmsg m_tooltip relayevent pmsg getcapture getsafehwnd m_hwnd setcapture cwnd pretranslatemessage pmsg c colour popupxp c colour popupxp m font delete object m palette delete object ccolourpopupxp ccolourpopupxp m_font deleteobject m_palette deleteobject bool c colour popupxp get cell rect int n index const lprect rect if n index custom box value set rect rect m customtextrect left m customtextrect top m customtextrect right m customtextrect bottom return true else if n index default box value set rect rect m defaulttextrect left m defaulttextrect top m defaulttextrect right m defaulttextrect bottom return true if n index 0 n index m nnumcolours return false rect left get column n index m nboxsize m nmargin rect top get row n index m nboxsize m nmargin move everything down if we are displaying a default text area if m strdefaulttext get length rect top m nmargin m defaulttextrect height rect right rect left m nboxsize rect bottom rect top m nboxsize return true ccolourpopupxp getcellrect nindex nindex custom_box_value setrect m_customtextrect m_customtextrect m_customtextrect m_customtextrect nindex default_box_value setrect m_defaulttextrect m_defaulttextrect m_defaulttextrect m_defaulttextrect nindex nindex m_nnumcolours getcolumn nindex m_nboxsize m_nmargin getrow nindex m_nboxsize m_nmargin m_strdefaulttext getlength m_nmargin m_defaulttextrect m_nboxsize m_nboxsize void c colour popupxp find cell from colour colorref cr colour if cr colour clr default m strdefaulttext get length m nchosencoloursel default box value return for int i 0 i m nnumcolours i if get colour i cr colour m nchosencoloursel i return if m strcustomtext get length m nchosencoloursel custom box value else m nchosencoloursel invalid colour ccolourpopupxp findcellfromcolour crcolour crcolour clr_default m_strdefaulttext getlength m_nchosencoloursel default_box_value m_nnumcolours getcolour crcolour m_nchosencoloursel m_strcustomtext getlength m_nchosencoloursel custom_box_value m_nchosencoloursel invalid_colour void c colour popupxp set window size c size text size c size 0 0 if we are showing a custom or default text area get the font and text size if m strcustomtext get length m strdefaulttext get length c clientdc dc this c font p old font c font dc select object m font get the size of the custom text if there is custom text if m strcustomtext get length text size dc get text extent m strcustomtext get the size of the default text if there is default text if m strdefaulttext get length c size default size dc get text extent m strdefaulttext if default size cx text size cx text size cx default size cx if default size cy text size cy text size cy default size cy dc select object p old font text size c size 2 m nmargin 2 m nmargin add even more space to draw the horizontal line text size cy 2 m nmargin 2 get the number of columns and rows m nnumcolumns int sqrt double m nnumcolours for a square window yuk m nnumcolumns 8 m nnumrows m nnumcolours m nnumcolumns if m nnumcolours m nnumcolumns m nnumrows get the current window position and set the new size c rect rect get window rect rect m windowrect set rect rect left rect top rect left m nnumcolumns m nboxsize 2 m nmargin rect top m nnumrows m nboxsize 2 m nmargin if custom text then expand window if necessary and set text width as window width if m strdefaulttext get length if text size cx m windowrect width m windowrect right m windowrect left text size cx text size cx m windowrect width 2 m nmargin work out the text area m defaulttextrect set rect m nmargin m nmargin m nmargin text size cx 2 m nmargin text size cy m windowrect bottom m defaulttextrect height 2 m nmargin else m defaulttextrect set rect empty if custom text then expand window if necessary and set text width as window width if m strcustomtext get length if text size cx m windowrect width m windowrect right m windowrect left text size cx text size cx m windowrect width 2 m nmargin work out the text area m customtextrect set rect m nmargin m windowrect height m nmargin text size cx m windowrect height m nmargin text size cy m windowrect bottom m customtextrect height m nmargin else m customtextrect set rect empty compute the min width int n box total width m nnumcolumns m nboxsize int n min width n box total width if n min width text size cx n min width text size cx initialize the color box rectangle m boxesrect c rect c point n min width n box total width 2 m defaulttextrect bottom c size n box total width m nnumrows m nboxsize get the screen size with multi monitor support c size screen size get system metrics sm cxscreen get system metrics sm cyscreen if winver 0x0500 hmodule h user32 get module handle t user32 dll if h user32 null typedef hmonitor winapi fn monitorfromwindow hwnd h wnd dword dw flags typedef bool winapi fn getmonitorinfo hmonitor h monitor lpmonitorinfo lpmi fn monitorfromwindow pfn monitor from window fn monitorfromwindow get proc address h user32 monitor from window fn getmonitorinfo pfn get monitor info fn getmonitorinfo get proc address h user32 get monitor infoa if pfn monitor from window null pfn get monitor info null monitorinfo mi hmonitor h monitor pfn monitor from window m hwnd monitor defaulttonearest mi cb size sizeof mi pfn get monitor info h monitor mi screen size cx mi rc work right mi rc work left screen size cy mi rc work bottom mi rc work top endif need to check it ll fit on screen too far right if m windowrect right screen size cx m windowrect offset rect m windowrect right screen size cx 0 too far left if m windowrect left 0 m windowrect offset rect m windowrect left 0 bottom falling out of screen if m windowrect bottom screen size cy c rect parent rect m pparent get window rect parent rect m windowrect offset rect 0 parent rect height m windowrect height set the window size and position move window m windowrect true ccolourpopupxp setwindowsize csize textsize csize m_strcustomtext getlength m_strdefaulttext getlength cclientdc cfont poldfont cfont selectobject m_font m_strcustomtext getlength textsize gettextextent m_strcustomtext m_strdefaulttext getlength csize defaultsize gettextextent m_strdefaulttext defaultsize textsize textsize defaultsize defaultsize textsize textsize defaultsize selectobject poldfont textsize csize m_nmargin m_nmargin textsize m_nmargin m_nnumcolumns m_nnumcolours m_nnumcolumns m_nnumrows m_nnumcolours m_nnumcolumns m_nnumcolours m_nnumcolumns m_nnumrows crect getwindowrect m_windowrect setrect m_nnumcolumns m_nboxsize m_nmargin m_nnumrows m_nboxsize m_nmargin m_strdefaulttext getlength textsize m_windowrect m_windowrect m_windowrect textsize textsize m_windowrect m_nmargin m_defaulttextrect setrect m_nmargin m_nmargin m_nmargin textsize m_nmargin textsize m_windowrect m_defaulttextrect m_nmargin m_defaulttextrect setrectempty m_strcustomtext getlength textsize m_windowrect m_windowrect m_windowrect textsize textsize m_windowrect m_nmargin m_customtextrect setrect m_nmargin m_windowrect m_nmargin textsize m_windowrect m_nmargin textsize m_windowrect m_customtextrect m_nmargin m_customtextrect setrectempty nboxtotalwidth m_nnumcolumns m_nboxsize nminwidth nboxtotalwidth nminwidth textsize nminwidth textsize m_boxesrect crect cpoint nminwidth nboxtotalwidth m_defaulttextrect csize nboxtotalwidth m_nnumrows m_nboxsize csize screensize getsystemmetrics sm_cxscreen getsystemmetrics sm_cyscreen huser32 getmodulehandle _t huser32 fn_monitorfromwindow hwnd dwflags fn_getmonitorinfo hmonitor fn_monitorfromwindow pfnmonitorfromwindow fn_monitorfromwindow getprocaddress huser32 monitorfromwindow fn_getmonitorinfo pfngetmonitorinfo fn_getmonitorinfo getprocaddress huser32 getmonitorinfoa pfnmonitorfromwindow pfngetmonitorinfo hmonitor pfnmonitorfromwindow m_hwnd monitor_defaulttonearest cbsize pfngetmonitorinfo hmonitor screensize rcwork rcwork screensize rcwork rcwork m_windowrect screensize m_windowrect offsetrect m_windowrect screensize m_windowrect m_windowrect offsetrect m_windowrect m_windowrect screensize crect parentrect m_pparent getwindowrect parentrect m_windowrect offsetrect parentrect m_windowrect movewindow m_windowrect void c colour popupxp create tool tips create the tool tip if m tooltip create this return add a tool for each cell for int i 0 i m nnumcolours i c rect rect if get cell rect i rect continue m tooltip add tool this get colour name i rect 1 ccolourpopupxp createtooltips m_tooltip m_nnumcolours crect getcellrect m_tooltip addtool getcolourname void c colour popupxp change selection int n index c clientdc dc this device context for drawing if n index m nnumcolours n index custom box value if m ncurrentsel 0 m ncurrentsel m nnumcolours m ncurrentsel custom box value m ncurrentsel default box value set current selection as invalid and redraw old selection this way the old selection will be drawn unselected int old sel m ncurrentsel m ncurrentsel invalid colour draw cell dc old sel set the current selection as row col and draw it will be drawn selected m ncurrentsel n index draw cell dc m ncurrentsel store the current colour if m ncurrentsel custom box value m pparent send message cpn selchange wparam m crinitialcolour 0 else if m ncurrentsel default box value m crcolour clr default m pparent send message cpn selchange wparam clr default 0 else if m ncurrentsel invalid colour m crcolour colorref invalid colour m pparent send message cpn selchange wparam m crinitialcolour 0 else m crcolour get colour m ncurrentsel m pparent send message cpn selchange wparam m crcolour 0 ccolourpopupxp changeselection nindex cclientdc nindex m_nnumcolours nindex custom_box_value m_ncurrentsel m_ncurrentsel m_nnumcolours m_ncurrentsel custom_box_value m_ncurrentsel default_box_value oldsel m_ncurrentsel m_ncurrentsel invalid_colour drawcell oldsel m_ncurrentsel nindex drawcell m_ncurrentsel m_ncurrentsel custom_box_value m_pparent sendmessage cpn_selchange m_crinitialcolour m_ncurrentsel default_box_value m_crcolour clr_default m_pparent sendmessage cpn_selchange clr_default m_ncurrentsel invalid_colour m_crcolour invalid_colour m_pparent sendmessage cpn_selchange m_crinitialcolour m_crcolour getcolour m_ncurrentsel m_pparent sendmessage cpn_selchange m_crcolour void c colour popupxp end selection int n message release capture if custom text selected perform a custom colour selection if n message cpn selendcancel m ncurrentsel custom box value m bchildwindowvisible true c color dialog dlg m crinitialcolour cc fullopen cc anycolor this colorref cl custom colors 16 c string sz temp dword dw value dword dw type dword dw count sizeof dword hkey h sec key null if m strregsection get length h sec key afx get app get section key m strregsection for int i 0 i 16 i if h sec key null cl custom colors i rgb 255 255 255 continue sz temp format t custom color d i if reg query value ex h sec key lpctstr sz temp null dw type lpbyte dw value dw count error success assert dw type reg dword assert dw count sizeof dw value cl custom colors i dw value continue cl custom colors i rgb 255 255 255 dlg m cc lp cust colors cl custom colors if dlg do modal idok m crcolour dlg get color else n message cpn selendcancel if h sec key null for int i 0 i 16 i sz temp format t custom color d i reg set value ex h sec key lpctstr sz temp null reg dword lpbyte cl custom colors i sizeof cl custom colors i reg close key h sec key m bchildwindowvisible false if n message cpn selendcancel m crcolour m crinitialcolour m pparent send message n message wparam m crcolour 0 kill focus bug fixed by martin wawrusch if m bchildwindowvisible destroy window ccolourpopupxp endselection nmessage releasecapture nmessage cpn_selendcancel m_ncurrentsel custom_box_value m_bchildwindowvisible ccolordialog m_crinitialcolour cc_fullopen cc_anycolor clcustomcolors cstring sztemp dwvalue dwtype dwcount hseckey m_strregsection getlength hseckey afxgetapp getsectionkey m_strregsection hseckey clcustomcolors sztemp _t custom_color_ regqueryvalueex hseckey sztemp dwtype dwvalue dwcount error_success dwtype reg_dword dwcount dwvalue clcustomcolors dwvalue clcustomcolors m_cc lpcustcolors clcustomcolors domodal m_crcolour getcolor nmessage cpn_selendcancel hseckey sztemp _t custom_color_ regsetvalueex hseckey sztemp reg_dword clcustomcolors clcustomcolors regclosekey hseckey m_bchildwindowvisible nmessage cpn_selendcancel m_crcolour m_crinitialcolour m_pparent sendmessage nmessage m_crcolour m_bchildwindowvisible destroywindow void c colour popupxp draw cell cdc pdc int n index get the drawing rect c rect rect if get cell rect n index rect return get the text pointer and colors c string sz text colorref clr box c size size margin c size size hi border uint n border 0 switch n index case custom box value sz text m strcustomtext size margin s sizetextmargin size hi border s sizetexthiborder n border bf top break case default box value sz text m strdefaulttext size margin s sizetextmargin size hi border s sizetexthiborder n border bf bottom break default sz text t clr box get colour n index size margin s sizeboxmargin size hi border s sizeboxhiborder based on the selectons get our colors colorref clr hi light colorref clr text bool b selected colorref clr3d top left rgb 128 128 128 clr3d bottom right rgb 128 128 128 if m ncurrentsel n index b selected true clr hi light m clrhilight clr text m bflatmenus m clrhilighttext m clrtext clr3d top left get sys color color 3dhighlight clr3d bottom right get sys color color 3dshadow else if m nchosencoloursel n index b selected true clr hi light m clrlolight clr text m clrtext clr3d top left get sys color color 3dshadow clr3d bottom right get sys color color 3dhighlight else b selected false clr hi light m clrlolight clr text m clrtext select and realize the palette c palette p old palette null if sz text t if pdc get device caps rastercaps rc palette p old palette pdc select palette m palette false pdc realize palette if we are currently selected if b selected if we have a background margin then draw that if size margin cx 0 size margin cy 0 pdc fill solid rect rect m clrbackground rect deflate rect size margin cx size margin cy draw the selection rectagle if m bflatmenus c pen pen ps solid 1 m clrhilightborder c pen p old pen pdc select object pen c brush brush clr hi light c brush p old brush pdc select object brush pdc rectangle rect rect deflate rect size hi border cx 1 size hi border cy 1 restore dc pdc select object p old pen pdc select object p old brush else pdc fill solid rect rect m clrbackground pdc draw3d rect rect clr3d top left clr3d bottom right rect deflate rect size hi border cx size hi border cy otherwise we are not selected else draw the background pdc fill solid rect rect m clrbackground rect deflate rect size margin cx size hi border cx size margin cy size hi border cy draw custom text if sz text t c font p old font c font pdc select object m font pdc set text color clr text pdc set bk mode transparent pdc draw text sz text rect dt center dt vcenter dt singleline pdc select object p old font otherwise draw color else draw color c pen pen ps solid 1 get sys color color 3dshadow c pen p old pen pdc select object pen c brush brush palettergb getr value get colour n index getg value get colour n index getb value get colour n index c brush p old brush pdc select object brush draw the cell colour rect deflate rect 1 1 pdc rectangle rect restore dc pdc select object p old pen pdc select object p old brush draw border if n border c rect r get cell rect n index r r inflate rect 2 1 draw border pdc r edge etched n border cleanup if p old palette pdc get device caps rastercaps rc palette pdc select palette p old palette false ccolourpopupxp drawcell nindex crect getcellrect nindex cstring sztext clrbox csize sizemargin csize sizehiborder nborder nindex custom_box_value sztext m_strcustomtext sizemargin s_sizetextmargin sizehiborder s_sizetexthiborder nborder bf_top default_box_value sztext m_strdefaulttext sizemargin s_sizetextmargin sizehiborder s_sizetexthiborder nborder bf_bottom sztext _t clrbox getcolour nindex sizemargin s_sizeboxmargin sizehiborder s_sizeboxhiborder clrhilight clrtext bselected clr3dtopleft clr3dbottomright m_ncurrentsel nindex bselected clrhilight m_clrhilight clrtext m_bflatmenus m_clrhilighttext m_clrtext clr3dtopleft getsyscolor color_3dhighlight clr3dbottomright getsyscolor color_3dshadow m_nchosencoloursel nindex bselected clrhilight m_clrlolight clrtext m_clrtext clr3dtopleft getsyscolor color_3dshadow clr3dbottomright getsyscolor color_3dhighlight bselected clrhilight m_clrlolight clrtext m_clrtext cpalette poldpalette sztext _t getdevicecaps rc_palette poldpalette selectpalette m_palette realizepalette bselected sizemargin sizemargin fillsolidrect m_clrbackground deflaterect sizemargin sizemargin m_bflatmenus cpen ps_solid m_clrhilightborder cpen poldpen selectobject cbrush clrhilight cbrush poldbrush selectobject deflaterect sizehiborder sizehiborder selectobject poldpen selectobject poldbrush fillsolidrect m_clrbackground draw3drect clr3dtopleft clr3dbottomright deflaterect sizehiborder sizehiborder fillsolidrect m_clrbackground deflaterect sizemargin sizehiborder sizemargin sizehiborder sztext _t cfont poldfont cfont selectobject m_font settextcolor clrtext setbkmode drawtext sztext dt_center dt_vcenter dt_singleline selectobject poldfont cpen ps_solid getsyscolor color_3dshadow cpen poldpen selectobject cbrush getrvalue getcolour nindex getgvalue getcolour nindex getbvalue getcolour nindex cbrush poldbrush selectobject deflaterect selectobject poldpen selectobject poldbrush nborder crect getcellrect nindex inflaterect drawborder edge_etched nborder poldpalette getdevicecaps rc_palette selectpalette poldpalette int c colour popupxp get index int row int col const if row custom box value col custom box value m strcustomtext get length return custom box value else if row default box value col default box value m strdefaulttext get length return default box value else if row 0 col 0 row m nnumrows col m nnumcolumns return invalid colour else if row m nnumcolumns col m nnumcolours return invalid colour else return row m nnumcolumns col ccolourpopupxp getindex custom_box_value custom_box_value m_strcustomtext getlength custom_box_value default_box_value default_box_value m_strdefaulttext getlength default_box_value m_nnumrows m_nnumcolumns invalid_colour m_nnumcolumns m_nnumcolours invalid_colour m_nnumcolumns int c colour popupxp get row int n index const if n index custom box value m strcustomtext get length return custom box value else if n index default box value m strdefaulttext get length return default box value else if n index 0 n index m nnumcolours return invalid colour else return n index m nnumcolumns ccolourpopupxp getrow nindex nindex custom_box_value m_strcustomtext getlength custom_box_value nindex default_box_value m_strdefaulttext getlength default_box_value nindex nindex m_nnumcolours invalid_colour nindex m_nnumcolumns int c colour popupxp get column int n index const if n index custom box value m strcustomtext get length return custom box value else if n index default box value m strdefaulttext get length return default box value else if n index 0 n index m nnumcolours return invalid colour else return n index m nnumcolumns ccolourpopupxp getcolumn nindex nindex custom_box_value m_strcustomtext getlength custom_box_value nindex default_box_value m_strdefaulttext getlength default_box_value nindex nindex m_nnumcolours invalid_colour nindex m_nnumcolumns void c colour popupxp draw border cdc pdc c rect rect uint n edge uint n border if m bflatmenus c pen pen ps solid 1 get sys color color graytext c pen p old pen pdc select object pen rect deflate rect 0 0 1 1 if n border bf top pdc move to rect left rect top pdc line to rect right 1 rect top if n border bf bottom pdc move to rect left rect bottom pdc line to rect right 1 rect bottom if n border bf left pdc move to rect left rect top pdc line to rect left rect bottom 1 if n border bf right pdc move to rect right rect top pdc line to rect right rect bottom 1 pdc select object p old pen else pdc draw edge rect n edge n border ccolourpopupxp drawborder crect nedge nborder m_bflatmenus cpen ps_solid getsyscolor color_graytext cpen poldpen selectobject deflaterect nborder bf_top moveto lineto nborder bf_bottom moveto lineto nborder bf_left moveto lineto nborder bf_right moveto lineto selectobject poldpen drawedge nedge nborder void c colour popupxp on nc destroy c wnd on nc destroy delete this ccolourpopupxp onncdestroy cwnd onncdestroy void c colour popupxp onl button up uint n flags c point point c wnd onl button up n flags point dword pos get message pos point c point loword pos hiword pos if m windowrect pt in rect point end selection cpn selendok else end selection cpn selendcancel ccolourpopupxp onlbuttonup nflags cpoint cwnd onlbuttonup nflags getmessagepos cpoint m_windowrect ptinrect endselection cpn_selendok endselection cpn_selendcancel void c colour popupxp on paint c paintdc dc this device context for painting draw the default area text if m strdefaulttext get length draw cell dc default box value draw colour cells for int i 0 i m nnumcolours i draw cell dc i draw custom text if m strcustomtext get length draw cell dc custom box value draw raised window edge ex window style ws ex windowedge is sposed to do this but for some reason isn t c rect rect get client rect rect draw border dc rect edge raised bf rect ccolourpopupxp onpaint cpaintdc m_strdefaulttext getlength drawcell default_box_value m_nnumcolours drawcell m_strcustomtext getlength drawcell custom_box_value ws_ex_windowedge crect getclientrect drawborder edge_raised bf_rect void c colour popupxp on mouse move uint n flags c point point int n new selection invalid colour translate points to be relative raised window edge point x m nmargin point y m nmargin first check we aren t in text box if m strcustomtext get length m customtextrect pt in rect point n new selection custom box value else if m strdefaulttext get length m defaulttextrect pt in rect point n new selection default box value else if m boxesrect pt in rect point n new selection invalid colour else take into account text box if m strdefaulttext get length point y m defaulttextrect height get the row and column n new selection get index point y m nboxsize point x m nboxsize in range if not default and exit if n new selection 0 n new selection m nnumcolours c wnd on mouse move n flags point return n new selection invalid colour ok we have the row and column of the current selection may be custom box value has the row col selection changed if yes then redraw old and new cells if n new selection m ncurrentsel change selection n new selection c wnd on mouse move n flags point ccolourpopupxp onmousemove nflags cpoint nnewselection invalid_colour m_nmargin m_nmargin m_strcustomtext getlength m_customtextrect ptinrect nnewselection custom_box_value m_strdefaulttext getlength m_defaulttextrect ptinrect nnewselection default_box_value m_boxesrect ptinrect nnewselection invalid_colour m_strdefaulttext getlength m_defaulttextrect nnewselection getindex m_nboxsize m_nboxsize nnewselection nnewselection m_nnumcolours cwnd onmousemove nflags nnewselection invalid_colour custom_box_value nnewselection m_ncurrentsel changeselection nnewselection cwnd onmousemove nflags void c colour popupxp on key down uint n char uint n rep cnt uint n flags int row get row m ncurrentsel col get column m ncurrentsel if n char vk down if row default box value row col 0 else if row custom box value row invalid colour if m strdefaulttext get length row col default box value else row col 0 else row if get index row col 0 if m strcustomtext get length row col custom box value else if m strdefaulttext get length row col default box value else row col 0 change selection get index row col if n char vk up if row default box value row invalid colour if m strcustomtext get length row col custom box value else row get row m nnumcolours 1 col get column m nnumcolours 1 else if row custom box value row get row m nnumcolours 1 col get column m nnumcolours 1 else if row 0 row else row 0 if m strdefaulttext get length row col default box value else if m strcustomtext get length row col custom box value else row get row m nnumcolours 1 col get column m nnumcolours 1 change selection get index row col if n char vk right if row default box value row col 0 else if row custom box value row invalid colour if m strdefaulttext get length row col default box value else row col 0 else if col m nnumcolumns 1 col else col 0 row if get index row col invalid colour if m strcustomtext get length row col custom box value else if m strdefaulttext get length row col default box value else row col 0 change selection get index row col if n char vk left if row default box value row invalid colour if m strcustomtext get length row col custom box value else row get row m nnumcolours 1 col get column m nnumcolours 1 else if row custom box value row get row m nnumcolours 1 col get column m nnumcolours 1 else if col 0 col else col 0 if row 0 row col m nnumcolumns 1 else if m strdefaulttext get length row col default box value else if m strcustomtext get length row col custom box value else row get row m nnumcolours 1 col get column m nnumcolours 1 change selection get index row col if n char vk escape m crcolour m crinitialcolour end selection cpn selendcancel return if n char vk return n char vk space end selection cpn selendok return c wnd on key down n char n rep cnt n flags ccolourpopupxp onkeydown nchar nrepcnt nflags getrow m_ncurrentsel getcolumn m_ncurrentsel nchar vk_down default_box_value custom_box_value invalid_colour m_strdefaulttext getlength default_box_value getindex m_strcustomtext getlength custom_box_value m_strdefaulttext getlength default_box_value changeselection getindex nchar vk_up default_box_value invalid_colour m_strcustomtext getlength custom_box_value getrow m_nnumcolours getcolumn m_nnumcolours custom_box_value getrow m_nnumcolours getcolumn m_nnumcolours m_strdefaulttext getlength default_box_value m_strcustomtext getlength custom_box_value getrow m_nnumcolours getcolumn m_nnumcolours changeselection getindex nchar vk_right default_box_value custom_box_value invalid_colour m_strdefaulttext getlength default_box_value m_nnumcolumns getindex invalid_colour m_strcustomtext getlength custom_box_value m_strdefaulttext getlength default_box_value changeselection getindex nchar vk_left default_box_value invalid_colour m_strcustomtext getlength custom_box_value getrow m_nnumcolours getcolumn m_nnumcolours custom_box_value getrow m_nnumcolours getcolumn m_nnumcolours m_nnumcolumns m_strdefaulttext getlength default_box_value m_strcustomtext getlength custom_box_value getrow m_nnumcolours getcolumn m_nnumcolours changeselection getindex nchar vk_escape m_crcolour m_crinitialcolour endselection cpn_selendcancel nchar vk_return nchar vk_space endselection cpn_selendok cwnd onkeydown nchar nrepcnt nflags bool c colour popupxp on query new palette invalidate false return c wnd on query new palette ccolourpopupxp onquerynewpalette cwnd onquerynewpalette void c colour popupxp on palette changed c wnd p focus wnd c wnd on palette changed p focus wnd if p focus wnd get safe hwnd get safe hwnd invalidate false ccolourpopupxp onpalettechanged cwnd pfocuswnd cwnd onpalettechanged pfocuswnd pfocuswnd getsafehwnd getsafehwnd void c colour popupxp on kill focus c wnd p new wnd c wnd on kill focus p new wnd release capture destroy window causes crash when custom colour dialog appears ccolourpopupxp onkillfocus cwnd pnewwnd cwnd onkillfocus pnewwnd releasecapture destroywindow void c colour popupxp on activate app bool b active htask h task c wnd on activate app b active h task endif if deactivating app cancel this selection if b active end selection cpn selendcancel ccolourpopupxp onactivateapp bactive htask cwnd onactivateapp bactive htask bactive endselection cpn_selendcancel c auto rich edit ctrl fx c auto rich edit ctrl fx cautoricheditctrlfx cautoricheditctrlfx c auto rich edit ctrl fx c auto rich edit ctrl fx cautoricheditctrlfx cautoricheditctrlfx void c auto rich edit ctrl fx setrtf c string srtf int n stream type editstream es zero memory es sizeof editstream ifdef unicode if n stream type sf rtf 0 es pfn callback cb stream inrtf else endif es pfn callback cb stream in m strstreamincache srtf es dw cookie dword m strstreamincache stream in n stream type es cautoricheditctrlfx cstring nstreamtype zeromemory _unicode nstreamtype sf_rtf pfncallback cbstreaminrtf pfncallback cbstreamin m_strstreamincache dwcookie m_strstreamincache streamin nstreamtype c string c auto rich edit ctrl fx getrtf editstream es zero memory es sizeof editstream es pfn callback cb stream out c string srtf es dw cookie dword srtf stream out sf rtf es return srtf cstring cautoricheditctrlfx zeromemory pfncallback cbstreamout cstring dwcookie streamout sf_rtf dword callback c auto rich edit ctrl fx cb stream in dword dw cookie lpbyte pb buff long cb long pcb c string pstr c string dw cookie assert pstr null if pstr null return 0 if pstr get length int sizeof tchar cb pcb pstr get length sizeof tchar memcpy pb buff lpctstr pstr pcb pstr empty else pcb cb memcpy pb buff lpctstr pstr pcb pstr pstr right pstr get length cb sizeof tchar return 0 cautoricheditctrlfx cbstreamin dwcookie pbbuff cstring cstring dwcookie getlength getlength pbbuff pbbuff getlength dword callback c auto rich edit ctrl fx cb stream out dword dw cookie lpbyte pb buff long cb long pcb unreferenced parameter pcb c string ps entry c string dw cookie assert ps entry null if ps entry null return 0 c string tmp entry lpctstr pb buff if cb 0 ps entry tmp entry left cb sizeof tchar return 0 cautoricheditctrlfx cbstreamout dwcookie pbbuff unreferenced_parameter cstring psentry cstring dwcookie psentry psentry cstring tmpentry pbbuff psentry tmpentry m rgbtext 0 m uinternalflags none m_rgbtext m_uinternalflags destroys the object virtual cams edit cams edit camsedit camsedit void cams edit set text const c string str text set window text str text camsedit settext cstring strtext setwindowtext strtext c string cams edit get text const c string str text get window text str text return str text cstring camsedit gettext cstring strtext getwindowtext strtext strtext c string cams edit get trimmed text const c string str text get text str text trim left str text trim right return str text cstring camsedit gettrimmedtext cstring strtext gettext strtext trimleft strtext trimright strtext void cams edit set background color colorref rgb m brushbackground delete object m brushbackground create solid brush rgb invalidate camsedit setbackgroundcolor m_brushbackground deleteobject m_brushbackground createsolidbrush colorref cams edit get background color const cams edit p this const cast cams edit this if m brushbackground get safe handle colorref rgb p this getdc get bk color p this m brushbackground create solid brush rgb return rgb logbrush lb p this m brushbackground get log brush lb return lb lb color camsedit getbackgroundcolor camsedit pthis const_cast camsedit m_brushbackground getsafehandle pthis getbkcolor pthis m_brushbackground createsolidbrush pthis m_brushbackground getlogbrush lbcolor void cams edit set text color colorref rgb m rgbtext rgb m uinternalflags text color has been set invalidate camsedit settextcolor m_rgbtext m_uinternalflags textcolorhasbeenset colorref cams edit get text color const if m uinternalflags text color has been set cams edit p this const cast cams edit this p this m rgbtext p this getdc get text color p this m uinternalflags text color has been set return m rgbtext camsedit gettextcolor m_uinternalflags textcolorhasbeenset camsedit pthis const_cast camsedit pthis m_rgbtext pthis gettextcolor pthis m_uinternalflags textcolorhasbeenset m_rgbtext bool cams edit is read only const return get style es readonly camsedit isreadonly getstyle es_readonly void cams edit redraw if is window m hwnd return c string str text get valid text if str text get text set window text str text camsedit iswindow m_hwnd cstring strtext getvalidtext strtext gettext setwindowtext strtext c string cams edit get valid text const return get text cstring camsedit getvalidtext gettext bool cams edit on child notify uint message wparam w param lparam l param lresult pl result if message wm ctlcoloredit message wm ctlcolorstatic m brushbackground get safe handle m uinternalflags text color has been set cdc pdc cdc from handle hdc w param if m rgbtext pdc set text color m rgbtext set the text background to the requested background color pdc set bk color get background color pl result lresult m brushbackground get safe handle return true return c edit on child notify message w param l param pl result camsedit onchildnotify wparam lparam plresult wm_ctlcoloredit wm_ctlcolorstatic m_brushbackground getsafehandle m_uinternalflags textcolorhasbeenset fromhandle wparam m_rgbtext settextcolor m_rgbtext setbkcolor getbackgroundcolor plresult m_brushbackground getsafehandle cedit onchildnotify wparam lparam plresult bool cams edit should enter tchar const return true camsedit shouldenter long cams edit on cut uint long int n start n end get sel n start n end if n start n end send message wm copy copy the selection and replace sel t delete it return 0 camsedit oncut nstart nend getsel nstart nend nstart nend sendmessage wm_copy replacesel _t long cams edit on paste uint long int n start n end get sel n start n end c edit default c string str text get valid text if str text get text set window text str text set sel n start n end return 0 camsedit onpaste nstart nend getsel nstart nend cedit cstring strtext getvalidtext strtext gettext setwindowtext strtext setsel nstart nend long cams edit on clear uint long int n start n end get sel n start n end if n start n end send message wm keydown vk delete delete the selection return 0 camsedit onclear nstart nend getsel nstart nend nstart nend sendmessage wm_keydown vk_delete long cams edit on set text uint long l param long n result c edit default c string str text get valid text if str text lpctstr l param set window text str text return n result camsedit onsettext lparam nresult cedit cstring strtext getvalidtext strtext lparam setwindowtext strtext nresult m pedit p edit assert p edit p edit get sel m nstart m nend m_pedit pedit pedit pedit getsel m_nstart m_nend m nend n end assert p edit assert n start n end m_nend nend pedit nstart nend cams edit selection saver selection saver if m pedit m pedit set sel m nstart m nend true camsedit selectionsaver selectionsaver m_pedit m_pedit setsel m_nstart m_nend void cams edit selection saver move to int n start int n end assert n start n end m nstart n start m nend n end camsedit selectionsaver moveto nstart nend nstart nend m_nstart nstart m_nend nend void cams edit selection saver move by int n start int n end m nstart n start m nend n end assert m nstart m nend camsedit selectionsaver moveby nstart nend m_nstart nstart m_nend nend m_nstart m_nend void cams edit selection saver move by int n pos m nstart n pos m nend n pos camsedit selectionsaver moveby npos m_nstart npos m_nend npos void cams edit selection saver operator int n pos move by n pos camsedit selectionsaver npos moveby npos int cams edit selection saver get start const return m nstart camsedit selectionsaver getstart m_nstart int cams edit selection saver get end const return m nend camsedit selectionsaver getend m_nend void cams edit selection saver update if m pedit m pedit get sel m nstart m nend camsedit selectionsaver m_pedit m_pedit getsel m_nstart m_nend void cams edit selection saver disable m pedit null camsedit selectionsaver m_pedit m uflags 0 assert m pedit m_uflags m_pedit destroys the object virtual cams edit behavior behavior camsedit bool cams edit behavior modify flags uint u add uint u remove uint u flags m uflags u remove u add if m uflags u flags return false m uflags u flags redraw return true camsedit modifyflags uadd uremove uflags m_uflags uremove uadd m_uflags uflags m_uflags uflags _redraw uint cams edit behavior get flags const return m uflags camsedit getflags m_uflags void cams edit behavior onchar uint u char uint n rep cnt uint n flags m pedit on char u char n rep cnt n flags camsedit _onchar uchar nrepcnt nflags m_pedit onchar uchar nrepcnt nflags void cams edit behavior onkeydown uint u char uint n rep cnt uint n flags m pedit on key down u char n rep cnt n flags camsedit _onkeydown uchar nrepcnt nflags m_pedit onkeydown uchar nrepcnt nflags void cams edit behavior onkillfocus c wnd p new wnd m pedit on kill focus p new wnd camsedit _onkillfocus cwnd pnewwnd m_pedit onkillfocus pnewwnd long cams edit behavior onpaste uint w param long l param return m pedit on paste w param l param camsedit _onpaste wparam lparam m_pedit onpaste wparam lparam lresult cams edit behavior default return m pedit default camsedit _default m_pedit void cams edit behavior redraw m pedit redraw camsedit _redraw m_pedit bool cams edit behavior shouldenter tchar c const return m pedit should enter c camsedit _shouldenter m_pedit shouldenter m csep get the system s date separator if get locale info locale user default locale sdate null 0 get locale info locale user default locale sdate m csep sizeof m csep determine if the day should go before the month tchar sz short date max path if get locale info locale user default locale sshortdate null 0 get locale info locale user default locale sshortdate sz short date sizeof sz short date sizeof tchar for int i pos 0 sz short date i pos i pos tchar c static cast tchar totupper sz short date i pos if c m see if the month is first break if c d see if the day is first and then set the flag m uflags day before month break m_csep getlocaleinfo locale_user_default locale_sdate getlocaleinfo locale_user_default locale_sdate m_csep m_csep szshortdate max_path getlocaleinfo locale_user_default locale_sshortdate getlocaleinfo locale_user_default locale_sshortdate szshortdate szshortdate ipos szshortdate ipos ipos static_cast _totupper szshortdate ipos m_uflags daybeforemonth void cams edit date behavior set date int n year int n month int n day assert is within range c ole date time n year n month n day 0 0 0 m pedit set window text get formatted date n year n month n day camsedit datebehavior setdate nyear nmonth nday iswithinrange coledatetime nyear nmonth nday m_pedit setwindowtext getformatteddate nyear nmonth nday void cams edit date behavior set date const c time date set date date get year date get month date get day camsedit datebehavior setdate ctime setdate getyear getmonth getday void cams edit date behavior set date const c ole date time date set date date get year date get month date get day camsedit datebehavior setdate coledatetime setdate getyear getmonth getday void cams edit date behavior set date to today set date c ole date time get current time camsedit datebehavior setdatetotoday setdate coledatetime getcurrenttime c time cams edit date behavior get date const return c time get year get month get day 0 0 0 ctime camsedit datebehavior getdate ctime getyear getmonth getday c ole date time cams edit date behavior get ole date const return c ole date time get year get month get day 0 0 0 coledatetime camsedit datebehavior getoledate coledatetime getyear getmonth getday int cams edit date behavior get year const c string str text m pedit get text int n slash str text reverse find m csep if n slash 0 return ttoi str text mid n slash 1 4 return 0 camsedit datebehavior getyear cstring strtext m_pedit gettext nslash strtext reversefind m_csep nslash _ttoi strtext nslash int cams edit date behavior get month const c string str text m pedit get text int n start pos get month start position if str text get length n start pos 2 return ttoi str text mid n start pos 2 return 0 camsedit datebehavior getmonth cstring strtext m_pedit gettext nstartpos getmonthstartposition strtext getlength nstartpos _ttoi strtext nstartpos int cams edit date behavior get day const c string str text m pedit get text int n start pos get day start position if str text get length n start pos 2 return ttoi str text mid n start pos 2 return 0 camsedit datebehavior getday cstring strtext m_pedit gettext nstartpos getdaystartposition strtext getlength nstartpos _ttoi strtext nstartpos void cams edit date behavior set year int n year assert is valid year n year selection saver selection m pedit remember the current selection if get year 0 see if there s already a year m pedit set sel get year start position get year start position 4 c string str text str text format t 4d n year m pedit replace sel str text true set the year adjust max month and day adjust the month and or day if they re out of range camsedit datebehavior setyear nyear isvalidyear nyear selectionsaver m_pedit getyear m_pedit setsel getyearstartposition getyearstartposition cstring strtext strtext _t nyear m_pedit replacesel strtext adjustmaxmonthandday void cams edit date behavior set month int n month selection saver selection m pedit remember the current selection if get month 0 see if there s already a month m pedit set sel get month start position get month start position 3 c string str text str text format t 02d c n month m csep m pedit replace sel str text true set the month adjust max day adjust the day if it s out of range assert is valid month n month camsedit datebehavior setmonth nmonth selectionsaver m_pedit getmonth m_pedit setsel getmonthstartposition getmonthstartposition cstring strtext strtext _t nmonth m_csep m_pedit replacesel strtext adjustmaxday isvalidmonth nmonth void cams edit date behavior set day int n day assert is valid day n day selection saver selection m pedit remember the current selection if get day 0 see if there s already a day m pedit set sel get day start position get day start position 3 c string str text str text format t 02d c n day m csep m pedit replace sel str text true set the day camsedit datebehavior setday nday isvalidday nday selectionsaver m_pedit getday m_pedit setsel getdaystartposition getdaystartposition cstring strtext strtext _t nday m_csep m_pedit replacesel strtext bool cams edit date behavior is valid const return is within range c ole date time get year get month get day 0 0 0 camsedit datebehavior isvalid iswithinrange coledatetime getyear getmonth getday bool cams edit date behavior check if valid bool b show error if not valid true if m pedit is window enabled return true bool b valid is valid if b valid b show error if not valid show error message m pedit set focus return b valid camsedit datebehavior checkifvalid bshowerrorifnotvalid m_pedit iswindowenabled bvalid isvalid bvalid bshowerrorifnotvalid showerrormessage m_pedit setfocus bvalid void cams edit date behavior set range const c time date min const c time date max assert date min ams min ctime assert date max ams max ctime assert date min date max m datemin set date date min get year date min get month date min get day m datemax set date date max get year date max get month date max get day redraw camsedit datebehavior setrange ctime datemin ctime datemax datemin ams_min_ctime datemax ams_max_ctime datemin datemax m_datemin setdate datemin getyear datemin getmonth datemin getday m_datemax setdate datemax getyear datemax getmonth datemax getday _redraw void cams edit date behavior set range const c ole date time date min const c ole date time date max assert date min ams min oledatetime assert date max ams max oledatetime assert date min date max m datemin date min m datemax date max redraw camsedit datebehavior setrange coledatetime datemin coledatetime datemax datemin ams_min_oledatetime datemax ams_max_oledatetime datemin datemax m_datemin datemin m_datemax datemax _redraw void cams edit date behavior get range c time p date min c time p date max const if p date min p date min c time m datemin get year m datemin get month m datemin get day 0 0 0 if p date max p date max c time m datemax get year m datemax get month m datemax get day 0 0 0 camsedit datebehavior getrange ctime pdatemin ctime pdatemax pdatemin pdatemin ctime m_datemin getyear m_datemin getmonth m_datemin getday pdatemax pdatemax ctime m_datemax getyear m_datemax getmonth m_datemax getday void cams edit date behavior get range c ole date time p date min c ole date time p date max const if p date min p date min m datemin if p date max p date max m datemax camsedit datebehavior getrange coledatetime pdatemin coledatetime pdatemax pdatemin pdatemin m_datemin pdatemax pdatemax m_datemax void cams edit date behavior set separator tchar c sep assert c sep assert istdigit c sep if m csep c sep m csep c sep redraw camsedit datebehavior setseparator csep csep _istdigit csep m_csep csep m_csep csep _redraw tchar cams edit date behavior get separator const return m csep camsedit datebehavior getseparator m_csep void cams edit date behavior show day before month bool b day before month true modify flags b day before month day before month 0 b day before month 0 day before month camsedit datebehavior showdaybeforemonth bdaybeforemonth modifyflags bdaybeforemonth daybeforemonth bdaybeforemonth daybeforemonth bool cams edit date behavior is day shown before month const return m uflags day before month true false camsedit datebehavior isdayshownbeforemonth m_uflags daybeforemonth c string cams edit date behavior getvalidtext const c string str text m pedit get text if str text is empty return str text if is valid return get formatted date get year get month get day if the date is empty try using today if get year 0 get month 0 get day 0 cams edit date behavior this set date to today int n year get valid year int n month get valid month int n day get valid day if is within range c ole date time n year n month n day 0 0 0 n month get min month if is within range c ole date time n year n month n day 0 0 0 n day get max day return get formatted date n year n month n day cstring camsedit datebehavior _getvalidtext cstring strtext m_pedit gettext strtext isempty strtext isvalid getformatteddate getyear getmonth getday getyear getmonth getday camsedit datebehavior setdatetotoday nyear getvalidyear nmonth getvalidmonth nday getvalidday iswithinrange coledatetime nyear nmonth nday nmonth getminmonth iswithinrange coledatetime nyear nmonth nday nday getmaxday getformatteddate nyear nmonth nday void cams edit date behavior onchar uint u char uint n rep cnt uint n flags check to see if it s read only if m pedit is read only return tchar c static cast tchar u char int n start n end m pedit get sel n start n end c string str text m pedit get text int n len str text get length check for a non printable character such as ctrl c if istprint c if c vk back n start n len m pedit send message wm keydown vk left move the cursor left return allow backspace only if the cursor is all the way to the right if shouldenter c behavior onchar u char n rep cnt n flags return add the digit depending on its location switch n start case 0 first digit if m uflags day before month if is valid day digit c 0 shouldenter c if n len n start m pedit set sel n start n start 1 m pedit replace sel c string c true if n len n start 1 if is valid day get day m pedit set sel n start 1 n start 2 m pedit replace sel c string get min day digit 1 true m pedit set sel n start 1 n start 2 else behavior onchar u char n rep cnt n flags check if we can insert the digit with a leading zero else if n len n start get min day digit 0 0 is valid day digit c 1 shouldenter c m pedit set sel n start n start 2 m pedit replace sel c string 0 c true else if is valid month digit c 0 shouldenter c if n len n start m pedit set sel n start n start 1 m pedit replace sel c string c true if n len n start 1 if is valid month get month m pedit set sel n start 1 n start 2 m pedit replace sel c string get min month digit 1 true m pedit set sel n start 1 n start 2 adjust max day else behavior onchar u char n rep cnt n flags check if we can insert the digit with a leading zero else if n len n start get min month digit 0 0 is valid month digit c 1 shouldenter c m pedit set sel n start n start 2 m pedit replace sel c string 0 c true break case 1 second digit if m uflags day before month if is valid day digit c 1 shouldenter c if n len n start m pedit set sel n start n start 1 m pedit replace sel c string c true else behavior onchar u char n rep cnt n flags check if it s a slash and the first digit preceded by a zero is a valid month else if c m csep n len n start get min day digit 0 0 is valid day ttoi c string 0 str text 0 shouldenter c m pedit set sel 0 n start m pedit replace sel c string 0 str text 0 c true else if is valid month digit c 1 shouldenter c if n len n start m pedit set sel n start n start 1 m pedit replace sel c string c true if get day 0 adjust max day m pedit set sel get day start position get day start position 2 else behavior onchar u char n rep cnt n flags check if it s a slash and the first digit preceded by a zero is a valid month else if c m csep n len n start get min month digit 0 0 is valid month ttoi c string 0 str text 0 shouldenter c m pedit set sel 0 n start m pedit replace sel c string 0 str text 0 c true break case 2 first slash int n slash 0 if c m csep n slash 1 else if m uflags day before month n slash is valid month digit c 0 n len n start get min month digit 0 0 is valid month digit c 1 2 0 else n slash is valid day digit c 0 n len n start get min day digit 0 0 is valid day digit c 1 2 0 if we need the slash enter it if n slash shouldenter c m pedit set sel n start n start 1 false m pedit replace sel c string m csep true if the slash is to be preceded by a valid digit type it in if n slash 2 keybd event byte c 0 0 0 break case 3 third digit if m uflags day before month if is valid month digit c 0 shouldenter c if n len n start m pedit set sel n start n start 1 m pedit replace sel c string c true if n len n start 1 if is valid month get month m pedit set sel n start 1 n start 2 m pedit replace sel c string get min month digit 1 true m pedit set sel n start 1 n start 2 else behavior onchar u char n rep cnt n flags adjust max day check if we can insert the digit with a leading zero else if n len n start get min month digit 0 0 is valid month digit c 1 shouldenter c m pedit set sel n start n start 2 m pedit replace sel c string 0 c true adjust max day else if is valid day digit c 0 shouldenter c if n len n start m pedit set sel n start n start 1 m pedit replace sel c string c true if n len n start 1 if is valid day get day m pedit set sel n start 1 n start 2 m pedit replace sel c string get min day digit 1 true m pedit set sel n start 1 n start 2 else behavior onchar u char n rep cnt n flags check if we can insert the digit with a leading zero else if n len n start get min day digit 0 0 is valid day digit c 1 shouldenter c m pedit set sel n start n start 2 m pedit replace sel c string 0 c true break case 4 fourth digit if m uflags day before month if is valid month digit c 1 shouldenter c if n len n start m pedit set sel n start n start 1 m pedit replace sel c string c true if get day 0 adjust max day m pedit set sel get day start position get day start position 2 else behavior onchar u char n rep cnt n flags adjust max day check if it s a slash and the first digit preceded by a zero is a valid month else if c m csep n len n start get min month digit 0 0 is valid month ttoi c string 0 str text 3 shouldenter c m pedit set sel 3 n start m pedit replace sel c string 0 str text 3 c true else if is valid day digit c 1 shouldenter c if n len n start m pedit set sel n start n start 1 m pedit replace sel c string c true else behavior onchar u char n rep cnt n flags check if it s a slash and the first digit preceded by a zero is a valid month else if c m csep n len n start get min day digit 0 0 is valid day ttoi c string 0 str text 3 shouldenter c m pedit set sel 3 n start m pedit replace sel c string 0 str text 3 c true break case 5 second slash year s first digit int n slash 0 if c m csep n slash 1 else n slash is valid year digit c 0 2 0 if we need the slash enter it if n slash shouldenter c m pedit set sel n start n start 1 false m pedit replace sel c string m csep true if the slash is to be preceded by a valid digit type it in if n slash 2 keybd event byte c 0 0 0 break case 6 year all 4 digits case 7 case 8 case 9 if is valid year digit c n start get year start position shouldenter c if n len n start m pedit set sel n start n start 1 false m pedit replace sel c string c true for n start 1 n len n start 9 n start if is valid year digit str text n start 1 n start get year start position 1 m pedit set sel n start 1 10 false c string str portion for int i pos n start 1 i pos n len i pos 10 i pos str portion get min year digit i pos get year start position false m pedit replace sel str portion true m pedit set sel n start 1 10 false break else behavior onchar u char n rep cnt n flags if is valid year get year adjust max day adjust the day first adjust max month and day then adjust the month and the day if necessary break camsedit datebehavior _onchar uchar nrepcnt nflags m_pedit isreadonly static_cast uchar nstart nend m_pedit getsel nstart nend cstring strtext m_pedit gettext nlen strtext getlength _istprint vk_back nstart nlen m_pedit sendmessage wm_keydown vk_left _shouldenter _onchar uchar nrepcnt nflags nstart m_uflags daybeforemonth isvaliddaydigit _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring nlen nstart isvalidday getday m_pedit setsel nstart nstart m_pedit replacesel cstring getmindaydigit m_pedit setsel nstart nstart _onchar uchar nrepcnt nflags nlen nstart getmindaydigit isvaliddaydigit _shouldenter m_pedit setsel nstart nstart m_pedit replacesel cstring isvalidmonthdigit _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring nlen nstart isvalidmonth getmonth m_pedit setsel nstart nstart m_pedit replacesel cstring getminmonthdigit m_pedit setsel nstart nstart adjustmaxday _onchar uchar nrepcnt nflags nlen nstart getminmonthdigit isvalidmonthdigit _shouldenter m_pedit setsel nstart nstart m_pedit replacesel cstring m_uflags daybeforemonth isvaliddaydigit _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring _onchar uchar nrepcnt nflags m_csep nlen nstart getmindaydigit isvalidday _ttoi cstring strtext _shouldenter m_pedit setsel nstart m_pedit replacesel cstring strtext isvalidmonthdigit _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring getday adjustmaxday m_pedit setsel getdaystartposition getdaystartposition _onchar uchar nrepcnt nflags m_csep nlen nstart getminmonthdigit isvalidmonth _ttoi cstring strtext _shouldenter m_pedit setsel nstart m_pedit replacesel cstring strtext nslash m_csep nslash m_uflags daybeforemonth nslash isvalidmonthdigit nlen nstart getminmonthdigit isvalidmonthdigit nslash isvaliddaydigit nlen nstart getmindaydigit isvaliddaydigit nslash _shouldenter m_pedit setsel nstart nstart m_pedit replacesel cstring m_csep nslash keybd_event m_uflags daybeforemonth isvalidmonthdigit _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring nlen nstart isvalidmonth getmonth m_pedit setsel nstart nstart m_pedit replacesel cstring getminmonthdigit m_pedit setsel nstart nstart _onchar uchar nrepcnt nflags adjustmaxday nlen nstart getminmonthdigit isvalidmonthdigit _shouldenter m_pedit setsel nstart nstart m_pedit replacesel cstring adjustmaxday isvaliddaydigit _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring nlen nstart isvalidday getday m_pedit setsel nstart nstart m_pedit replacesel cstring getmindaydigit m_pedit setsel nstart nstart _onchar uchar nrepcnt nflags nlen nstart getmindaydigit isvaliddaydigit _shouldenter m_pedit setsel nstart nstart m_pedit replacesel cstring m_uflags daybeforemonth isvalidmonthdigit _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring getday adjustmaxday m_pedit setsel getdaystartposition getdaystartposition _onchar uchar nrepcnt nflags adjustmaxday m_csep nlen nstart getminmonthdigit isvalidmonth _ttoi cstring strtext _shouldenter m_pedit setsel nstart m_pedit replacesel cstring strtext isvaliddaydigit _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring _onchar uchar nrepcnt nflags m_csep nlen nstart getmindaydigit isvalidday _ttoi cstring strtext _shouldenter m_pedit setsel nstart m_pedit replacesel cstring strtext nslash m_csep nslash nslash isvalidyeardigit nslash _shouldenter m_pedit setsel nstart nstart m_pedit replacesel cstring m_csep nslash keybd_event isvalidyeardigit nstart getyearstartposition _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring nstart nlen nstart nstart isvalidyeardigit strtext nstart nstart getyearstartposition m_pedit setsel nstart cstring strportion ipos nstart ipos nlen ipos ipos strportion getminyeardigit ipos getyearstartposition m_pedit replacesel strportion m_pedit setsel nstart _onchar uchar nrepcnt nflags isvalidyear getyear adjustmaxday adjustmaxmonthandday void cams edit date behavior onkeydown uint u char uint n rep cnt uint n flags check to see if it s read only if m pedit is read only return switch u char case vk delete if deleting make sure it s the last character or that the selection goes all the way to the end of the text int n start n end m pedit get sel n start n end c string str text m pedit get text int n len str text get length if n end n len if n end n start n end n len 1 return break case vk up if pressing the up arrow increment the corresponding value int n start n end m pedit get sel n start n end if n start get year start position n start get year start position 4 int n year get year if n year m datemin get year n year m datemax get year set year n year else if n start get month start position n start get month start position 2 int n month get month if n month get min month n month get max month set month n month else if n start get day start position n start get day start position 2 int n day get day if n day get min day n day get max day set day n day return case vk down if pressing the down arrow decrement the corresponding value int n start n end m pedit get sel n start n end if n start get year start position n start get year start position 4 int n year get year if n year m datemin get year set year n year else if n start get month start position n start get month start position 2 int n month get month if n month get min month set month n month else if n start get day start position n start get day start position 2 int n day get day if n day get min day set day n day return behavior onkeydown u char n rep cnt n flags camsedit datebehavior _onkeydown uchar nrepcnt nflags m_pedit isreadonly uchar vk_delete nstart nend m_pedit getsel nstart nend cstring strtext m_pedit gettext nlen strtext getlength nend nlen nend nstart nend nlen vk_up nstart nend m_pedit getsel nstart nend nstart getyearstartposition nstart getyearstartposition nyear getyear nyear m_datemin getyear nyear m_datemax getyear setyear nyear nstart getmonthstartposition nstart getmonthstartposition nmonth getmonth nmonth getminmonth nmonth getmaxmonth setmonth nmonth nstart getdaystartposition nstart getdaystartposition nday getday nday getminday nday getmaxday setday nday vk_down nstart nend m_pedit getsel nstart nend nstart getyearstartposition nstart getyearstartposition nyear getyear nyear m_datemin getyear setyear nyear nstart getmonthstartposition nstart getmonthstartposition nmonth getmonth nmonth getminmonth setmonth nmonth nstart getdaystartposition nstart getdaystartposition nday getday nday getminday setday nday _onkeydown uchar nrepcnt nflags void cams edit date behavior onkillfocus c wnd p new wnd behavior onkillfocus p new wnd check if any of the on kill focus flags is set if m uflags onkillfocus max return c string str text m pedit get text if it s empty take action based on the flag if str text is empty if m uflags onkillfocus beep ifempty message beep mb iconexclamation if m uflags onkillfocus setvalid ifempty m pedit set window text t if m uflags onkillfocus showmessage ifempty onkillfocus showmessage ifempty show error message if m uflags onkillfocus setfocus ifempty m pedit set focus return if is valid if m uflags onkillfocus beep ifinvalid message beep mb iconexclamation if m uflags onkillfocus setvalid ifinvalid redraw if m uflags onkillfocus showmessage ifinvalid onkillfocus showmessage ifinvalid show error message if m uflags onkillfocus setfocus ifinvalid m pedit set focus camsedit datebehavior _onkillfocus cwnd pnewwnd _onkillfocus pnewwnd onkillfocus m_uflags onkillfocus_max cstring strtext m_pedit gettext strtext isempty m_uflags onkillfocus_beep_ifempty messagebeep mb_iconexclamation m_uflags onkillfocus_setvalid_ifempty m_pedit setwindowtext _t m_uflags onkillfocus_showmessage_ifempty onkillfocus_showmessage_ifempty showerrormessage m_uflags onkillfocus_setfocus_ifempty m_pedit setfocus isvalid m_uflags onkillfocus_beep_ifinvalid messagebeep mb_iconexclamation m_uflags onkillfocus_setvalid_ifinvalid _redraw m_uflags onkillfocus_showmessage_ifinvalid onkillfocus_showmessage_ifinvalid showerrormessage m_uflags onkillfocus_setfocus_ifinvalid m_pedit setfocus bool cams edit date behavior adjust max month and day int n month get month if n month is valid month n month set month get min month this adjusts the day automatically return true return adjust max day camsedit datebehavior adjustmaxmonthandday nmonth getmonth nmonth isvalidmonth nmonth setmonth getminmonth adjustmaxday bool cams edit date behavior adjust max day int n day get day if n day is valid day n day set day get max day return true return false nothing had to be adjusted camsedit datebehavior adjustmaxday nday getday nday isvalidday nday setday getmaxday int cams edit date behavior get valid month const int n month get month it it s outside the range fix it if n month get min month n month get min month else if n month get max month n month get max month return n month camsedit datebehavior getvalidmonth nmonth getmonth nmonth getminmonth nmonth getminmonth nmonth getmaxmonth nmonth getmaxmonth nmonth int cams edit date behavior get max month const if get valid year m datemax get year return m datemax get month return 12 camsedit datebehavior getmaxmonth getvalidyear m_datemax getyear m_datemax getmonth int cams edit date behavior get min month const if get valid year m datemin get year return m datemin get month return 1 camsedit datebehavior getminmonth getvalidyear m_datemin getyear m_datemin getmonth int cams edit date behavior get month start position const return m uflags day before month 3 0 camsedit datebehavior getmonthstartposition m_uflags daybeforemonth tchar cams edit date behavior get max month digit int n pos const assert n pos 0 n pos 1 int n year get valid year int n max month m datemax get month int n max year m datemax get year first digit if n pos 0 if the year is at the max then use the first digit of the max month if n year n max year return get string n max month 0 otherwise it s always 1 return 1 second digit c string str text m pedit get text tchar c first digit str text get length get month start position str text get month start position 0 assert c first digit must have a valid first digit at this point if the year is at the max then check if the first digits match if n year n max year is valid year get year n max year m datemin get year if the first digits match then use the second digit of the max month if get string n max month 0 c first digit return get string n max month 1 assuming the logic for the first digit is correct then it must be 0 assert c first digit 0 return 9 use the first digit to determine the second digit s max return c first digit 1 2 9 camsedit datebehavior getmaxmonthdigit npos npos npos nyear getvalidyear nmaxmonth m_datemax getmonth nmaxyear m_datemax getyear npos nyear nmaxyear getstring nmaxmonth cstring strtext m_pedit gettext cfirstdigit strtext getlength getmonthstartposition strtext getmonthstartposition cfirstdigit nyear nmaxyear isvalidyear getyear nmaxyear m_datemin getyear getstring nmaxmonth cfirstdigit getstring nmaxmonth cfirstdigit cfirstdigit tchar cams edit date behavior get min month digit int n pos const assert n pos 0 n pos 1 int n year get valid year int n min month m datemin get month int n min year m datemin get year first digit if n pos 0 if the year is at the min then use the first digit of the min month if n year n min year return get string n min month 0 otherwise it s always 0 return 0 second digit c string str text m pedit get text tchar c first digit str text get length get month start position str text get month start position 0 if c first digit return 1 if the year is at the max then check if the first digits match if n year n min year is valid year get year n min year m datemax get year if the first digits match then use the second digit of the max month if get string n min month 0 c first digit return get string n min month 1 return 0 use the first digit to determine the second digit s min return c first digit 1 0 1 camsedit datebehavior getminmonthdigit npos npos npos nyear getvalidyear nminmonth m_datemin getmonth nminyear m_datemin getyear npos nyear nminyear getstring nminmonth cstring strtext m_pedit gettext cfirstdigit strtext getlength getmonthstartposition strtext getmonthstartposition cfirstdigit nyear nminyear isvalidyear getyear nminyear m_datemax getyear getstring nminmonth cfirstdigit getstring nminmonth cfirstdigit bool cams edit date behavior is valid month digit tchar c int n pos const return c get min month digit n pos c get max month digit n pos camsedit datebehavior isvalidmonthdigit npos getminmonthdigit npos getmaxmonthdigit npos bool cams edit date behavior is valid month int n month const int n year get valid year int n day get valid day return is within range c ole date time n year n month n day 0 0 0 camsedit datebehavior isvalidmonth nmonth nyear getvalidyear nday getvalidday iswithinrange coledatetime nyear nmonth nday int cams edit date behavior get valid day const int n day get day it it s outside the range fix it if n day get min day n day get min day else if n day get max day n day get max day return n day camsedit datebehavior getvalidday nday getday nday getminday nday getminday nday getmaxday nday getmaxday nday int cams edit date behavior get max day const int n year get valid year int n month get valid month if n year m datemax get year n month m datemax get month return m datemax get day return get max day of month n month n year camsedit datebehavior getmaxday nyear getvalidyear nmonth getvalidmonth nyear m_datemax getyear nmonth m_datemax getmonth m_datemax getday getmaxdayofmonth nmonth nyear int cams edit date behavior get min day const int n year get valid year int n month get valid month if n year m datemin get year n month m datemin get month return m datemin get day return 1 camsedit datebehavior getminday nyear getvalidyear nmonth getvalidmonth nyear m_datemin getyear nmonth m_datemin getmonth m_datemin getday int cams edit date behavior get day start position const return m uflags day before month 0 3 camsedit datebehavior getdaystartposition m_uflags daybeforemonth tchar cams edit date behavior get max day digit int n pos const assert n pos 0 n pos 1 int n month get valid month int n year get valid year int n max day m datemax get day int n max month m datemax get month int n max year m datemax get year first digit if n pos 0 if the year and month are at the max then use the first digit of the max day if n year n max year n month n max month return get string n max day 0 return get string get max day of month n month n year 0 second digit c string str text m pedit get text tchar c first digit str text get length get day start position str text get day start position 0 assert c first digit must have a valid first digit at this point if the year and month are at the max then use the second digit of the max day if n year n max year n month n max month get string n max day 0 c first digit return get string n max day 1 if c first digit 0 c first digit 1 c first digit 2 n month 2 n month 2 is valid year get year return 9 return get string get max day of month n month n year 1 camsedit datebehavior getmaxdaydigit npos npos npos nmonth getvalidmonth nyear getvalidyear nmaxday m_datemax getday nmaxmonth m_datemax getmonth nmaxyear m_datemax getyear npos nyear nmaxyear nmonth nmaxmonth getstring nmaxday getstring getmaxdayofmonth nmonth nyear cstring strtext m_pedit gettext cfirstdigit strtext getlength getdaystartposition strtext getdaystartposition cfirstdigit nyear nmaxyear nmonth nmaxmonth getstring nmaxday cfirstdigit getstring nmaxday cfirstdigit cfirstdigit cfirstdigit nmonth nmonth isvalidyear getyear getstring getmaxdayofmonth nmonth nyear tchar cams edit date behavior get min day digit int n pos const assert n pos 0 n pos 1 int n month get valid month int n year get valid year int n min day m datemin get day int n min month m datemin get month int n min year m datemin get year first digit if n pos 0 if the year and month are at the min then use the first digit of the min day if n year n min year n month n min month return get string n min day 0 return 0 second digit c string str text m pedit get text tchar c first digit str text get length get day start position str text get day start position 0 if c first digit must have a valid first digit at this point return 1 if the year and month are at the max then use the first second of the max day if n year n min year n month n min month get string n min day 0 c first digit return get string n min day 1 use the first digit to determine the second digit s min return c first digit 0 1 0 camsedit datebehavior getmindaydigit npos npos npos nmonth getvalidmonth nyear getvalidyear nminday m_datemin getday nminmonth m_datemin getmonth nminyear m_datemin getyear npos nyear nminyear nmonth nminmonth getstring nminday cstring strtext m_pedit gettext cfirstdigit strtext getlength getdaystartposition strtext getdaystartposition cfirstdigit nyear nminyear nmonth nminmonth getstring nminday cfirstdigit getstring nminday cfirstdigit bool cams edit date behavior is valid day digit tchar c int n pos const return c get min day digit n pos c get max day digit n pos camsedit datebehavior isvaliddaydigit npos getmindaydigit npos getmaxdaydigit npos bool cams edit date behavior is valid day int n day const return is within range c ole date time get valid year get valid month n day 0 0 0 camsedit datebehavior isvalidday nday iswithinrange coledatetime getvalidyear getvalidmonth nday int cams edit date behavior get valid year const int n year get year if n year m datemin get year n year c ole date time get current time get year if n year m datemin get year n year m datemin get year if n year m datemax get year n year m datemax get year return n year camsedit datebehavior getvalidyear nyear getyear nyear m_datemin getyear nyear coledatetime getcurrenttime getyear nyear m_datemin getyear nyear m_datemin getyear nyear m_datemax getyear nyear m_datemax getyear nyear int cams edit date behavior get year start position const return 6 camsedit datebehavior getyearstartposition tchar cams edit date behavior get max year digit int n pos const assert n pos 0 n pos 3 c string str year get string get year false c string str max year get string m datemax get year false if n pos 0 ttoi str max year left n pos ttoi str year left n pos return str max year n pos return 9 camsedit datebehavior getmaxyeardigit npos npos npos cstring stryear getstring getyear cstring strmaxyear getstring m_datemax getyear npos _ttoi strmaxyear npos _ttoi stryear npos strmaxyear npos tchar cams edit date behavior get min year digit int n pos bool b valid year false const assert n pos 0 n pos 3 int n year get year if is valid year n year b valid year n year get valid year c string str year get string n year false c string str min year get string m datemin get year false if n pos 0 ttoi str min year left n pos ttoi str year left n pos return str min year n pos return 0 camsedit datebehavior getminyeardigit npos bvalidyear npos npos nyear getyear isvalidyear nyear bvalidyear nyear getvalidyear cstring stryear getstring nyear cstring strminyear getstring m_datemin getyear npos _ttoi strminyear npos _ttoi stryear npos strminyear npos bool cams edit date behavior is valid year digit tchar c int n pos const return c get min year digit n pos c get max year digit n pos camsedit datebehavior isvalidyeardigit npos getminyeardigit npos getmaxyeardigit npos bool cams edit date behavior is valid year int n year const return n year m datemin get year n year m datemax get year camsedit datebehavior isvalidyear nyear nyear m_datemin getyear nyear m_datemax getyear bool cams edit date behavior is within range const c ole date time date bool true const return date get status c ole date time valid date m datemin date m datemax camsedit datebehavior iswithinrange coledatetime getstatus coledatetime m_datemin m_datemax void cams edit date behavior show error message const afx message box t please specify a date between get formatted date m datemin get year m datemin get month m datemin get day t and get formatted date m datemax get year m datemax get month m datemax get day mb iconexclamation camsedit datebehavior showerrormessage afxmessagebox _t getformatteddate m_datemin getyear m_datemin getmonth m_datemin getday _t getformatteddate m_datemax getyear m_datemax getmonth m_datemax getday mb_iconexclamation c string cams edit date behavior get formatted date int n year int n month int n day const c string str text if m uflags day before month str text format t 02d c 02d c 4d n day m csep n month m csep n year else str text format t 02d c 02d c 4d n month m csep n day m csep n year return str text cstring camsedit datebehavior getformatteddate nyear nmonth nday cstring strtext m_uflags daybeforemonth strtext _t nday m_csep nmonth m_csep nyear strtext _t nmonth m_csep nday m_csep nyear strtext bool cams edit date behavior is leap year int n year return n year 3 0 n year 100 0 n year 400 0 camsedit datebehavior isleapyear nyear nyear nyear nyear c string cams edit date behavior get string int n value bool b two digit with leading zero true c string str value if b two digit with leading zero str value format t 02d n value else str value format t d n value return str value cstring camsedit datebehavior getstring nvalue btwodigitwithleadingzero cstring strvalue btwodigitwithleadingzero strvalue _t nvalue strvalue _t nvalue strvalue int cams edit date behavior get max day of month int n month int n year assert n month 1 n month 12 switch n month case 4 case 6 case 9 case 11 return 30 case 2 return is leap year n year 29 28 return 31 camsedit datebehavior getmaxdayofmonth nmonth nyear nmonth nmonth nmonth isleapyear nyear m nhourstart 0 get the system s time separator if get locale info locale user default locale stime null 0 get locale info locale user default locale stime m csep sizeof m csep determine if it s in 24 hour format tchar sz buffer 3 if get locale info locale user default locale itime null 0 get locale info locale user default locale itime sz buffer sizeof sz buffer sizeof tchar if ttoi sz buffer m uflags twenty four hour format get the am symbol if get locale info locale user default locale s1159 null 0 get locale info locale user default locale s1159 sz buffer sizeof sz buffer sizeof tchar m stram sz buffer get the pm symbol if get locale info locale user default locale s2359 null 0 get locale info locale user default locale s2359 sz buffer sizeof sz buffer sizeof tchar m strpm sz buffer m nampmlength m stram get length verify the lengths are the same otherwise use the default if m nampmlength 0 m nampmlength m strpm get length m stram ams am symbol m strpm ams pm symbol m nampmlength m stram get length m_nhourstart getlocaleinfo locale_user_default locale_stime getlocaleinfo locale_user_default locale_stime m_csep m_csep szbuffer getlocaleinfo locale_user_default locale_itime getlocaleinfo locale_user_default locale_itime szbuffer szbuffer _ttoi szbuffer m_uflags twentyfourhourformat getlocaleinfo locale_user_default locale_s1159 getlocaleinfo locale_user_default locale_s1159 szbuffer szbuffer m_stram szbuffer getlocaleinfo locale_user_default locale_s2359 getlocaleinfo locale_user_default locale_s2359 szbuffer szbuffer m_strpm szbuffer m_nampmlength m_stram getlength m_nampmlength m_nampmlength m_strpm getlength m_stram ams_am_symbol m_strpm ams_pm_symbol m_nampmlength m_stram getlength void cams edit time behavior set time int n hour int n minute int n second 0 assert is valid hour n hour true assert is valid minute n minute assert is valid second n second m pedit set window text get formatted time n hour n minute n second camsedit timebehavior settime nhour nminute nsecond isvalidhour nhour isvalidminute nminute isvalidsecond nsecond m_pedit setwindowtext getformattedtime nhour nminute nsecond void cams edit time behavior set time const c time time set time time get hour time get minute time get second camsedit timebehavior settime ctime settime gethour getminute getsecond void cams edit time behavior set time const c ole date time time set time time get hour time get minute time get second camsedit timebehavior settime coledatetime settime gethour getminute getsecond void cams edit time behavior set time to now set time c time get current time camsedit timebehavior settimetonow settime ctime getcurrenttime c time cams edit time behavior get time const if is showing24 hour format return c time 1970 1 1 get hour get minute get valid second return c time 1970 1 1 convert to24 hour get hour getampm get minute get valid second ctime camsedit timebehavior gettime isshowing24hourformat ctime gethour getminute getvalidsecond ctime convertto24hour gethour getminute getvalidsecond c ole date time cams edit time behavior get ole time const if is showing24 hour format return c ole date time ams default date get hour get minute get valid second return c ole date time ams default date convert to24 hour get hour getampm get minute get valid second coledatetime camsedit timebehavior getoletime isshowing24hourformat coledatetime ams_default_date gethour getminute getvalidsecond coledatetime ams_default_date convertto24hour gethour getminute getvalidsecond int cams edit time behavior get hour const c string str text m pedit get text int n start pos get hour start position if str text get length n start pos 2 return ttoi str text mid n start pos 2 return 1 camsedit timebehavior gethour cstring strtext m_pedit gettext nstartpos gethourstartposition strtext getlength nstartpos _ttoi strtext nstartpos int cams edit time behavior get minute const c string str text m pedit get text int n start pos get minute start position if str text get length n start pos 2 return ttoi str text mid n start pos 2 return 1 camsedit timebehavior getminute cstring strtext m_pedit gettext nstartpos getminutestartposition strtext getlength nstartpos _ttoi strtext nstartpos int cams edit time behavior get second const c string str text m pedit get text int n start pos get second start position if str text get length n start pos 2 istdigit str text n start pos istdigit str text n start pos 1 return ttoi str text mid n start pos 2 return 1 camsedit timebehavior getsecond cstring strtext m_pedit gettext nstartpos getsecondstartposition strtext getlength nstartpos _istdigit strtext nstartpos _istdigit strtext nstartpos _ttoi strtext nstartpos c string cams edit time behavior getampm const c string str text m pedit get text int n pos getampm position str text if n pos 0 return str text mid n pos return t cstring camsedit timebehavior cstring strtext m_pedit gettext npos getampmposition strtext npos strtext npos _t void cams edit time behavior set hour int n hour assert is valid hour n hour false selection saver selection m pedit remember the current selection if get hour 0 see if there s already an hour m pedit set sel get hour start position get hour start position 3 convert it to am pm hour if necessary c string strampm if is showing24 hour format n hour 12 n hour convert toampm hour n hour strampm c string str text str text format t 02d c n hour m csep m pedit replace sel str text true set the hour change the am pm if it s present if strampm is empty is validampm getampm setampm strampm m stram camsedit timebehavior sethour nhour isvalidhour nhour selectionsaver m_pedit gethour m_pedit setsel gethourstartposition gethourstartposition cstring isshowing24hourformat nhour nhour converttoampmhour nhour cstring strtext strtext _t nhour m_csep m_pedit replacesel strtext isempty isvalidampm m_stram void cams edit time behavior set minute int n minute assert is valid minute n minute selection saver selection m pedit remember the current selection if get minute 0 see if there s already a minute m pedit set sel get minute start position get minute start position 2 is showing seconds c string str text str text format t 02d n minute if is showing seconds str text m csep m pedit replace sel str text true set the minute append the am pm if no seconds come after and it s not in 24 hour format if is showing seconds showampm camsedit timebehavior setminute nminute isvalidminute nminute selectionsaver m_pedit getminute m_pedit setsel getminutestartposition getminutestartposition isshowingseconds cstring strtext strtext _t nminute isshowingseconds strtext m_csep m_pedit replacesel strtext isshowingseconds void cams edit time behavior set second int n second assert is valid second n second if is showing seconds return selection saver selection m pedit remember the current selection if get second 0 see if there s already a second m pedit set sel get second start position get second start position 2 c string str text str text format t 02d n second m pedit replace sel str text true set the second append the am pm if it s not in 24 hour format showampm camsedit timebehavior setsecond nsecond isvalidsecond nsecond isshowingseconds selectionsaver m_pedit getsecond m_pedit setsel getsecondstartposition getsecondstartposition cstring strtext strtext _t nsecond m_pedit replacesel strtext void cams edit time behavior setampm bool bam if is showing24 hour format return selection saver selection m pedit remember the current selection m pedit set sel getampm start position 1 getampm start position m nampmlength c string str text str text format t s bam m stram m strpm m pedit replace sel str text true set the am pm camsedit timebehavior isshowing24hourformat selectionsaver m_pedit m_pedit setsel getampmstartposition getampmstartposition m_nampmlength cstring strtext strtext _t m_stram m_strpm m_pedit replacesel strtext bool cams edit time behavior is valid const return is valid true camsedit timebehavior isvalid isvalid bool cams edit time behavior is valid bool b check range also const check that we have a valid hour and minute int n hour get hour int n minute get minute if n hour 0 n minute 0 return false check that the seconds are valid if being shown int n second get second bool b showing seconds is showing seconds if b showing seconds n second 0 return false check the am pm portion c string strampm getampm bool b24 hour format is showing24 hour format if b24 hour format strampm is empty b24 hour format strampm m stram strampm m strpm return false if b24 hour format strampm m strpm n hour 12 if n hour 24 n hour 0 if b showing seconds n second m timemin get second avoids possible problem when checking range below check that it s valid c ole date time date ams default date n hour n minute n second if date get status c ole date time valid return false check the range if desired if b check range also return is within range date false return true camsedit timebehavior isvalid bcheckrangealso nhour gethour nminute getminute nhour nminute nsecond getsecond bshowingseconds isshowingseconds bshowingseconds nsecond cstring b24hourformat isshowing24hourformat b24hourformat isempty b24hourformat m_stram m_strpm b24hourformat m_strpm nhour nhour nhour bshowingseconds nsecond m_timemin getsecond coledatetime ams_default_date nhour nminute nsecond getstatus coledatetime bcheckrangealso iswithinrange bool cams edit time behavior check if valid bool b show error if not valid true if m pedit is window enabled return true bool b valid is valid if b valid b show error if not valid show error message m pedit set focus return b valid camsedit timebehavior checkifvalid bshowerrorifnotvalid m_pedit iswindowenabled bvalid isvalid bvalid bshowerrorifnotvalid showerrormessage m_pedit setfocus bvalid void cams edit time behavior set range const c time date min const c time date max assert date min ams min ctime assert date max ams max ctime m timemin set time date min get hour date min get minute date min get second m timemax set time date max get hour date max get minute date min get second assert m timemin m timemax redraw camsedit timebehavior setrange ctime datemin ctime datemax datemin ams_min_ctime datemax ams_max_ctime m_timemin settime datemin gethour datemin getminute datemin getsecond m_timemax settime datemax gethour datemax getminute datemin getsecond m_timemin m_timemax _redraw void cams edit time behavior set range const c ole date time date min const c ole date time date max assert date min ams min oledatetime assert date max ams max oledatetime m timemin set time date min get hour date min get minute date min get second m timemax set time date max get hour date max get minute date min get second assert m timemin m timemax redraw camsedit timebehavior setrange coledatetime datemin coledatetime datemax datemin ams_min_oledatetime datemax ams_max_oledatetime m_timemin settime datemin gethour datemin getminute datemin getsecond m_timemax settime datemax gethour datemax getminute datemin getsecond m_timemin m_timemax _redraw void cams edit time behavior get range c time p date min c time p date max const if p date min p date min c time p date min get year p date min get month p date min get day m timemin get hour m timemin get minute m timemin get second if p date max p date max c time p date min get year p date min get month p date min get day m timemax get hour m timemax get minute m timemax get second camsedit timebehavior getrange ctime pdatemin ctime pdatemax pdatemin pdatemin ctime pdatemin getyear pdatemin getmonth pdatemin getday m_timemin gethour m_timemin getminute m_timemin getsecond pdatemax pdatemax ctime pdatemin getyear pdatemin getmonth pdatemin getday m_timemax gethour m_timemax getminute m_timemax getsecond void cams edit time behavior get range c ole date time p date min c ole date time p date max const if p date min p date min c ole date time p date min get year p date min get month p date min get day m timemin get hour m timemin get minute m timemin get second if p date max p date max c ole date time p date min get year p date min get month p date min get day m timemax get hour m timemax get minute m timemax get second camsedit timebehavior getrange coledatetime pdatemin coledatetime pdatemax pdatemin pdatemin coledatetime pdatemin getyear pdatemin getmonth pdatemin getday m_timemin gethour m_timemin getminute m_timemin getsecond pdatemax pdatemax coledatetime pdatemin getyear pdatemin getmonth pdatemin getday m_timemax gethour m_timemax getminute m_timemax getsecond void cams edit time behavior set separator tchar c sep assert c sep assert istdigit c sep if m csep c sep m csep c sep redraw camsedit timebehavior setseparator csep csep _istdigit csep m_csep csep m_csep csep _redraw tchar cams edit time behavior get separator const return m csep camsedit timebehavior getseparator m_csep void cams edit time behavior show24 hour format bool b show24 hour format true modify flags b show24 hour format twenty four hour format 0 b show24 hour format 0 twenty four hour format camsedit timebehavior show24hourformat bshow24hourformat modifyflags bshow24hourformat twentyfourhourformat bshow24hourformat twentyfourhourformat bool cams edit time behavior is showing24 hour format const return m uflags twenty four hour format true false camsedit timebehavior isshowing24hourformat m_uflags twentyfourhourformat void cams edit time behavior show seconds bool b show seconds true modify flags b show seconds with seconds 0 b show seconds 0 with seconds camsedit timebehavior showseconds bshowseconds modifyflags bshowseconds withseconds bshowseconds withseconds bool cams edit time behavior is showing seconds const return m uflags with seconds true false camsedit timebehavior isshowingseconds m_uflags withseconds void cams edit time behavior setampm symbols const c string stram const c string strpm assert stram get length strpm get length make sure they re the same length m stram stram m strpm strpm if m stram t m stram ams am symbol if m strpm t m strpm ams pm symbol m nampmlength m stram get length redraw camsedit timebehavior setampmsymbols cstring cstring getlength getlength m_stram m_strpm m_stram _t m_stram ams_am_symbol m_strpm _t m_strpm ams_pm_symbol m_nampmlength m_stram getlength _redraw void cams edit time behavior getampm symbols c string p stram c string p strpm const assert p stram assert p strpm p stram m stram p strpm m strpm camsedit timebehavior getampmsymbols cstring pstram cstring pstrpm pstram pstrpm pstram m_stram pstrpm m_strpm c string cams edit time behavior getvalidtext const c string str text m pedit get text if it s empty or has a valid time return it if str text is empty return str text if is valid false return get formatted time get hour get minute get second getampm if the hour minute and second are invalid set it to the current time if get hour 0 get minute 0 get second 0 c time time c time get current time return get formatted time time get hour time get minute time get second otherwise retrieve the validated time return get formatted time get valid hour true get valid minute get valid second getampm cstring camsedit timebehavior _getvalidtext cstring strtext m_pedit gettext strtext isempty strtext isvalid getformattedtime gethour getminute getsecond gethour getminute getsecond ctime ctime getcurrenttime getformattedtime gethour getminute getsecond getformattedtime getvalidhour getvalidminute getvalidsecond void cams edit time behavior onchar uint u char uint n rep cnt uint n flags check to see if it s read only if m pedit is read only return tchar c static cast tchar u char int n start n end m pedit get sel n start n end c string str text m pedit get text int n len str text get length check for a non printable character such as ctrl c if istprint c if c vk back n start n len m pedit send message wm keydown vk left move the cursor left return allow backspace only if the cursor is all the way to the right if shouldenter c behavior onchar u char n rep cnt n flags return add the digit depending on its location if n start m nhourstart first digit if is valid hour digit c 0 shouldenter c if n len n start m pedit set sel n start n start 1 m pedit replace sel c string c true if n len n start 1 if the second digit is no longer valid correct and select it if is valid hour get hour m pedit set sel n start 1 n start 2 m pedit replace sel c string get min hour digit 1 true m pedit set sel n start 1 n start 2 else behavior onchar u char n rep cnt n flags else if n len n start is valid hour digit c 1 shouldenter c m pedit set sel n start n start 2 m pedit replace sel c string 0 c true else changeampm c allow changing am pm if it s being shown by pressing a or p else if n start m nhourstart 1 second digit if is valid hour digit c 1 shouldenter c if n len n start m pedit set sel n start n start 1 m pedit replace sel c string c true else behavior onchar u char n rep cnt n flags else if c m csep n len n start is valid hour ttoi c string 0 str text m nhourstart shouldenter c m pedit set sel m nhourstart n start m pedit replace sel c string 0 str text m nhourstart c true else changeampm c allow changing am pm if it s being shown by pressing a or p else if n start m nhourstart 2 first colon int n colon 0 if c m csep n colon 1 else n colon is valid minute digit c 0 2 0 if we need the colon enter it if n colon shouldenter c m pedit set sel n start n start 1 false m pedit replace sel c string m csep true if the colon is to be preceded by a valid digit type it in if n colon 2 keybd event byte c 0 0 0 else changeampm c allow changing am pm if it s being shown by pressing a or p else if n start m nhourstart 3 third digit if is valid minute digit c 0 shouldenter c if n len n start m pedit set sel n start n start 1 m pedit replace sel c string c true if n len n start 1 if is valid minute get minute m pedit set sel n start 1 n start 2 m pedit replace sel c string get min minute digit 1 true m pedit set sel n start 1 n start 2 else behavior onchar u char n rep cnt n flags else changeampm c allow changing am pm if it s being shown by pressing a or p else if n start m nhourstart 4 fourth digit if is valid minute digit c 1 shouldenter c if n len n start m pedit set sel n start n start 1 m pedit replace sel c string c true else behavior onchar u char n rep cnt n flags show the am pm symbol if we re not showing seconds if is showing seconds showampm else changeampm c allow changing am pm if it s being shown by pressing a or p else if n start m nhourstart 5 second colon or first space seconds first digit or am pm if is showing seconds int n colon 0 if c m csep n colon 1 else n colon is valid second digit c 0 2 0 if we need the slash enter it if n colon shouldenter c int n replace n start n len str text n start m pedit set sel n start n start n replace false m pedit replace sel c string m csep true if the colon is to be preceded by a valid digit type it in if n colon 2 keybd event byte c 0 0 0 else if is showing24 hour format if c m pedit set sel n start n start 1 false m pedit replace sel c string c true showampm changeampm c allow changing am pm if it s being shown by pressing a or p else if n start m nhourstart 6 fifth digit first digit of seconds or am pm if is showing seconds if is valid second digit c 0 shouldenter c if n len n start int n replace n start n len str text n start m pedit set sel n start n start n replace false m pedit replace sel c string c true else behavior onchar u char n rep cnt n flags changeampm c allow changing am pm if it s being shown by pressing a or p else if n start m nhourstart 7 sixth digit second digit of seconds or am pm if is showing seconds if is valid second digit c 1 shouldenter c if n len n start int n replace n start n len str text n start m pedit set sel n start n start n replace false m pedit replace sel c string c true else behavior onchar u char n rep cnt n flags show the am pm symbol if we re not in 24 hour format showampm changeampm c allow changing am pm if it s being shown by pressing a or p else if n start m nhourstart 8 first space with seconds showing if is showing seconds is showing24 hour format if c m pedit set sel n start n start 1 false m pedit replace sel c string c true showampm changeampm c allow changing am pm if it s being shown by pressing a or p else am pm changeampm c camsedit timebehavior _onchar uchar nrepcnt nflags m_pedit isreadonly static_cast uchar nstart nend m_pedit getsel nstart nend cstring strtext m_pedit gettext nlen strtext getlength _istprint vk_back nstart nlen m_pedit sendmessage wm_keydown vk_left _shouldenter _onchar uchar nrepcnt nflags nstart m_nhourstart isvalidhourdigit _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring nlen nstart isvalidhour gethour m_pedit setsel nstart nstart m_pedit replacesel cstring getminhourdigit m_pedit setsel nstart nstart _onchar uchar nrepcnt nflags nlen nstart isvalidhourdigit _shouldenter m_pedit setsel nstart nstart m_pedit replacesel cstring nstart m_nhourstart isvalidhourdigit _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring _onchar uchar nrepcnt nflags m_csep nlen nstart isvalidhour _ttoi cstring strtext m_nhourstart _shouldenter m_pedit setsel m_nhourstart nstart m_pedit replacesel cstring strtext m_nhourstart nstart m_nhourstart ncolon m_csep ncolon ncolon isvalidminutedigit ncolon _shouldenter m_pedit setsel nstart nstart m_pedit replacesel cstring m_csep ncolon keybd_event nstart m_nhourstart isvalidminutedigit _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring nlen nstart isvalidminute getminute m_pedit setsel nstart nstart m_pedit replacesel cstring getminminutedigit m_pedit setsel nstart nstart _onchar uchar nrepcnt nflags nstart m_nhourstart isvalidminutedigit _shouldenter nlen nstart m_pedit setsel nstart nstart m_pedit replacesel cstring _onchar uchar nrepcnt nflags isshowingseconds nstart m_nhourstart isshowingseconds ncolon m_csep ncolon ncolon isvalidseconddigit ncolon _shouldenter nreplace nstart nlen strtext nstart m_pedit setsel nstart nstart nreplace m_pedit replacesel cstring m_csep ncolon keybd_event isshowing24hourformat m_pedit setsel nstart nstart m_pedit replacesel cstring nstart m_nhourstart isshowingseconds isvalidseconddigit _shouldenter nlen nstart nreplace nstart nlen strtext nstart m_pedit setsel nstart nstart nreplace m_pedit replacesel cstring _onchar uchar nrepcnt nflags nstart m_nhourstart isshowingseconds isvalidseconddigit _shouldenter nlen nstart nreplace nstart nlen strtext nstart m_pedit setsel nstart nstart nreplace m_pedit replacesel cstring _onchar uchar nrepcnt nflags nstart m_nhourstart isshowingseconds isshowing24hourformat m_pedit setsel nstart nstart m_pedit replacesel cstring void cams edit time behavior onkeydown uint u char uint n rep cnt uint n flags check to see if it s read only if m pedit is read only return switch u char case vk delete if deleting make sure it s the last character or that the selection goes all the way to the end of the text int n start n end m pedit get sel n start n end c string str text m pedit get text int n len str text get length if n end n len if n end n start n end n len 1 return break case vk up if pressing the up arrow increment the corresponding value int n start n end m pedit get sel n start n end if n start get hour start position n start get hour start position 2 int n hour get hour if n hour get min hour handle moving up through the noon hour c string strampm getampm if is validampm strampm if n hour 11 if strampm m strpm stop at midnight return setampm false else if n hour 12 n hour 0 if n hour get max hour set hour n hour else if n start get minute start position n start get minute start position 2 int n minute get minute if n minute get min minute n minute get max minute set minute n minute else if n start getampm start position n start getampm start position m nampmlength c string strampm getampm setampm is validampm strampm strampm m strpm else if n start get second start position n start get second start position 2 int n second get second if n second get min second n second get max second set second n second return case vk down if pressing the down arrow decrement the corresponding value int n start n end m pedit get sel n start n end if n start get hour start position n start get hour start position 2 int n hour get hour if n hour get max hour handle moving up through the noon hour c string strampm getampm if is validampm strampm if n hour 12 if strampm m stram stop at midnight return setampm true else if n hour 1 n hour 13 if n hour get min hour set hour n hour else if n start get minute start position n start get minute start position 2 int n minute get minute if n minute get min minute n minute get max minute set minute n minute else if n start getampm start position n start getampm start position m nampmlength c string strampm getampm setampm is validampm strampm strampm m strpm else if n start get second start position n start get second start position 2 int n second get second if n second get min second n second get max second set second n second return behavior onkeydown u char n rep cnt n flags camsedit timebehavior _onkeydown uchar nrepcnt nflags m_pedit isreadonly uchar vk_delete nstart nend m_pedit getsel nstart nend cstring strtext m_pedit gettext nlen strtext getlength nend nlen nend nstart nend nlen vk_up nstart nend m_pedit getsel nstart nend nstart gethourstartposition nstart gethourstartposition nhour gethour nhour getminhour cstring isvalidampm nhour m_strpm nhour nhour nhour getmaxhour sethour nhour nstart getminutestartposition nstart getminutestartposition nminute getminute nminute getminminute nminute getmaxminute setminute nminute nstart getampmstartposition nstart getampmstartposition m_nampmlength cstring isvalidampm m_strpm nstart getsecondstartposition nstart getsecondstartposition nsecond getsecond nsecond getminsecond nsecond getmaxsecond setsecond nsecond vk_down nstart nend m_pedit getsel nstart nend nstart gethourstartposition nstart gethourstartposition nhour gethour nhour getmaxhour cstring isvalidampm nhour m_stram nhour nhour nhour getminhour sethour nhour nstart getminutestartposition nstart getminutestartposition nminute getminute nminute getminminute nminute getmaxminute setminute nminute nstart getampmstartposition nstart getampmstartposition m_nampmlength cstring isvalidampm m_strpm nstart getsecondstartposition nstart getsecondstartposition nsecond getsecond nsecond getminsecond nsecond getmaxsecond setsecond nsecond _onkeydown uchar nrepcnt nflags void cams edit time behavior onkillfocus c wnd p new wnd behavior onkillfocus p new wnd check if any of the on kill focus flags is set if m uflags onkillfocus max return c string str text m pedit get text if it s empty take action based on the flag if str text is empty if m uflags onkillfocus beep ifempty message beep mb iconexclamation if m uflags onkillfocus setvalid ifempty adjust within range if m uflags onkillfocus showmessage ifempty onkillfocus showmessage ifempty show error message if m uflags onkillfocus setfocus ifempty m pedit set focus return if is valid if m uflags onkillfocus beep ifinvalid message beep mb iconexclamation if m uflags onkillfocus setvalid ifinvalid adjust within range if m uflags onkillfocus showmessage ifinvalid onkillfocus showmessage ifinvalid show error message if m uflags onkillfocus setfocus ifinvalid m pedit set focus camsedit timebehavior _onkillfocus cwnd pnewwnd _onkillfocus pnewwnd onkillfocus m_uflags onkillfocus_max cstring strtext m_pedit gettext strtext isempty m_uflags onkillfocus_beep_ifempty messagebeep mb_iconexclamation m_uflags onkillfocus_setvalid_ifempty adjustwithinrange m_uflags onkillfocus_showmessage_ifempty onkillfocus_showmessage_ifempty showerrormessage m_uflags onkillfocus_setfocus_ifempty m_pedit setfocus isvalid m_uflags onkillfocus_beep_ifinvalid messagebeep mb_iconexclamation m_uflags onkillfocus_setvalid_ifinvalid adjustwithinrange m_uflags onkillfocus_showmessage_ifinvalid onkillfocus_showmessage_ifinvalid showerrormessage m_uflags onkillfocus_setfocus_ifinvalid m_pedit setfocus int cams edit time behavior get valid hour bool b24 hour format false const int n hour get hour it it s outside the range fix it if n hour get min hour b24 hour format n hour get min hour b24 hour format else if n hour get max hour b24 hour format n hour get max hour b24 hour format return n hour camsedit timebehavior getvalidhour b24hourformat nhour gethour nhour getminhour b24hourformat nhour getminhour b24hourformat nhour getmaxhour b24hourformat nhour getmaxhour b24hourformat nhour int cams edit time behavior get max hour bool b24 hour format false const return b24 hour format is showing24 hour format 23 12 camsedit timebehavior getmaxhour b24hourformat b24hourformat isshowing24hourformat int cams edit time behavior get min hour bool b24 hour format false const return b24 hour format is showing24 hour format 0 1 camsedit timebehavior getminhour b24hourformat b24hourformat isshowing24hourformat int cams edit time behavior get hour start position const return m nhourstart camsedit timebehavior gethourstartposition m_nhourstart tchar cams edit time behavior get max hour digit int n pos const assert n pos 0 n pos 1 first digit if n pos 0 return is showing24 hour format 2 1 second digit c string str text m pedit get text tchar c first digit str text get length get hour start position str text get hour start position 0 assert c first digit must have a valid first digit at this point use the first digit to determine the second digit s max if c first digit 2 return 3 if c first digit 1 is showing24 hour format return 2 return 9 camsedit timebehavior getmaxhourdigit npos npos npos npos isshowing24hourformat cstring strtext m_pedit gettext cfirstdigit strtext getlength gethourstartposition strtext gethourstartposition cfirstdigit cfirstdigit cfirstdigit isshowing24hourformat tchar cams edit time behavior get min hour digit int n pos const assert n pos 0 n pos 1 first digit if n pos 0 return 0 second digit c string str text m pedit get text tchar c first digit str text get length get hour start position str text get hour start position 0 assert c first digit must have a valid first digit at this point if the first digit is a 0 and we re not in 24 hour format don t allow 0 if c first digit 0 is showing24 hour format return 1 for all other cases it s always 0 return 0 camsedit timebehavior getminhourdigit npos npos npos npos cstring strtext m_pedit gettext cfirstdigit strtext getlength gethourstartposition strtext gethourstartposition cfirstdigit cfirstdigit isshowing24hourformat bool cams edit time behavior is valid hour digit tchar c int n pos const return c get min hour digit n pos c get max hour digit n pos camsedit timebehavior isvalidhourdigit npos getminhourdigit npos getmaxhourdigit npos bool cams edit time behavior is valid hour int n hour bool b24 hour format false const return n hour get min hour b24 hour format n hour get max hour b24 hour format camsedit timebehavior isvalidhour nhour b24hourformat nhour getminhour b24hourformat nhour getmaxhour b24hourformat int cams edit time behavior convert to24 hour int n hour const c string strampm const if strampm m strpm n hour 1 n hour 11 n hour 12 else if strampm m stram n hour 12 n hour 0 return n hour camsedit timebehavior convertto24hour nhour cstring m_strpm nhour nhour nhour m_stram nhour nhour nhour int cams edit time behavior convert toampm hour int n hour c string p strampm null const c string strampm m stram if n hour 12 n hour 12 strampm m strpm if n hour 0 n hour 12 if p strampm p strampm strampm return n hour camsedit timebehavior converttoampmhour nhour cstring pstrampm cstring m_stram nhour nhour m_strpm nhour nhour pstrampm pstrampm nhour int cams edit time behavior get valid minute const int n minute get minute it it s outside the range fix it if n minute get min minute n minute get min minute else if n minute get max minute n minute get max minute return n minute camsedit timebehavior getvalidminute nminute getminute nminute getminminute nminute getminminute nminute getmaxminute nminute getmaxminute nminute int cams edit time behavior get max minute const return 59 camsedit timebehavior getmaxminute int cams edit time behavior get min minute const return 0 camsedit timebehavior getminminute int cams edit time behavior get max second const return 59 camsedit timebehavior getmaxsecond int cams edit time behavior get min second const return 0 camsedit timebehavior getminsecond int cams edit time behavior get minute start position const return m nhourstart 3 camsedit timebehavior getminutestartposition m_nhourstart tchar cams edit time behavior get max minute digit int n pos const assert n pos 0 n pos 1 return n pos 0 5 9 camsedit timebehavior getmaxminutedigit npos npos npos npos tchar cams edit time behavior get min minute digit int const return 0 camsedit timebehavior getminminutedigit bool cams edit time behavior is valid minute digit tchar c int n pos const return c get min minute digit n pos c get max minute digit n pos camsedit timebehavior isvalidminutedigit npos getminminutedigit npos getmaxminutedigit npos bool cams edit time behavior is valid minute int n minute const return n minute get min minute n minute get max minute camsedit timebehavior isvalidminute nminute nminute getminminute nminute getmaxminute int cams edit time behavior get valid second const int n second get second if n second get min second n second get min second else if n second get max second n second get max second return n second camsedit timebehavior getvalidsecond nsecond getsecond nsecond getminsecond nsecond getminsecond nsecond getmaxsecond nsecond getmaxsecond nsecond int cams edit time behavior get second start position const return m nhourstart 6 camsedit timebehavior getsecondstartposition m_nhourstart tchar cams edit time behavior get max second digit int n pos const assert n pos 0 n pos 1 return n pos 0 5 9 camsedit timebehavior getmaxseconddigit npos npos npos npos tchar cams edit time behavior get min second digit int const return 0 camsedit timebehavior getminseconddigit bool cams edit time behavior is valid second digit tchar c int n pos const return c get min second digit n pos c get max second digit n pos camsedit timebehavior isvalidseconddigit npos getminseconddigit npos getmaxseconddigit npos bool cams edit time behavior is valid second int n second const return n second get min second n second get max second camsedit timebehavior isvalidsecond nsecond nsecond getminsecond nsecond getmaxsecond void cams edit time behavior showampm if is showing24 hour format is validampm getampm setampm true camsedit timebehavior isshowing24hourformat isvalidampm bool cams edit time behavior changeampm tchar c if is showing24 hour format return false c string str text m pedit get text int n len str text get length int n pos getampm position str text if n pos 0 return false int n start n end m pedit get sel n start n end c string strampm getampm tchar c upper static cast tchar totupper c switch c upper case a case p setampm c upper a if c upper tchar totupper m stram 0 c upper tchar totupper m strpm 0 move the cursor right if we re in front of the am pm symbols if n start n pos m pedit post message wm keydown vk right move the cursor right twice if we re in front of the space in front of the am pm symbols if n start 1 n pos m pedit post message wm keydown vk right m pedit post message wm keydown vk right return true default handle entries after the first character of the am pm symbol allow the user to enter each character if n start n pos check if we re adding a character of the am pm symbol after the first one if n len n start is validampm strampm n len n end n end n start const c string strampm to use totupper str text n pos totupper m stram 0 m stram m strpm if c upper tchar totupper strampm to use n start n pos m pedit replace sel strampm to use mid n start n pos true set the rest of the am pm m pedit set sel n start n start true reset the selection so that the cursor can be moved return changeampm c move the cursor below check if the am pm symbol is ok and we just need to move over one if n len n start n end n start c upper tchar totupper str text n start m pedit post message wm keydown vk right return true return false camsedit timebehavior isshowing24hourformat cstring strtext m_pedit gettext nlen strtext getlength npos getampmposition strtext npos nstart nend m_pedit getsel nstart nend cstring cupper static_cast _totupper cupper cupper cupper _totupper m_stram cupper _totupper m_strpm nstart npos m_pedit postmessage wm_keydown vk_right nstart npos m_pedit postmessage wm_keydown vk_right m_pedit postmessage wm_keydown vk_right nstart npos nlen nstart isvalidampm nlen nend nend nstart cstring strampmtouse _totupper strtext npos _totupper m_stram m_stram m_strpm cupper _totupper strampmtouse nstart npos m_pedit replacesel strampmtouse nstart npos m_pedit setsel nstart nstart nlen nstart nend nstart cupper _totupper strtext nstart m_pedit postmessage wm_keydown vk_right c string cams edit time behavior get validampm const c string strampm getampm if is validampm strampm return m stram return strampm cstring camsedit timebehavior getvalidampm cstring isvalidampm m_stram int cams edit time behavior getampm start position const return m nhourstart is showing seconds 9 6 camsedit timebehavior getampmstartposition m_nhourstart isshowingseconds bool cams edit time behavior is validampm const c string strampm const return strampm m stram strampm m strpm camsedit timebehavior isvalidampm cstring m_stram m_strpm int cams edit time behavior getampm position const c string str text const int n pos str text find m stram return n pos 0 str text find m strpm n pos 1 camsedit timebehavior getampmposition cstring strtext npos strtext m_stram npos strtext m_strpm npos bool cams edit time behavior is within range const c ole date time date bool true const return date get status c ole date time valid date m timemin date m timemax camsedit timebehavior iswithinrange coledatetime getstatus coledatetime m_timemin m_timemax void cams edit time behavior show error message const afx message box t please specify a time between get formatted time m timemin get hour m timemin get minute m timemin get second t and get formatted time m timemax get hour m timemax get minute m timemax get second mb iconexclamation camsedit timebehavior showerrormessage afxmessagebox _t getformattedtime m_timemin gethour m_timemin getminute m_timemin getsecond _t getformattedtime m_timemax gethour m_timemax getminute m_timemax getsecond mb_iconexclamation c string cams edit time behavior get formatted time int n hour int n minute int n second const c string strampm t const if is showing24 hour format handle switching from am pm to 24 hour format if is validampm strampm n hour convert to24 hour n hour strampm else handle switching from 24 hour format to am pm if is validampm strampm n hour convert toampm hour n hour const cast c string strampm c string str text if is showing seconds if is showing24 hour format str text format t 02d c 02d c 02d n hour m csep n minute m csep n second else str text format t 02d c 02d c 02d s n hour m csep n minute m csep n second strampm else if is showing24 hour format str text format t 02d c 02d n hour m csep n minute else str text format t 02d c 02d s n hour m csep n minute strampm return str text cstring camsedit timebehavior getformattedtime nhour nminute nsecond cstring _t isshowing24hourformat isvalidampm nhour convertto24hour nhour isvalidampm nhour converttoampmhour nhour const_cast cstring cstring strtext isshowingseconds isshowing24hourformat strtext _t nhour m_csep nminute m_csep nsecond strtext _t nhour m_csep nminute m_csep nsecond isshowing24hourformat strtext _t nhour m_csep nminute strtext _t nhour m_csep nminute strtext void cams edit time behavior adjust within range check if it s already within the range if is valid return if it s empty set it to the current time if m pedit get text is empty m pedit set window text t else redraw make it fall within the range c ole date time date get ole time if date m timemin set time m timemin else if date m timemax set time m timemax camsedit timebehavior adjustwithinrange isvalid m_pedit gettext isempty m_pedit setwindowtext _t _redraw coledatetime getoletime m_timemin settime m_timemin m_timemax settime m_timemax behavior p edit m nhourstart 11 pedit m_nhourstart void cams edit date time behavior set date time int n year int n month int n day int n hour int n minute int n second 0 if m uflags date only set date n year n month n day else if m uflags time only set time n hour n minute n second else assert is within range c ole date time n year n month n day n hour n minute n second m pedit set window text get formatted date n year n month n day get formatted time n hour n minute n second camsedit datetimebehavior setdatetime nyear nmonth nday nhour nminute nsecond m_uflags dateonly setdate nyear nmonth nday m_uflags timeonly settime nhour nminute nsecond iswithinrange coledatetime nyear nmonth nday nhour nminute nsecond m_pedit setwindowtext getformatteddate nyear nmonth nday getformattedtime nhour nminute nsecond void cams edit date time behavior set date time const c time dt set date time dt get year dt get month dt get day dt get hour dt get minute dt get second camsedit datetimebehavior setdatetime ctime setdatetime getyear getmonth getday gethour getminute getsecond void cams edit date time behavior set date time const c ole date time dt set date time dt get year dt get month dt get day dt get hour dt get minute dt get second camsedit datetimebehavior setdatetime coledatetime setdatetime getyear getmonth getday gethour getminute getsecond void cams edit date time behavior set to now set date time c ole date time get current time camsedit datetimebehavior settonow setdatetime coledatetime getcurrenttime c time cams edit date time behavior get date time const c time date get date c time time get time if m uflags date only return date if m uflags time only return time return c time date get year date get month date get day time get hour time get minute time get second ctime camsedit datetimebehavior getdatetime ctime getdate ctime gettime m_uflags dateonly m_uflags timeonly ctime getyear getmonth getday gethour getminute getsecond c ole date time cams edit date time behavior get ole date time const c ole date time date get ole date c ole date time time get ole time if m uflags date only return date if m uflags time only return time return c ole date time date get year date get month date get day time get hour time get minute time get second coledatetime camsedit datetimebehavior getoledatetime coledatetime getoledate coledatetime getoletime m_uflags dateonly m_uflags timeonly coledatetime getyear getmonth getday gethour getminute getsecond bool cams edit date time behavior is valid const if m uflags date only return date behavior is valid if m uflags time only return time behavior is valid return date behavior is valid time behavior is valid camsedit datetimebehavior isvalid m_uflags dateonly datebehavior isvalid m_uflags timeonly timebehavior isvalid datebehavior isvalid timebehavior isvalid void cams edit date time behavior set range const c time date min const c time date max date behavior set range date min date max time behavior set range date min date max camsedit datetimebehavior setrange ctime datemin ctime datemax datebehavior setrange datemin datemax timebehavior setrange datemin datemax void cams edit date time behavior set range const c ole date time date min const c ole date time date max date behavior set range date min date max time behavior set range date min date max camsedit datetimebehavior setrange coledatetime datemin coledatetime datemax datebehavior setrange datemin datemax timebehavior setrange datemin datemax void cams edit date time behavior get range c time p date min c time p date max const date behavior get range p date min p date max time behavior get range p date min p date max camsedit datetimebehavior getrange ctime pdatemin ctime pdatemax datebehavior getrange pdatemin pdatemax timebehavior getrange pdatemin pdatemax void cams edit date time behavior get range c ole date time p date min c ole date time p date max const date behavior get range p date min p date max time behavior get range p date min p date max camsedit datetimebehavior getrange coledatetime pdatemin coledatetime pdatemax datebehavior getrange pdatemin pdatemax timebehavior getrange pdatemin pdatemax void cams edit date time behavior set separator tchar c sep bool b date if b date date behavior set separator c sep else time behavior set separator c sep camsedit datetimebehavior setseparator csep bdate bdate datebehavior setseparator csep timebehavior setseparator csep tchar cams edit date time behavior get separator bool b date const return b date date behavior get separator time behavior get separator camsedit datetimebehavior getseparator bdate bdate datebehavior getseparator timebehavior getseparator bool cams edit date time behavior modify flags uint u add uint u remove uint u flags m uflags u remove u add m nhourstart u flags time only 0 11 return behavior modify flags u add u remove camsedit datetimebehavior modifyflags uadd uremove uflags m_uflags uremove uadd m_nhourstart uflags timeonly modifyflags uadd uremove c string cams edit date time behavior getvalidtext const check if we re showing the date only c string str date date behavior getvalidtext if m uflags date only return str date check if we re showing the time only c string str time time behavior getvalidtext if m uflags time only return str time c string str space str date is empty str time is empty t t return str date str space str time cstring camsedit datetimebehavior _getvalidtext cstring strdate datebehavior _getvalidtext m_uflags dateonly strdate cstring strtime timebehavior _getvalidtext m_uflags timeonly strtime cstring strspace strdate isempty strtime isempty _t _t strdate strspace strtime void cams edit date time behavior onchar uint u char uint n rep cnt uint n flags check to see if it s read only if m pedit is read only return check if we re showing the date or the time only if m uflags date only date behavior onchar u char n rep cnt n flags return if m uflags time only time behavior onchar u char n rep cnt n flags return tchar c static cast tchar u char int n start n end date behavior m pedit get sel n start n end c string str text m pedit get text int n len str text get length if n start 0 n start 9 date behavior onchar u char n rep cnt n flags changeampm c allow changing am pm if it s being shown by pressing a or p else if n start 10 date behavior onchar u char n rep cnt n flags int n space 0 if c n space 1 else n space is valid hour digit c 0 is valid hour digit c 1 n len 11 2 0 if we need the space enter it if n space shouldenter c date behavior m pedit set sel n start n start 1 false date behavior m pedit replace sel c string true if the space is to be preceded by a valid digit type it in if n space 2 keybd event byte c 0 0 0 else changeampm c allow changing am pm if it s being shown by pressing a or p else time behavior onchar u char n rep cnt n flags camsedit datetimebehavior _onchar uchar nrepcnt nflags m_pedit isreadonly m_uflags dateonly datebehavior _onchar uchar nrepcnt nflags m_uflags timeonly timebehavior _onchar uchar nrepcnt nflags static_cast uchar nstart nend datebehavior m_pedit getsel nstart nend cstring strtext m_pedit gettext nlen strtext getlength nstart nstart datebehavior _onchar uchar nrepcnt nflags nstart datebehavior _onchar uchar nrepcnt nflags nspace nspace nspace isvalidhourdigit isvalidhourdigit nlen nspace _shouldenter datebehavior m_pedit setsel nstart nstart datebehavior m_pedit replacesel cstring nspace keybd_event timebehavior _onchar uchar nrepcnt nflags void cams edit date time behavior onkeydown uint u char uint n rep cnt uint n flags check if we re showing the time only if m uflags time only time behavior onkeydown u char n rep cnt n flags return date behavior onkeydown u char n rep cnt n flags if u char vk up u char vk down m uflags date only time behavior onkeydown u char n rep cnt n flags camsedit datetimebehavior _onkeydown uchar nrepcnt nflags m_uflags timeonly timebehavior _onkeydown uchar nrepcnt nflags datebehavior _onkeydown uchar nrepcnt nflags uchar vk_up uchar vk_down m_uflags dateonly timebehavior _onkeydown uchar nrepcnt nflags void cams edit date time behavior onkillfocus c wnd p new wnd date behavior onkillfocus p new wnd camsedit datetimebehavior _onkillfocus cwnd pnewwnd datebehavior _onkillfocus pnewwnd bool cams edit date time behavior is within range const c ole date time date bool b date only true const if b date only return date behavior is within range date c ole date time dt get year get month get day date get hour date get minute date get second c ole date time dt min m datemin get year m datemin get month m datemin get day m timemin get hour m timemin get minute m timemin get second c ole date time dt max m datemax get year m datemax get month m datemax get day m timemax get hour m timemax get minute m timemax get second return dt get status c ole date time valid dt dt min dt dt max camsedit datetimebehavior iswithinrange coledatetime bdateonly bdateonly datebehavior iswithinrange coledatetime getyear getmonth getday gethour getminute getsecond coledatetime dtmin m_datemin getyear m_datemin getmonth m_datemin getday m_timemin gethour m_timemin getminute m_timemin getsecond coledatetime dtmax m_datemax getyear m_datemax getmonth m_datemax getday m_timemax gethour m_timemax getminute m_timemax getsecond getstatus coledatetime dtmin dtmax void cams edit date time behavior show error message const show the message depending on what we re showing if m uflags date only date behavior show error message else if m uflags time only time behavior show error message else c string str min date time get formatted date m datemin get year m datemin get month m datemin get day get formatted time m timemin get hour m timemin get minute m timemin get second c string str max date time get formatted date m datemax get year m datemax get month m datemax get day get formatted time m timemax get hour m timemax get minute m timemax get second afx message box t please specify a date and time between str min date time t and str max date time mb iconexclamation camsedit datetimebehavior showerrormessage m_uflags dateonly datebehavior showerrormessage m_uflags timeonly timebehavior showerrormessage cstring strmindatetime getformatteddate m_datemin getyear m_datemin getmonth m_datemin getday getformattedtime m_timemin gethour m_timemin getminute m_timemin getsecond cstring strmaxdatetime getformatteddate m_datemax getyear m_datemax getmonth m_datemax getday getformattedtime m_timemax gethour m_timemax getminute m_timemax getsecond afxmessagebox _t strmindatetime _t strmaxdatetime mb_iconexclamation date behavior this behavior this required because date behavior derives virtually from behavior datebehavior datebehavior c string cams date edit get valid text const return getvalidtext cstring camsdateedit getvalidtext _getvalidtext void cams date edit on char uint u char uint n rep cnt uint n flags onchar u char n rep cnt n flags camsdateedit onchar uchar nrepcnt nflags _onchar uchar nrepcnt nflags void cams date edit on key down uint u char uint n rep cnt uint n flags onkeydown u char n rep cnt n flags camsdateedit onkeydown uchar nrepcnt nflags _onkeydown uchar nrepcnt nflags void cams date edit on kill focus c wnd p new wnd onkillfocus p new wnd camsdateedit onkillfocus cwnd pnewwnd _onkillfocus pnewwnd long cams date edit on paste uint long return onpaste 0 0 camsdateedit onpaste _onpaste time behavior this behavior this required because time behavior derives virtually from behavior timebehavior timebehavior c string cams time edit get valid text const return getvalidtext cstring camstimeedit getvalidtext _getvalidtext void cams time edit on char uint u char uint n rep cnt uint n flags onchar u char n rep cnt n flags camstimeedit onchar uchar nrepcnt nflags _onchar uchar nrepcnt nflags void cams time edit on key down uint u char uint n rep cnt uint n flags onkeydown u char n rep cnt n flags camstimeedit onkeydown uchar nrepcnt nflags _onkeydown uchar nrepcnt nflags void cams time edit on kill focus c wnd p new wnd onkillfocus p new wnd camstimeedit onkillfocus cwnd pnewwnd _onkillfocus pnewwnd long cams time edit on paste uint long return onpaste 0 0 camstimeedit onpaste _onpaste date time behavior this behavior this required because date time behavior derives virtually from behavior datetimebehavior datetimebehavior c string cams date time edit get valid text const return getvalidtext cstring camsdatetimeedit getvalidtext _getvalidtext void cams date time edit on char uint u char uint n rep cnt uint n flags onchar u char n rep cnt n flags camsdatetimeedit onchar uchar nrepcnt nflags _onchar uchar nrepcnt nflags void cams date time edit on key down uint u char uint n rep cnt uint n flags onkeydown u char n rep cnt n flags camsdatetimeedit onkeydown uchar nrepcnt nflags _onkeydown uchar nrepcnt nflags void cams date time edit on kill focus c wnd p new wnd onkillfocus p new wnd camsdatetimeedit onkillfocus cwnd pnewwnd _onkillfocus pnewwnd