c layered window helperst c layered window helperst load dll m hdll load library t user32 dll clayeredwindowhelperst clayeredwindowhelperst m_hdll loadlibrary _t c layered window helperst c layered window helperst unload dll if any if m hdll free library m hdll m hdll null clayeredwindowhelperst clayeredwindowhelperst m_hdll freelibrary m_hdll m_hdll long c layered window helperst add layered style hwnd h wnd return set window long h wnd gwl exstyle get window long h wnd gwl exstyle ws ex layered clayeredwindowhelperst addlayeredstyle hwnd setwindowlong hwnd gwl_exstyle getwindowlong hwnd gwl_exstyle ws_ex_layered long c layered window helperst remove layered style hwnd h wnd return set window long h wnd gwl exstyle get window long h wnd gwl exstyle ws ex layered clayeredwindowhelperst removelayeredstyle hwnd setwindowlong hwnd gwl_exstyle getwindowlong hwnd gwl_exstyle ws_ex_layered bool c layered window helperst set layered window attributes hwnd h wnd colorref cr key byte b alpha dword dw flags bool b ret value true if m hdll lpfn set layered window attributes p fn null p fn lpfn set layered window attributes get proc address m hdll set layered window attributes if p fn b ret value p fn h wnd cr key b alpha dw flags if else b ret value false if return b ret value clayeredwindowhelperst setlayeredwindowattributes hwnd crkey balpha dwflags bretvalue m_hdll lpfnsetlayeredwindowattributes pfn pfn lpfnsetlayeredwindowattributes getprocaddress m_hdll setlayeredwindowattributes pfn bretvalue pfn hwnd crkey balpha dwflags bretvalue bretvalue bool c layered window helperst set transparent percentage hwnd h wnd byte by percentage do not accept values greater than 100 if by percentage 100 by percentage 100 return set layered window attributes h wnd 0 255 by percentage 100 lwa alpha clayeredwindowhelperst settransparentpercentage hwnd bypercentage bypercentage bypercentage setlayeredwindowattributes hwnd bypercentage lwa_alpha c child view c child view cchildview cchildview bool c child view pre create window createstruct cs if c wnd pre create window cs return false cs dw ex style ws ex clientedge cs style ws border cs lpsz class afx register wnd class cs hredraw cs vredraw cs dblclks load cursor null idc arrow hbrush color window 1 null return true cchildview precreatewindow cwnd precreatewindow dwexstyle ws_ex_clientedge ws_border lpszclass afxregisterwndclass cs_hredraw cs_vredraw cs_dblclks loadcursor idc_arrow color_window c child view c child view cchildview cchildview void c child view on paint c paintdc dc this device context for painting todo add your message handler code here do not call c wnd on paint for painting messages cchildview onpaint cpaintdc cwnd onpaint 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 lr shared return set icon h icon csystemtray seticon lpsziconname hicon loadimage afxgetresourcehandle lpsziconname image_icon lr_defaultcolor lr_shared seticon hicon 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 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 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 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 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 bc menu menu c 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 bcmenu 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 ifndef win32 wce if 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 _win32_wce 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 ifndef win32 wce if 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 _win32_wce 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 bc menu menu c 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 dow we have an alarm c main frame p main c main frame afx get main wnd if p main show alarm dialog return 0l if menu load menu m tnd uid return 0 p sub menu menu get sub menu 0 add any minimized notes here bc menu p minimized null p minimized bc menu p sub menu get sub menu 6 p main create minimized menu bc menu p sub menu p minimized bc menu a b a bc menu p sub menu get sub menu 1 b bc menu p sub menu get sub menu 2 change the text to the right language menu set menu text id traymain newnote c translate read string 0 new note mf string a set menu text id traymain importexport import c translate read string 2 import mf string a set menu text id traymain importexport export c translate read string 3 export mf string b set menu text id traymain uploaddownload uploadnotes c translate read string 5 upload mf string b set menu text id traymain uploaddownload downloadnotes c translate read string 6 download mf string menu set menu text id traymain stayontop c translate read string 7 stay on top mf string menu set menu text id traymain minimizeall c translate read string 8 minimize all mf string menu set menu text id traymain recyclebin c translate read string 10 recycle bin mf string menu set menu text id traymain visitanotewebsite c translate read string 11 visit a note s website mf string menu set menu text id traymain checkforupdates c translate read string 12 check for updates mf string menu set menu text id traymain faq c translate read string 13 faq mf string menu set menu text id traymain sendbugg c translate read string 14 send bug feedback mf string menu set menu text id traymain options c translate read string 15 options mf string menu set menu text id app about c translate read string 16 about mf string menu set menu text id app exit c translate read string 17 exit mf string 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 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 do we have an alarm c main frame p main c main frame afx get main wnd if p main show alarm dialog return 0l make sure that the programm don t think we have singleclicked kill timer id traysingleclick m bsingleclicked false 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 bc 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 send message wm command u item 0 else if loword l param wm lbuttondown do we have an alarm c main frame p main c main frame afx get main wnd if p main show alarm dialog return 0l we have singleclicked to be realy sure that the user didn t double click we have to start a timer set timer id traysingleclick get double click time null m bsingleclicked true return 1 csystemtray ontraynotification wparam lparam wparam m_tnd bcmenu cmenu psubmenu cwnd ptargetwnd gettargetwnd ptargetwnd _win32_wce _win32_wce baltpressed getkeystate vk_menu lparam wm_lbuttonup baltpressed lparam wm_rbuttonup cmainframe pmain cmainframe afxgetmainwnd pmain showalarmdialog loadmenu m_tnd psubmenu getsubmenu bcmenu pminimized pminimized bcmenu psubmenu getsubmenu pmain createminimizedmenu bcmenu psubmenu pminimized bcmenu bcmenu psubmenu getsubmenu bcmenu psubmenu getsubmenu setmenutext id_traymain_newnote ctranslate readstring mf_string setmenutext id_traymain_importexport_import ctranslate readstring mf_string setmenutext id_traymain_importexport_export ctranslate readstring mf_string setmenutext id_traymain_uploaddownload_uploadnotes ctranslate readstring mf_string setmenutext id_traymain_uploaddownload_downloadnotes ctranslate readstring mf_string setmenutext id_traymain_stayontop ctranslate readstring mf_string setmenutext id_traymain_minimizeall ctranslate readstring mf_string setmenutext id_traymain_recyclebin ctranslate readstring mf_string setmenutext id_traymain_visitanotewebsite ctranslate readstring mf_string setmenutext id_traymain_checkforupdates ctranslate readstring mf_string setmenutext id_traymain_faq ctranslate readstring mf_string setmenutext id_traymain_sendbugg ctranslate readstring mf_string setmenutext id_traymain_options ctranslate readstring mf_string setmenutext id_app_about ctranslate readstring mf_string setmenutext id_app_exit ctranslate readstring mf_string psubmenu _win32_wce setmenudefaultitem psubmenu m_hmenu m_defaultmenuitemid m_defaultmenuitembypos 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 cmainframe pmain cmainframe afxgetmainwnd pmain showalarmdialog killtimer id_traysingleclick m_bsingleclicked ptargetwnd setforegroundwindow uitem m_defaultmenuitembypos loadmenu m_tnd psubmenu bcmenu getsubmenu psubmenu uitem psubmenu getmenuitemid m_defaultmenuitemid destroymenu uitem m_defaultmenuitemid ptargetwnd sendmessage wm_command uitem lparam wm_lbuttondown cmainframe pmain cmainframe afxgetmainwnd pmain showalarmdialog settimer id_traysingleclick getdoubleclicktime m_bsingleclicked 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 bsingleclicked false 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_bsingleclicked 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 id traysingleclick kill timer id traysingleclick send the message to mainframe that the user clicked with the left mouse button c wnd p target wnd get target wnd p target wnd set foreground window p target wnd send message wm command id pressedleftbuttonontrayicon 0 m bsingleclicked false if nid event m uidtimer 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 id_traysingleclick killtimer id_traysingleclick cwnd ptargetwnd gettargetwnd ptargetwnd setforegroundwindow ptargetwnd sendmessage wm_command id_pressedleftbuttonontrayicon m_bsingleclicked 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 install icon pending csystemtray onsettingchange uflags lpszsection cwnd onsettingchange uflags lpszsection uflags spi_setworkarea installiconpending lresult c system tray on taskbar created wparam w param lparam l param install icon pending return 0l csystemtray ontaskbarcreated wparam lparam installiconpending 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 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 cp acp cp info m loadmenu false bcmenu bcmenu m_bdynicons disable_old_style m_selectcheck m_unselectcheck m_bitmapbackground m_bitmapbackgroundflag getcpinfo cp_acp cpinfo 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 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 tool bar 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 nstyle ctoolbar cwnd pwnd afxgetmainwnd pwnd pwnd cwnd getdesktopwindow pwnd loadtoolbar ntoolbar cimagelist m_iconx m_icony ilc_colorddb ilc_mask addbitmaptoimagelist ntoolbar 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 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 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 c string junk option text 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 cstring optiontext 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 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 for int 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 for int 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 if num menu items 12 m menulist 1 set wide string lpctstr c translate read string 1 import export m menulist 2 set wide string lpctstr c translate read string 4 upload download m menulist 6 set wide string lpctstr c translate read string 9 restore else m menulist id set ansi string string if num menu items 12 m menulist 1 set ansi string c translate read string 1 import export m menulist 2 set ansi string c translate read string 4 upload download m menulist 6 set ansi string c translate read string 9 restore 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 nummenuitems m_menulist setwidestring ctranslate readstring m_menulist setwidestring ctranslate readstring m_menulist setwidestring ctranslate readstring m_menulist setansistring nummenuitems m_menulist setansistring ctranslate readstring m_menulist setansistring ctranslate readstring m_menulist setansistring ctranslate readstring 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 if lp bitmap bi clr used 0 return word lp bitmap bi clr used switch lp bitmap bi bit count case 1 return 2 case 4 return 16 case 8 return 256 default return 0 return 0 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 faded bitmap c bitmap bmp cdc ddc colorref bgcol col 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 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 lighten color col 0 3 ddc select object pddc old bmp bcmenu getfadedbitmap 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 bitmap bmwidth bitmap bmheight getpixel setpixel lightencolor selectobject pddcoldbmp void bc menu get transparent bitmap c bitmap bmp cdc ddc colorref bgcol col newcol 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 rgb 192 192 192 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 newcol get sys color color 3dface 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 newcol ddc select object pddc old bmp bcmenu gettransparentbitmap cbitmap bitmap getbitmap bitmap createcompatibledc cbitmap pddcoldbmp selectobject cbrush cbitmap createcompatibledc createcompatiblebitmap bitmap bmwidth bitmap bmheight createsolidbrush cbitmap pddcoldbmp2 selectobject crect bitmap bmwidth bitmap bmheight fillrect getpixel deleteobject selectobject pddcoldbmp2 getsyscolor color_3dface bitmap bmwidth bitmap bmheight getpixel setpixel selectobject pddcoldbmp 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 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 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 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 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 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 m crcolors btnst color bk in get sys color color btnface m crcolors btnst color fg in get sys color color btntext m crcolors btnst color bk out get sys color color btnface m crcolors btnst color fg out get sys color color btntext m crcolors btnst color bk focus get sys color color btnface m crcolors btnst color fg focus get sys color color btntext if b repaint invalidate return btnst ok cbuttonst setdefaultcolors brepaint m_crcolors btnst_color_bk_in getsyscolor color_btnface m_crcolors btnst_color_fg_in getsyscolor color_btntext m_crcolors btnst_color_bk_out getsyscolor color_btnface m_crcolors btnst_color_fg_out getsyscolor color_btntext m_crcolors btnst_color_bk_focus getsyscolor color_btnface 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 if b repaint invalidate return btnst ok cbuttonst setcolor bycolorindex crcolor brepaint bycolorindex btnst_max_colors btnst_invalidindex m_crcolors bycolorindex crcolor 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 255 by red if by green sh offset 255 sh offsetg 255 by green if by blue sh offset 255 sh offsetb 255 by blue sh offset min min sh offsetr sh offsetg sh offsetb if else if by red sh offset 0 sh offsetr by red if by green sh offset 0 sh offsetg by green if by blue sh offset 0 sh offsetb 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 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 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 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 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 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 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 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_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 icon 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 0 0 0 set icon when the mouse is out the button if n icon out if n icon out int btnst auto gray h icon out btnst auto gray else h icon out hicon load image h inst resource makeintresource n icon out image icon 0 0 0 if return set icon h icon in h icon out cbuttonst seticon niconin niconout hiconin hiconout hinstresource hinstresource afxfindresourcehandle niconin rt_group_icon hiconin loadimage hinstresource niconin image_icon niconout niconout btnst_auto_gray hiconout btnst_auto_gray hiconout loadimage hinstresource niconout image_icon seticon hiconin hiconout 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 if h icon out btnst auto gray h icon out create grayscale icon h icon in if 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 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 if n bitmap out h bitmap out hbitmap load image h inst resource makeintresource n bitmap out image bitmap 0 0 0 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 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 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 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 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 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 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 dword c buttonst set sound lpctstr lpsz sound hmodule h mod bool b play on click bool b play async byte by index b play on click 1 0 store new sound if lpsz sound if h mod from resource identifier m cssounds by index lpsz sound lpsz sound if else tcscpy m cssounds by index sz sound lpsz sound m cssounds by index lpsz sound m cssounds by index sz sound else m cssounds by index h mod h mod m cssounds by index dw flags snd nodefault snd nowait m cssounds by index dw flags h mod snd resource snd filename m cssounds by index dw flags b play async snd async snd sync if else or remove any existing zero memory m cssounds by index sizeof struct sound else return btnst ok cbuttonst setsound lpszsound hmod bplayonclick bplayasync byindex bplayonclick lpszsound hmod m_cssounds byindex lpszsound lpszsound _tcscpy m_cssounds byindex szsound lpszsound m_cssounds byindex lpszsound m_cssounds byindex szsound m_cssounds byindex hmod hmod m_cssounds byindex dwflags snd_nodefault snd_nowait m_cssounds byindex dwflags hmod snd_resource snd_filename m_cssounds byindex dwflags bplayasync snd_async snd_sync zeromemory m_cssounds byindex struct_sound 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 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 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 c wnd p wnd get parent get next dlg tab item this if p wnd p wnd set focus else get parent set focus cancel hover if cbuttonst onenable benable cbutton onenable benable benable cwnd pwnd getparent getnextdlgtabitem pwnd pwnd setfocus getparent setfocus 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 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 return hbrush get stock object null brush cbuttonst ctlcolor 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 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 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 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 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 wparam bst_checked bst_indeterminate setcheck setcheck lresult c buttonst on get check wparam w param lparam l param assert m bischeckbox return get check cbuttonst ongetcheck wparam 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 cancel hover return 0 cbuttonst onmouseleave wparam 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 0 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 m csbitmaps 1 h bitmap null 0 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 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 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 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_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 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 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 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 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 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 m crcolors btnst color bk in get sys color color btnface m crcolors btnst color fg in get sys color color btntext m crcolors btnst color bk out get sys color color btnface m crcolors btnst color fg out get sys color color btntext m crcolors btnst color bk focus get sys color color btnface m crcolors btnst color fg focus get sys color color btntext if b repaint invalidate return btnst ok cbuttonst setdefaultcolors brepaint m_crcolors btnst_color_bk_in getsyscolor color_btnface m_crcolors btnst_color_fg_in getsyscolor color_btntext m_crcolors btnst_color_bk_out getsyscolor color_btnface m_crcolors btnst_color_fg_out getsyscolor color_btntext m_crcolors btnst_color_bk_focus getsyscolor color_btnface 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 if b repaint invalidate return btnst ok cbuttonst setcolor bycolorindex crcolor brepaint bycolorindex btnst_max_colors btnst_invalidindex m_crcolors bycolorindex crcolor 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 255 by red if by green sh offset 255 sh offsetg 255 by green if by blue sh offset 255 sh offsetb 255 by blue sh offset min min sh offsetr sh offsetg sh offsetb if else if by red sh offset 0 sh offsetr by red if by green sh offset 0 sh offsetg by green if by blue sh offset 0 sh offsetb 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 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 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 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 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 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 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 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_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 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 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 dword c buttonst set sound lpctstr lpsz sound hmodule h mod bool b play on click bool b play async byte by index b play on click 1 0 store new sound if lpsz sound if h mod from resource identifier m cssounds by index lpsz sound lpsz sound if else tcscpy m cssounds by index sz sound lpsz sound m cssounds by index lpsz sound m cssounds by index sz sound else m cssounds by index h mod h mod m cssounds by index dw flags snd nodefault snd nowait m cssounds by index dw flags h mod snd resource snd filename m cssounds by index dw flags b play async snd async snd sync if else or remove any existing zero memory m cssounds by index sizeof struct sound else return btnst ok cbuttonst setsound lpszsound hmod bplayonclick bplayasync byindex bplayonclick lpszsound hmod m_cssounds byindex lpszsound lpszsound _tcscpy m_cssounds byindex szsound lpszsound m_cssounds byindex lpszsound m_cssounds byindex szsound m_cssounds byindex hmod hmod m_cssounds byindex dwflags snd_nodefault snd_nowait m_cssounds byindex dwflags hmod snd_resource snd_filename m_cssounds byindex dwflags bplayasync snd_async snd_sync zeromemory m_cssounds byindex struct_sound 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 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 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 c wnd p wnd get parent get next dlg tab item this if p wnd p wnd set focus else get parent set focus cancel hover if cbuttonst onenable benable cbutton onenable benable benable cwnd pwnd getparent getnextdlgtabitem pwnd pwnd setfocus getparent setfocus 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 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 return hbrush get stock object null brush cbuttonst ctlcolor 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 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 wparam bst_checked bst_indeterminate setcheck setcheck lresult c buttonst on get check wparam w param lparam l param assert m bischeckbox return get check cbuttonst ongetcheck wparam 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 cancel hover return 0 cbuttonst onmouseleave wparam 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 0 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 m csbitmaps 1 h bitmap null 0 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 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 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 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_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 auto rich edit ctrl c auto rich edit ctrl cautoricheditctrl cautoricheditctrl long c auto rich edit ctrl get selection font size charformat cf get char format long n size cf y height 20 return n size cautoricheditctrl getselectionfontsize getcharformat nsize yheight nsize c string c auto rich edit ctrl get selection font name charformat cf get char format c string s name cf sz face name return s name cstring cautoricheditctrl getselectionfontname getcharformat cstring sname szfacename sname void c auto rich edit ctrl get system fonts c string array sa font list cdc pdc getdc enum fonts pdc get safe hdc null fontenumproc cb enum fonts lparam sa font list enumerate cautoricheditctrl getsystemfonts cstringarray safontlist enumfonts getsafehdc cbenumfonts safontlist void c auto rich edit ctrl set font size int n point size charformat cf get char format n point size 20 convert from to twips cf y height n point size cf dw mask cfm size set selection char format cf cautoricheditctrl setfontsize npointsize getcharformat npointsize yheight npointsize dwmask cfm_size setselectioncharformat void c auto rich edit ctrl set font name c string s font name charformat cf get char format set the font name for int i 0 i s font name get length 1 i cf sz face name i s font name i cf dw mask cfm face set selection char format cf cautoricheditctrl setfontname cstring sfontname getcharformat sfontname getlength szfacename sfontname dwmask cfm_face setselectioncharformat void c auto rich edit ctrl select color c color dialog dlg charformat cf get char format if cf dw effects cfe autocolor cf dw effects cfe autocolor get a color from the common color dialog if dlg do modal idok cf cr text color dlg get color cf dw mask cfm color set selection char format cf cautoricheditctrl selectcolor ccolordialog getcharformat dweffects cfe_autocolor dweffects cfe_autocolor domodal crtextcolor getcolor dwmask cfm_color setselectioncharformat bool c auto rich edit ctrl paragraph is bulleted paraformat pf get paragraph format if pf w numbering pfn bullet return true else return false cautoricheditctrl paragraphisbulleted getparagraphformat wnumbering pfn_bullet void c auto rich edit ctrl set paragraph bulleted paraformat paraformat get paragraph format if paraformat dw mask pfm numbering paraformat w numbering pfn bullet paraformat w numbering 0 paraformat dx offset 0 paraformat dx start indent 0 paraformat dw mask pfm numbering pfm startindent pfm offset else paraformat w numbering pfn bullet paraformat dw mask pfm numbering if paraformat dx offset 0 paraformat dx offset 4 paraformat dw mask pfm numbering pfm startindent pfm offset set para format paraformat cautoricheditctrl setparagraphbulleted getparagraphformat dwmask pfm_numbering wnumbering pfn_bullet wnumbering dxoffset dxstartindent dwmask pfm_numbering pfm_startindent pfm_offset wnumbering pfn_bullet dwmask pfm_numbering dxoffset dxoffset dwmask pfm_numbering pfm_startindent pfm_offset setparaformat void c auto rich edit ctrl set selection strike out long start 0 end 0 get sel start end set char style cfm strikeout cfe strikeout start end cautoricheditctrl setselectionstrikeout getsel setcharstyle cfm_strikeout cfe_strikeout paraformat c auto rich edit ctrl get paragraph format paraformat pf pf cb size sizeof paraformat pf dw mask pfm alignment pfm numbering get para format pf return pf cautoricheditctrl getparagraphformat cbsize dwmask pfm_alignment pfm_numbering getparaformat bool c auto rich edit ctrl paragraph is right paraformat pf get paragraph format if pf w alignment pfa right return true else return false cautoricheditctrl paragraphisright getparagraphformat walignment pfa_right bool c auto rich edit ctrl paragraph is left paraformat pf get paragraph format if pf w alignment pfa left return true else return false cautoricheditctrl paragraphisleft getparagraphformat walignment pfa_left bool c auto rich edit ctrl paragraph is centered paraformat pf get paragraph format if pf w alignment pfa center return true else return false cautoricheditctrl paragraphiscentered getparagraphformat walignment pfa_center void c auto rich edit ctrl set paragraph right paraformat para format para format cb size sizeof paraformat para format dw mask pfm alignment para format w alignment pfa right set para format para format cautoricheditctrl setparagraphright paraformat paraformat cbsize paraformat dwmask pfm_alignment paraformat walignment pfa_right setparaformat paraformat void c auto rich edit ctrl set paragraph left paraformat para format para format cb size sizeof paraformat para format dw mask pfm alignment para format w alignment pfa left set para format para format cautoricheditctrl setparagraphleft paraformat paraformat cbsize paraformat dwmask pfm_alignment paraformat walignment pfa_left setparaformat paraformat void c auto rich edit ctrl set paragraph center paraformat para format para format cb size sizeof paraformat para format dw mask pfm alignment para format w alignment pfa center set para format para format set the paragraph cautoricheditctrl setparagraphcenter paraformat paraformat cbsize paraformat dwmask pfm_alignment paraformat walignment pfa_center setparaformat paraformat charformat c auto rich edit ctrl get char format dword dw mask charformat cf cf cb size sizeof charformat cf dw mask dw mask get selection char format cf return cf cautoricheditctrl getcharformat dwmask cbsize dwmask dwmask getselectioncharformat bool c auto rich edit ctrl selection is bold charformat cf get char format if cf dw effects cfm bold return true else return false cautoricheditctrl selectionisbold getcharformat dweffects cfm_bold bool c auto rich edit ctrl selection is italic charformat cf get char format if cf dw effects cfm italic return true else return false cautoricheditctrl selectionisitalic getcharformat dweffects cfm_italic bool c auto rich edit ctrl selection is underlined charformat cf get char format if cf dw effects cfm underline return true else return false cautoricheditctrl selectionisunderlined getcharformat dweffects cfm_underline void c auto rich edit ctrl set text color colorref cf color charformat cf get char format if cf dw effects cfe autocolor cf dw effects cfe autocolor cf cr text color cf color cf dw mask cfm color set selection char format cf cautoricheditctrl settextcolor cfcolor getcharformat dweffects cfe_autocolor dweffects cfe_autocolor crtextcolor cfcolor dwmask cfm_color setselectioncharformat void c auto rich edit ctrl set selection bold long start 0 end 0 get sel start end get the current selection set char style cfm bold cfe bold start end make it bold cautoricheditctrl setselectionbold getsel setcharstyle cfm_bold cfe_bold void c auto rich edit ctrl set selection italic long start 0 end 0 get sel start end set char style cfm italic cfe italic start end cautoricheditctrl setselectionitalic getsel setcharstyle cfm_italic cfe_italic void c auto rich edit ctrl set selection underlined long start 0 end 0 get sel start end set char style cfm underline cfe underline start end cautoricheditctrl setselectionunderlined getsel setcharstyle cfm_underline cfe_underline void c auto rich edit ctrl setrtf c string srtf put the rtf string srtf into the rich edit control read the text in editstream es es dw error 0 es pfn callback cb stream in es dw cookie dword srtf stream in sf rtf sf unicode es do it cautoricheditctrl cstring dwerror pfncallback cbstreamin dwcookie streamin sf_rtf sf_unicode c string c auto rich edit ctrl getrtf return the rtf string of the text in the control stream out here editstream es es dw error 0 es pfn callback cb stream out set the callback c string srtf es dw cookie dword srtf so srtf receives the string stream out sf rtf sf unicode es call c rich edit ctrl stream out to get the string return srtf cstring cautoricheditctrl dwerror pfncallback cbstreamout cstring dwcookie streamout sf_rtf sf_unicode cricheditctrl streamout c auto rich edit ctrl c auto rich edit ctrl cautoricheditctrl cautoricheditctrl uint c auto rich edit ctrl on get dlg code return dlgc wantallkeys cautoricheditctrl ongetdlgcode dlgc_wantallkeys void c auto rich edit ctrl onr button up uint n flags c point point so we will get the popup in win 9x c note p note c note get parent client to screen point p note on context menu this point cautoricheditctrl onrbuttonup nflags cpoint cnote pnote cnote getparent clienttoscreen pnote oncontextmenu void c auto rich edit ctrl set char style int mask int style int n start int n end charformat cf cf cb size sizeof charformat cf dw mask mask get selection char format cf if cf dw mask mask selection is all the same cf dw effects style else cf dw effects style cf dw mask mask set selection char format cf cautoricheditctrl setcharstyle nstart nend cbsize dwmask getselectioncharformat dwmask dweffects dweffects dwmask setselectioncharformat dword callback c auto rich edit ctrl cb stream in dword dw cookie lpbyte pb buff long cb long pcb c string pstr c string dw cookie pcb pstr get length if defined unicode defined unicode c string a pstr int i length i multibyte wchar pwc unicode char pc dest c string sz result i length pstr get length pwc unicode wchar malloc sizeof wchar i length 1 pc dest char malloc 2 i length 1 memset pwc unicode 0 sizeof wchar i length 1 memset pc dest 0 sizeof char i length 1 tcscpy pwc unicode a to utf 8 i multibyte wide char to multi byte cp utf8 0 pwc unicode i length pc dest 2 i length null null sz result c string pc dest sz result sz result left i multibyte pc dest i multibyte 0 if pstr get length cb memcpy pb buff pc dest i multibyte else pcb cb memcpy pb buff pc dest cb pstr pstr right pstr get length cb free pwc unicode free pc dest return 0 else if pstr get length cb pcb pstr get length memcpy pb buff pstr pcb pstr empty else pcb cb memcpy pb buff pstr pcb pstr pstr right pstr get length cb return 0 endif cautoricheditctrl cbstreamin dwcookie pbbuff cstring cstring dwcookie getlength _unicode cstring ilength imultibyte pwcunicode pcdest cstring szresult ilength getlength pwcunicode ilength pcdest ilength pwcunicode ilength pcdest ilength _tcscpy pwcunicode imultibyte widechartomultibyte cp_utf8 pwcunicode ilength pcdest ilength szresult cstring pcdest szresult szresult imultibyte pcdest imultibyte getlength pbbuff pcdest imultibyte pbbuff pcdest getlength pwcunicode pcdest getlength getlength pbbuff pbbuff getlength dword callback c auto rich edit ctrl cb stream out dword dw cookie lpbyte pb buff long cb long pcb address of our string var is in ps entry c string ps entry c string dw cookie c string tmp entry tmp entry c string pb buff and write it ps entry tmp entry left cb return 0 cautoricheditctrl cbstreamout dwcookie pbbuff psentry cstring psentry cstring dwcookie cstring tmpentry tmpentry cstring pbbuff psentry tmpentry bool callback c auto rich edit ctrl cb enum fonts lplogfont lplf lptextmetric lptm dword dw type lparam lp data this function was written with the help of c cust combo box by girish bharadwaj available from codeguru if dw type truetype fonttype c string array lp data add lplf lf face name return true cautoricheditctrl cbenumfonts dwtype lpdata ccustcombobox dwtype truetype_fonttype cstringarray lpdata lffacename void c note show buttons determine which buttons to show and where to show them c rect rc get client rect rc int i where rc right 20 show the alarm button if m busealarm m palarm get safe hwnd m palarm move window 5 4 16 16 m palarm show window sw show always show the close button if m pclose get safe hwnd m pclose move window i where 4 16 16 m pclose show window sw show i where 18 place the rest of the buttons for int i 1 i 10 i minimize if the app m itoolbaruseminimize i m pminimize get safe hwnd m pminimize move window i where 4 16 16 m pminimize show window sw show i where 18 slide right if the app m itoolbaruseslideright i m pslideright get safe hwnd m pslideright move window i where 4 16 16 m pslideright show window sw show i where 18 slide left if the app m itoolbaruseslideleft i m pslideleft get safe hwnd m pslideleft move window i where 4 16 16 m pslideleft show window sw show i where 18 bullet if the app m itoolbarusebullet i m pbullet get safe hwnd m pbullet move window i where 4 16 16 m pbullet show window sw show i where 18 underline if the app m itoolbaruseunderline i m punderline get safe hwnd m punderline move window i where 4 16 16 m punderline show window sw show i where 18 strikeout if the app m itoolbarusestrikeout i m pstrikeout get safe hwnd m pstrikeout move window i where 4 16 16 m pstrikeout show window sw show i where 18 italic if the app m itoolbaruseitalic i m pitalic get safe hwnd m pitalic move window i where 4 16 16 m pitalic show window sw show i where 18 bold if the app m itoolbarusebold i m pbold get safe hwnd m pbold move window i where 4 16 16 m pbold show window sw show i where 18 calculate the maximal length of the title to avoid that the text is crashing into the toolbar buttons if m busealarm m ititlemaxwidth i where 5 else m ititlemaxwidth i where 18 resize the title via on paint invalidate cnote showbuttons crect getclientrect iwhere m_busealarm m_palarm getsafehwnd m_palarm movewindow m_palarm showwindow sw_show m_pclose getsafehwnd m_pclose movewindow iwhere m_pclose showwindow sw_show iwhere theapp m_itoolbaruseminimize m_pminimize getsafehwnd m_pminimize movewindow iwhere m_pminimize showwindow sw_show iwhere theapp m_itoolbaruseslideright m_pslideright getsafehwnd m_pslideright movewindow iwhere m_pslideright showwindow sw_show iwhere theapp m_itoolbaruseslideleft m_pslideleft getsafehwnd m_pslideleft movewindow iwhere m_pslideleft showwindow sw_show iwhere theapp m_itoolbarusebullet m_pbullet getsafehwnd m_pbullet movewindow iwhere m_pbullet showwindow sw_show iwhere theapp m_itoolbaruseunderline m_punderline getsafehwnd m_punderline movewindow iwhere m_punderline showwindow sw_show iwhere theapp m_itoolbarusestrikeout m_pstrikeout getsafehwnd m_pstrikeout movewindow iwhere m_pstrikeout showwindow sw_show iwhere theapp m_itoolbaruseitalic m_pitalic getsafehwnd m_pitalic movewindow iwhere m_pitalic showwindow sw_show iwhere theapp m_itoolbarusebold m_pbold getsafehwnd m_pbold movewindow iwhere m_pbold showwindow sw_show iwhere m_busealarm m_ititlemaxwidth iwhere m_ititlemaxwidth iwhere onpaint void c note hide buttons m palarm show window sw hide m pclose show window sw hide m pbullet show window sw hide m pminimize show window sw hide m pclose show window sw hide m pslideright show window sw hide m pslideleft show window sw hide m pbold show window sw hide m pitalic show window sw hide m punderline show window sw hide m pstrikeout show window sw hide cnote hidebuttons m_palarm showwindow sw_hide m_pclose showwindow sw_hide m_pbullet showwindow sw_hide m_pminimize showwindow sw_hide m_pclose showwindow sw_hide m_pslideright showwindow sw_hide m_pslideleft showwindow sw_hide m_pbold showwindow sw_hide m_pitalic showwindow sw_hide m_punderline showwindow sw_hide m_pstrikeout showwindow sw_hide void c note close alarm c main frame p main c main frame afx get main wnd close the alarm and reset everything play sound null afx get instance handle snd resource snd async kill timer id noteblink show window sw show p main no animate m bisalarmshouting false cnote closealarm cmainframe pmain cmainframe afxgetmainwnd playsound afxgetinstancehandle snd_resource snd_async killtimer id_noteblink showwindow sw_show pmain noanimate m_bisalarmshouting void c note set border style bool b thin set if the border should be thin or thick if b thin set button color m cfnotecolor if m bvisible m pminimize set bitmaps idb noteminimize1 rgb 100 100 100 idb noteminimize1 rgb 100 100 100 else m pminimize set bitmaps idb noteminimize2 rgb 100 100 100 idb noteminimize2 rgb 100 100 100 if m busealarm m palarm set bitmaps idb notealarm1 rgb 100 100 100 idb notealarm1 rgb 100 100 100 m pbullet set bitmaps idb notebullet1 rgb 100 100 100 idb notebullet1 rgb 100 100 100 m pclose set bitmaps idb noteclose1 rgb 100 100 100 idb noteclose1 rgb 100 100 100 m pslideright set bitmaps idb slideright1 rgb 100 100 100 idb slideright1 rgb 100 100 100 m pslideleft set bitmaps idb slideleft1 rgb 100 100 100 idb slideleft1 rgb 100 100 100 m pbold set bitmaps idb bold1 rgb 100 100 100 idb bold1 rgb 100 100 100 m punderline set bitmaps idb underline1 rgb 100 100 100 idb underline1 rgb 100 100 100 m pstrikeout set bitmaps idb strikeout1 rgb 100 100 100 idb strikeout1 rgb 100 100 100 m pitalic set bitmaps idb italic1 rgb 100 100 100 idb italic1 rgb 100 100 100 m ptext set background color false m cfnotecolor invalidate else set button color rgb 130 130 130 m pbullet set bitmaps idb notebullet rgb 100 100 100 idb notebullet rgb 100 100 100 m pclose set bitmaps idb noteclose rgb 100 100 100 idb noteclose rgb 100 100 100 m pslideright set bitmaps idb slideright rgb 100 100 100 idb slideright rgb 100 100 100 m pslideleft set bitmaps idb slideleft rgb 100 100 100 idb slideleft rgb 100 100 100 m punderline set bitmaps idb underline rgb 100 100 100 idb underline rgb 100 100 100 m pstrikeout set bitmaps idb strikeout rgb 100 100 100 idb strikeout rgb 100 100 100 m pitalic set bitmaps idb italic rgb 100 100 100 idb italic rgb 100 100 100 if m bvisible m pminimize set bitmaps idb noteminimize rgb 100 100 100 idb noteminimize rgb 100 100 100 else m pminimize set bitmaps idb noteminimize3 rgb 100 100 100 idb noteminimize3 rgb 100 100 100 m palarm set bitmaps idb notealarm rgb 100 100 100 idb notealarm rgb 100 100 100 m ptext set background color false m cfnotecolor invalidate cnote setborderstyle bthin bthin setbuttoncolor m_cfnotecolor m_bvisible m_pminimize setbitmaps idb_noteminimize1 idb_noteminimize1 m_pminimize setbitmaps idb_noteminimize2 idb_noteminimize2 m_busealarm m_palarm setbitmaps idb_notealarm1 idb_notealarm1 m_pbullet setbitmaps idb_notebullet1 idb_notebullet1 m_pclose setbitmaps idb_noteclose1 idb_noteclose1 m_pslideright setbitmaps idb_slideright1 idb_slideright1 m_pslideleft setbitmaps idb_slideleft1 idb_slideleft1 m_pbold setbitmaps idb_bold1 idb_bold1 m_punderline setbitmaps idb_underline1 idb_underline1 m_pstrikeout setbitmaps idb_strikeout1 idb_strikeout1 m_pitalic setbitmaps idb_italic1 idb_italic1 m_ptext setbackgroundcolor m_cfnotecolor setbuttoncolor m_pbullet setbitmaps idb_notebullet idb_notebullet m_pclose setbitmaps idb_noteclose idb_noteclose m_pslideright setbitmaps idb_slideright idb_slideright m_pslideleft setbitmaps idb_slideleft idb_slideleft m_punderline setbitmaps idb_underline idb_underline m_pstrikeout setbitmaps idb_strikeout idb_strikeout m_pitalic setbitmaps idb_italic idb_italic m_bvisible m_pminimize setbitmaps idb_noteminimize idb_noteminimize m_pminimize setbitmaps idb_noteminimize3 idb_noteminimize3 m_palarm setbitmaps idb_notealarm idb_notealarm m_ptext setbackgroundcolor m_cfnotecolor void c note stay not on top stay not on top set window pos wnd no top most 0 0 0 0 swp nomove swp nosize cnote staynotontop setwindowpos wndnotopmost swp_nomove swp_nosize void c note stay on top stay on top set window pos wnd top most 0 0 0 0 swp nomove swp nosize cnote stayontop setwindowpos wndtopmost swp_nomove swp_nosize void c note set transparancy int i normal int i minimized set the trasparency only win2k and xp if m bvisible m pposition get slided to left m pposition get slided to right the app m layered set transparent percentage m hwnd i normal else the app m layered set transparent percentage m hwnd i minimized cnote settransparancy inormal iminimized m_bvisible m_pposition getslidedtoleft m_pposition getslidedtoright theapp m_layered settransparentpercentage m_hwnd inormal theapp m_layered settransparentpercentage m_hwnd iminimized void c note show alarm c main frame p main c main frame afx get main wnd the alarm will be played if the app m bplayalarmsound the app m szalarmsoundfile is empty play sound the app m szalarmsoundfile afx get instance handle snd filename snd async change the tray icon p main animate tray alarm set the window to top set window pos wnd top most 0 0 0 0 swp nomove swp nosize start to blink set timer id noteblink 1000 timerproc null show that the alarm is shouting m bisalarmshouting true cnote showalarm cmainframe pmain cmainframe afxgetmainwnd theapp m_bplayalarmsound theapp m_szalarmsoundfile isempty playsound theapp m_szalarmsoundfile afxgetinstancehandle snd_filename snd_async pmain animatetrayalarm setwindowpos wndtopmost swp_nomove swp_nosize settimer id_noteblink m_bisalarmshouting c dialog c note idd p parent initialize m bbelongstorecyclebin false m sznoteid m inoteversion 0 m bisalarmshouting false m busealarm false m alarm c ole date time get current time m sztitle get default title m sztext m bvisible true srand unsigned time null for int i 0 i 50 i m sznoteid set at i rand 1 70 1 33 the note s color if the app m brndnotecolor int i color 8 rgb 255 128 128 rgb 255 255 128 rgb 128 255 128 rgb 128 255 255 rgb 255 128 64 rgb 0 128 128 rgb 0 128 192 rgb 255 0 0 int i rnd rand 1 8 1 m cfnotecolor i color i rnd else m cfnotecolor the app m cfnotecolor afx data init c note afx data init cdialog cnote pparent m_bbelongstorecyclebin m_sznoteid m_inoteversion m_bisalarmshouting m_busealarm m_alarm coledatetime getcurrenttime m_sztitle getdefaulttitle m_sztext m_bvisible m_sznoteid setat theapp m_brndnotecolor icolor irnd m_cfnotecolor icolor irnd m_cfnotecolor theapp m_cfnotecolor afx_data_init cnote afx_data_init void c note set button color colorref cf color for int i 0 i 6 i m pclose set color i cf color true m pminimize set color i cf color true m palarm set color i cf color true m pbullet set color i cf color true m pslideright set color i cf color true m pslideleft set color i cf color true m pbold set color i cf color true m punderline set color i cf color true m pitalic set color i cf color true m pstrikeout set color i cf color true cnote setbuttoncolor cfcolor m_pclose setcolor cfcolor m_pminimize setcolor cfcolor m_palarm setcolor cfcolor m_pbullet setcolor cfcolor m_pslideright setcolor cfcolor m_pslideleft setcolor cfcolor m_pbold setcolor cfcolor m_punderline setcolor cfcolor m_pitalic setcolor cfcolor m_pstrikeout setcolor cfcolor void c note initialize initialize the note c rect r r1 r1 m pposition get note position r m pposition get slided note position m ptext setrtf m sztext m pposition set slided note position r this false m pposition set note position r1 this false make sure that the note is within the monitor m pposition fix note position this is it slided to the left if m pposition get slided to left m ptext show window sw hide hide buttons is it slided to the right if m pposition get slided to right m ptext show window sw hide hide buttons m bvisible m bvisible false m bvisible true m ioldheight m pposition get note position bottom on minimize if the app m bminimizeshrink show window sw show if m busealarm m pposition get slided to left m pposition get slided to right m palarm show window sw show set border style the app m bthinnoteborder invalidate cnote crect m_pposition getnoteposition m_pposition getslidednoteposition m_ptext m_sztext m_pposition setslidednoteposition m_pposition setnoteposition m_pposition fixnoteposition m_pposition getslidedtoleft m_ptext showwindow sw_hide hidebuttons m_pposition getslidedtoright m_ptext showwindow sw_hide hidebuttons m_bvisible m_bvisible m_bvisible m_ioldheight m_pposition getnoteposition onminimize theapp m_bminimizeshrink showwindow sw_show m_busealarm m_pposition getslidedtoleft m_pposition getslidedtoright m_palarm showwindow sw_show setborderstyle theapp m_bthinnoteborder void c note restore note show it again if the app m bminimizeshrink m bvisible true c rect rc system parameters info spi getworkarea 0 rc 0 set transparancy the app m itransparantnormal the app m itransparantminimized if rc bottom m pposition get note position top m ioldheight c rect c rect c rect m pposition get note position c rect top rc bottom m ioldheight m pposition set note position c rect this false m pposition set docked bottom true this true move window m pposition get note position left m pposition get note position top m pposition get note position right m ioldheight move the cursor to the minimize button if the app m bminimizemovecursor c rect rect m pminimize get window rect rect set cursor pos rect left 8 m pposition get note position top 10 changed by leonardo zide lmz else m bvisible true set transparancy the app m itransparantnormal the app m itransparantminimized show window sw show if the app m bthinnoteborder m pminimize set bitmaps idb noteminimize1 rgb 100 100 100 idb noteminimize1 rgb 100 100 100 else m pminimize set bitmaps idb noteminimize rgb 100 100 100 idb noteminimize rgb 100 100 100 cnote restorenote theapp m_bminimizeshrink m_bvisible crect systemparametersinfo spi_getworkarea settransparancy theapp m_itransparantnormal theapp m_itransparantminimized m_pposition getnoteposition m_ioldheight crect crect crect m_pposition getnoteposition crect m_ioldheight m_pposition setnoteposition crect m_pposition setdockedbottom movewindow m_pposition getnoteposition m_pposition getnoteposition m_pposition getnoteposition m_ioldheight theapp m_bminimizemovecursor crect m_pminimize getwindowrect setcursorpos m_pposition getnoteposition m_bvisible settransparancy theapp m_itransparantnormal theapp m_itransparantminimized showwindow sw_show theapp m_bthinnoteborder m_pminimize setbitmaps idb_noteminimize1 idb_noteminimize1 m_pminimize setbitmaps idb_noteminimize idb_noteminimize void c note minimize note if m bvisible on minimize cnote minimizenote m_bvisible onminimize c string c note get readable text get the text from the textbox in a readable mode not rtf this is used so we can read the text from the server if we want to read the notes from the web c string sz text m ptext get window text sz text return sz text cstring cnote getreadabletext cstring sztext m_ptext getwindowtext sztext sztext c rect c note get position if m bvisible return m pposition get note position else return c rect m pposition get note position left m pposition get note position top m pposition get note position right m ioldheight crect cnote getposition m_bvisible m_pposition getnoteposition crect m_pposition getnoteposition m_pposition getnoteposition m_pposition getnoteposition m_ioldheight c rect c note get slide position return c rect m pposition get slided note position left m pposition get slided note position top m pposition get slided note position right m pposition get slided note position bottom crect cnote getslideposition crect m_pposition getslidednoteposition m_pposition getslidednoteposition m_pposition getslidednoteposition m_pposition getslidednoteposition void c note on context menu c wnd p wnd c point point bc menu menu menu load menu idr popupmenu menu load toolbar idr menubar bc menu psub bc menu menu get sub menu 0 psub set menu text id popupmenu cut c translate read string 27 t cut mf string psub set menu text id popupmenu copy c translate read string 28 t copy mf string psub set menu text id popupmenu paste c translate read string 29 t paste mf string psub set menu text id popupmenu font c translate read string 30 t font mf string psub set menu text id popupmenu notecolor c translate read string 31 t note color mf string psub set menu text id popupmenu settitle c translate read string 32 t set title mf string psub set menu text id popupmenu alarm c translate read string 33 t alarm mf string psub set menu text id popupmenu email c translate read string 34 t email mf string psub set menu text id popupmenu print c translate read string 35 t print mf string psub track popup menu tpm leftalign tpm rightbutton point x point y this menu destroy menu cnote oncontextmenu cwnd pwnd cpoint bcmenu loadmenu idr_popupmenu loadtoolbar idr_menubar bcmenu bcmenu getsubmenu setmenutext id_popupmenu_cut ctranslate readstring _t mf_string setmenutext id_popupmenu_copy ctranslate readstring _t mf_string setmenutext id_popupmenu_paste ctranslate readstring _t mf_string setmenutext id_popupmenu_font ctranslate readstring _t mf_string setmenutext id_popupmenu_notecolor ctranslate readstring _t mf_string setmenutext id_popupmenu_settitle ctranslate readstring _t mf_string setmenutext id_popupmenu_alarm ctranslate readstring _t mf_string setmenutext id_popupmenu_email ctranslate readstring _t mf_string setmenutext id_popupmenu_print ctranslate readstring _t mf_string trackpopupmenu tpm_leftalign tpm_rightbutton destroymenu bool c note pre translate message msg p msg if p msg message wm keydown get key state vk control 0x8000 switch p msg w param case 0x42 ctrl b m ptext set selection bold break case 0x49 ctrl i m ptext set selection italic p msg w param wm null to avoid that ctrl i becomes a tab break case 0x55 ctrl u m ptext set selection underlined break case 0x50 ctrl p on popupmenu print break return c dialog pre translate message p msg cnote pretranslatemessage pmsg pmsg wm_keydown getkeystate vk_control pmsg wparam m_ptext setselectionbold m_ptext setselectionitalic pmsg wparam wm_null m_ptext setselectionunderlined onpopupmenuprint cdialog pretranslatemessage pmsg void c note do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c note afx data map cnote dodataexchange cdataexchange cdialog dodataexchange afx_data_map cnote afx_data_map void c note restore from right slide we are in the right sliding mode and the use has pressed on the note and therefore we want to slide back where the note were m pposition restore slide from right this show the text and title m ptext show window sw show show buttons the app m layered set transparent percentage m hwnd the app m itransparantnormal invalidate true cnote restorefromrightslide m_pposition restoreslidefromright m_ptext showwindow sw_show showbuttons theapp m_layered settransparentpercentage m_hwnd theapp m_itransparantnormal void c note restore from left slide we are in the right sliding mode and the use has pressed on the note and therefore we want to slide back where the note were m pposition restore slide from left this show the text and title and the buttons m ptext show window sw show show buttons the app m layered set transparent percentage m hwnd the app m itransparantnormal invalidate true cnote restorefromleftslide m_pposition restoreslidefromleft m_ptext showwindow sw_show showbuttons theapp m_layered settransparentpercentage m_hwnd theapp m_itransparantnormal c string c note get default title look if the default title is date or time if date or time is not used then use the default word as stated c string sz temp the app m szdefaulttitle c string sz retur sz temp sz temp make lower int i sz temp find t time if i 1 c string sz time c ole date time get current time format t h m s sz retur replace t time sz time i sz temp find t date if i 1 c string sz time c ole date time get current time format t m d y sz retur replace t date sz time c ole date time p time p time parse date time sz retur return sz retur cstring cnote getdefaulttitle cstring sztemp theapp m_szdefaulttitle cstring szretur sztemp sztemp makelower sztemp _t cstring sztime coledatetime getcurrenttime _t szretur _t sztime sztemp _t cstring sztime coledatetime getcurrenttime _t szretur _t sztime coledatetime ptime ptime parsedatetime szretur szretur void c note paint thin border cdc pdc create pens and brushes c rect rc get client rect rc c pen blackpen c brush notebrush blackpen create pen ps solid 1 rgb 0 0 0 notebrush create solid brush m cfnotecolor create a bitmap in memory avoid flicker cdc p memdc p memdc create compatibledc pdc hbitmap h bitmap h bitmap create compatible bitmap pdc m hdc rc right rc bottom hbitmap p old bmp hbitmap p memdc select object h bitmap paint the note hgdiobj p old pen hgdiobj p memdc select object blackpen hgdiobj p old brush hgdiobj p memdc select object notebrush p memdc select object notebrush p memdc rectangle rc if m pposition get slided to right m pposition get slided to left p memdc move to 3 22 p memdc line to rc right 3 22 bit blt the in memory bitmap pdc bit blt 0 0 rc right rc bottom p memdc 0 0 srccopy clean up p memdc select object p old pen p memdc select object p old brush p memdc select object p old bmp delete object h bitmap blackpen delete object notebrush delete object cnote paintthinborder crect getclientrect cpen cbrush createpen ps_solid createsolidbrush m_cfnotecolor pmemdc pmemdc createcompatibledc hbitmap hbitmap createcompatiblebitmap m_hdc poldbmp pmemdc selectobject hbitmap poldpen pmemdc selectobject poldbrush pmemdc selectobject pmemdc selectobject pmemdc m_pposition getslidedtoright m_pposition getslidedtoleft pmemdc moveto pmemdc lineto bitblt bitblt pmemdc pmemdc selectobject poldpen pmemdc selectobject poldbrush pmemdc selectobject poldbmp deleteobject hbitmap deleteobject deleteobject void c note paint thick border cdc pdc create pens and brushes c rect rc get client rect rc c pen lightpen c pen darkpen c pen blackpen c pen darkestpen c brush notebrush c brush borderbrush lightpen create pen ps solid 1 rgb 195 195 195 darkpen create pen ps solid 1 rgb 130 130 130 darkestpen create pen ps solid 1 rgb 80 80 80 blackpen create pen ps solid 1 rgb 0 0 0 notebrush create solid brush m cfnotecolor borderbrush create solid brush rgb 130 130 130 create a bitmap in memory avoid flicker cdc p memdc p memdc create compatibledc pdc hbitmap h bitmap h bitmap create compatible bitmap pdc m hdc rc right rc bottom hbitmap p old bmp hbitmap p memdc select object h bitmap paint the note p memdc select object notebrush p memdc rectangle rc hgdiobj p old pen hgdiobj p memdc select object darkpen p memdc move to 0 rc bottom 2 p memdc line to 0 0 p memdc move to 0 0 p memdc line to rc right 0 p memdc move to 2 rc bottom 3 p memdc line to 2 1 p memdc move to 3 rc bottom 3 p memdc line to 3 1 p memdc move to 2 rc bottom 3 p memdc line to rc right 2 rc bottom 3 p memdc move to 2 rc bottom 4 p memdc line to rc right 2 rc bottom 4 if m pposition get slided to right m pposition get slided to left p memdc move to rc right 4 rc bottom 4 p memdc line to rc right 4 1 p memdc move to rc right 3 rc bottom 4 p memdc line to rc right 3 1 p memdc move to rc right 5 rc bottom 5 p memdc line to rc right 4 rc bottom 4 p memdc move to rc right 9 rc bottom 5 p memdc line to rc right 4 rc bottom 10 p memdc move to rc right 13 rc bottom 5 p memdc line to rc right 4 rc bottom 14 hgdiobj p old brush hgdiobj p memdc select object borderbrush if m pposition get slided to right m pposition get slided to left p memdc rectangle 2 2 rc right 1 3 else p memdc rectangle 2 2 rc right 1 22 if m pposition get slided to right m pposition get slided to left p memdc select object lightpen p memdc move to 1 rc bottom 2 p memdc line to 1 1 p memdc move to 1 1 p memdc line to rc right 2 1 p memdc move to rc right 8 rc bottom 5 p memdc line to rc right 4 rc bottom 9 p memdc move to rc right 12 rc bottom 5 p memdc line to rc right 4 rc bottom 13 p memdc select object blackpen p memdc move to 1 rc bottom p memdc line to rc right rc bottom p memdc line to rc right 0 p memdc move to rc right 6 rc bottom 5 p memdc line to rc right 4 rc bottom 7 p memdc move to rc right 7 rc bottom 5 p memdc line to rc right 4 rc bottom 8 p memdc move to rc right 10 rc bottom 5 p memdc line to rc right 4 rc bottom 11 p memdc move to rc right 11 rc bottom 5 p memdc line to rc right 4 rc bottom 12 p memdc select object darkestpen p memdc move to 1 rc bottom 2 p memdc line to rc right 2 rc bottom 2 p memdc line to rc right 2 0 bit blt the in memory bitmap pdc bit blt 0 0 rc right rc bottom p memdc 0 0 srccopy clean up p memdc select object p old pen p memdc select object p old brush p memdc select object p old bmp delete object h bitmap lightpen delete object darkpen delete object blackpen delete object darkestpen delete object notebrush delete object borderbrush delete object cnote paintthickborder crect getclientrect cpen cpen cpen cpen cbrush cbrush createpen ps_solid createpen ps_solid createpen ps_solid createpen ps_solid createsolidbrush m_cfnotecolor createsolidbrush pmemdc pmemdc createcompatibledc hbitmap hbitmap createcompatiblebitmap m_hdc poldbmp pmemdc selectobject hbitmap pmemdc selectobject pmemdc poldpen pmemdc selectobject pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto m_pposition getslidedtoright m_pposition getslidedtoleft pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto poldbrush pmemdc selectobject m_pposition getslidedtoright m_pposition getslidedtoleft pmemdc pmemdc m_pposition getslidedtoright m_pposition getslidedtoleft pmemdc selectobject pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc selectobject pmemdc moveto pmemdc lineto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc moveto pmemdc lineto pmemdc selectobject pmemdc moveto pmemdc lineto pmemdc lineto bitblt bitblt pmemdc pmemdc selectobject poldpen pmemdc selectobject poldbrush pmemdc selectobject poldbmp deleteobject hbitmap deleteobject deleteobject deleteobject deleteobject deleteobject deleteobject bool c note on init dialog c dialog on init dialog modify the style the app m layered add layered style m hwnd set the trasparency only win2k and xp set transparancy the app m itransparantnormal the app m itransparantminimized create the text m ptext create ws child es wantreturn es autovscroll es multiline ws visible c rect 0 0 0 0 this id notetext charformat2 c c cb size afx get app get profile int t options font t cb size 0 c dw mask afx get app get profile int t options font t dw mask 0 c dw effects afx get app get profile int t options font t dw effects 0 c y height afx get app get profile int t options font t y height 0 c y offset afx get app get profile int t options font t y offset 0 c cr text color afx get app get profile int t options font t cr text color 0 c b char set afx get app get profile int t options font t b char set 0 c b pitch and family afx get app get profile int t options font t b pitch and family 0 c string sz temp afx get app get profile string t options font t sz face name t tcscpy c sz face name sz temp first time if c cb size 0 m ptext set font get font false else m ptext set selection char format c m ptext send message em autourldetect 1 0 m ptext set event mask enm requestresize enm link create the alarm button m palarm create t ws child ws visible c rect 0 0 0 0 this id notealarm create the minimize button m pminimize create t ws child ws visible c rect 0 0 0 0 this id noteminimize create the close button m pclose create t ws child ws visible c rect 0 0 0 0 this id noteclose create the bullet button m pbullet create t ws child ws visible c rect 0 0 0 0 this id notebullet create the slide right button m pslideright create t ws child ws visible c rect 0 0 0 0 this id slideright create the slide left button m pslideleft create t ws child ws visible c rect 0 0 0 0 this id slideleft create the bold button m pbold create t ws child ws visible c rect 0 0 0 0 this id bold create the italic button m pitalic create t ws child ws visible c rect 0 0 0 0 this id italic create the underline button m punderline create t ws child ws visible c rect 0 0 0 0 this id underline creazte the strikeout button m pstrikeout create t ws child ws visible c rect 0 0 0 0 this id strikeout should it stay on top or not if the app m bstayontop set window pos wnd top most 0 0 0 0 swp nomove swp nosize else set window pos wnd no top most 0 0 0 0 swp nomove swp nosize set border style the app m bthinnoteborder m ptext set focus return false cnote oninitdialog cdialog oninitdialog theapp m_layered addlayeredstyle m_hwnd settransparancy theapp m_itransparantnormal theapp m_itransparantminimized m_ptext ws_child es_wantreturn es_autovscroll es_multiline ws_visible crect id_notetext cbsize afxgetapp getprofileint _t _t cbsize dwmask afxgetapp getprofileint _t _t dwmask dweffects afxgetapp getprofileint _t _t dweffects yheight afxgetapp getprofileint _t _t yheight yoffset afxgetapp getprofileint _t _t yoffset crtextcolor afxgetapp getprofileint _t _t crtextcolor bcharset afxgetapp getprofileint _t _t bcharset bpitchandfamily afxgetapp getprofileint _t _t bpitchandfamily cstring sztemp afxgetapp getprofilestring _t _t szfacename _t _tcscpy szfacename sztemp cbsize m_ptext setfont getfont m_ptext setselectioncharformat m_ptext sendmessage em_autourldetect m_ptext seteventmask enm_requestresize enm_link m_palarm _t ws_child ws_visible crect id_notealarm m_pminimize _t ws_child ws_visible crect id_noteminimize m_pclose _t ws_child ws_visible crect id_noteclose m_pbullet _t ws_child ws_visible crect id_notebullet m_pslideright _t ws_child ws_visible crect id_slideright m_pslideleft _t ws_child ws_visible crect id_slideleft m_pbold _t ws_child ws_visible crect id_bold m_pitalic _t ws_child ws_visible crect id_italic m_punderline _t ws_child ws_visible crect id_underline m_pstrikeout _t ws_child ws_visible crect id_strikeout theapp m_bstayontop setwindowpos wndtopmost swp_nomove swp_nosize setwindowpos wndnotopmost swp_nomove swp_nosize setborderstyle theapp m_bthinnoteborder m_ptext setfocus bool c note on erase bkgnd cdc pdc return true cnote onerasebkgnd void c note on paint c paintdc dc this cdc pdc pdc getdc if the app m bthinnoteborder paint thin border pdc else paint thick border pdc write the title s text note that we have to check if the title won t fit to the left of the buttons if the text doesn t fit end the title with in the right place if m pposition get slided to left m pposition get slided to right int i start c font font c font p font font create font 12 0 0 0 fw normal false false 0 the app m icharset out default precis clip default precis default quality ff modern t arial p font pdc select object font pdc set text color rgb 0 0 0 pdc set bk color get note color be sure that the text isn t too long if so terminate the text with c size size c string sz title sz title get title size pdc get text extent sz title sz title get length if size cx m ititlemaxwidth while size cx m ititlemaxwidth is this the first time if sz title right 3 t if sz title get length 3 sz title sz title left sz title get length 3 sz title t else sz title t else if sz title get length 4 sz title sz title left sz title get length 4 sz title t else sz title t if sz title t break get the new length in pixels size pdc get text extent sz title sz title get length where should the text start i start m busealarm 22 5 if defined unicode defined unicode text outw pdc get safe hdc i start 5 sz title sz title get length else pdc text out i start 5 sz title sz title get length endif if m pposition get slided to left c font font c font p font font create font 12 0 900 0 fw normal false false 0 the app m icharset out default precis clip default precis default quality ff modern t arial p font pdc select object font pdc set text color rgb 0 0 0 pdc set bk color get note color c size size size pdc get text extent get title get title get length if defined unicode defined unicode text outw pdc get safe hdc 5 m pposition get note position bottom m pposition get note position bottom size cx 2 get title get title get length else pdc text out 5 m pposition get note position bottom m pposition get note position bottom size cx 2 get title get title get length endif if m pposition get slided to right c font font c font p font font create font 12 0 900 0 fw normal false false 0 the app m icharset out default precis clip default precis default quality ff modern t arial p font pdc select object font pdc set text color rgb 0 0 0 pdc set bk color get note color c size size size pdc get text extent get title get title get length if defined unicode defined unicode text outw pdc get safe hdc 5 m pposition get note position bottom m pposition get note position bottom size cx 2 get title get title get length else pdc text out 5 m pposition get note position bottom m pposition get note position bottom size cx 2 get title get title get length endif m pminimize invalidate false m pclose invalidate false m ptext invalidate false m pslideright invalidate false m pslideleft invalidate false m pbullet invalidate false m pstrikeout invalidate false m pitalic invalidate false m punderline invalidate false m pbold invalidate false cnote onpaint cpaintdc theapp m_bthinnoteborder paintthinborder paintthickborder m_pposition getslidedtoleft m_pposition getslidedtoright istart cfont cfont pfont createfont fw_normal theapp m_icharset out_default_precis clip_default_precis default_quality ff_modern _t pfont selectobject settextcolor setbkcolor getnotecolor csize cstring sztitle sztitle gettitle gettextextent sztitle sztitle getlength m_ititlemaxwidth m_ititlemaxwidth sztitle _t sztitle getlength sztitle sztitle sztitle getlength sztitle _t sztitle _t sztitle getlength sztitle sztitle sztitle getlength sztitle _t sztitle _t sztitle _t gettextextent sztitle sztitle getlength istart m_busealarm _unicode textoutw getsafehdc istart sztitle sztitle getlength textout istart sztitle sztitle getlength m_pposition getslidedtoleft cfont cfont pfont createfont fw_normal theapp m_icharset out_default_precis clip_default_precis default_quality ff_modern _t pfont selectobject settextcolor setbkcolor getnotecolor csize gettextextent gettitle gettitle getlength _unicode textoutw getsafehdc m_pposition getnoteposition m_pposition getnoteposition gettitle gettitle getlength textout m_pposition getnoteposition m_pposition getnoteposition gettitle gettitle getlength m_pposition getslidedtoright cfont cfont pfont createfont fw_normal theapp m_icharset out_default_precis clip_default_precis default_quality ff_modern _t pfont selectobject settextcolor setbkcolor getnotecolor csize gettextextent gettitle gettitle getlength _unicode textoutw getsafehdc m_pposition getnoteposition m_pposition getnoteposition gettitle gettitle getlength textout m_pposition getnoteposition m_pposition getnoteposition gettitle gettitle getlength m_pminimize m_pclose m_ptext m_pslideright m_pslideleft m_pbullet m_pstrikeout m_pitalic m_punderline m_pbold void c note on destroy c dialog on destroy to avoid memory leakage delete this cnote ondestroy cdialog ondestroy uint c note on nc hit test c point point c rect rc screen to client point get client rect rc minimized caption if m pposition get slided to left m pposition get slided to right m bvisible the app m bminimizeshrink point y 25 point y 3 point x 3 point x rc right 3 return htcaption else if m pposition get slided to left m pposition get slided to right m bvisible the app m bminimizeshrink return 0 caption when not slided if m pposition get slided to left m pposition get slided to right point y 25 point y 3 point x 3 point x rc right 3 return htcaption caption when slided if m pposition get slided to left m pposition get slided to right return htclient top if point x 20 point x rc right 20 point y 3 return httop left if point y 20 point y rc bottom 20 point x 3 return htleft bottom if point y rc bottom 3 point x 20 point x rc right 20 return htbottom right if point y 25 point y rc bottom 20 point x rc right 3 return htright upper left if point x 20 point y 20 return httopleft upper right if point x rc right 20 point y 20 return httopright lower left if point x 20 point y rc bottom 20 return htbottomleft lower right if point x rc right 20 point y rc bottom 20 return htbottomright return htclient cnote onnchittest cpoint crect screentoclient getclientrect m_pposition getslidedtoleft m_pposition getslidedtoright m_bvisible theapp m_bminimizeshrink m_pposition getslidedtoleft m_pposition getslidedtoright m_bvisible theapp m_bminimizeshrink m_pposition getslidedtoleft m_pposition getslidedtoright m_pposition getslidedtoleft m_pposition getslidedtoright void c note on size uint n type int cx int cy c dialog on size n type cx cy show buttons save the windows state if m pposition get slided to left m pposition get slided to right c rect c rect c rect m pposition get note position c rect right cx c rect bottom cy m pposition set note position c rect this true if m ptext get safe hwnd m ptext move window 5 25 cx 12 cy 35 invalidate false cnote onsize ntype cdialog onsize ntype showbuttons m_pposition getslidedtoleft m_pposition getslidedtoright crect crect crect m_pposition getnoteposition crect crect m_pposition setnoteposition crect m_ptext getsafehwnd m_ptext movewindow void c note on move int x int y c dialog on move x y cnote onmove cdialog onmove void c note on close note remove the note if the app m bshowdeletemessage c dlg delete information dlg dlg do modal afx get app write profile int t settings options t show delete message dlg m bshowagain the app m bshowdeletemessage dlg m bshowagain see if the user wants to delete it without saving it in deleted notes xml bool b shift get key state vk shift 0x8000 true false if the app m bwarnondelete m bbelongstorecyclebin if message box c translate read string 183 t do you want to delete the note t a note mb iconexclamation mb yesno idno return c main frame p main c main frame afx get main wnd p main delete note this b shift onok cnote onclosenote theapp m_bshowdeletemessage cdlgdeleteinformation domodal afxgetapp writeprofileint _t _t m_bshowagain theapp m_bshowdeletemessage m_bshowagain bshift getkeystate vk_shift theapp m_bwarnondelete m_bbelongstorecyclebin messagebox ctranslate readstring _t _t mb_iconexclamation mb_yesno cmainframe pmain cmainframe afxgetmainwnd pmain deletenote bshift void c note on alarm snooze or something and close the sound c dlg snooze dlg if m bisalarmshouting if dlg do modal idok snooze set the alarm 10 minutes forward from now c ole date time t1 c ole date time get current time c ole date time t2 t2 set time 0 10 0 m alarm t1 t2 close alarm m busealarm true else turn off c rect rc get client rect rc close alarm m busealarm false m palarm show window sw hide invalidate else the alarm is not shouting show the alarm dialog on popupmenu alarm cnote onalarm cdlgsnooze m_bisalarmshouting domodal coledatetime coledatetime getcurrenttime coledatetime settime m_alarm closealarm m_busealarm crect getclientrect closealarm m_busealarm m_palarm showwindow sw_hide onpopupmenualarm void c note on minimize minimize the note or restore it if the app m bminimizeshrink if m bvisible c rect rc system parameters info spi getworkarea 0 rc 0 if m pposition get docked bottom c rect c rect c rect m pposition get note position c rect top rc bottom 23 m pposition set note position c rect this false move the cursor to the minimize button if the app m bminimizemovecursor c rect rect m pminimize get window rect rect set cursor pos rect left 8 m pposition get note position top 10 m ioldheight m pposition get note position bottom move window m pposition get note position left m pposition get note position top m pposition get note position right 23 if the app m bthinnoteborder m pminimize set bitmaps idb noteminimize2 rgb 100 100 100 idb noteminimize2 rgb 100 100 100 else m pminimize set bitmaps idb noteminimize3 rgb 100 100 100 idb noteminimize3 rgb 100 100 100 m bvisible false set transparancy the app m itransparantnormal the app m itransparantminimized else restore note set transparancy the app m itransparantnormal the app m itransparantminimized else if m bvisible m bvisible false set transparancy the app m itransparantnormal the app m itransparantminimized added by leonardo zide lmz move window m pposition get note position left m pposition get note position top m pposition get note position right m pposition get note position bottom show window sw hide else restore note cnote onminimize theapp m_bminimizeshrink m_bvisible crect systemparametersinfo spi_getworkarea m_pposition getdockedbottom crect crect crect m_pposition getnoteposition crect m_pposition setnoteposition crect theapp m_bminimizemovecursor crect m_pminimize getwindowrect setcursorpos m_pposition getnoteposition m_ioldheight m_pposition getnoteposition movewindow m_pposition getnoteposition m_pposition getnoteposition m_pposition getnoteposition theapp m_bthinnoteborder m_pminimize setbitmaps idb_noteminimize2 idb_noteminimize2 m_pminimize setbitmaps idb_noteminimize3 idb_noteminimize3 m_bvisible settransparancy theapp m_itransparantnormal theapp m_itransparantminimized restorenote settransparancy theapp m_itransparantnormal theapp m_itransparantminimized m_bvisible m_bvisible settransparancy theapp m_itransparantnormal theapp m_itransparantminimized movewindow m_pposition getnoteposition m_pposition getnoteposition m_pposition getnoteposition m_pposition getnoteposition showwindow sw_hide restorenote void c note on bullet the user pressed the bullet button m ptext set paragraph bulleted cnote onbullet m_ptext setparagraphbulleted void c note on bold the user pressed the bold button m ptext set selection bold cnote onbold m_ptext setselectionbold void c note on italic the user pressed the italic button m ptext set selection italic cnote onitalic m_ptext setselectionitalic void c note on strike out m ptext set selection strike out cnote onstrikeout m_ptext setselectionstrikeout void c note on underline the user pressed the underline button m ptext set selection underlined cnote onunderline m_ptext setselectionunderlined void c note on slide right m pposition slide position to right this hide the text and title invalidate m ptext show window sw hide hide buttons the app m layered set transparent percentage m hwnd the app m itransparantminimized write the title vertically invalidate cnote onslideright m_pposition slidepositiontoright m_ptext showwindow sw_hide hidebuttons theapp m_layered settransparentpercentage m_hwnd theapp m_itransparantminimized void c note on slide left slide the note to the right m pposition slide position to left this hide the text and title m ptext show window sw hide hide buttons the app m layered set transparent percentage m hwnd the app m itransparantminimized write the title vertically invalidate cnote onslideleft m_pposition slidepositiontoleft m_ptext showwindow sw_hide hidebuttons theapp m_layered settransparentpercentage m_hwnd theapp m_itransparantminimized void c note on popupmenu cut m ptext cut cnote onpopupmenucut m_ptext void c note on popupmenu copy m ptext copy cnote onpopupmenucopy m_ptext void c note on popupmenu paste m ptext paste cnote onpopupmenupaste m_ptext void c note on popupmenu notecolor change the note color c color dialog dlg m cfnotecolor if dlg do modal idok m cfnotecolor dlg get color set border style the app m bthinnoteborder invalidate false cnote onpopupmenunotecolor ccolordialog m_cfnotecolor domodal m_cfnotecolor getcolor setborderstyle theapp m_bthinnoteborder void c note on popupmenu font change the font c font dialog dlg m ptext get char format if dlg do modal idok charformat cf dlg get char format cf m ptext set selection char format cf cnote onpopupmenufont cfontdialog m_ptext getcharformat domodal getcharformat m_ptext setselectioncharformat void c note on ncl button dbl clk uint n hit test c point point double click on the title either set it or restore the window if the app m bdoubleclickontitlebar on minimize else c dlg set title dlg c point pnt point screen to client pnt if pnt y 30 dlg m sztitle m sztitle if dlg do modal idok m sztitle dlg m sztitle invalidate c dialog on ncl button dbl clk n hit test point cnote onnclbuttondblclk nhittest cpoint theapp m_bdoubleclickontitlebar onminimize cdlgsettitle cpoint screentoclient m_sztitle m_sztitle domodal m_sztitle m_sztitle cdialog onnclbuttondblclk nhittest void c note on popupmenu alarm change the alarm c rect rc get client rect rc c dlg set alarm dlg c ole date time tid dlg m busealarm m busealarm dlg m time m alarm if dlg do modal idok m busealarm dlg m busealarm m alarm dlg m time if m busealarm if the app m bthinnoteborder m palarm set bitmaps idb notealarm1 rgb 100 100 100 idb notealarm1 rgb 100 100 100 else m palarm set bitmaps idb notealarm rgb 100 100 100 idb notealarm rgb 100 100 100 show buttons else m busealarm false show buttons m palarm show window sw hide close alarm cnote onpopupmenualarm crect getclientrect cdlgsetalarm coledatetime m_busealarm m_busealarm m_time m_alarm domodal m_busealarm m_busealarm m_alarm m_time m_busealarm theapp m_bthinnoteborder m_palarm setbitmaps idb_notealarm1 idb_notealarm1 m_palarm setbitmaps idb_notealarm idb_notealarm showbuttons m_busealarm showbuttons m_palarm showwindow sw_hide closealarm void c note on popupmenu settitle set the title c dlg set title dlg dlg m sztitle m sztitle if dlg do modal idok m sztitle dlg m sztitle invalidate cnote onpopupmenusettitle cdlgsettitle m_sztitle m_sztitle domodal m_sztitle m_sztitle void c note on text link nmhdr pnmhdr lresult p result open the url that the user pressed on enlink pen link enlink pnmhdr p result 0 switch pen link msg case wm lbuttondown c string szurl charrange save range save range cp min 0 save range cp max 0 m ptext get sel save range m ptext set sel pen link chrg szurl m ptext get sel text m ptext set sel save range c wait cursor wait szurl trim left if szurl is empty shell execute get parent get safe hwnd t open szurl null null sw shownormal else p result 0 p result 1 break case wm lbuttonup p result 1 break cnote ontextlink presult penlink presult penlink wm_lbuttondown cstring saverange saverange cpmin saverange cpmax m_ptext getsel saverange m_ptext setsel penlink m_ptext getseltext m_ptext setsel saverange cwaitcursor trimleft isempty shellexecute getparent getsafehwnd _t sw_shownormal presult presult wm_lbuttonup presult void c note on timer uint nid event if nid event id noteblink the app m bblinknote static bool b show true show window b show sw show sw hide b show b show false b show true c dialog on timer nid event cnote ontimer nidevent nidevent id_noteblink theapp m_bblinknote bshow showwindow bshow sw_show sw_hide bshow bshow bshow cdialog ontimer nidevent void c note on request resize nmhdr pnmhdr lresult p result assert pnmhdr code en requestresize storing the requested sized to be used in the binary search reqresize prr reqresize pnmhdr c rect rect system parameters info spi getworkarea 0 rect 0 if m pposition get slided to left m pposition get slided to right p result 0 return if m pposition get docked bottom c rect c rect c rect m pposition get note position c rect top rect bottom prr rc bottom 10 m pposition set note position c rect this true if m bvisible move window m pposition get note position left m pposition get note position top m pposition get note position right prr rc bottom 10 p result 0 cnote onrequestresize presult _assert en_requestresize crect systemparametersinfo spi_getworkarea m_pposition getslidedtoleft m_pposition getslidedtoright presult m_pposition getdockedbottom crect crect crect m_pposition getnoteposition crect m_pposition setnoteposition crect m_bvisible movewindow m_pposition getnoteposition m_pposition getnoteposition m_pposition getnoteposition presult void c note on moving uint fw side lprect p rect c point pnt c rect rc rect c rect c rect m pposition get note position c rect left p rect left c rect top p rect top m pposition set note position c rect this true if we have slided the note we don t want it to change it s height here if m pposition get slided to left m pposition get slided to right return see if we should dock the window if the app m bdockable where are we get cursor pos pnt get client rect rc system parameters info spi getworkarea 0 rect 0 is it docked from serialization if m pposition get docked point x 0 m pposition get docked point y 0 if m pposition get docked left m pposition set docked point c point pnt x m pposition get docked point y if m pposition get docked top m pposition set docked point c point m pposition get docked point x pnt y if m pposition get docked right m pposition set docked point c point pnt x m pposition get docked point y if m pposition get docked bottom m pposition set docked point c point m pposition get docked point x pnt y left if m pposition get docked left if pnt x m pposition get docked point x 3 m pposition set docked left false this false p rect left 23 p rect right rc right 23 else p rect left 0 p rect right rc right else if m pposition get docked left p rect left 20 m pposition set docked left true this false p rect left 0 p rect right rc right m pposition set docked point pnt top if m pposition get docked top if pnt y m pposition get docked point y 3 m pposition set docked top false this false p rect top 23 p rect bottom rc bottom 23 else p rect top 0 p rect bottom rc bottom else if m pposition get docked top p rect top 20 m pposition set docked top true this false p rect top 0 p rect bottom rc bottom m pposition set docked point pnt right if m pposition get docked right if pnt x m pposition get docked point x 3 m pposition set docked right false this false p rect right rect right 23 p rect left rect right rc right 23 else p rect right rect right p rect left rect right rc right else if m pposition get docked right p rect right rect right 20 m pposition set docked right true this false p rect left rect right rc right p rect right rect right m pposition set docked point pnt bottom if m pposition get docked bottom if pnt y m pposition get docked point y 3 m pposition set docked bottom false this false p rect bottom rect bottom 23 p rect top rect bottom rc bottom 23 else p rect bottom rect bottom p rect top rect bottom rc bottom else if m pposition get docked bottom p rect bottom rect bottom 20 m pposition set docked bottom true this false p rect top rect bottom rc bottom p rect bottom rect bottom m pposition set docked point pnt c dialog on moving fw side p rect cnote onmoving fwside prect cpoint crect crect crect m_pposition getnoteposition crect prect crect prect m_pposition setnoteposition crect m_pposition getslidedtoleft m_pposition getslidedtoright theapp m_bdockable getcursorpos getclientrect systemparametersinfo spi_getworkarea m_pposition getdockedpoint m_pposition getdockedpoint m_pposition getdockedleft m_pposition setdockedpoint cpoint m_pposition getdockedpoint m_pposition getdockedtop m_pposition setdockedpoint cpoint m_pposition getdockedpoint m_pposition getdockedright m_pposition setdockedpoint cpoint m_pposition getdockedpoint m_pposition getdockedbottom m_pposition setdockedpoint cpoint m_pposition getdockedpoint m_pposition getdockedleft m_pposition getdockedpoint m_pposition setdockedleft prect prect prect prect m_pposition getdockedleft prect m_pposition setdockedleft prect prect m_pposition setdockedpoint m_pposition getdockedtop m_pposition getdockedpoint m_pposition setdockedtop prect prect prect prect m_pposition getdockedtop prect m_pposition setdockedtop prect prect m_pposition setdockedpoint m_pposition getdockedright m_pposition getdockedpoint m_pposition setdockedright prect prect prect prect m_pposition getdockedright prect m_pposition setdockedright prect prect m_pposition setdockedpoint m_pposition getdockedbottom m_pposition getdockedpoint m_pposition setdockedbottom prect prect prect prect m_pposition getdockedbottom prect m_pposition setdockedbottom prect prect m_pposition setdockedpoint cdialog onmoving fwside prect void c note on popupmenu email send the note as email c wait cursor wc create the message c mapi message message setup the all the recipient types for this message message add multiple recipients t to someone com c mapi message to add the subject and body c string sz text m ptext get window text sz text message m sbody sz text message m ssubject m sztitle connect to server c mapi session connection bool b logon false b logon connection shared logon if b logon else send the message bool b success false if connection send message 1 1 this c string s msg s msg format t s n error d c translate read string 25 t couldn t send message connection get last error afx message box s msg mb iconstop cnote onpopupmenuemail cwaitcursor cmapimessage addmultiplerecipients _t cmapimessage cstring sztext m_ptext getwindowtext sztext m_sbody sztext m_ssubject m_sztitle cmapisession blogon blogon sharedlogon blogon bsuccess cstring smsg smsg _t nerror ctranslate readstring _t getlasterror afxmessagebox smsg mb_iconstop void c note on popupmenu print c print dialog dlg false pd allpages pd returndc pd noselection pd hideprinttofile pd nopagenums this dlg m pd n copies 1 dlg m pd h dev mode null dlg m pd h dev names null if dlg do modal idok return hdc hdc dlg get printerdc cdc printdc printdc cdc from handle hdc assert hdc global free dlg m pd h dev mode global free dlg m pd h dev names cdc p printdc cdc from handle hdc p printdc start doc m sztitle formatrange fr get the page width and height from the printer long l page width mul div printdc get device caps physicalwidth 1440 printdc get device caps logpixelsx long l page height mul div printdc get device caps physicalheight 1440 printdc get device caps logpixelsy c rect rc page 0 0 l page width l page height p printdc start page format the text and render it to the printer fr hdc printdc m hdc fr hdc target printdc m hdc fr rc rc page fr rc page rc page fr chrg cp min 0 fr chrg cp max 1 m ptext format range fr true update the display with the new formatting rect rc client m ptext get client rect rc client m ptext display band rc client p printdc end page p printdc end doc p printdc deletedc cnote onpopupmenuprint cprintdialog pd_allpages pd_returndc pd_noselection pd_hideprinttofile pd_nopagenums m_pd ncopies m_pd hdevmode m_pd hdevnames domodal getprinterdc fromhandle globalfree m_pd hdevmode globalfree m_pd hdevnames pprintdc fromhandle pprintdc startdoc m_sztitle lpagewidth muldiv getdevicecaps getdevicecaps lpageheight muldiv getdevicecaps getdevicecaps crect rcpage lpagewidth lpageheight pprintdc startpage m_hdc hdctarget m_hdc rcpage rcpage rcpage cpmin cpmax m_ptext formatrange rcclient m_ptext getclientrect rcclient m_ptext displayband rcclient pprintdc endpage pprintdc enddoc pprintdc void c note on nc mouse move uint n hit test c point point if m pposition get docked left m pposition set docked point c point point x m pposition get docked point y if m pposition get docked top m pposition set docked point c point m pposition get docked point x point y if m pposition get docked right m pposition set docked point c point point x m pposition get docked point y if m pposition get docked bottom m pposition set docked point c point m pposition get docked point x point y c dialog on nc mouse move n hit test point cnote onncmousemove nhittest cpoint m_pposition getdockedleft m_pposition setdockedpoint cpoint m_pposition getdockedpoint m_pposition getdockedtop m_pposition setdockedpoint cpoint m_pposition getdockedpoint m_pposition getdockedright m_pposition setdockedpoint cpoint m_pposition getdockedpoint m_pposition getdockedbottom m_pposition setdockedpoint cpoint m_pposition getdockedpoint cdialog onncmousemove nhittest void c note on ncr button up uint n hit test c point point bc menu menu menu load menu idr popupmenu menu load toolbar idr menubar bc menu psub bc menu menu get sub menu 0 psub set menu text id popupmenu cut c translate read string 27 t cut mf string psub set menu text id popupmenu copy c translate read string 28 t copy mf string psub set menu text id popupmenu paste c translate read string 29 t paste mf string psub set menu text id popupmenu font c translate read string 30 t font mf string psub set menu text id popupmenu notecolor c translate read string 31 t note color mf string psub set menu text id popupmenu settitle c translate read string 32 t set title mf string psub set menu text id popupmenu alarm c translate read string 33 t alarm mf string psub set menu text id popupmenu email c translate read string 34 t email mf string psub set menu text id popupmenu print c translate read string 35 t print mf string psub track popup menu tpm leftalign tpm rightbutton point x point y this menu destroy menu c dialog on ncr button up n hit test point cnote onncrbuttonup nhittest cpoint bcmenu loadmenu idr_popupmenu loadtoolbar idr_menubar bcmenu bcmenu getsubmenu setmenutext id_popupmenu_cut ctranslate readstring _t mf_string setmenutext id_popupmenu_copy ctranslate readstring _t mf_string setmenutext id_popupmenu_paste ctranslate readstring _t mf_string setmenutext id_popupmenu_font ctranslate readstring _t mf_string setmenutext id_popupmenu_notecolor ctranslate readstring _t mf_string setmenutext id_popupmenu_settitle ctranslate readstring _t mf_string setmenutext id_popupmenu_alarm ctranslate readstring _t mf_string setmenutext id_popupmenu_email ctranslate readstring _t mf_string setmenutext id_popupmenu_print ctranslate readstring _t mf_string trackpopupmenu tpm_leftalign tpm_rightbutton destroymenu cdialog onncrbuttonup nhittest void c note onl button down uint n flags c point point if we have slided the note positionate it were it was if m pposition get slided to right restore from right slide if m pposition get slided to left restore from left slide c dialog onl button down n flags point cnote onlbuttondown nflags cpoint m_pposition getslidedtoright restorefromrightslide m_pposition getslidedtoleft restorefromleftslide cdialog onlbuttondown nflags lresult c note on display change wparam w param lparam l param retrive the new size int cx screen loword l param int cy screen hiword l param the display has changed the size move the note s where they should be m pposition set note position display resolution changed this c point cx screen cy screen return 0 cnote ondisplaychange wparam lparam cxscreen lparam cyscreen lparam m_pposition setnotepositiondisplayresolutionchanged cpoint cxscreen cyscreen void c note on nc paint on paint cnote onncpaint onpaint void c main frame load c string sz file name read the xml file c string szxml char p temp p data dword dw read 1 dw total 0 try to open the file c stdio file cf if cf open sz file name c file mode read c file type text return p data char malloc buffersize memset p data null buffersize p temp char malloc buffersize memset p temp null buffersize while dw read memset p temp null buffersize try dw read cf read p temp buffersize catch c file exception e c error log c error log err t could not read the file notes xml free p temp free p data return end catch dw total dw read if dw read 0 p data char realloc p data dw total 1 memcpy p data dw total dw read p temp dw read p data dw total 0 try cf close catch c file exception e c error log c error log info t could not close the file notes xml when reading free p temp free p data end catch parse the xml parsexml c string p data free p temp free p data cmainframe cstring szfilename cstring ptemp pdata dwread dwtotal cstdiofile szfilename cfile moderead cfile typetext pdata pdata ptemp ptemp dwread ptemp dwread ptemp cfileexception cerrorlog cerrorlog _t ptemp pdata end_catch dwtotal dwread dwread pdata pdata dwtotal pdata dwtotal dwread ptemp dwread pdata dwtotal cfileexception cerrorlog cerrorlog _t ptemp pdata end_catch cstring pdata ptemp pdata bool c main frame send c string sz server address c string sz path c string szxml c string sz data back send the xml to the server this function is being called whenever anything should be sent to the server bool b read true dword dw reply c internet session session c http connection connect c http file file c string sz temp connect to the server connect session get http connection lpctstr sz server address null ttoi the app m szserverport null null write a post and get the services file connect open request t post sz path file add request headers t content type text xml charset utf 8 n try if defined unicode defined unicode int i length i multibyte i length szxml get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 char res tcscpy pwc unicode szxml to utf 8 i multibyte wide char to multi byte cp utf8 0 pwc unicode i length pc dest 2 i length null null pc dest i multibyte 0 pc dest i multibyte 1 0 file send request null 0 lpvoid lpctstr pc dest i multibyte delete pc dest delete pwc unicode else file send request null 0 lpvoid lpctstr szxml szxml get length endif catch c internet exception e e delete change the tray icon to normal no animate delete connect delete file return false see what the server replied file query info status code dw reply if dw reply 200 connect close file close delete connect delete file change the tray icon to normal no animate return false 200 ok read the reply to receive the services and send it back since the string on the server is ansi coded we have to read it like that if defined unicode defined unicode char p temp p data bool b done true dword dw total 0 p data char malloc 100 memset p data null 100 p temp char malloc 100 memset p temp null 100 while b read memset p temp null 100 b read bool file read string lptstr p temp 50 dw total strlen p temp 2 if strlen p temp 0 p data char realloc p data dw total 2 int a strlen p temp memcpy p data dw total strlen p temp 2 p temp strlen p temp 2 fix the end p data dw total 0 p data dw total 1 0 sz data back c string p data free p data free p temp else read the ansi coded string from the server while b read b read bool file read string sz temp sz data back sz temp endif close the session session close connect close file close delete connect delete file change the tray icon to normal no animate return true cmainframe cstring szserveraddress cstring szpath cstring cstring szdataback bread dwreply cinternetsession chttpconnection chttpfile cstring sztemp gethttpconnection szserveraddress _ttoi theapp m_szserverport openrequest _t szpath addrequestheaders _t _unicode ilength imultibyte ilength getlength pwcunicode ilength pcdest ilength _tcscpy pwcunicode imultibyte widechartomultibyte cp_utf8 pwcunicode ilength pcdest ilength pcdest imultibyte pcdest imultibyte sendrequest pcdest imultibyte pcdest pwcunicode sendrequest getlength cinternetexception noanimate queryinfostatuscode dwreply dwreply noanimate _unicode ptemp pdata bdone dwtotal pdata pdata ptemp ptemp bread ptemp bread readstring ptemp dwtotal ptemp ptemp pdata pdata dwtotal ptemp pdata dwtotal ptemp ptemp ptemp pdata dwtotal pdata dwtotal szdataback cstring pdata pdata ptemp bread bread readstring sztemp szdataback sztemp noanimate bool c main frame show alarm dialog if we have an alarm show the snooze dialog this function will be called from the systemtray if the user presses on the tray icon bool b alarm false c ole date time time c ole date time get current time position pos m pnotes get head position while pos c note p note c note m pnotes get next pos if p note get use alarm p note is alarm shouting if date greater than or equal time p note get alarm b alarm true if b alarm c dlg snooze dlg if dlg do modal idok pos m pnotes get head position while pos c note p note c note m pnotes get next pos if p note get use alarm p note is alarm shouting if date greater than or equal time p note get alarm snooze set the alarm 10 minutes forward from now c ole date time t1 c ole date time get current time c ole date time t2 t2 set time 0 10 0 p note set alarm t1 t2 c string a a p note get alarm format p note close alarm p note set use alarm true p note show window sw show p note invalidate else pos m pnotes get head position while pos c note p note c note m pnotes get next pos if p note get use alarm p note is alarm shouting if date greater than or equal time p note get alarm turn off c rect rc rc p note get position p note close alarm p note set use alarm false p note m palarm show window sw hide p note show window sw show p note invalidate return true return false cmainframe showalarmdialog balarm coledatetime coledatetime getcurrenttime m_pnotes getheadposition cnote pnote cnote m_pnotes getnext pnote getusealarm pnote isalarmshouting dategreaterthanorequal pnote getalarm balarm balarm cdlgsnooze domodal m_pnotes getheadposition cnote pnote cnote m_pnotes getnext pnote getusealarm pnote isalarmshouting dategreaterthanorequal pnote getalarm coledatetime coledatetime getcurrenttime coledatetime settime pnote setalarm cstring pnote getalarm pnote closealarm pnote setusealarm pnote showwindow sw_show pnote m_pnotes getheadposition cnote pnote cnote m_pnotes getnext pnote getusealarm pnote isalarmshouting dategreaterthanorequal pnote getalarm crect pnote getposition pnote closealarm pnote setusealarm pnote m_palarm showwindow sw_hide pnote showwindow sw_show pnote void c main frame send notes to web change the tray icon to show arrows animate tray upload c string sz path sz sendxml szxml sz path format t ssendnotes php user s password s the app m szserverpath string encode the app m szusername string encode the app m szpassword get the send xml sz sendxml create sendxml if send the app m szserveraddress sz path sz sendxml szxml c stdio file f if f open get application data path t send notes xml c file mode create c file mode write c error log c error log info t could not open the file send notes xml for writing return try if defined unicode defined unicode int i length i length sz sendxml get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 wide char to multi byte cp utf8 0 sz sendxml i length pc dest 2 i length null null f write pc dest i length delete pc dest delete pwc unicode else f write sz sendxml sz sendxml get length endif f close catch c file exception e c error log c error log err t could not write the file send notes xml return end catch c stdio file fp if fp open get application data path t send answer xml c file mode create c file mode write c error log c error log info t could not open the file send answer xml for writing return try if defined unicode defined unicode int i length i length szxml get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 wide char to multi byte cp utf8 0 szxml i length pc dest 2 i length null null fp write pc dest i length delete pc dest delete pwc unicode else fp write szxml szxml get length endif fp close catch c file exception e c error log c error log err t could not write the file send answer xml return end catch cmainframe sendnotestoweb animatetrayupload cstring szpath szsendxml szpath _t theapp m_szserverpath stringencode theapp m_szusername stringencode theapp m_szpassword szsendxml createsendxml theapp m_szserveraddress szpath szsendxml cstdiofile getapplicationdatapath _t cfile modecreate cfile modewrite cerrorlog cerrorlog _t _unicode ilength ilength szsendxml getlength pwcunicode ilength pcdest ilength widechartomultibyte cp_utf8 szsendxml ilength pcdest ilength pcdest ilength pcdest pwcunicode szsendxml szsendxml getlength cfileexception cerrorlog cerrorlog _t end_catch cstdiofile getapplicationdatapath _t cfile modecreate cfile modewrite cerrorlog cerrorlog _t _unicode ilength ilength getlength pwcunicode ilength pcdest ilength widechartomultibyte cp_utf8 ilength pcdest ilength pcdest ilength pcdest pwcunicode getlength cfileexception cerrorlog cerrorlog _t end_catch void c main frame parsexml c string szxml parse the xml save the xml c string szxml file szxml file format t s tmp xml get application data path c stdio file fp if fp open szxml file c file mode create c file mode write c error log c error log err t could not open the tmp xml file for parsing the xml file return try if defined unicode defined unicode int i length i multibyte c string sz result i length szxml get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 i multibyte wide char to multi byte cp utf8 0 szxml i length pc dest 2 i length null null fp write pc dest i length delete pwc unicode delete pc dest else fp write szxml szxml get length endif fp close catch c file exception e c error log c error log err t could not read the tmp xml file for parsing the xml return end catch convert xml file name string to something com can handle bstr bstr t bstr file name bstr file name szxml file alloc sys string call the ixmldom document ptr s load function to load the xml document variant t v result v result m pldomdocument load bstr file name if bool v result true now that the document is loaded we need to initialize the root pointer m pdocroot m pldomdocument document element else delete file szxml file return getxml children m pdocroot delete the xml file delete file szxml file cmainframe cstring cstring szxmlfile szxmlfile _t getapplicationdatapath cstdiofile szxmlfile cfile modecreate cfile modewrite cerrorlog cerrorlog _t _unicode ilength imultibyte cstring szresult ilength getlength pwcunicode ilength pcdest ilength imultibyte widechartomultibyte cp_utf8 ilength pcdest ilength pcdest ilength pwcunicode pcdest getlength cfileexception cerrorlog cerrorlog _t end_catch _bstr_t bstrfilename bstrfilename szxmlfile allocsysstring ixmldomdocumentptr variant_t vresult vresult m_pldomdocument bstrfilename vresult m_pdocroot m_pldomdocument documentelement deletefile szxmlfile getxmlchildren m_pdocroot deletefile szxmlfile c main frame c main frame m bnotesarehidden false cmainframe cmainframe m_bnotesarehidden void c main frame create minimized menu bc menu p main menu bc menu p minimize show the minimized notes on the system tray menu max 20 p main menu enable menu item 6 mf grayed mf byposition for int i 0 i 20 i p minimize remove menu 0 mf byposition int i count 0 position pos m pnotes get head position while pos c note note c note m pnotes get next pos if note get visible i count 20 uses conversion char p temp char malloc note get title get length 1 for i 0 i note get title get length i p temp i note get title get at i p temp note get title get length 1 0 tchar sz wide a2t p temp delete p temp p minimize append menu mf string id minimizedmenuitem i count sz wide p main menu enable menu item 6 mf enabled mf byposition i count cmainframe createminimizedmenu bcmenu pmainmenu bcmenu pminimize pmainmenu enablemenuitem mf_grayed mf_byposition pminimize removemenu mf_byposition icount m_pnotes getheadposition cnote cnote m_pnotes getnext getvisible icount uses_conversion ptemp gettitle getlength gettitle getlength ptemp gettitle getat ptemp gettitle getlength szwide ptemp ptemp pminimize appendmenu mf_string id_minimizedmenuitem icount szwide pmainmenu enablemenuitem mf_enabled mf_byposition icount void c main frame no animate stop the animation m trayicon stop animation cmainframe noanimate m_trayicon stopanimation void c main frame animate tray alarm start to animate the tray so that the user knows that the alarm is shouting m trayicon set icon list idi alarm idi alarm1 m trayicon animate 300 1 cmainframe animatetrayalarm m_trayicon seticonlist idi_alarm idi_alarm1 m_trayicon void c main frame delete note void p note bool b save deleted note delete one note in the list assert p note position pos m pnotes get head position while pos position delpos pos void note m pnotes get next pos if note p note save the note in the deleted notes xml if b save deleted note c recycle bin bin bin save deleted note p note remove the note from the linked list m pnotes remove at delpos cmainframe deletenote pnote bsavedeletednote pnote m_pnotes getheadposition m_pnotes getnext pnote bsavedeletednote crecyclebin savedeletednote pnote m_pnotes removeat void c main frame add note void p note add one note to the list assert p note m pnotes add tail p note cmainframe addnote pnote pnote m_pnotes addtail pnote hmenu c main frame new menu load the menu from the resources m menu load menu idr mainframe idr traymain replace idr mainframe with your menu id use modifyod menu to add a bitmap to a menu options the first parameter is the menu option text string if it s null keep the current text string the second option is the id of the menu option to change the third option is the resource id of the bitmap this can also be a toolbar id in which case the class searches the toolbar for the appropriate bitmap only bitmap and toolbar resources are supported m menu modifyod menu null id zoom idb zoom another method for adding bitmaps to menu options is through the load toolbar member function this method allows you to add all the bitmaps in a toolbar object to menu options if they exist the function parameter is an the toolbar id there is also a function called load toolbars that takes an array of id s m menu load toolbar idr menubar return m menu detach cmainframe newmenu m_menu loadmenu idr_mainframe idr_traymain idr_mainframe modifyodmenu m_menu modifyodmenu id_zoom idb_zoom loadtoolbar loadtoolbars m_menu loadtoolbar idr_menubar m_menu bool c main frame pre create window createstruct cs if c frame wnd pre create window cs return false todo modify the window class or styles here by modifying the createstruct cs cs dw ex style ws ex clientedge cs lpsz class afx register wnd class 0 return true cmainframe precreatewindow cframewnd precreatewindow dwexstyle ws_ex_clientedge lpszclass afxregisterwndclass bool c main frame on cmd msg uint nid int n code void p extra afx cmdhandlerinfo p handler info let the view have first crack at the command if m wndview on cmd msg nid n code p extra p handler info return true otherwise do default handling return c frame wnd on cmd msg nid n code p extra p handler info cmainframe oncmdmsg ncode pextra afx_cmdhandlerinfo phandlerinfo m_wndview oncmdmsg ncode pextra phandlerinfo cframewnd oncmdmsg ncode pextra phandlerinfo c main frame c main frame cmainframe cmainframe void c main frame save c string sz file name c rect rc1 rc2 c string szxml c ole date time p time save the data as xml c xml xml xml start create save xml save the notes position pos m pnotes get head position while pos void p note void m pnotes get next pos xml create save xml p note xml end create save xml szxml xml get create save xml c stdio file cf if cf open sz file name c file mode create c file mode write c file type text c error log c error log info t could not open the file notes xml when saving the notes return try if defined unicode defined unicode int i length i length szxml get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 wide char to multi byte cp utf8 0 szxml i length pc dest 2 i length null null cf write pc dest i length delete pc dest delete pwc unicode else cf write szxml szxml get length endif cf close catch c file exception e c error log c error log err t could not write the notes xml file return end catch cmainframe cstring szfilename crect cstring coledatetime ptime cxml startcreatesavexml m_pnotes getheadposition pnote m_pnotes getnext createsavexml pnote endcreatesavexml getcreatesavexml cstdiofile szfilename cfile modecreate cfile modewrite cfile typetext cerrorlog cerrorlog _t _unicode ilength ilength getlength pwcunicode ilength pcdest ilength widechartomultibyte cp_utf8 ilength pcdest ilength pcdest ilength pcdest pwcunicode getlength cfileexception cerrorlog cerrorlog _t end_catch void c main frame animate tray upload start to animate the tray so that the user knows that the notes is being uploaded from the web m trayicon set icon list idi uploadnote idi uploadnote7 m trayicon animate 300 1 cmainframe animatetrayupload m_trayicon seticonlist idi_uploadnote idi_uploadnote7 m_trayicon void c main frame animate tray download start to animate the tray so that the user knows that the notes is being downloaded from the web m trayicon set icon list idi downloadnote idi downloadnote7 m trayicon animate 300 1 cmainframe animatetraydownload m_trayicon seticonlist idi_downloadnote idi_downloadnote7 m_trayicon void c main frame use user create a new user c dlg use user information dlg dlg m szpassword the app m szpassword dlg m szusername the app m szusername if dlg do modal idok save the new user the app m szusername dlg m szusername the app m szpassword dlg m szpassword afx get app write profile string t settings options t database user name dlg m szusername afx get app write profile string t settings options t database password dlg m szpassword get the notes get notes from server cmainframe useuser cdlguseuserinformation m_szpassword theapp m_szpassword m_szusername theapp m_szusername domodal theapp m_szusername m_szusername theapp m_szpassword m_szpassword afxgetapp writeprofilestring _t _t m_szusername afxgetapp writeprofilestring _t _t m_szpassword getnotesfromserver void c main frame get notes from server change the tray icon to show arrows animate tray download c string sz temp szxml sz path sz path format t sgetnotes php user s password s the app m szserverpath string encode the app m szusername string encode the app m szpassword if send the app m szserveraddress sz path szxml c file f if f open get application data path t get notes answer xml c file mode create c file mode write c error log c error log info t could not open get notes anser xml return try f write szxml szxml get length f close catch c file exception e c error log c error log err t could not write file get notes answer xml return end catch parsexml szxml cmainframe getnotesfromserver animatetraydownload cstring sztemp szpath szpath _t theapp m_szserverpath stringencode theapp m_szusername stringencode theapp m_szpassword theapp m_szserveraddress szpath cfile getapplicationdatapath _t cfile modecreate cfile modewrite cerrorlog cerrorlog _t getlength cfileexception cerrorlog cerrorlog _t end_catch void c main frame check for newer version c string sz userid sz userid afx get app get profile string t settings extra t user id used to count number of users in database t if sz userid t sz userid t srand unsigned time null for int i 0 i 50 i sz userid set at i rand 1 25 1 65 afx get app write profile string t settings extra t user id used to count number of users in database sz userid c string sz path szxml sz path format t sgetversion php userid s the app m szserverpath sz userid see if there are any newer version on the database if send t a note sourceforge net sz path szxml c stdio file f if f open get application data path t get latest version xml c file mode create c file mode write c error log c error log info t could not open the file get latest version xml return try if defined unicode defined unicode int i length i multibyte c string sz result i length szxml get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 i multibyte wide char to multi byte cp utf8 0 szxml i length pc dest 2 i length null null f write pc dest i multibyte delete pwc unicode delete pc dest else f write szxml szxml get length endif f close catch c file exception e c error log c error log err t could not write the file get latest version xml return end catch parsexml szxml cmainframe checkfornewerversion cstring szuserid szuserid afxgetapp getprofilestring _t _t _t szuserid _t szuserid _t szuserid setat afxgetapp writeprofilestring _t _t szuserid cstring szpath szpath _t theapp m_szserverpath szuserid _t szpath cstdiofile getapplicationdatapath _t cfile modecreate cfile modewrite cerrorlog cerrorlog _t _unicode ilength imultibyte cstring szresult ilength getlength pwcunicode ilength pcdest ilength imultibyte widechartomultibyte cp_utf8 ilength pcdest ilength pcdest imultibyte pwcunicode pcdest getlength cfileexception cerrorlog cerrorlog _t end_catch void c main frame send password to email send the right password to the email address that is associated to the user c string sz data sz temp sz path szxml sz path format t ssendpasswordtoemail php the app m szserverpath sz data t xml version 1 0 encoding iso 8859 1 send email sz temp format t username s username string encode the app m szusername sz data sz temp sz data t user information if send the app m szserveraddress sz path sz data szxml c stdio file f if f open get application data path t send email xml c file mode create c file mode write c error log c error log info t could not open the file send email xml return try if defined unicode defined unicode int i length i length sz data get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 wide char to multi byte cp utf8 0 sz data i length pc dest 2 i length null null f write pc dest i length delete pc dest delete pwc unicode else f write sz data sz data get length endif f close catch c file exception e c error log c error log err t could not write the file send eamil xml return end catch c stdio file fp if fp open get application data path t send email answer xml c file mode create c file mode write c error log c error log info t could not open the file send email answer xml return try if defined unicode defined unicode int i length i length szxml get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 wide char to multi byte cp utf8 0 szxml i length pc dest 2 i length null null fp write pc dest i length delete pc dest delete pwc unicode else fp write szxml szxml get length endif fp close catch c file exception e c error log c error log err t could not write the file send email answer xml return end catch parsexml szxml cmainframe sendpasswordtoemail cstring szdata sztemp szpath szpath _t theapp m_szserverpath szdata _t sendemail sztemp _t stringencode theapp m_szusername szdata sztemp szdata _t userinformation theapp m_szserveraddress szpath szdata cstdiofile getapplicationdatapath _t cfile modecreate cfile modewrite cerrorlog cerrorlog _t _unicode ilength ilength szdata getlength pwcunicode ilength pcdest ilength widechartomultibyte cp_utf8 szdata ilength pcdest ilength pcdest ilength pcdest pwcunicode szdata szdata getlength cfileexception cerrorlog cerrorlog _t end_catch cstdiofile getapplicationdatapath _t cfile modecreate cfile modewrite cerrorlog cerrorlog _t _unicode ilength ilength getlength pwcunicode ilength pcdest ilength widechartomultibyte cp_utf8 ilength pcdest ilength pcdest ilength pcdest pwcunicode getlength cfileexception cerrorlog cerrorlog _t end_catch void c main frame create new user create a new user c dlg user information dlg dlg m szpassword the app m szpassword dlg m szusername the app m szusername if dlg do modal idok save the new user the app m szusername dlg m szusername the app m szpassword dlg m szpassword afx get app write profile string t settings options t database user name dlg m szusername afx get app write profile string t settings options t database password dlg m szpassword try to create the new user c string sz path sz data sz temp szxml sz path format t screateuser php the app m szserverpath sz data t xml version 1 0 encoding iso 8859 1 user information sz temp format t username s username string encode the app m szusername sz data sz temp sz temp format t password s password string encode the app m szpassword sz data sz temp sz temp format t email s email string encode dlg m szemail sz data sz temp sz data t user information if send the app m szserveraddress sz path sz data szxml c stdio file f if f open get application data path t send user name xml c file mode create c file mode write c error log c error log info t could not open the file send user name xml return try if defined unicode defined unicode int i length i length sz data get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 wide char to multi byte cp utf8 0 sz data i length pc dest 2 i length null null f write pc dest i length delete pc dest delete pwc unicode else f write sz data sz data get length endif f close catch c file exception e c error log c error log err t could not write in the file send user name xml return end catch c stdio file fp if fp open get application data path t create new user answer xml c file mode create c file mode write c error log c error log info t could not open the file create new user answer xml return try if defined unicode defined unicode int i length i length szxml get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 wide char to multi byte cp utf8 0 szxml i length pc dest 2 i length null null fp write pc dest i length delete pc dest delete pwc unicode else fp write szxml szxml get length endif fp close catch c file exception e c error log c error log err t could not write the file create new user answer xml return end catch parsexml szxml cmainframe createnewuser cdlguserinformation m_szpassword theapp m_szpassword m_szusername theapp m_szusername domodal theapp m_szusername m_szusername theapp m_szpassword m_szpassword afxgetapp writeprofilestring _t _t m_szusername afxgetapp writeprofilestring _t _t m_szpassword cstring szpath szdata sztemp szpath _t theapp m_szserverpath szdata _t userinformation sztemp _t stringencode theapp m_szusername szdata sztemp sztemp _t stringencode theapp m_szpassword szdata sztemp sztemp _t stringencode m_szemail szdata sztemp szdata _t userinformation theapp m_szserveraddress szpath szdata cstdiofile getapplicationdatapath _t username cfile modecreate cfile modewrite cerrorlog cerrorlog _t username _unicode ilength ilength szdata getlength pwcunicode ilength pcdest ilength widechartomultibyte cp_utf8 szdata ilength pcdest ilength pcdest ilength pcdest pwcunicode szdata szdata getlength cfileexception cerrorlog cerrorlog _t username end_catch cstdiofile getapplicationdatapath _t cfile modecreate cfile modewrite cerrorlog cerrorlog _t _unicode ilength ilength getlength pwcunicode ilength pcdest ilength widechartomultibyte cp_utf8 ilength pcdest ilength pcdest ilength pcdest pwcunicode getlength cfileexception cerrorlog cerrorlog _t end_catch c string c main frame create sendxml create the xml that will be sent to a note s database position pos m pnotes get head position c xml xml xml start create upload xml while pos void p note void m pnotes get next pos xml create upload xml p note xml end create upload xml return xml get create upload xml cstring cmainframe createsendxml m_pnotes getheadposition cxml startcreateuploadxml pnote m_pnotes getnext createuploadxml pnote endcreateuploadxml getcreateuploadxml bool c main frame date greater than or equal c ole date time odt1 c ole date time odt2 if dates equal odt1 odt2 return true else return odt1 odt2 cmainframe dategreaterthanorequal coledatetime coledatetime datesequal bool c main frame dates equal c ole date time odt1 c ole date time odt2 c string str1 odt1 format c string str2 odt2 format return str1 compare str2 cmainframe datesequal coledatetime coledatetime cstring cstring int c main frame on create lpcreatestruct lp create struct if c frame wnd on create lp create struct 1 return 1 create a view to occupy the client area of the frame if m wndview create null null afx ws default view c rect 0 0 0 0 this afx idw pane first null trace0 failed to create view window n return 1 create the backup file c backup backup backup create backup initialize the xml parser co initialize null hresult hr m pldomdocument create instance clsid domdocument if failed hr c error log c error log err t could not initialize the xml parser show window sw hide create the tray icon if m trayicon create null parent window wm icon notify icon notify message to use t a note tooltip null icon to use idr mainframe idr traymain id of tray icon return false when i m debugging the code it s easier for me to know if i m running in unicode mode or not unicode blue tray icon unicode yellow tray icon if defined debug defined unicode defined unicode m trayicon set icon makeintresource idi traymain1 else m trayicon set icon makeintresource idi traymain endif m trayicon minimise to tray this set the transparancy to zero to avoid ugly coloring the app m itransparantnormal the app m itransparantminimized 0 see if whe should have hot keys enabled if the app m busehotkey uint i modifiers 0 the app m ihotkeyid global add atom t a note if the app m bhotkeyctrl i modifiers mod control if the app m bhotkeyshift i modifiers mod shift if the app m bhotkeyalt i modifiers mod alt if the app m bhotkeywin i modifiers mod win register hot key get safe hwnd the app m ihotkeyid i modifiers 65 the app m ihotkeycharacter to prevent the cursor to jump around on the screen because the notes are minimized we fake that the cursor shouldn t move when the notes are minimized the app m bminimizemovecursor false load the notes c string sz file sz file format t s notes xml get application data path load sz file start the timer that shows when we want to connect to internet and download the notes set timer id startconnecttointernet 1000 the app m istartdownloadingafter timerproc null start the timer for the alarm set timer id alarmtimer 1000 timerproc null start the autosave timer set timer id savetimer 10000 timerproc null restore the transparancy color the app m itransparantnormal afx get app get profile int t settings options t transparancy 100 the app m itransparantminimized afx get app get profile int t settings options t transparancy when minimized 100 position pos m pnotes get head position while pos c note p note c note m pnotes get next pos p note set transparancy the app m itransparantnormal the app m itransparantminimized we alow the cursor to move when the notes are minimized see a bit up in the code here the app m bminimizemovecursor afx get app get profile int t settings options t when minimized move cursor 1 return 0 cmainframe oncreate lpcreatestruct cframewnd oncreate lpcreatestruct m_wndview afx_ws_default_view crect afx_idw_pane_first cbackup createbackup coinitialize m_pldomdocument createinstance clsid_domdocument cerrorlog cerrorlog _t showwindow sw_hide m_trayicon wm_icon_notify _t idr_mainframe idr_traymain _debug _unicode m_trayicon seticon idi_traymain1 m_trayicon seticon idi_traymain m_trayicon minimisetotray theapp m_itransparantnormal theapp m_itransparantminimized theapp m_busehotkey imodifiers theapp m_ihotkeyid globaladdatom _t theapp m_bhotkeyctrl imodifiers mod_control theapp m_bhotkeyshift imodifiers mod_shift theapp m_bhotkeyalt imodifiers mod_alt theapp m_bhotkeywin imodifiers mod_win registerhotkey getsafehwnd theapp m_ihotkeyid imodifiers theapp m_ihotkeycharacter theapp m_bminimizemovecursor cstring szfile szfile _t getapplicationdatapath szfile settimer id_startconnecttointernet theapp m_istartdownloadingafter settimer id_alarmtimer settimer id_savetimer theapp m_itransparantnormal afxgetapp getprofileint _t _t theapp m_itransparantminimized afxgetapp getprofileint _t _t m_pnotes getheadposition cnote pnote cnote m_pnotes getnext pnote settransparancy theapp m_itransparantnormal theapp m_itransparantminimized theapp m_bminimizemovecursor afxgetapp getprofileint _t _t void c main frame on set focus c wnd p old wnd forward focus to the view window m wndview set focus cmainframe onsetfocus cwnd poldwnd m_wndview setfocus void c main frame on traymain newnote add a new note and show it c note p note new c note p note create idd note this c rect rc system parameters info spi getworkarea 0 rc 0 c rect rcnote where should the note appear if the app m bdockable the app m bnewnotedockleft rcnote left 0 else rcnote left the app m inewnoteleft if the app m bdockable the app m bnewnotedocktop rcnote top 0 else rcnote top the app m inewnotetop if the app m bdockable the app m bnewnotedockright rcnote left rc right the app m inewnotewidth if the app m bdockable the app m bnewnotedockbottom rcnote top rc bottom 50 rcnote right rcnote left the app m inewnotewidth rcnote bottom rcnote top 50 p note move window rcnote p note set position c rect rcnote left rcnote top the app m inewnotewidth 50 false p note set docked bottom the app m bnewnotedockbottom false p note set docked right the app m bnewnotedockright false p note set docked left the app m bnewnotedockleft false p note set docked top the app m bnewnotedocktop false p note fix note position p note p note show window sw show add note void p note cmainframe ontraymainnewnote cnote pnote cnote pnote idd_note crect systemparametersinfo spi_getworkarea crect theapp m_bdockable theapp m_bnewnotedockleft theapp m_inewnoteleft theapp m_bdockable theapp m_bnewnotedocktop theapp m_inewnotetop theapp m_bdockable theapp m_bnewnotedockright theapp m_inewnotewidth theapp m_bdockable theapp m_bnewnotedockbottom theapp m_inewnotewidth pnote movewindow pnote setposition crect theapp m_inewnotewidth pnote setdockedbottom theapp m_bnewnotedockbottom pnote setdockedright theapp m_bnewnotedockright pnote setdockedleft theapp m_bnewnotedockleft pnote setdockedtop theapp m_bnewnotedocktop pnote fixnoteposition pnote pnote showwindow sw_show addnote pnote void c main frame on traymain restoreall restore all notes position pos m pnotes get head position we don t want the cursor to jump like h ll bool b move cursor b move cursor the app m bminimizemovecursor the app m bminimizemovecursor false while pos c note p note c note m pnotes get next pos if p note get slided left p note get slided right p note restore note the app m bminimizemovecursor b move cursor cmainframe ontraymainrestoreall m_pnotes getheadposition bmovecursor bmovecursor theapp m_bminimizemovecursor theapp m_bminimizemovecursor cnote pnote cnote m_pnotes getnext pnote getslidedleft pnote getslidedright pnote restorenote theapp m_bminimizemovecursor bmovecursor void c main frame on traymain minimizeall minimize all notes position pos m pnotes get head position we don t want the cursor to jump like h ll bool b move cursor b move cursor the app m bminimizemovecursor the app m bminimizemovecursor false while pos c note p note c note m pnotes get next pos if p note get slided left p note get slided right p note minimize note the app m bminimizemovecursor b move cursor cmainframe ontraymainminimizeall m_pnotes getheadposition bmovecursor bmovecursor theapp m_bminimizemovecursor theapp m_bminimizemovecursor cnote pnote cnote m_pnotes getnext pnote getslidedleft pnote getslidedright pnote minimizenote theapp m_bminimizemovecursor bmovecursor void c main frame on traymain options csa prefs dialog dlg c dlg options general general c dlg options behaviour behaviour c dlg options looks looks c dlg options new note newnote c dlg options font font c dlg options alarm alarm c dlg options database database c dlg options transparancy transparancy c dlg options hot key hotkey c dlg options server server c dlg options recycle bin recyclebin c dlg options toolbar toolbar c dlg options language language c dlg options charset charset dlg add page general c translate read string 54 t general dlg add page looks c translate read string 55 t looks dlg add page behaviour c translate read string 56 t behaviour dlg add page newnote c translate read string 57 t new note dlg add page font c translate read string 58 t font dlg add page alarm c translate read string 59 t alarm dlg add page database c translate read string 60 t database dlg add page server c translate read string 61 t server dlg add page transparancy c translate read string 62 t transparancy dlg add page hotkey c translate read string 63 t hot key dlg add page recyclebin c translate read string 64 t recycle bin dlg add page toolbar c translate read string 65 t toolbar dlg add page language c translate read string 66 t language dlg add page charset c translate read string 195 t charset general m bwarnondelete the app m bwarnondelete general m szdefaulttitle the app m szdefaulttitle general m bversioncheck the app m bchecklatestversion looks m brndcolor the app m brndnotecolor looks m bthinborder the app m bthinnoteborder looks m cfcolor the app m cfnotecolor behaviour m bhideonminimize the app m bminimizeshrink behaviour m bdockable the app m bdockable behaviour m bdoubleclickontitlebar the app m bdoubleclickontitlebar behaviour m bminimizemovecursor the app m bminimizemovecursor behaviour m iclickonce the app m ileftclickontrayicon newnote m bdockbottom the app m bnewnotedockbottom newnote m bdockleft the app m bnewnotedockleft newnote m bdockright the app m bnewnotedockright newnote m bdocktop the app m bnewnotedocktop newnote m szleft format t d the app m inewnoteleft newnote m sztop format t d the app m inewnotetop newnote m szwidth format t d the app m inewnotewidth alarm m bblink the app m bblinknote alarm m bplaysound the app m bplayalarmsound alarm m szsoundfile the app m szalarmsoundfile database m buploaddownload the app m buploaddownload database m szpassword the app m szpassword database m szusername the app m szusername database m szdownloadafter format t d the app m istartdownloadingafter server m szaddress the app m szserveraddress server m szpath the app m szserverpath server m szport the app m szserverport server m busedefaultserver the app m busedefaultserver transparancy m itransparantminimized the app m itransparantminimized transparancy m itransparantnormal the app m itransparantnormal hotkey m balt the app m bhotkeyalt hotkey m bctrl the app m bhotkeyctrl hotkey m bshift the app m bhotkeyshift hotkey m bwin the app m bhotkeywin hotkey m busehotkey the app m busehotkey hotkey m icharacter the app m ihotkeycharacter recyclebin m bsortdescending the app m bsortrecyclebindescending recyclebin m sznumberofnotes the app m szrecyclebinnumberofnotes toolbar m iinusebold the app m itoolbarusebold toolbar m iinusebullet the app m itoolbarusebullet toolbar m iinuseitalic the app m itoolbaruseitalic toolbar m iinuseminimize the app m itoolbaruseminimize toolbar m iinuseslideleft the app m itoolbaruseslideleft toolbar m iinuseslideright the app m itoolbaruseslideright toolbar m iinuseunderline the app m itoolbaruseunderline toolbar m iinusestrikeout the app m itoolbarusestrikeout toolbar m ibuttonwidth the app m itoolbarbuttonwidth language m szlanguageini the app m szlanguageini charset m icharset the app m icharset charset m szcharsetname the app m szcharsetname the prefs dialog title dlg set title c translate read string 67 t options dlg set constant text t launch it like any other dialog if dlg do modal idok the app m bwarnondelete general m bwarnondelete the app m szdefaulttitle general m szdefaulttitle the app m bchecklatestversion general m bversioncheck the app m brndnotecolor looks m brndcolor the app m bthinnoteborder looks m bthinborder the app m cfnotecolor looks m cfcolor the app m bminimizeshrink behaviour m bhideonminimize the app m bdockable behaviour m bdockable the app m bdoubleclickontitlebar behaviour m bdoubleclickontitlebar the app m bminimizemovecursor behaviour m bminimizemovecursor the app m ileftclickontrayicon behaviour m iclickonce the app m bnewnotedockbottom newnote m bdockbottom the app m bnewnotedockleft newnote m bdockleft the app m bnewnotedockright newnote m bdockright the app m bnewnotedocktop newnote m bdocktop the app m inewnoteleft ttoi newnote m szleft the app m inewnotetop ttoi newnote m sztop the app m inewnotewidth ttoi newnote m szwidth the app m bblinknote alarm m bblink the app m bplayalarmsound alarm m bplaysound the app m szalarmsoundfile alarm m szsoundfile the app m buploaddownload database m buploaddownload the app m szpassword database m szpassword the app m szusername database m szusername the app m istartdownloadingafter ttoi database m szdownloadafter the app m szlanguageini language m szlanguageini server m szaddress make lower if server m szaddress find t http 0 server m szaddress replace t http t the app m szserveraddress server m szaddress the app m szserverpath server m szpath the app m szserverport server m szport the app m busedefaultserver server m busedefaultserver the app m itransparantminimized transparancy m itransparantminimized the app m itransparantnormal transparancy m itransparantnormal the app m bhotkeyalt hotkey m balt the app m bhotkeyctrl hotkey m bctrl the app m bhotkeyshift hotkey m bshift the app m bhotkeywin hotkey m bwin the app m busehotkey hotkey m busehotkey the app m ihotkeycharacter hotkey m icharacter the app m bsortrecyclebindescending recyclebin m bsortdescending the app m szrecyclebinnumberofnotes recyclebin m sznumberofnotes the app m itoolbarusebold toolbar m iinusebold the app m itoolbaruseitalic toolbar m iinuseitalic the app m itoolbaruseunderline toolbar m iinuseunderline the app m itoolbarusebullet toolbar m iinusebullet the app m itoolbaruseminimize toolbar m iinuseminimize the app m itoolbaruseslideleft toolbar m iinuseslideleft the app m itoolbaruseslideright toolbar m iinuseslideright the app m itoolbarusestrikeout toolbar m iinusestrikeout the app m itoolbarbuttonwidth toolbar m ibuttonwidth the app m szcharsetname charset m szcharsetname the app m icharset charset m icharset afx get app write profile int t settings options t warn on delete general m bwarnondelete afx get app write profile int t settings options t check for latest version general m bversioncheck afx get app write profile string t settings options t default title general m szdefaulttitle afx get app write profile int t settings options t shrinked when minimized behaviour m bhideonminimize afx get app write profile int t settings options t randomize note color looks m brndcolor afx get app write profile int t settings options t thin note border looks m bthinborder afx get app write profile int t settings options t default note color looks m cfcolor afx get app write profile int t settings options t notes are dockable behaviour m bdockable afx get app write profile int t settings options t double click on the title bar behaviour m bdoubleclickontitlebar afx get app write profile int t settings options t when minimized move cursor behaviour m bminimizemovecursor afx get app write profile int t settings options t action for single left click on the tray icon behaviour m iclickonce afx get app write profile int t settings options t new note docked left newnote m bdockleft afx get app write profile int t settings options t new note docked top newnote m bdocktop afx get app write profile int t settings options t new note docked right newnote m bdockright afx get app write profile int t settings options t new note docked bottom newnote m bdockbottom afx get app write profile int t settings options t new note left ttoi newnote m szleft afx get app write profile int t settings options t new note top ttoi newnote m sztop afx get app write profile int t settings options t new note width ttoi newnote m szwidth afx get app write profile int t settings options t blink on alarm alarm m bblink afx get app write profile int t settings options t play sound on alarm alarm m bplaysound afx get app write profile string t settings options t alarm sound file alarm m sz cmainframe ontraymainoptions csaprefsdialog cdlgoptionsgeneral cdlgoptionsbehaviour cdlgoptionslooks cdlgoptionsnewnote cdlgoptionsfont cdlgoptionsalarm cdlgoptionsdatabase cdlgoptionstransparancy cdlgoptionshotkey cdlgoptionsserver cdlgoptionsrecyclebin cdlgoptionstoolbar cdlgoptionslanguage cdlgoptionscharset addpage ctranslate readstring _t addpage ctranslate readstring _t addpage ctranslate readstring _t addpage ctranslate readstring _t addpage ctranslate readstring _t addpage ctranslate readstring _t addpage ctranslate readstring _t addpage ctranslate readstring _t addpage ctranslate readstring _t addpage ctranslate readstring _t addpage ctranslate readstring _t addpage ctranslate readstring _t addpage ctranslate readstring _t addpage ctranslate readstring _t m_bwarnondelete theapp m_bwarnondelete m_szdefaulttitle theapp m_szdefaulttitle m_bversioncheck theapp m_bchecklatestversion m_brndcolor theapp m_brndnotecolor m_bthinborder theapp m_bthinnoteborder m_cfcolor theapp m_cfnotecolor m_bhideonminimize theapp m_bminimizeshrink m_bdockable theapp m_bdockable m_bdoubleclickontitlebar theapp m_bdoubleclickontitlebar m_bminimizemovecursor theapp m_bminimizemovecursor m_iclickonce theapp m_ileftclickontrayicon m_bdockbottom theapp m_bnewnotedockbottom m_bdockleft theapp m_bnewnotedockleft m_bdockright theapp m_bnewnotedockright m_bdocktop theapp m_bnewnotedocktop m_szleft _t theapp m_inewnoteleft m_sztop _t theapp m_inewnotetop m_szwidth _t theapp m_inewnotewidth m_bblink theapp m_bblinknote m_bplaysound theapp m_bplayalarmsound m_szsoundfile theapp m_szalarmsoundfile m_buploaddownload theapp m_buploaddownload m_szpassword theapp m_szpassword m_szusername theapp m_szusername m_szdownloadafter _t theapp m_istartdownloadingafter m_szaddress theapp m_szserveraddress m_szpath theapp m_szserverpath m_szport theapp m_szserverport m_busedefaultserver theapp m_busedefaultserver m_itransparantminimized theapp m_itransparantminimized m_itransparantnormal theapp m_itransparantnormal m_balt theapp m_bhotkeyalt m_bctrl theapp m_bhotkeyctrl m_bshift theapp m_bhotkeyshift m_bwin theapp m_bhotkeywin m_busehotkey theapp m_busehotkey m_icharacter theapp m_ihotkeycharacter m_bsortdescending theapp m_bsortrecyclebindescending m_sznumberofnotes theapp m_szrecyclebinnumberofnotes m_iinusebold theapp m_itoolbarusebold m_iinusebullet theapp m_itoolbarusebullet m_iinuseitalic theapp m_itoolbaruseitalic m_iinuseminimize theapp m_itoolbaruseminimize m_iinuseslideleft theapp m_itoolbaruseslideleft m_iinuseslideright theapp m_itoolbaruseslideright m_iinuseunderline theapp m_itoolbaruseunderline m_iinusestrikeout theapp m_itoolbarusestrikeout m_ibuttonwidth theapp m_itoolbarbuttonwidth m_szlanguageini theapp m_szlanguageini m_icharset theapp m_icharset m_szcharsetname theapp m_szcharsetname settitle ctranslate readstring _t setconstanttext _t domodal theapp m_bwarnondelete m_bwarnondelete theapp m_szdefaulttitle m_szdefaulttitle theapp m_bchecklatestversion m_bversioncheck theapp m_brndnotecolor m_brndcolor theapp m_bthinnoteborder m_bthinborder theapp m_cfnotecolor m_cfcolor theapp m_bminimizeshrink m_bhideonminimize theapp m_bdockable m_bdockable theapp m_bdoubleclickontitlebar m_bdoubleclickontitlebar theapp m_bminimizemovecursor m_bminimizemovecursor theapp m_ileftclickontrayicon m_iclickonce theapp m_bnewnotedockbottom m_bdockbottom theapp m_bnewnotedockleft m_bdockleft theapp m_bnewnotedockright m_bdockright theapp m_bnewnotedocktop m_bdocktop theapp m_inewnoteleft _ttoi m_szleft theapp m_inewnotetop _ttoi m_sztop theapp m_inewnotewidth _ttoi m_szwidth theapp m_bblinknote m_bblink theapp m_bplayalarmsound m_bplaysound theapp m_szalarmsoundfile m_szsoundfile theapp m_buploaddownload m_buploaddownload theapp m_szpassword m_szpassword theapp m_szusername m_szusername theapp m_istartdownloadingafter _ttoi m_szdownloadafter theapp m_szlanguageini m_szlanguageini m_szaddress makelower m_szaddress _t m_szaddress _t _t theapp m_szserveraddress m_szaddress theapp m_szserverpath m_szpath theapp m_szserverport m_szport theapp m_busedefaultserver m_busedefaultserver theapp m_itransparantminimized m_itransparantminimized theapp m_itransparantnormal m_itransparantnormal theapp m_bhotkeyalt m_balt theapp m_bhotkeyctrl m_bctrl theapp m_bhotkeyshift m_bshift theapp m_bhotkeywin m_bwin theapp m_busehotkey m_busehotkey theapp m_ihotkeycharacter m_icharacter theapp m_bsortrecyclebindescending m_bsortdescending theapp m_szrecyclebinnumberofnotes m_sznumberofnotes theapp m_itoolbarusebold m_iinusebold theapp m_itoolbaruseitalic m_iinuseitalic theapp m_itoolbaruseunderline m_iinuseunderline theapp m_itoolbarusebullet m_iinusebullet theapp m_itoolbaruseminimize m_iinuseminimize theapp m_itoolbaruseslideleft m_iinuseslideleft theapp m_itoolbaruseslideright m_iinuseslideright theapp m_itoolbarusestrikeout m_iinusestrikeout theapp m_itoolbarbuttonwidth m_ibuttonwidth theapp m_szcharsetname m_szcharsetname theapp m_icharset m_icharset afxgetapp writeprofileint _t _t m_bwarnondelete afxgetapp writeprofileint _t _t m_bversioncheck afxgetapp writeprofilestring _t _t m_szdefaulttitle afxgetapp writeprofileint _t _t m_bhideonminimize afxgetapp writeprofileint _t _t m_brndcolor afxgetapp writeprofileint _t _t m_bthinborder afxgetapp writeprofileint _t _t m_cfcolor afxgetapp writeprofileint _t _t m_bdockable afxgetapp writeprofileint _t _t titlebar m_bdoubleclickontitlebar afxgetapp writeprofileint _t _t m_bminimizemovecursor afxgetapp writeprofileint _t _t m_iclickonce afxgetapp writeprofileint _t _t m_bdockleft afxgetapp writeprofileint _t _t m_bdocktop afxgetapp writeprofileint _t _t m_bdockright afxgetapp writeprofileint _t _t m_bdockbottom afxgetapp writeprofileint _t _t _ttoi m_szleft afxgetapp writeprofileint _t _t _ttoi m_sztop afxgetapp writeprofileint _t _t _ttoi m_szwidth afxgetapp writeprofileint _t _t m_bblink afxgetapp writeprofileint _t _t m_bplaysound afxgetapp writeprofilestring _t _t m_sz void c main frame on traymain stayontop the app m bstayontop the app m bstayontop false the app m bstayontop true afx get app write profile int t settings options t stay on top the app m bstayontop position pos m pnotes get head position while pos c note p note c note m pnotes get next pos if the app m bstayontop p note set window pos wnd top most 0 0 0 0 swp nomove swp nosize else p note set window pos wnd no top most 0 0 0 0 swp nomove swp nosize cmainframe ontraymainstayontop theapp m_bstayontop theapp m_bstayontop theapp m_bstayontop afxgetapp writeprofileint _t _t theapp m_bstayontop m_pnotes getheadposition cnote pnote cnote m_pnotes getnext theapp m_bstayontop pnote setwindowpos wndtopmost swp_nomove swp_nosize pnote setwindowpos wndnotopmost swp_nomove swp_nosize void c main frame on update traymain stayontop c cmdui p cmdui p cmdui set check the app m bstayontop cmainframe onupdatetraymainstayontop ccmdui pcmdui pcmdui setcheck theapp m_bstayontop void c main frame on close delete the timer kill timer id alarmtimer kill timer id savetimer save any note c string sz file sz file format t s notes xml get application data path save sz file send the notes to the web if the app m buploaddownload send notes to web unregister any hotkey unregister hot key m hwnd the app m ihotkeyid c frame wnd on close cmainframe onclose killtimer id_alarmtimer killtimer id_savetimer cstring szfile szfile _t getapplicationdatapath szfile theapp m_buploaddownload sendnotestoweb unregisterhotkey m_hwnd theapp m_ihotkeyid cframewnd onclose void c main frame on timer uint nid event see if we want to connect to internet if nid event id startconnecttointernet kill timer id startconnecttointernet get the notes from the website if the app m buploaddownload the app m bminimizemovecursor false get notes from server the app m bminimizemovecursor afx get app get profile int t settings options t when minimized move cursor 1 check for newer version if the app m bchecklatestversion check for newer version see if any alarm is beating if nid event id alarmtimer c ole date time time c ole date time get current time position pos m pnotes get head position while pos c note p note c note m pnotes get next pos if p note get use alarm p note is alarm shouting if date greater than or equal time p note get alarm p note show alarm see if we should autosave if nid event id savetimer c string sz file sz file format t s notes xml get application data path save sz file c frame wnd on timer nid event cmainframe ontimer nidevent nidevent id_startconnecttointernet killtimer id_startconnecttointernet theapp m_buploaddownload theapp m_bminimizemovecursor getnotesfromserver theapp m_bminimizemovecursor afxgetapp getprofileint _t _t theapp m_bchecklatestversion checkfornewerversion nidevent id_alarmtimer coledatetime coledatetime getcurrenttime m_pnotes getheadposition cnote pnote cnote m_pnotes getnext pnote getusealarm pnote isalarmshouting dategreaterthanorequal pnote getalarm pnote showalarm nidevent id_savetimer cstring szfile szfile _t getapplicationdatapath szfile cframewnd ontimer nidevent void c main frame 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 c menu cmenu c menu from handle hmenu lp measure item struct itemid if bc menu is menu cmenu m menu measure item lp measure item struct setflag true if setflag c frame wnd on measure item nid ctl lp measure item struct cmainframe onmeasureitem nidctl lpmeasureitemstruct lpmeasureitemstruct ctltype odt_menu ismenu lpmeasureitemstruct cmenu cmenu fromhandle lpmeasureitemstruct bcmenu ismenu m_menu measureitem lpmeasureitemstruct cframewnd onmeasureitem nidctl lpmeasureitemstruct lresult c main frame on menu char uint n char uint n flags c menu p menu lresult lresult if bc menu is menu p menu lresult bc menu find keyboard shortcut n char n flags p menu else lresult c frame wnd on menu char n char n flags p menu return lresult cmainframe onmenuchar nchar nflags cmenu pmenu bcmenu ismenu pmenu bcmenu findkeyboardshortcut nchar nflags pmenu cframewnd onmenuchar nchar nflags pmenu void c main frame on init menu popup c menu p popup menu uint n index bool b sys menu c frame wnd on init menu popup p popup menu n index b sys menu if b sys menu if bc menu is menu p popup menu bc menu update menu p popup menu cmainframe oninitmenupopup cmenu ppopupmenu nindex bsysmenu cframewnd oninitmenupopup ppopupmenu nindex bsysmenu bsysmenu bcmenu ismenu ppopupmenu bcmenu updatemenu ppopupmenu void c main frame on traymain visitanotewebsite go to a note s website with the default web browser c string sz temp tchar s path max path sz temp format t stemp htm get application data path c file fp fp open sz temp c file mode create c file mode write fp close hinstance hi nst find executable sz temp get application data path s path delete file sz temp shell execute null t open s path t http a note sourceforge net null sw showmaximized cmainframe ontraymainvisitanotewebsite cstring sztemp spath max_path sztemp _t getapplicationdatapath cfile sztemp cfile modecreate cfile modewrite hinst findexecutable sztemp getapplicationdatapath spath deletefile sztemp shellexecute _t spath _t sw_showmaximized void c main frame on update traymain minimizeall c cmdui p cmdui see if any is minimized bool b minimize false position pos m pnotes get head position while pos c note p note c note m pnotes get next pos if p note get visible b minimize true p cmdui enable b minimize cmainframe onupdatetraymainminimizeall ccmdui pcmdui bminimize m_pnotes getheadposition cnote pnote cnote m_pnotes getnext pnote getvisible bminimize pcmdui bminimize void c main frame on update traymain restoreall c cmdui p cmdui see if any is minimized bool b minimize false position pos m pnotes get head position while pos c note p note c note m pnotes get next pos if p note get visible b minimize true p cmdui enable b minimize cmainframe onupdatetraymainrestoreall ccmdui pcmdui bminimize m_pnotes getheadposition cnote pnote cnote m_pnotes getnext pnote getvisible bminimize pcmdui bminimize void c main frame on traymain importexport import import notes openfilename ofn tchar sz file 260 sz file 0 null zero memory ofn sizeof openfilename ofn l struct size sizeof openfilename ofn hwnd owner m hwnd ofn lpstr file sz file ofn n max file sizeof sz file ofn lpstr filter t a note file xml 0 xml ofn n filter index 1 ofn lpstr file title null ofn n max file title 0 ofn lpstr initial dir null ofn flags ofn pathmustexist ofn filemustexist if get open file name ofn true return c string sz name sz name c string ofn lpstr file load sz name cmainframe ontraymainimportexportimport szfile szfile zeromemory lstructsize hwndowner m_hwnd lpstrfile szfile nmaxfile szfile lpstrfilter _t nfilterindex lpstrfiletitle nmaxfiletitle lpstrinitialdir ofn_pathmustexist ofn_filemustexist getopenfilename cstring szname szname cstring lpstrfile szname void c main frame on restore minimized note uint nid restore the note that is minimized this functions is called from the traymenu int i count nid id minimizedmenuitem position pos m pnotes get head position while pos c note note c note m pnotes get next pos if note get visible i count 0 note restore note return if note get visible i count cmainframe onrestoreminimizednote icount id_minimizedmenuitem m_pnotes getheadposition cnote cnote m_pnotes getnext getvisible icount restorenote getvisible icount void c main frame on traymain importexport export export notes openfilename ofn tchar sz file 260 sz file 0 null zero memory ofn sizeof openfilename ofn l struct size sizeof openfilename ofn hwnd owner m hwnd ofn lpstr file sz file ofn n max file sizeof sz file ofn lpstr filter t a note file xml 0 xml ofn n filter index 1 ofn lpstr file title null ofn n max file title 0 ofn lpstr initial dir null ofn flags ofn pathmustexist ofn filemustexist if get save file name ofn true return c string sz name sz name c string ofn lpstr file add xml sz name make lower if sz name right 4 t xml sz name t xml save the file save sz name cmainframe ontraymainimportexportexport szfile szfile zeromemory lstructsize hwndowner m_hwnd lpstrfile szfile nmaxfile szfile lpstrfilter _t nfilterindex lpstrfiletitle nmaxfiletitle lpstrinitialdir ofn_pathmustexist ofn_filemustexist getsavefilename cstring szname szname cstring lpstrfile szname makelower szname _t szname _t szname hresult c main frame on get notes thread wparam w param lparam l param assert w param l param determin what we should do show the download tray icon arrows if w param 1 l param 0 animate tray download show the upload tray icon arrows if w param 2 l param 0 animate tray upload show the normal tray icon if w param 3 l param 0 no animate parse the xml and create the notes if w param 4 l param null c string szxml c string l param parsexml szxml return 0 cmainframe ongetnotesthread wparam lparam wparam lparam wparam lparam animatetraydownload wparam lparam animatetrayupload wparam lparam noanimate wparam lparam cstring cstring lparam hresult c main frame on get lates version thread wparam w param lparam l param assert w param l param determin what we should do show the download tray icon arrows if w param 1 l param 0 animate tray download show the normal tray icon if w param 3 l param 0 no animate parse the xml and see if we have an older version than sourceforge if w param 4 l param null c string szxml c string l param parsexml szxml return 0 cmainframe ongetlatesversionthread wparam lparam wparam lparam wparam lparam animatetraydownload wparam lparam noanimate wparam lparam cstring cstring lparam void c main frame on traymain uploaddownload downloadnotes download the notes get notes from server cmainframe ontraymainuploaddownloaddownloadnotes getnotesfromserver void c main frame on traymain uploaddownload uploadnotes send the notes to the web send notes to web cmainframe ontraymainuploaddownloaduploadnotes sendnotestoweb void c main frame on update traymain uploaddownload uploadnotes c cmdui p cmdui p cmdui enable m pnotes get count 0 true false cmainframe onupdatetraymainuploaddownloaduploadnotes ccmdui pcmdui pcmdui m_pnotes getcount void c main frame on traymain sendbugg send bugg or feedback email to a note s admin create the message c mapi message message setup the all the recipient types for this message message add multiple recipients t brummelisa users sourceforge net c mapi message to add the subject and body message m sbody t place your bugg or feedback here message m ssubject t bug feedback from a note connect to server c mapi session connection bool b logon false b logon connection shared logon if b logon else send the message bool b success false if connection send message 1 1 this c string s msg s msg format t s n error d c translate read string 25 t couldn t send message connection get last error afx message box s msg mb iconstop cmainframe ontraymainsendbugg cmapimessage addmultiplerecipients _t cmapimessage m_sbody _t m_ssubject _t cmapisession blogon blogon sharedlogon blogon bsuccess cstring smsg smsg _t nerror ctranslate readstring _t getlasterror afxmessagebox smsg mb_iconstop lresult c main frame on hot key wparam w param lparam l param the hot key was pressed on traymain newnote return 0 cmainframe onhotkey wparam lparam ontraymainnewnote void c main frame on traymain faq show the faq shell execute null t open get program path t faq html t null sw showmaximized cmainframe ontraymainfaq shellexecute _t getprogrampath _t _t sw_showmaximized bool c main frame on query end session if c frame wnd on query end session return false windows is shutting down save c main frame p main c main frame afx get main wnd c string sz file sz file format t s notes xml get application data path save sz file send the notes to the web if the app m buploaddownload p main send notes to web return true cmainframe onqueryendsession cframewnd onqueryendsession cmainframe pmain cmainframe afxgetmainwnd cstring szfile szfile _t getapplicationdatapath szfile theapp m_buploaddownload pmain sendnotestoweb void c main frame on traymain recyclebin start the recycle bin part so we can find our deleted notes c dlg recycle bin dlg dlg do modal cmainframe ontraymainrecyclebin cdlgrecyclebin domodal void c main frame on traymain checkforupdates check for newer version if m szversion get program version afx message box c translate read string 26 t you have the latest version of a note cmainframe ontraymaincheckforupdates checkfornewerversion m_szversion getprogramversion afxmessagebox ctranslate readstring _t void c main frame on pressed left button on tray icon the user has pressed on the tray icon with the left button and no alarm is on determin what we should do position pos switch the app m ileftclickontrayicon case 0 create a new note fast on traymain newnote break case 1 hide show all notes pos m pnotes get head position while pos c note p note c note m pnotes get next pos if m bnotesarehidden p note show window sw show m trayicon set tooltip text t a note else p note show window sw hide c string sz temp sz temp format t a note n s c translate read string 19 t notes are hidden m trayicon set tooltip text sz temp m bnotesarehidden m bnotesarehidden break default oups something is wrong here assert false break cmainframe onpressedleftbuttonontrayicon theapp m_ileftclickontrayicon ontraymainnewnote m_pnotes getheadposition cnote pnote cnote m_pnotes getnext m_bnotesarehidden pnote showwindow sw_show m_trayicon settooltiptext _t pnote showwindow sw_hide cstring sztemp sztemp _t ctranslate readstring _t m_trayicon settooltiptext sztemp m_bnotesarehidden m_bnotesarehidden c error log c error log cerrorlog cerrorlog c error log c error log int i type c string sz error text c string sz time sz text sz file sz type c stdio file fp get the time sz time get time format the text switch i type case 1 sz type t info break case 2 sz type t error break default assert false break sz text format t s s s r n sz type sz time sz error text try to write the text sz file format t s error log txt get application data path if fp open sz file c file mode create c file mode write c file mode no truncate assert false something went wrong and we could not open the file return try dword dw fp seek to end if defined unicode defined unicode int i length i length sz text get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 i length wide char to multi byte cp utf8 0 sz text i length pc dest 2 i length null null fp write pc dest i length delete pc dest delete pwc unicode else fp write sz text sz text get length endif fp close catch c file exception e assert false we could not write to the file return end catch cerrorlog cerrorlog itype cstring szerrortext cstring sztime sztext szfile sztype cstdiofile sztime gettime itype sztype _t sztype _t sztext _t sztype sztime szerrortext szfile _t errorlog getapplicationdatapath szfile cfile modecreate cfile modewrite cfile modenotruncate seektoend _unicode ilength ilength sztext getlength pwcunicode ilength pcdest ilength ilength widechartomultibyte cp_utf8 sztext ilength pcdest ilength pcdest ilength pcdest pwcunicode sztext sztext getlength cfileexception end_catch c error log c error log cerrorlog cerrorlog c string c error log get time return the current time as 2004 09 30 21 34 30 return c time get current time format t y m d h m s cstring cerrorlog gettime ctime getcurrenttime _t c translate c translate ctranslate ctranslate c translate c translate ctranslate ctranslate c string c translate read string int i what c string sz default assert i what text size c string sz file sz file format t s language s get program path the app m szlanguageini find the text from the default inifile tchar c text 255 c string sz temp sz temp format t d i what get private profile string t translation sz temp sz default c text 255 sz file return c string c text cstring ctranslate readstring iwhat cstring szdefault iwhat textsize cstring szfile szfile _t getprogrampath theapp m_szlanguageini ctext cstring sztemp sztemp _t iwhat getprivateprofilestring _t sztemp szdefault ctext szfile cstring ctext c string c translate read string int i what c string sz default c string sz ini file assert i what text size find the text from the selected inifile tchar c text 255 c string sz temp sz temp format t d i what get private profile string t translation sz temp sz default c text 255 sz ini file return c string c text cstring ctranslate readstring iwhat cstring szdefault cstring szinifile iwhat textsize ctext cstring sztemp sztemp _t iwhat getprivateprofilestring _t sztemp szdefault ctext szinifile cstring ctext void c translate save string int i what c string sz text c string sz ini file assert i what text size save the text c string sz temp sz temp format t d i what write private profile string t translation sz temp sz text sz ini file ctranslate savestring iwhat cstring sztext cstring szinifile iwhat textsize cstring sztemp sztemp _t iwhat writeprivateprofilestring _t sztemp sztext szinifile ca note app ca note app canoteapp canoteapp bool ca note app init instance afx enable control container set registry key t a note m bstayontop get profile int t settings options t stay on top 1 m cfnotecolor get profile int t settings options t default note color rgb 255 255 125 m itransparantnormal get profile int t settings options t transparancy 100 m itransparantminimized get profile int t settings options t transparancy when minimized 100 m brndnotecolor get profile int t settings options t randomize note color 0 m bthinnoteborder get profile int t settings options t thin note border 1 m bminimizeshrink get profile int t settings options t shrinked when minimized 1 m bwarnondelete get profile int t settings options t warn on delete 0 m bblinknote get profile int t settings options t blink on alarm 1 m bplayalarmsound get profile int t settings options t play sound on alarm 1 m bdockable get profile int t settings options t notes are dockable 1 m bchecklatestversion get profile int t settings options t check for latest version 1 m bnewnotedockleft get profile int t settings options t new note docked left 0 m bnewnotedocktop get profile int t settings options t new note docked top 0 m bnewnotedockright get profile int t settings options t new note docked right 1 m bnewnotedockbottom get profile int t settings options t new note docked bottom 1 m inewnoteleft get profile int t settings options t new note left 0 m inewnotetop get profile int t settings options t new note top 0 m inewnotewidth get profile int t settings options t new note width 150 m bdoubleclickontitlebar get profile int t settings options t double click on the title bar 0 m bhotkeyalt get profile int t settings options t hot key alt 0 m bhotkeyctrl get profile int t settings options t hot key ctrl 0 m bhotkeyshift get profile int t settings options t hot key shift 0 m bhotkeywin get profile int t settings options t hot key win 0 m busehotkey get profile int t settings options t hot key use it 0 m ihotkeycharacter get profile int t settings options t hot key character 0 m bminimizemovecursor get profile int t settings options t when minimized move cursor 1 m szdefaulttitle get profile string t settings options t default title t untitled m szserveraddress get profile string t settings options t server address t http a note sourceforge net m szserverport get profile string t settings options t server port t 80 m szserverpath get profile string t settings options t server path t m busedefaultserver get profile int t settings options t use default server 1 m bshowdeletemessage get profile int t settings options t show delete message 1 m istartdownloadingafter get profile int t settings options t start downloading after 0 m bsortrecyclebindescending get profile int t settings options t sort recycle bin descending 1 m szrecyclebinnumberofnotes get profile string t settings options t save total number of notes for the recycle bin t 0 m ileftclickontrayicon get profile int t settings options t action for single left click on the tray icon 0 m szlanguageini get profile string t settings options t ini file used for language t english ini m itoolbarusebold get profile int t settings options t tool bar use bold button where 0 m itoolbaruseitalic get profile int t settings options t tool bar use italic button where 0 m itoolbaruseunderline get profile int t settings options t tool bar use underline button where 0 m itoolbarusebullet get profile int t settings options t tool bar use bullet button where 0 m itoolbaruseminimize get profile int t settings options t tool bar use minimize button where 1 m itoolbaruseslideleft get profile int t settings options t tool bar use slide left button where 0 m itoolbaruseslideright get profile int t settings options t tool bar use slide right button where 2 m itoolbarusestrikeout get profile int t settings options t tool bar use strikeout where 0 m itoolbarbuttonwidth get profile int t settings options t tool bar button width 0 m icharset get profile int t settings options t selected charset value unicode default charset m szcharsetname get profile string t settings options t selected charset readable name unicode t default charset c string sz temp sz temp format t s alarm wav get program path m szalarmsoundfile get profile string t settings options t alarm sound file sz temp m buploaddownload get profile int t settings options t upload and download notes 1 m szusername get profile string t settings options t database user name t m szpassword get profile string t settings options t database password t show the help information that shows for beginner ifdef showhelp c dlg guide dlgguide if get profile int t settings help t show beginners help 0 0 dlgguide do modal write profile int t settings help t show beginners help dlgguide m bdontshowagain endif note this will only happen the first time if get profile int t settings options t ask questions first time the program runs 1 upload download notes c string sz temp sz temp format t s n s n s n s n s c translate read string 166 t every time a note starts and ends it will contact a server c translate read string 167 t and upload and download any notes that you have this feature lets you share your c translate read string 168 t notes between different computers if you want this to happen automatically press yes c translate read string 169 t if you don t want this feature to start automatically press no c translate read string 170 t you can always change this behaviour in the options menu if message box null sz temp c translate read string 171 upload download notes mb yesno mb iconquestion idno m buploaddownload false write profile int t settings options t upload and download notes 0 write profile int t settings options t ask questions first time the program runs 0 ifdef afxdll enable3d controls else enable3d controls static endif c main frame p frame new c main frame m pmainwnd p frame p frame load frame idr mainframe ws overlappedwindow fws addtotitle null null p frame show window sw show p frame update window c menu p menu m pmainwnd get menu if p menu p menu destroy menu hmenu h menu c main frame m pmainwnd new menu p menu c menu from handle h menu m pmainwnd set menu p menu c main frame m pmainwnd m hmenudefault h menu return true canoteapp initinstance afxenablecontrolcontainer setregistrykey _t m_bstayontop getprofileint _t _t m_cfnotecolor getprofileint _t _t m_itransparantnormal getprofileint _t _t m_itransparantminimized getprofileint _t _t m_brndnotecolor getprofileint _t _t m_bthinnoteborder getprofileint _t _t m_bminimizeshrink getprofileint _t _t m_bwarnondelete getprofileint _t _t m_bblinknote getprofileint _t _t m_bplayalarmsound getprofileint _t _t m_bdockable getprofileint _t _t m_bchecklatestversion getprofileint _t _t m_bnewnotedockleft getprofileint _t _t m_bnewnotedocktop getprofileint _t _t m_bnewnotedockright getprofileint _t _t m_bnewnotedockbottom getprofileint _t _t m_inewnoteleft getprofileint _t _t m_inewnotetop getprofileint _t _t m_inewnotewidth getprofileint _t _t m_bdoubleclickontitlebar getprofileint _t _t titlebar m_bhotkeyalt getprofileint _t _t m_bhotkeyctrl getprofileint _t _t m_bhotkeyshift getprofileint _t _t m_bhotkeywin getprofileint _t _t m_busehotkey getprofileint _t _t m_ihotkeycharacter getprofileint _t _t m_bminimizemovecursor getprofileint _t _t m_szdefaulttitle getprofilestring _t _t _t m_szserveraddress getprofilestring _t _t _t m_szserverport getprofilestring _t _t _t m_szserverpath getprofilestring _t _t _t m_busedefaultserver getprofileint _t _t m_bshowdeletemessage getprofileint _t _t m_istartdownloadingafter getprofileint _t _t m_bsortrecyclebindescending getprofileint _t _t m_szrecyclebinnumberofnotes getprofilestring _t _t _t m_ileftclickontrayicon getprofileint _t _t m_szlanguageini getprofilestring _t _t _t m_itoolbarusebold getprofileint _t _t toolbar m_itoolbaruseitalic getprofileint _t _t toolbar m_itoolbaruseunderline getprofileint _t _t toolbar m_itoolbarusebullet getprofileint _t _t toolbar m_itoolbaruseminimize getprofileint _t _t toolbar m_itoolbaruseslideleft getprofileint _t _t toolbar m_itoolbaruseslideright getprofileint _t _t toolbar m_itoolbarusestrikeout getprofileint _t _t toolbar m_itoolbarbuttonwidth getprofileint _t _t toolbar m_icharset getprofileint _t _t default_charset m_szcharsetname getprofilestring _t _t _t default_charset cstring sztemp sztemp _t getprogrampath m_szalarmsoundfile getprofilestring _t _t sztemp m_buploaddownload getprofileint _t _t m_szusername getprofilestring _t _t _t m_szpassword getprofilestring _t _t _t _showhelp cdlgguide getprofileint _t _t domodal writeprofileint _t _t m_bdontshowagain getprofileint _t _t cstring sztemp sztemp _t ctranslate readstring _t ctranslate readstring _t ctranslate readstring _t ctranslate readstring _t ctranslate readstring _t messagebox sztemp ctranslate readstring mb_yesno mb_iconquestion m_buploaddownload writeprofileint _t _t writeprofileint _t _t _afxdll enable3dcontrols enable3dcontrolsstatic cmainframe pframe cmainframe m_pmainwnd pframe pframe loadframe idr_mainframe ws_overlappedwindow fws_addtotitle pframe showwindow sw_show pframe updatewindow cmenu pmenu m_pmainwnd getmenu pmenu pmenu destroymenu hmenu cmainframe m_pmainwnd newmenu pmenu cmenu fromhandle hmenu m_pmainwnd setmenu pmenu cmainframe m_pmainwnd m_hmenudefault hmenu int ca note app exit instance return c win app exit instance canoteapp exitinstance cwinapp exitinstance void ca note app on app about c about dlg about dlg about dlg do modal canoteapp onappabout caboutdlg aboutdlg aboutdlg domodal c dialog c dlg guide idd p parent afx data init c dlg guide m bdontshowagain false afx data init m ipage 1 cdialog cdlgguide pparent afx_data_init cdlgguide m_bdontshowagain afx_data_init m_ipage void c dlg guide do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c dlg guide ddx check pdx idc showagain m bdontshowagain afx data map cdlgguide dodataexchange cdataexchange cdialog dodataexchange afx_data_map cdlgguide ddx_check idc_showagain m_bdontshowagain afx_data_map void c dlg guide on next make sure that the previous button is enabled c button get dlg item idc previous enable window true go to next page m ipage are we at the end if m ipage 10 c button get dlg item idc next enable window false load the right image c string sz name sz name format t s guide guide d jpg get program path m ipage m pimage load sz name show the right page invalidate false cdlgguide onnext cbutton getdlgitem idc_previous enablewindow m_ipage m_ipage cbutton getdlgitem idc_next enablewindow cstring szname szname _t guide_ getprogrampath m_ipage m_pimage szname void c dlg guide on previous make sure that the next button is enabled c button get dlg item idc next enable window true go to previous page m ipage are we at the first page if m ipage 1 c button get dlg item idc previous enable window false load the right image c string sz name sz name format t s guide guide d jpg get program path m ipage m pimage load sz name show the right page invalidate false cdlgguide onprevious cbutton getdlgitem idc_next enablewindow m_ipage m_ipage cbutton getdlgitem idc_previous enablewindow cstring szname szname _t guide_ getprogrampath m_ipage m_pimage szname bool c dlg guide on erase bkgnd cdc pdc to avoid flicker return true cdlgguide onerasebkgnd void c dlg guide on finish close the dialog onok cdlgguide onfinish void c dlg guide on paint c paintdc dc this cdc pdc pdc getdc c rect rect get client rect rect c brush brush brush create solid brush get sys color color 3dface c brush p old brush c brush dc select object brush dc rectangle rect c pen pen pen create pen ps solid 2 rgb 0 0 0 c pen p old pen c pen dc select object pen dc move to 0 252 dc line to rect right 252 m pimage draw pdc c point 1 1 c point 400 250 dc select object p old brush cdlgguide onpaint cpaintdc crect getclientrect cbrush createsolidbrush getsyscolor color_3dface cbrush poldbrush cbrush selectobject cpen createpen ps_solid cpen poldpen cpen selectobject moveto lineto m_pimage cpoint cpoint selectobject poldbrush bool c dlg guide on init dialog language stuff c button get dlg item idc showagain set window text c translate read string 46 don t show again c button get dlg item idc previous set window text c translate read string 47 previous c button get dlg item idc next set window text c translate read string 48 next c button get dlg item idc finish set window text c translate read string 49 finish load the first image c string sz name sz name format t s guide guide 1 jpg get program path m pimage load sz name invalidate false c dialog on init dialog return true cdlgguide oninitdialog cbutton getdlgitem idc_showagain setwindowtext ctranslate readstring cbutton getdlgitem idc_previous setwindowtext ctranslate readstring cbutton getdlgitem idc_next setwindowtext ctranslate readstring cbutton getdlgitem idc_finish setwindowtext ctranslate readstring cstring szname szname _t guide_1 getprogrampath m_pimage szname cdialog oninitdialog m nebuflen 0 m_nebuflen c base64 c base64 if m pdbuffer null delete m pdbuffer if m pebuffer null delete m pebuffer cbase64 cbase64 m_pdbuffer m_pdbuffer m_pebuffer m_pebuffer void c base64 encode const pbyte p buffer dword n buf len set decode buffer p buffer n buf len alloc encode n buf len 2 temp bucket raw dword n index 0 while n index 3 n buf len raw clear copy memory raw m pdbuffer n index 3 raw n size 3 encodetobuffer raw m pebuffer m nedatalen n index 3 m nedatalen 4 if n buf len n index raw clear raw n size byte n buf len n index copy memory raw m pdbuffer n index n buf len n index encodetobuffer raw m pebuffer m nedatalen m nedatalen 4 cbase64 pbuffer nbuflen setdecodebuffer pbuffer nbuflen allocencode nbuflen tempbucket nindex nindex nbuflen copymemory m_pdbuffer nindex nsize _encodetobuffer m_pebuffer m_nedatalen nindex m_nedatalen nbuflen nindex nsize nbuflen nindex copymemory m_pdbuffer nindex nbuflen nindex _encodetobuffer m_pebuffer m_nedatalen m_nedatalen void c base64 decode const pbyte p buffer dword dw buf len if c base64 m init init set encode buffer p buffer dw buf len alloc decode dw buf len temp bucket raw dword n index 0 while n index 4 m nedatalen raw clear raw n data 0 c base64 m decodetable m pebuffer n index raw n data 1 c base64 m decodetable m pebuffer n index 1 raw n data 2 c base64 m decodetable m pebuffer n index 2 raw n data 3 c base64 m decodetable m pebuffer n index 3 if raw n data 2 255 raw n data 2 0 if raw n data 3 255 raw n data 3 0 raw n size 4 decodetobuffer raw m pdbuffer m nddatalen n index 4 m nddatalen 3 if n index m nedatalen then we got a decode message without padding we may want to throw some kind of warning here but we are still required to handle the decoding as if it was properly padded if n index m nedatalen raw clear for dword i n index i m nedatalen i raw n data i n index c base64 m decodetable m pebuffer i raw n size if raw n data i n index 255 raw n data i n index 0 decodetobuffer raw m pdbuffer m nddatalen m nddatalen m nedatalen n index cbase64 pbuffer dwbuflen cbase64 m_init _init setencodebuffer pbuffer dwbuflen allocdecode dwbuflen tempbucket nindex nindex m_nedatalen ndata cbase64 m_decodetable m_pebuffer nindex ndata cbase64 m_decodetable m_pebuffer nindex ndata cbase64 m_decodetable m_pebuffer nindex ndata cbase64 m_decodetable m_pebuffer nindex ndata ndata ndata ndata nsize _decodetobuffer m_pdbuffer m_nddatalen nindex m_nddatalen nindex m_nedatalen nindex m_nedatalen nindex m_nedatalen ndata nindex cbase64 m_decodetable m_pebuffer nsize ndata nindex ndata nindex _decodetobuffer m_pdbuffer m_nddatalen m_nddatalen m_nedatalen nindex void c base64 encode char sz message if sz message null c base64 encode const pbyte sz message strlen sz message cbase64 szmessage szmessage cbase64 szmessage szmessage void c base64 decode char sz message if sz message null c base64 decode const pbyte sz message strlen sz message cbase64 szmessage szmessage cbase64 szmessage szmessage int c base64 get length const return m nddatalen cbase64 getlength m_nddatalen char c base64 decoded message const return char m pdbuffer cbase64 decodedmessage m_pdbuffer char c base64 encoded message const return char m pebuffer cbase64 encodedmessage m_pebuffer void c base64 alloc encode dword n size if m nebuflen n size if m pebuffer null delete m pebuffer m nebuflen roundtopage n size m pebuffer new byte m nebuflen zero memory m pebuffer m nebuflen m nedatalen 0 cbase64 allocencode nsize m_nebuflen nsize m_pebuffer m_pebuffer m_nebuflen nsize m_pebuffer m_nebuflen zeromemory m_pebuffer m_nebuflen m_nedatalen void c base64 alloc decode dword n size if m ndbuflen n size if m pdbuffer null delete m pdbuffer m ndbuflen roundtopage n size m pdbuffer new byte m ndbuflen zero memory m pdbuffer m ndbuflen m nddatalen 0 cbase64 allocdecode nsize m_ndbuflen nsize m_pdbuffer m_pdbuffer m_ndbuflen nsize m_pdbuffer m_ndbuflen zeromemory m_pdbuffer m_ndbuflen m_nddatalen void c base64 set encode buffer const pbyte p buffer dword n buf len dword i 0 alloc encode n buf len while i n buf len if isbadmimechar p buffer i m pebuffer m nedatalen p buffer i m nedatalen i cbase64 setencodebuffer pbuffer nbuflen allocencode nbuflen nbuflen _isbadmimechar pbuffer m_pebuffer m_nedatalen pbuffer m_nedatalen void c base64 set decode buffer const pbyte p buffer dword n buf len alloc decode n buf len copy memory m pdbuffer p buffer n buf len m nddatalen n buf len cbase64 setdecodebuffer pbuffer nbuflen allocdecode nbuflen copymemory m_pdbuffer pbuffer nbuflen m_nddatalen nbuflen void c base64 encodetobuffer const temp bucket decode pbyte p buffer temp bucket data encoderaw data decode for int i 0 i 4 i p buffer i base64 digits data n data i switch decode n size case 1 p buffer 2 case 2 p buffer 3 cbase64 _encodetobuffer tempbucket pbuffer tempbucket _encoderaw pbuffer base64digits ndata nsize pbuffer pbuffer dword c base64 decodetobuffer const temp bucket decode pbyte p buffer temp bucket data dword n count 0 decoderaw data decode for int i 0 i 3 i p buffer i data n data i if p buffer i 255 n count return n count cbase64 _decodetobuffer tempbucket pbuffer tempbucket ncount _decoderaw pbuffer ndata pbuffer ncount ncount void c base64 encoderaw temp bucket data const temp bucket decode byte n temp data n data 0 decode n data 0 data n data 0 2 data n data 1 decode n data 0 data n data 1 4 n temp decode n data 1 n temp 4 data n data 1 n temp data n data 1 0x3f data n data 2 decode n data 1 data n data 2 2 n temp decode n data 2 n temp 6 data n data 2 n temp data n data 2 0x3f data n data 3 decode n data 2 data n data 3 0x3f cbase64 _encoderaw tempbucket tempbucket ntemp ndata ndata ndata ndata ndata ndata ntemp ndata ntemp ndata ntemp ndata ndata ndata ndata ntemp ndata ntemp ndata ntemp ndata ndata ndata ndata void c base64 decoderaw temp bucket data const temp bucket decode byte n temp data n data 0 decode n data 0 data n data 0 2 n temp decode n data 1 n temp 4 n temp 0x03 data n data 0 n temp data n data 1 decode n data 1 data n data 1 4 n temp decode n data 2 n temp 2 n temp 0x0f data n data 1 n temp data n data 2 decode n data 2 data n data 2 6 n temp decode n data 3 n temp 0x3f data n data 2 n temp cbase64 _decoderaw tempbucket tempbucket ntemp ndata ndata ndata ntemp ndata ntemp ntemp ndata ntemp ndata ndata ndata ntemp ndata ntemp ntemp ndata ntemp ndata ndata ndata ntemp ndata ntemp ndata ntemp bool c base64 isbadmimechar byte n data switch n data case r case n case t case case b case a case f case v return true default return false cbase64 _isbadmimechar ndata ndata void c base64 init initialize decoding table int i for i 0 i 256 i c base64 m decodetable i 2 for i 0 i 64 i c base64 m decodetable base64 digits i i c base64 m decodetable base64 digits i 0x80 i c base64 m decodetable 1 c base64 m decodetable 0x80 1 c base64 m init true cbase64 _init cbase64 m_decodetable cbase64 m_decodetable base64digits cbase64 m_decodetable base64digits cbase64 m_decodetable cbase64 m_decodetable cbase64 m_init 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 afx data map caboutdlg dodataexchange cdataexchange cdialog dodataexchange afx_data_map caboutdlg afx_data_map void c about dlg on paint c paintdc dc this cdc pdc pdc getdc m pimage draw pdc c point 0 0 c point 400 250 version text hfont hfont logfont lf get object get stock object ansi var font sizeof logfont lf lf lf weight fw extralight hfont create font lf lf height lf lf width lf lf escapement lf lf orientation lf lf weight lf lf italic lf lf underline lf lf strike out lf lf char set lf lf out precision lf lf clip precision lf lf quality lf lf pitch and family lf lf face name hgdiobj oldfont dc select object hfont dc set text color rgb 0 0 0 dc set bk mode transparent dc text out 238 190 m szversion dc text out 238 205 freeware by dc text out 238 220 sourceforge delete object hfont dc select object oldfont clean up releasedc pdc caboutdlg onpaint cpaintdc m_pimage cpoint cpoint getobject getstockobject ansi_var_font lfweight fw_extralight createfont lfheight lfwidth lfescapement lforientation lfweight lfitalic lfunderline lfstrikeout lfcharset lfoutprecision lfclipprecision lfquality lfpitchandfamily lffacename selectobject settextcolor setbkmode textout m_szversion textout textout deleteobject selectobject void c about dlg onl button down uint n flags c point point close the dialog c dialog onok caboutdlg onlbuttondown nflags cpoint cdialog bool c about dlg on init dialog c dialog on init dialog load the image c string sz name sz name format t s about jpg get program path m pimage load sz name calculate the version number c string sz version tchar sz app name max path get module file name afx get instance handle sz app name max path tchar sz file max path get module file name null sz file max path dword dw ver hnd dword dw ver info size get file version info size sz file dw ver hnd if dw ver info size return false byte p ver info new byte dw ver info size if p ver info return false bool f ret get file version info sz file 0l dw ver info size p ver info if f ret tchar p ver null uint cc ver 0 f ret ver query value p ver info t string file info 040904b0 product version void p ver cc ver sz version p ver delete p ver info sz version replace t t while 1 if sz version right 2 0 sz version sz version left sz version get length 2 else break if sz version find 1 sz version 0 m szversion format t version s sz version return true caboutdlg oninitdialog cdialog oninitdialog cstring szname szname _t getprogrampath m_pimage szname cstring szversion szappname _max_path getmodulefilename afxgetinstancehandle szappname _max_path szfile _max_path getmodulefilename szfile _max_path dwverhnd dwverinfosize getfileversioninfosize szfile dwverhnd dwverinfosize pverinfo dwverinfosize pverinfo fret getfileversioninfo szfile dwverinfosize pverinfo fret pver ccver fret verqueryvalue pverinfo _t stringfileinfo productversion pver ccver szversion pver pverinfo szversion _t _t szversion szversion szversion szversion getlength szversion szversion m_szversion _t szversion c backup c backup void cbackup cbackup c backup c backup void cbackup cbackup void c backup create backup void create the backup by taking the notes xml file and copy it to the backup folder and renaming the file to the date and time stamp c string sz from file c string sz to file c ole date time time get the file name of the to file int i file afx get app get profile int t settings options t backup file name 0 i file afx get app write profile int t settings options t backup file name i file sz from file format t s notes xml get application data path sz to file format t s backup d xml get application data path i file create the backup directory if it doesn t exist c string sz folder sz folder format t s backup get application data path create directory sz folder null copy the file copy file sz from file sz to file false cbackup createbackup cstring szfromfile cstring sztofile coledatetime ifile afxgetapp getprofileint _t _t ifile afxgetapp writeprofileint _t _t ifile szfromfile _t getapplicationdatapath sztofile _t getapplicationdatapath ifile cstring szfolder szfolder _t getapplicationdatapath createdirectory szfolder copyfile szfromfile sztofile csa prefs sub dlg csa prefs sub dlg assert 0 don t use this constructor csaprefssubdlg csaprefssubdlg c dialog nid m id nid cdialog m_id csa prefs sub dlg csa prefs sub dlg csaprefssubdlg csaprefssubdlg void csa prefs sub dlg onok end dialog idok csaprefssubdlg enddialog void csa prefs sub dlg on cancel end dialog idcancel csaprefssubdlg oncancel enddialog bool csa prefs sub dlg pre translate message msg p msg don t let c dialog process the escape key if p msg message wm keydown p msg w param vk escape return true don t let c dialog process the return key if a multi line edit has focus if p msg message wm keydown p msg w param vk return special case if control with focus is an edit control with es wantreturn style let it handle the return key tchar sz class 10 c wnd p wnd focus get focus if p wnd focus get focus null is child p wnd focus p wnd focus get style es wantreturn get class name p wnd focus m hwnd sz class 10 lstrcmpi sz class t edit 0 p wnd focus send message wm char p msg w param p msg l param return true return false return c dialog pre translate message p msg csaprefssubdlg pretranslatemessage pmsg cdialog pmsg wm_keydown pmsg wparam vk_escape cdialog pmsg wm_keydown pmsg wparam vk_return es_wantreturn szclass cwnd pwndfocus getfocus pwndfocus getfocus ischild pwndfocus pwndfocus getstyle es_wantreturn getclassname pwndfocus m_hwnd szclass szclass _t pwndfocus sendmessage wm_char pmsg wparam pmsg lparam cdialog pretranslatemessage pmsg c dlg options charset c dlg options charset c wnd p parent null csa prefs sub dlg c dlg options charset idd p parent cdlgoptionscharset cdlgoptionscharset cwnd pparent csaprefssubdlg cdlgoptionscharset pparent c dlg options charset c dlg options charset cdlgoptionscharset cdlgoptionscharset void c dlg options charset do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx ddx control pdx idc charset m pcharset cdlgoptionscharset dodataexchange cdataexchange csaprefssubdlg dodataexchange ddx_control idc_charset m_pcharset bool c dlg options charset on init dialog csa prefs sub dlg on init dialog language stuff c string sz temp sz temp format t s c translate read string 195 t charset c static get dlg item idc static1 set window text sz temp c static get dlg item idc static2 set window text c translate read string 195 t charset fill the combobox with different charset m pcharset add string t ansi charset m pcharset add string t default charset m pcharset add string t symbol charset m pcharset add string t shiftjis charset m pcharset add string t hangeul charset m pcharset add string t hangul charset m pcharset add string t gb2312 charset m pcharset add string t chinesebig5 charset m pcharset add string t oem charset m pcharset add string t johab charset m pcharset add string t hebrew charset m pcharset add string t arabic charset m pcharset add string t greek charset m pcharset add string t turkish charset m pcharset add string t vietnamese charset m pcharset add string t thai charset m pcharset add string t easteurope charset m pcharset add string t russian charset m pcharset add string t baltic charset m pcharset set item height 0 17 select the charset wer are using m pcharset select string 0 m szcharsetname change the font logfont lf memset lf 0 sizeof logfont lf lf height 15 lf lf weight fw extralight tcscpy lf lf face name t microsoft sans serif m font create font indirect lf m pcharset set font m font return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionscharset oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring _t m_pcharset addstring _t ansi_charset m_pcharset addstring _t default_charset m_pcharset addstring _t symbol_charset m_pcharset addstring _t shiftjis_charset m_pcharset addstring _t hangeul_charset m_pcharset addstring _t hangul_charset m_pcharset addstring _t gb2312_charset m_pcharset addstring _t chinesebig5_charset m_pcharset addstring _t oem_charset m_pcharset addstring _t johab_charset m_pcharset addstring _t hebrew_charset m_pcharset addstring _t arabic_charset m_pcharset addstring _t greek_charset m_pcharset addstring _t turkish_charset m_pcharset addstring _t vietnamese_charset m_pcharset addstring _t thai_charset m_pcharset addstring _t easteurope_charset m_pcharset addstring _t russian_charset m_pcharset addstring _t baltic_charset m_pcharset setitemheight m_pcharset selectstring m_szcharsetname lfheight lfweight fw_extralight _tcscpy lffacename _t m_font createfontindirect m_pcharset setfont m_font void c dlg options charset on cbn selchange charset remember the ini file the user has selected int i index m pcharset get cur sel m pcharset getlb text i index m szcharsetname find the value of the name and save it if m szcharsetname t ansi charset m icharset ansi charset if m szcharsetname t default charset m icharset default charset if m szcharsetname t symbol charset m icharset symbol charset if m szcharsetname t shiftjis charset m icharset shiftjis charset if m szcharsetname t hangeul charset m icharset hangeul charset if m szcharsetname t hangul charset m icharset hangul charset if m szcharsetname t gb2312 charset m icharset gb2312 charset if m szcharsetname t chinesebig5 charset m icharset chinesebig5 charset if m szcharsetname t oem charset m icharset oem charset if m szcharsetname t johab charset m icharset johab charset if m szcharsetname t hebrew charset m icharset hebrew charset if m szcharsetname t arabic charset m icharset arabic charset if m szcharsetname t greek charset m icharset greek charset if m szcharsetname t turkish charset m icharset turkish charset if m szcharsetname t vietnamese charset m icharset vietnamese charset if m szcharsetname t thai charset m icharset thai charset if m szcharsetname t easteurope charset m icharset easteurope charset if m szcharsetname t russian charset m icharset russian charset if m szcharsetname t baltic charset m icharset baltic charset cdlgoptionscharset oncbnselchangecharset iindex m_pcharset getcursel m_pcharset getlbtext iindex m_szcharsetname m_szcharsetname _t ansi_charset m_icharset ansi_charset m_szcharsetname _t default_charset m_icharset default_charset m_szcharsetname _t symbol_charset m_icharset symbol_charset m_szcharsetname _t shiftjis_charset m_icharset shiftjis_charset m_szcharsetname _t hangeul_charset m_icharset hangeul_charset m_szcharsetname _t hangul_charset m_icharset hangul_charset m_szcharsetname _t gb2312_charset m_icharset gb2312_charset m_szcharsetname _t chinesebig5_charset m_icharset chinesebig5_charset m_szcharsetname _t oem_charset m_icharset oem_charset m_szcharsetname _t johab_charset m_icharset johab_charset m_szcharsetname _t hebrew_charset m_icharset hebrew_charset m_szcharsetname _t arabic_charset m_icharset arabic_charset m_szcharsetname _t greek_charset m_icharset greek_charset m_szcharsetname _t turkish_charset m_icharset turkish_charset m_szcharsetname _t vietnamese_charset m_icharset vietnamese_charset m_szcharsetname _t thai_charset m_icharset thai_charset m_szcharsetname _t easteurope_charset m_icharset easteurope_charset m_szcharsetname _t russian_charset m_icharset russian_charset m_szcharsetname _t baltic_charset m_icharset baltic_charset c dialog c dlg snooze idd p parent afx data init c dlg snooze note the class wizard will add member initialization here afx data init cdialog cdlgsnooze pparent afx_data_init cdlgsnooze classwizard afx_data_init void c dlg snooze do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c dlg snooze note the class wizard will add ddx and ddv calls here afx data map cdlgsnooze dodataexchange cdataexchange cdialog dodataexchange afx_data_map cdlgsnooze classwizard afx_data_map bool c dlg snooze on init dialog c dialog on init dialog language stuff c button get dlg item idok set window text c translate read string 158 snooze c button get dlg item idcancel set window text c translate read string 159 turn off set window text c translate read string 160 snooze or turn off move the window above the tray c rect rc c rect rect system parameters info spi getworkarea 0 rc 0 get client rect rect move window rc right rect right 10 rc bottom rect bottom 10 rect right 10 rect bottom 20 return true cdlgsnooze oninitdialog cdialog oninitdialog cbutton getdlgitem setwindowtext ctranslate readstring cbutton getdlgitem setwindowtext ctranslate readstring setwindowtext ctranslate readstring crect crect systemparametersinfo spi_getworkarea getclientrect movewindow c string c xml get delete xml we want to delete all the notes on the server we can delete all the notes on the server by uploading 0 notes c string szxml szxml format t s notes note note notes m szxmlheader return szxml cstring cxml getdeletexml cstring _t m_szxmlheader void c xml start create recycle bin xml m szrecyclebinxml format t s deleted m szxmlheader cxml startcreaterecyclebinxml m_szrecyclebinxml _t m_szxmlheader void c xml create recycle bin xml tag note note assert m szrecyclebinxml is empty c rect rc1 rc2 c string sz temp rc1 note c rect rc2 note c rect position sz temp format t note noteid s noteversion d dockedleft s dockedtop s dockedright s dockedbottom s alarmtime s usealarm s title s visible s notecolor d positionleft d positiontop d width d height d slided left s slided right s slidepositionleft d slidepositiontop d slidepositionright d slidepositionbottom d n string encode note sz noteid note i note version note b docked left t true t false note b docked top t true t false note b docked right t true t false note b docked bottom t true t false string encode note sz alarm time note b use alarm t true t false string encode note sz title note b visible t true t false note cf note color rc1 left rc1 top rc1 right rc1 bottom note b slided left t true t false note b slided right t true t false rc2 left rc2 top rc2 right rc2 bottom m szrecyclebinxml sz temp sz temp format t s note string encode note sz text m szrecyclebinxml sz temp cxml createrecyclebinxml tagnote m_szrecyclebinxml isempty crect cstring sztemp crect crectposition sztemp _t stringencode sznoteid inoteversion bdockedleft _t _t bdockedtop _t _t bdockedright _t _t bdockedbottom _t _t stringencode szalarmtime busealarm _t _t stringencode sztitle bvisible _t _t cfnotecolor bslidedleft _t _t bslidedright _t _t m_szrecyclebinxml sztemp sztemp _t stringencode sztext m_szrecyclebinxml sztemp void c xml end create recycle bin xml m szrecyclebinxml t deleted cxml endcreaterecyclebinxml m_szrecyclebinxml _t void c xml start create save xml m szsavexml format t s save version s notes m szxmlheader get program version cxml startcreatesavexml m_szsavexml _t m_szxmlheader getprogramversion void c xml create save xml void p note assert m szsavexml is empty assert p note null m szsavexml get one note xml p note cxml createsavexml pnote m_szsavexml isempty pnote m_szsavexml getonenotexml pnote void c xml end create save xml m szsavexml t notes n save cxml endcreatesavexml m_szsavexml _t void c xml start create upload xml m szuploadxml format t s notes m szxmlheader cxml startcreateuploadxml m_szuploadxml _t m_szxmlheader void c xml create upload xml void p note assert m szuploadxml is empty assert p note null c note note c note p note create the xml for one note c string szxml sz temp m szuploadxml t note sz temp format t noteversion d noteversion note get note version m szuploadxml sz temp sz temp format t noteid s noteid string encode note get noteid m szuploadxml sz temp sz temp format t alarmtime s alarmtime string encode note get alarm format t m d y h m s m szuploadxml sz temp sz temp format t usealarm s usealarm note get use alarm t true t false m szuploadxml sz temp sz temp format t title s title string encode note get title m szuploadxml sz temp sz temp format t visible s visible note get visible t true t false m szuploadxml sz temp sz temp format t notecolor d notecolor note get note color m szuploadxml sz temp sz temp format t positionleft d positionleft note get position left m szuploadxml sz temp sz temp format t positiontop d positiontop note get position top m szuploadxml sz temp sz temp format t width d width note get position right m szuploadxml sz temp sz temp format t height d height note get position bottom m szuploadxml sz temp sz temp format t text s text string encode note get text m szuploadxml sz temp sz temp format t dockedleft s dockedleft note get docked left t true t false m szuploadxml sz temp sz temp format t dockedtop s dockedtop note get docked top t true t false m szuploadxml sz temp sz temp format t dockedright s dockedright note get docked right t true t false m szuploadxml sz temp sz temp format t dockedbottom s dockedbottom note get docked bottom t true t false m szuploadxml sz temp sz temp format t slided left s slided left note get slided left t true t false m szuploadxml sz temp sz temp format t slided right s slided right note get slided right t true t false m szuploadxml sz temp sz temp format t slidepositionleft d slidepositionleft note get slide position left m szuploadxml sz temp sz temp format t slidepositiontop d slidepositiontop note get slide position top m szuploadxml sz temp sz temp format t slidepositionright d slidepositionright note get slide position right m szuploadxml sz temp sz temp format t slidepositionbottom d slidepositionbottom note get slide position bottom m szuploadxml sz temp sz temp format t readable note text s readable note text string encode note get readable text m szuploadxml sz temp m szuploadxml t note cxml createuploadxml pnote m_szuploadxml isempty pnote cnote cnote pnote cstring sztemp m_szuploadxml _t sztemp _t getnoteversion m_szuploadxml sztemp sztemp _t stringencode getnoteid m_szuploadxml sztemp sztemp _t stringencode getalarm _t m_szuploadxml sztemp sztemp _t getusealarm _t _t m_szuploadxml sztemp sztemp _t stringencode gettitle m_szuploadxml sztemp sztemp _t getvisible _t _t m_szuploadxml sztemp sztemp _t getnotecolor m_szuploadxml sztemp sztemp _t getposition m_szuploadxml sztemp sztemp _t getposition m_szuploadxml sztemp sztemp _t getposition m_szuploadxml sztemp sztemp _t getposition m_szuploadxml sztemp sztemp _t stringencode gettext m_szuploadxml sztemp sztemp _t getdockedleft _t _t m_szuploadxml sztemp sztemp _t getdockedtop _t _t m_szuploadxml sztemp sztemp _t getdockedright _t _t m_szuploadxml sztemp sztemp _t getdockedbottom _t _t m_szuploadxml sztemp sztemp _t getslidedleft _t _t m_szuploadxml sztemp sztemp _t getslidedright _t _t m_szuploadxml sztemp sztemp _t getslideposition m_szuploadxml sztemp sztemp _t getslideposition m_szuploadxml sztemp sztemp _t getslideposition m_szuploadxml sztemp sztemp _t getslideposition m_szuploadxml sztemp sztemp _t stringencode getreadabletext m_szuploadxml sztemp m_szuploadxml _t void c xml end create upload xml m szuploadxml t notes cxml endcreateuploadxml m_szuploadxml _t c xml c xml m szrecyclebinxml t m szsavexml t m szuploadxml t cxml cxml m_szrecyclebinxml _t m_szsavexml _t m_szuploadxml _t c xml c xml cxml cxml c string c xml get one note xml void p note c note note c note p note c rect rc1 rc2 c string sz temp c string szxml rc1 note get position rc2 note get slide position sz temp format t note noteid s noteversion d dockedleft s dockedtop s dockedright s dockedbottom s alarmtime s usealarm s title s visible s notecolor d positionleft d positiontop d width d height d slided left s slided right s slidepositionleft d slidepositiontop d slidepositionright d slidepositionbottom d n string encode note get noteid note get note version note get docked left t true t false note get docked top t true t false note get docked right t true t false note get docked bottom t true t false string encode note get alarm format t m d y h m s note get use alarm t true t false string encode note get title note get visible t true t false note get note color rc1 left rc1 top rc1 right rc1 bottom note get slided left t true t false note get slided right t true t false rc2 left rc2 top rc2 right rc2 bottom szxml sz temp sz temp format t s note n string encode note get text szxml sz temp return szxml cstring cxml getonenotexml pnote cnote cnote pnote crect cstring sztemp cstring getposition getslideposition sztemp _t stringencode getnoteid getnoteversion getdockedleft _t _t getdockedtop _t _t getdockedright _t _t getdockedbottom _t _t stringencode getalarm _t getusealarm _t _t stringencode gettitle getvisible _t _t getnotecolor getslidedleft _t _t getslidedright _t _t sztemp sztemp _t stringencode gettext sztemp c lite splash c lite splash c psplashwnd c lite splash c lite splash clitesplash clitesplash c_psplashwnd clitesplash clitesplash void c lite splash enable splash screen bool b enable true c bshowsplashwnd b enable clitesplash enablesplashscreen benable c_bshowsplashwnd benable void c lite splash show splash screen c wnd p parent wnd null if c bshowsplashwnd c psplashwnd null return allocate a new splash screen and create the window c psplashwnd new c lite splash if c psplashwnd create p parent wnd delete c psplashwnd else c psplashwnd update window clitesplash showsplashscreen cwnd pparentwnd c_bshowsplashwnd c_psplashwnd c_psplashwnd clitesplash c_psplashwnd pparentwnd c_psplashwnd c_psplashwnd updatewindow bool c lite splash pre translate app message msg p msg if c psplashwnd null return false if we get a keyboard or mouse message hide the splash screen if p msg message wm keydown p msg message wm syskeydown p msg message wm lbuttondown p msg message wm rbuttondown p msg message wm mbuttondown p msg message wm nclbuttondown p msg message wm ncrbuttondown p msg message wm ncmbuttondown c psplashwnd hide splash screen return true message handled here return false message not handled clitesplash pretranslateappmessage pmsg c_psplashwnd pmsg wm_keydown pmsg wm_syskeydown pmsg wm_lbuttondown pmsg wm_rbuttondown pmsg wm_mbuttondown pmsg wm_nclbuttondown pmsg wm_ncrbuttondown pmsg wm_ncmbuttondown c_psplashwnd hidesplashscreen c lite splash c lite splash clear the static window pointer assert c psplashwnd this c psplashwnd null clitesplash clitesplash c_psplashwnd c_psplashwnd void c lite splash post nc destroy free the c class delete this clitesplash postncdestroy bool c lite splash create c wnd p parent wnd null if m bitmap load bitmap idb splash return false bitmap bm m bitmap get bitmap bm return create ex 0 afx register wnd class 0 afx get app load standard cursor idc arrow null ws popup ws visible 0 0 bm bm width bm bm height p parent wnd get safe hwnd null clitesplash cwnd pparentwnd m_bitmap loadbitmap idb_splash m_bitmap getbitmap createex afxregisterwndclass afxgetapp loadstandardcursor idc_arrow ws_popup ws_visible bmwidth bmheight pparentwnd getsafehwnd void c lite splash hide splash screen destroy the window and update the mainframe destroy window afx get main wnd update window clitesplash hidesplashscreen destroywindow afxgetmainwnd updatewindow int c lite splash on create lpcreatestruct lp create struct if c wnd on create lp create struct 1 return 1 center the window center window set a timer to destroy the splash screen set timer 1 7000 null return 0 clitesplash oncreate lpcreatestruct cwnd oncreate lpcreatestruct centerwindow settimer void c lite splash on paint c paintdc dc this cdc dc image if dc image create compatibledc dc return bitmap bm m bitmap get bitmap bm paint the image c bitmap p old bitmap dc image select object m bitmap dc bit blt 0 0 bm bm width bm bm height dc image 0 0 srccopy dc image select object p old bitmap clitesplash onpaint cpaintdc dcimage dcimage createcompatibledc m_bitmap getbitmap cbitmap poldbitmap dcimage selectobject m_bitmap bitblt bmwidth bmheight dcimage dcimage selectobject poldbitmap void c lite splash on timer uint nid event destroy the splash screen window hide splash screen clitesplash ontimer nidevent hidesplashscreen csa prefs static csa prefs static m textclr get sys color color 3dface m fontweight fw normal m fontsize 12 csaprefsstatic csaprefsstatic m_textclr getsyscolor color_3dface m_fontweight fw_normal m_fontsize csa prefs static csa prefs static if m bm get safe handle m bm delete object if m captionfont get safe handle m captionfont delete object if m namefont get safe handle m namefont delete object csaprefsstatic csaprefsstatic m_bm getsafehandle m_bm deleteobject m_captionfont getsafehandle m_captionfont deleteobject m_namefont getsafehandle m_namefont deleteobject void csa prefs static make caption bitmap if m bm m hobject return already have bitmap return c rect cr get client rect cr int w cr width int h cr height create bitmap same size as caption area and select into memory dc c windowdc dc win this cdc dc dc create compatibledc dc win m bm delete object m bm create compatible bitmap dc win w h c bitmap p old bitmap dc select object m bm colorref clrbg get sys color color 3dface background color int r getr value clrbg red int g getg value clrbg green int b getb value clrbg blue color vals int x 8 cr right 8 start 5 6 of the way right int w1 x cr left width of area to shade int ncolorshades 128 this many shades in gradient int x delta max w ncolorshades 1 width of one shade band paint rect dc x 0 cr right x h clrbg while x x delta paint bands right to left x x delta next band int wmx2 w1 x w1 x w minus x squared int w2 w1 w1 w squared paint rect dc x 0 x delta h rgb r r wmx2 w2 g g wmx2 w2 b b wmx2 w2 paint rect dc 0 0 x h rgb 0 0 0 whatever s left black draw the constant text create a font if we need to if m namefont get safe handle null m namefont create font 18 0 0 0 fw bold 0 0 0 ansi charset out default precis clip default precis default quality ff modern m csfontname c font old font dc select object m namefont back up a little cr right 5 draw text in dc dc set bk mode transparent dc set text color get sys color color 3dhilight dc draw text m csconstanttext cr c point 1 1 dt singleline dt right dt vcenter dc set text color get sys color color 3dshadow dc draw text m csconstanttext cr dt singleline dt right dt vcenter restore old font dc select object old font restore dc dc select object p old bitmap csaprefsstatic makecaptionbitmap m_bm m_hobject crect getclientrect cwindowdc dcwin createcompatibledc dcwin m_bm deleteobject m_bm createcompatiblebitmap dcwin cbitmap poldbitmap selectobject m_bm getsyscolor color_3dface getrvalue getgvalue getbvalue xdelta paintrect xdelta xdelta paintrect xdelta paintrect m_namefont getsafehandle m_namefont createfont fw_bold ansi_charset out_default_precis clip_default_precis default_quality ff_modern m_csfontname cfont oldfont selectobject m_namefont setbkmode settextcolor getsyscolor color_3dhilight drawtext m_csconstanttext cpoint dt_singleline dt_right dt_vcenter settextcolor getsyscolor color_3dshadow drawtext m_csconstanttext dt_singleline dt_right dt_vcenter selectobject oldfont selectobject poldbitmap void csa prefs static on paint c paintdc dc this device context for painting c font p old font null set default font if m csfontname c wnd p wnd parent get parent if p wnd parent dc select object p wnd parent get font else create a font if we need to if m captionfont get safe handle null m captionfont create font m fontsize 0 0 0 m fontweight 0 0 0 ansi charset out default precis clip default precis default quality ff modern m csfontname if m captionfont get safe handle null p old font dc select object m captionfont draw text c string str text get window text str text dc set text color m textclr dc set bk mode transparent vertical center c rect cr get client rect cr cr left 5 dc draw text str text cr dt singleline dt left dt vcenter if p old font dc select object p old font csaprefsstatic onpaint cpaintdc cfont poldfont m_csfontname cwnd pwndparent getparent pwndparent selectobject pwndparent getfont m_captionfont getsafehandle m_captionfont createfont m_fontsize m_fontweight ansi_charset out_default_precis clip_default_precis default_quality ff_modern m_csfontname m_captionfont getsafehandle poldfont selectobject m_captionfont cstring strtext getwindowtext strtext settextcolor m_textclr setbkmode crect getclientrect drawtext strtext dt_singleline dt_left dt_vcenter poldfont selectobject poldfont bool csa prefs static on erase bkgnd cdc pdc if m bm get safe handle make caption bitmap if m bm get safe handle c rect cr get client rect cr cdc memdc memdc create compatibledc pdc c bitmap pob memdc select object m bm pdc bit blt 0 0 cr width cr height memdc 0 0 srccopy memdc select object pob return true csaprefsstatic onerasebkgnd m_bm getsafehandle makecaptionbitmap m_bm getsafehandle crect getclientrect createcompatibledc cbitmap selectobject m_bm bitblt selectobject lresult csa prefs static on set text wparam w param lparam l param def window proc wm settext w param l param invalidate true return true csaprefsstatic onsettext wparam lparam defwindowproc wm_settext wparam lparam c dialog csa prefs dialog idd p parent afx data init csa prefs dialog afx data init m icurpage 1 m pages remove all m pstartpage null m cstitle untitled m bvalidatebeforechangingpage false cdialog csaprefsdialog pparent afx_data_init csaprefsdialog afx_data_init m_icurpage m_pages removeall m_pstartpage m_cstitle m_bvalidatebeforechangingpage csa prefs dialog csa prefs dialog clean up for int i 0 i m pages get size i page struct pps page struct m pages get at i if pps delete pps csaprefsdialog csaprefsdialog m_pages getsize pagestruct pagestruct m_pages getat bool csa prefs dialog add page csa prefs sub dlg dlg const tchar p caption csa prefs sub dlg p dlg parent null if m hwnd can t add once the window has been created assert 0 return false page struct pps new page struct pps p dlg dlg pps id dlg getid pps cs caption p caption pps p dlg parent p dlg parent m pages add pps return true csaprefsdialog addpage csaprefssubdlg pcaption csaprefssubdlg pdlgparent m_hwnd pagestruct pagestruct pdlg cscaption pcaption pdlgparent pdlgparent m_pages bool csa prefs dialog show page int i page m captionbar set window text t turn off the current page if m icurpage 0 m icurpage m pages get size page struct pps page struct m pages get at m icurpage assert pps if pps assert pps p dlg if pps p dlg if is window pps p dlg m hwnd pps p dlg show window sw hide else return false show the new one if i page 0 i page m pages get size page struct pps page struct m pages get at i page assert pps if pps assert pps p dlg if pps p dlg update caption bar m captionbar set window text pps cs caption if we haven t already create the dialog if is window pps p dlg m hwnd pps p dlg create pps p dlg getid this move show focus if is window pps p dlg m hwnd pps p dlg move window m framerect left m framerect top m framerect width m framerect height pps p dlg show window sw show pps p dlg set focus change the tree find this in our map htreeitem h item findhtree item for dlg pps p dlg if h item select it m pagetree select item h item return true return false csaprefsdialog showpage ipage m_captionbar setwindowtext _t m_icurpage m_icurpage m_pages getsize pagestruct pagestruct m_pages getat m_icurpage pdlg pdlg iswindow pdlg m_hwnd pdlg showwindow sw_hide ipage ipage m_pages getsize pagestruct pagestruct m_pages getat ipage pdlg pdlg m_captionbar setwindowtext cscaption iswindow pdlg m_hwnd pdlg pdlg iswindow pdlg m_hwnd pdlg movewindow m_framerect m_framerect m_framerect m_framerect pdlg showwindow sw_show pdlg setfocus hitem findhtreeitemfordlg pdlg hitem m_pagetree selectitem hitem bool csa prefs dialog show page csa prefs sub dlg p page find that page for int i 0 i m pages get size i page struct pps page struct m pages get at i assert pps if pps assert pps p dlg if pps p dlg p page show page i m icurpage i return true return false csaprefsdialog showpage csaprefssubdlg ppage m_pages getsize pagestruct pagestruct m_pages getat pdlg pdlg ppage showpage m_icurpage void csa prefs dialog end special uint res bool b ok if b ok endok end dialog res csaprefsdialog endspecial bok bok enddialog bool csa prefs dialog pre translate message msg p msg assert p msg null assert valid this assert m hwnd null don t let c dialog process the escape key if p msg message wm keydown p msg w param vk escape return true if c wnd pre translate message p msg return true don t translate dialog messages when application is in help mode c frame wnd p frame wnd get top level frame if p frame wnd null p frame wnd m bhelpmode return false ensure the dialog messages will not eat frame accelerators p frame wnd get parent frame while p frame wnd null if p frame wnd pre translate message p msg return true p frame wnd p frame wnd get parent frame return pre translate input p msg csaprefsdialog pretranslatemessage pmsg pmsg assert_valid m_hwnd cdialog pmsg wm_keydown pmsg wparam vk_escape cwnd pretranslatemessage pmsg cframewnd pframewnd gettoplevelframe pframewnd pframewnd m_bhelpmode pframewnd getparentframe pframewnd pframewnd pretranslatemessage pmsg pframewnd pframewnd getparentframe pretranslateinput pmsg void csa prefs dialog do data exchange c data exchange pdx c dialog do data exchange pdx afx data map csa prefs dialog ddx control pdx idc page tree m pagetree ddx control pdx idc dlg frame m boundingframe ddx control pdx idc caption bar m captionbar afx data map csaprefsdialog dodataexchange cdataexchange cdialog dodataexchange afx_data_map csaprefsdialog ddx_control idc_page_tree m_pagetree ddx_control idc_dlg_frame m_boundingframe ddx_control idc_caption_bar m_captionbar afx_data_map bool csa prefs dialog pre create window createstruct cs if c wnd pre create window cs return false cs lpsz class afx register wnd class cs dblclks null null null cs style ws clipchildren return true csaprefsdialog precreatewindow cwnd precreatewindow lpszclass afxregisterwndclass cs_dblclks ws_clipchildren bool csa prefs dialog endok bool bok true csa prefs sub dlg p page null first update data for int i 0 i m pages get size i page struct pps page struct m pages get at i assert pps if pps assert pps p dlg if pps p dlg if is window pps p dlg m hwnd if pps p dlg update data true bok false p page pps p dlg break were there any update data errors if bok p page null show page p page return false tell all of the sub dialogs ok for i 0 i m pages get size i page struct pps page struct m pages get at i assert pps if pps assert pps p dlg if pps p dlg if is window pps p dlg m hwnd pps p dlg onok return true csaprefsdialog csaprefssubdlg ppage updatedata m_pages getsize pagestruct pagestruct m_pages getat pdlg pdlg iswindow pdlg m_hwnd pdlg updatedata ppage pdlg updatedata ppage showpage ppage m_pages getsize pagestruct pagestruct m_pages getat pdlg pdlg iswindow pdlg m_hwnd pdlg htreeitem csa prefs dialog findhtree item for dlg csa prefs sub dlg p parent if you didn t specify a parent in add page the dialog becomes a root level entry if p parent null return tvi root else dword dwh tree if m dlgmap lookup p parent dwh tree return htreeitem dwh tree else you have specified a parent that has not been added to the tree can t do that assert false return tvi root csaprefsdialog findhtreeitemfordlg csaprefssubdlg pparent addpage pparent tvi_root dwhtree m_dlgmap pparent dwhtree dwhtree tvi_root int csa prefs dialog on create lpcreatestruct lp create struct if c dialog on create lp create struct 1 return 1 return 0 csaprefsdialog oncreate lpcreatestruct cdialog oncreate lpcreatestruct bool csa prefs dialog on init dialog c dialog on init dialog long l get window long m pagetree m hwnd gwl style if msc ver 1100 l l tvs trackselect else define tvs trackselect 0x0200 l l 0x0200 endif set window long m pagetree m hwnd gwl style l where will the dlgs live m boundingframe get window rect m framerect screen to client m framerect m framerect deflate rect 2 2 set window text m cstitle language c button get dlg item idok set window text c translate read string 36 t ok c button get dlg item idcancel set window text c translate read string 37 t cancel set some styles for the pretty page indicator bar m captionbar m textclr get sys color color 3dface m captionbar m fontweight fw bold m captionbar m fontsize 14 m captionbar m csfontname t verdana m captionbar set constant text m csconstanttext fill the tree we ll create the pages as we need them for int i 0 i m pages get size i page struct pps page struct m pages get at i assert pps assert pps p dlg if pps tv insertstruct tvi find this node s parent tvi h parent findhtree item for dlg pps p dlg parent tvi h insert after tvi last tvi item cch text max 0 tvi item psz text lpstr textcallback tvi item l param long pps tvi item mask tvif param tvif text htreeitem h tree m pagetree insert item tvi keep track of the dlg s we ve added for parent selection if h tree dword dw tree dword h tree m dlgmap set at pps p dlg dw tree start with page 0 if m pstartpage null if show page 0 m icurpage 0 else find start page for int i 0 i m pages get size i page struct pps page struct m pages get at i assert pps if pps assert pps p dlg if pps p dlg m pstartpage show page i m icurpage i break return true return true unless you set the focus to a control exception ocx property pages should return false csaprefsdialog oninitdialog cdialog oninitdialog getwindowlong m_pagetree m_hwnd gwl_style _msc_ver tvs_trackselect tvs_trackselect setwindowlong m_pagetree m_hwnd gwl_style m_boundingframe getwindowrect m_framerect screentoclient m_framerect m_framerect deflaterect setwindowtext m_cstitle cbutton getdlgitem setwindowtext ctranslate readstring _t cbutton getdlgitem setwindowtext ctranslate readstring _t m_captionbar m_textclr getsyscolor color_3dface m_captionbar m_fontweight fw_bold m_captionbar m_fontsize m_captionbar m_csfontname _t m_captionbar setconstanttext m_csconstanttext m_pages getsize pagestruct pagestruct m_pages getat pdlg tv_insertstruct hparent findhtreeitemfordlg pdlgparent hinsertafter tvi_last cchtextmax psztext lpstr_textcallback lparam tvif_param tvif_text htree m_pagetree insertitem htree dwtree htree m_dlgmap setat pdlg dwtree m_pstartpage showpage m_icurpage m_pages getsize pagestruct pagestruct m_pages getat pdlg pdlg m_pstartpage showpage m_icurpage void csa prefs dialog onok if endok returns true all of the update data true s succeeded if endok c dialog onok csaprefsdialog updatedata cdialog void csa prefs dialog on cancel tell all of the sub dialogs cancel for int i 0 i m pages get size i page struct pps page struct m pages get at i assert pps if pps assert pps p dlg if pps p dlg if is window pps p dlg m hwnd pps p dlg on cancel c dialog on cancel csaprefsdialog oncancel m_pages getsize pagestruct pagestruct m_pages getat pdlg pdlg iswindow pdlg m_hwnd pdlg oncancel cdialog oncancel void csa prefs dialog on selchanged page tree nmhdr pnmhdr lresult p result nm treeview pnm tree view nm treeview pnmhdr if pnm tree view item new l param find out which page was selected int i idx 1 for int i 0 i m pages get size i if m pages get at i page struct pnm tree view item new l param i idx i break show that page if i idx 0 i idx m pages get size page struct pps page struct m pages get at i idx if m icurpage i idx post message wm change page i idx p result 0 csaprefsdialog onselchangedpagetree presult nm_treeview pnmtreeview nm_treeview pnmtreeview itemnew lparam iidx m_pages getsize m_pages getat pagestruct pnmtreeview itemnew lparam iidx iidx iidx m_pages getsize pagestruct pagestruct m_pages getat iidx m_icurpage iidx postmessage wm_change_page iidx presult void csa prefs dialog on getdispinfo page tree nmhdr pnmhdr lresult p result tv dispinfo ptv disp info tv dispinfo pnmhdr return the caption of the appropriate dialog if ptv disp info item l param if ptv disp info item mask tvif text page struct pps page struct ptv disp info item l param tcscpy ptv disp info item psz text pps cs caption p result 0 csaprefsdialog ongetdispinfopagetree presult tv_dispinfo ptvdispinfo tv_dispinfo ptvdispinfo lparam ptvdispinfo tvif_text pagestruct pagestruct ptvdispinfo lparam _tcscpy ptvdispinfo psztext cscaption presult void csa prefs dialog on phelp simulate the property sheet method of sending help with wm notify if m icurpage 0 m icurpage m pages get size page struct pps page struct m pages get at m icurpage assert pps assert pps p dlg if pps if pps p dlg if is window pps p dlg m hwnd help nmhdr nm nm code psn help nm hwnd from m hwnd nm id from csa prefs dialog idd pps p dlg send message wm notify 0 long nm csaprefsdialog onphelp wm_notify m_icurpage m_icurpage m_pages getsize pagestruct pagestruct m_pages getat m_icurpage pdlg pdlg iswindow pdlg m_hwnd psn_help hwndfrom m_hwnd idfrom csaprefsdialog pdlg sendmessage wm_notify void csa prefs dialog on selchanging page tree nmhdr pnmhdr lresult p result nm treeview pnm tree view nm treeview pnmhdr do we need to validate this page if m bvalidatebeforechangingpage is the current page a real page if m icurpage 0 m icurpage m pages get size page struct pps page struct m pages get at m icurpage if pps assert pps p dlg if pps p dlg if is window pps p dlg m hwnd now we know we have a valid window let s see if the data on it is ok if pps p dlg update data bad data when we leave here the tree wil grab focus again this is bad because we want the control that cause the update data to fail to have focus so the user knows what to fix so we ll do some trickery find out who has focus c wnd p lost pps p dlg get focus if p lost post a message back to this window with the hwnd of the window that had focus the one that broke the update data the handler for wm set focus wnd will set the focus back to that control post message wm set focus wnd uint p lost m hwnd don t switch pages p result 1 return if we re here the dialog validated ok we can switch pages ok to switch pages p result 0 csaprefsdialog onselchangingpagetree presult nm_treeview pnmtreeview nm_treeview m_bvalidatebeforechangingpage m_icurpage m_icurpage m_pages getsize pagestruct pagestruct m_pages getat m_icurpage pdlg pdlg iswindow pdlg m_hwnd pdlg updatedata updatedata cwnd plost pdlg getfocus plost updatedata wm_set_focus_wnd postmessage wm_set_focus_wnd plost m_hwnd presult presult long csa prefs dialog on change page uint u long l if show page u m icurpage u return 0l csaprefsdialog onchangepage showpage m_icurpage long csa prefs dialog on set focus wnd uint u long l if is window hwnd u set focus hwnd u return 0l csaprefsdialog onsetfocuswnd iswindow setfocus void c recycle bin save deleted note void p note the note will be deleted and therefore the note and its data will be saved in the file a note deleted notes xml read all the notes that are in the file deleted notes xml co initialize null hresult hr m pldomdocument create instance clsid domdocument if failed hr c error log c error log err could not initialize the xml parser return parsexml add the note that wants to be deleted add deleted note p note find out if we have hit the total limit if so delete the first one if ttoi the app m szrecyclebinnumberofnotes 0 m pnote get count ttoi the app m szrecyclebinnumberofnotes m pnote remove head save the notes in the file deleted notes xml save deleted notes crecyclebin savedeletednote pnote coinitialize m_pldomdocument createinstance clsid_domdocument cerrorlog cerrorlog adddeletednote pnote _ttoi theapp m_szrecyclebinnumberofnotes m_pnote getcount _ttoi theapp m_szrecyclebinnumberofnotes m_pnote removehead savedeletednotes c recycle bin c recycle bin crecyclebin crecyclebin c recycle bin c recycle bin crecyclebin crecyclebin void c recycle bin save deleted notes save all deleted notes c string sz file szxml sz temp sz xml start c stdio file fp c rect rc1 rc2 position pos c xml xml xml start create recycle bin xml pos m pnote get head position while pos tag note note m pnote get next pos xml create recycle bin xml note xml end create recycle bin xml szxml xml get create recycle bin xml save the note now sz file format t s deleted notes xml get application data path delete file sz file if fp open sz file c file mode create c file mode write c error log c error log info could not open the deleted notes xml return try if defined unicode defined unicode int i length i length szxml get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 wide char to multi byte cp utf8 0 szxml i length pc dest 2 i length null null fp write pc dest i length delete pc dest delete pwc unicode else fp write szxml szxml get length endif fp close catch c file exception e c error log c error log err could not write file deleted notes xml return end catch crecyclebin savedeletednotes cstring szfile sztemp szxmlstart cstdiofile crect cxml startcreaterecyclebinxml m_pnote getheadposition tagnote m_pnote getnext createrecyclebinxml endcreaterecyclebinxml getcreaterecyclebinxml szfile _t getapplicationdatapath deletefile szfile szfile cfile modecreate cfile modewrite cerrorlog cerrorlog _unicode ilength ilength getlength pwcunicode ilength pcdest ilength widechartomultibyte cp_utf8 ilength pcdest ilength pcdest ilength pcdest pwcunicode getlength cfileexception cerrorlog cerrorlog end_catch void c recycle bin add deleted note void note add the deleted note in the linked list last c note p note c note note tag note note note b docked bottom p note get docked bottom note b docked left p note get docked left note b docked right p note get docked right note b docked top p note get docked top note b use alarm p note get use alarm note b visible p note get visible note cf note color p note get note color note c rect p note get position note i note version p note get note version note sz alarm time p note get alarm format t m d y h m s note sz noteid p note get noteid note sz text p note get text note sz title p note get title note b slided left p note get slided left note b slided right p note get slided right note c rect position p note get slide position m pnote add tail note crecyclebin adddeletednote cnote pnote cnote tagnote bdockedbottom pnote getdockedbottom bdockedleft pnote getdockedleft bdockedright pnote getdockedright bdockedtop pnote getdockedtop busealarm pnote getusealarm bvisible pnote getvisible cfnotecolor pnote getnotecolor crect pnote getposition inoteversion pnote getnoteversion szalarmtime pnote getalarm _t sznoteid pnote getnoteid sztext pnote gettext sztitle pnote gettitle bslidedleft pnote getslidedleft bslidedright pnote getslidedright crectposition pnote getslideposition m_pnote addtail void c recycle bin parsexml parse the xml that was received from the server c string sz file sz file format t s deleted notes xml get application data path convert xml file name string to something com can handle bstr bstr t bstr file name bstr file name sz file alloc sys string call the ixmldom document ptr s load function to load the xml document variant t v result v result m pldomdocument load bstr file name if bool v result true now that the document is loaded we need to initialize the root pointer m pdocroot m pldomdocument document element else return getxml children m pdocroot crecyclebin cstring szfile szfile _t getapplicationdatapath _bstr_t bstrfilename bstrfilename szfile allocsysstring ixmldomdocumentptr variant_t vresult vresult m_pldomdocument bstrfilename vresult m_pdocroot m_pldomdocument documentelement getxmlchildren m_pdocroot c picture c picture m ppicture null cpicture cpicture m_ppicture c picture c picture un load cpicture cpicture unload bool c picture load c string s resource type c string s resource bool b result false if m ppicture null un load if m ppicture null byte p buff null int n size 0 if get resource s resource get buffer 0 s resource type get buffer 0 p buff n size if n size 0 p buff new byte n size if get resource s resource get buffer 0 s resource type get buffer 0 p buff n size if load from buffer p buff n size b result true delete p buff return b result cpicture cstring sresourcetype cstring sresource bresult m_ppicture unload m_ppicture pbuff nsize getresource sresource getbuffer sresourcetype getbuffer pbuff nsize nsize pbuff nsize getresource sresource getbuffer sresourcetype getbuffer pbuff nsize loadfrombuffer pbuff nsize bresult pbuff bresult bool c picture load c string s file name bool b result false if m ppicture null un load if m ppicture null c file c file c file exception e if c file open s file name c file mode read c file type binary e byte p buff new byte c file get length if c file read p buff c file get length 0 if load from buffer p buff c file get length b result true delete p buff return b result cpicture cstring sfilename bresult m_ppicture unload m_ppicture cfile cfile cfileexception cfile sfilename cfile moderead cfile typebinary pbuff cfile getlength cfile pbuff cfile getlength loadfrombuffer pbuff cfile getlength bresult pbuff bresult bool c picture draw cdc pdc if m ppicture null long hm width long hm height m ppicture get width hm width m ppicture get height hm height int n width mul div hm width pdc get device caps logpixelsx himetric inch int n height mul div hm height pdc get device caps logpixelsy himetric inch return draw pdc 0 0 n width n height return false cpicture m_ppicture hmwidth hmheight m_ppicture get_width hmwidth m_ppicture get_height hmheight nwidth muldiv hmwidth getdevicecaps himetric_inch nheight muldiv hmheight getdevicecaps himetric_inch nwidth nheight bool c picture draw cdc pdc c point pos if m ppicture null long hm width long hm height m ppicture get width hm width m ppicture get height hm height int n width mul div hm width pdc get device caps logpixelsx himetric inch int n height mul div hm height pdc get device caps logpixelsy himetric inch return draw pdc pos x pos y n width n height return false cpicture cpoint m_ppicture hmwidth hmheight m_ppicture get_width hmwidth m_ppicture get_height hmheight nwidth muldiv hmwidth getdevicecaps himetric_inch nheight muldiv hmheight getdevicecaps himetric_inch nwidth nheight bool c picture draw cdc pdc c point pos c size size if m ppicture null long hm width long hm height m ppicture get width hm width m ppicture get height hm height int n width size cx int n height size cy return draw pdc pos x pos y n width n height return false cpicture cpoint csize m_ppicture hmwidth hmheight m_ppicture get_width hmwidth m_ppicture get_height hmheight nwidth nheight nwidth nheight bool c picture draw cdc pdc double n size ratio if m ppicture null long hm width long hm height m ppicture get width hm width m ppicture get height hm height int n width int mul div hm width pdc get device caps logpixelsx himetric inch n size ratio int n height int mul div hm height pdc get device caps logpixelsy himetric inch n size ratio return draw pdc 0 0 n width n height return false cpicture nsizeratio m_ppicture hmwidth hmheight m_ppicture get_width hmwidth m_ppicture get_height hmheight nwidth muldiv hmwidth getdevicecaps himetric_inch nsizeratio nheight muldiv hmheight getdevicecaps himetric_inch nsizeratio nwidth nheight bool c picture draw cdc pdc c point pos double n size ratio if m ppicture null long hm width long hm height m ppicture get width hm width m ppicture get height hm height int n width int mul div hm width pdc get device caps logpixelsx himetric inch n size ratio int n height int mul div hm height pdc get device caps logpixelsy himetric inch n size ratio return draw pdc pos x pos y n width n height return false cpicture cpoint nsizeratio m_ppicture hmwidth hmheight m_ppicture get_width hmwidth m_ppicture get_height hmheight nwidth muldiv hmwidth getdevicecaps himetric_inch nsizeratio nheight muldiv hmheight getdevicecaps himetric_inch nsizeratio nwidth nheight c size c picture get size cdc pdc c size rc result c size 0 0 if m ppicture null long hm width long hm height m ppicture get width hm width m ppicture get height hm height rc result cx mul div hm width pdc get device caps logpixelsx himetric inch rc result cy mul div hm height pdc get device caps logpixelsy himetric inch return rc result csize cpicture getsize csize rcresult csize m_ppicture hmwidth hmheight m_ppicture get_width hmwidth m_ppicture get_height hmheight rcresult muldiv hmwidth getdevicecaps himetric_inch rcresult muldiv hmheight getdevicecaps himetric_inch rcresult bool c picture get resource c string lpstr lp name c string lpstr lp type void p resource int n buf size hrsrc h res info handle h res hmodule h inst null lpstr lp res null int n len 0 bool b result false find the resource h res info find resource h inst lp name lp type if h res info null return false load the resource h res load resource h inst h res info if h res null return false lock the resource lp res char lock resource h res if lp res null if p resource null n buf size sizeof resource h inst h res info b result true else if n buf size int sizeof resource h inst h res info memcpy p resource lp res n buf size b result true unlock resource h res free the resource free resource h res return b result cpicture getresource cstring lpname cstring lptype presource nbufsize hresinfo hres hinst lpres nlen bresult hresinfo findresource hinst lpname lptype hresinfo hres loadresource hinst hresinfo hres lpres lockresource hres lpres presource nbufsize sizeofresource hinst hresinfo bresult nbufsize sizeofresource hinst hresinfo presource lpres nbufsize bresult unlockresource hres freeresource hres bresult void c picture un load if m ppicture null m ppicture release m ppicture null cpicture unload m_ppicture m_ppicture m_ppicture bool c picture load from buffer byte p buff int n size bool b result false hglobal h global global alloc gmem moveable n size void p data global lock h global memcpy p data p buff n size global unlock h global i stream p stream null if create stream onh global h global true p stream s ok hresult hr if hr ole load picture p stream n size false iid ipicture lpvoid m ppicture s ok b result true p stream release return b result cpicture loadfrombuffer pbuff nsize bresult hglobal globalalloc gmem_moveable nsize pdata globallock hglobal pdata pbuff nsize globalunlock hglobal istream pstream createstreamonhglobal hglobal pstream s_ok oleloadpicture pstream nsize iid_ipicture m_ppicture s_ok bresult pstream bresult bool c picture draw cdc pdc int x int y int cx int cy long hm width long hm height m ppicture get width hm width m ppicture get height hm height if m ppicture render pdc m hdc x y cx cy 0 hm height hm width hm height null s ok return true return false cpicture hmwidth hmheight m_ppicture get_width hmwidth m_ppicture get_height hmheight m_ppicture m_hdc hmheight hmwidth hmheight s_ok c note position c note position void initialize the variables m cnoteposition set rect empty m cbeforeslidedposition set rect empty m bslidedtoleft false m bslidedtoright false m bdockedleft false m bdockedtop false m bdockedright false m bdockedbottom false m pdockpnt x 0 m pdockpnt y 0 save the screen s resolution c rect rc system parameters info spi getworkarea 0 rc 0 m csscreenresolution cx rc right m csscreenresolution cy rc bottom cnoteposition cnoteposition m_cnoteposition setrectempty m_cbeforeslidedposition setrectempty m_bslidedtoleft m_bslidedtoright m_bdockedleft m_bdockedtop m_bdockedright m_bdockedbottom m_pdockpnt m_pdockpnt crect systemparametersinfo spi_getworkarea m_csscreenresolution m_csscreenresolution c note position c note position void cnoteposition cnoteposition void c note position fix note position void p note the main function it will look into all of the variables and maybe change the note s position because the note will not appear correct within the display c note note c note p note c rect rc system parameters info spi getworkarea 0 rc 0 be sure that the note is within the boundaries of the display if rc right m cnoteposition left m cnoteposition left rc right m cnoteposition right if rc bottom m cnoteposition top m cnoteposition top rc bottom note get visible m cnoteposition bottom 23 if rc left m cnoteposition left m cnoteposition left rc left if rc top m cnoteposition top m cnoteposition top rc top note move window m cnoteposition left m cnoteposition top m cnoteposition right m cnoteposition bottom is it docked if the app m bdockable if m bdockedright m cnoteposition left rc right m cnoteposition right if m bdockedbottom m cnoteposition top rc bottom note get visible m cnoteposition bottom 23 if m bdockedleft m cnoteposition left rc left if m bdockedtop m cnoteposition top rc top note move window m cnoteposition left m cnoteposition top m cnoteposition right m cnoteposition bottom is it slided to the left if m bslidedtoleft m cnoteposition left 0 m cnoteposition right 30 note move window m cnoteposition left m cnoteposition top m cnoteposition right m cnoteposition bottom is it slided to the right if m bslidedtoright m cnoteposition left rc right 30 m cnoteposition right 30 note move window m cnoteposition right m cnoteposition top m cnoteposition right m cnoteposition bottom be sure that the note s height is always larger than 0 if m cnoteposition bottom 0 m cnoteposition bottom 50 note move window m cnoteposition right m cnoteposition top m cnoteposition right m cnoteposition bottom be sure that the note s width is always larger than 0 if m cnoteposition right 0 m cnoteposition right 100 note move window m cnoteposition right m cnoteposition top m cnoteposition right m cnoteposition bottom be sure that the note s position before it was slided is larger than 0 if m cbeforeslidedposition left 0 m cbeforeslidedposition left 0 if m cbeforeslidedposition top 0 m cbeforeslidedposition top 0 if m cbeforeslidedposition right 0 m cbeforeslidedposition right 100 if m cbeforeslidedposition bottom 0 m cbeforeslidedposition bottom 100 cnoteposition fixnoteposition pnote cnote cnote pnote crect systemparametersinfo spi_getworkarea m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition getvisible m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition movewindow m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition theapp m_bdockable m_bdockedright m_cnoteposition m_cnoteposition m_bdockedbottom m_cnoteposition getvisible m_cnoteposition m_bdockedleft m_cnoteposition m_bdockedtop m_cnoteposition movewindow m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_bslidedtoleft m_cnoteposition m_cnoteposition movewindow m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_bslidedtoright m_cnoteposition m_cnoteposition movewindow m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition movewindow m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition movewindow m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cbeforeslidedposition m_cbeforeslidedposition m_cbeforeslidedposition m_cbeforeslidedposition m_cbeforeslidedposition m_cbeforeslidedposition m_cbeforeslidedposition m_cbeforeslidedposition void c note position slide position to left void p note slide the note to the left side c note note c note p note show that we have slided the note m bslidedtoleft true remember where we were m cbeforeslidedposition m cnoteposition calculate the distance c rect rc system parameters info spi getworkarea 0 rc 0 int i dist i total i speed i dist i total m cnoteposition left i speed m cnoteposition left 10 while i dist 20 note move window i dist m cnoteposition top m cnoteposition right m cnoteposition bottom sleep 10 i dist i speed correct any error and make the window at least 300 px higher than the text but never shorter than 100 px c size size cdc pdc pdc note getdc c font font c font p font font create font 12 0 900 0 fw normal false false 0 the app m icharset out default precis clip default precis default quality ff modern t arial p font pdc select object font size pdc get text extent note get title note get title get length size cx 30 if size cx 100 size cx 100 m cnoteposition bottom size cx m cnoteposition top m cnoteposition top m cnoteposition bottom rc bottom rc bottom m cnoteposition bottom m cnoteposition top m cnoteposition left 0 m cnoteposition right 30 note move window 0 m cnoteposition top 30 m cnoteposition bottom cnoteposition slidepositiontoleft pnote cnote cnote pnote m_bslidedtoleft m_cbeforeslidedposition m_cnoteposition crect systemparametersinfo spi_getworkarea idist itotal ispeed idist itotal m_cnoteposition ispeed m_cnoteposition idist movewindow idist m_cnoteposition m_cnoteposition m_cnoteposition idist ispeed csize cfont cfont pfont createfont fw_normal theapp m_icharset out_default_precis clip_default_precis default_quality ff_modern _t pfont selectobject gettextextent gettitle gettitle getlength m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition movewindow m_cnoteposition m_cnoteposition void c note position slide position to right void p note c note note c note p note slide the note to the right show that we have slided the note m bslidedtoright true remember where we were m cbeforeslidedposition m cnoteposition calculate the distance c rect rc system parameters info spi getworkarea 0 rc 0 int i dist i total i speed i total rc right m cnoteposition left i dist m cnoteposition left i speed rc right m cnoteposition left 10 while i dist rc right 20 note move window i dist m cnoteposition top m cnoteposition right m cnoteposition bottom sleep 10 i dist i speed correct any error and make the window at least 30 px higher than the text but never shorter than 100 px c size size cdc pdc pdc note getdc c font font c font p font font create font 12 0 900 0 fw normal false false 0 the app m icharset out default precis clip default precis default quality ff modern t arial p font pdc select object font size pdc get text extent note get title note get title get length size cx 30 if size cx 100 size cx 100 m cnoteposition bottom size cx m cnoteposition right 30 m cnoteposition left rc right 30 m cnoteposition top m cnoteposition top m cnoteposition bottom rc bottom rc bottom m cnoteposition bottom m cnoteposition top note move window rc right 30 m cnoteposition top 30 m cnoteposition bottom cnoteposition slidepositiontoright pnote cnote cnote pnote m_bslidedtoright m_cbeforeslidedposition m_cnoteposition crect systemparametersinfo spi_getworkarea idist itotal ispeed itotal m_cnoteposition idist m_cnoteposition ispeed m_cnoteposition idist movewindow idist m_cnoteposition m_cnoteposition m_cnoteposition idist ispeed csize cfont cfont pfont createfont fw_normal theapp m_icharset out_default_precis clip_default_precis default_quality ff_modern _t pfont selectobject gettextextent gettitle gettitle getlength m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition m_cnoteposition movewindow m_cnoteposition m_cnoteposition void c note position restore slide from left void p note c note note c note p note we are in the right sliding mode and the use has pressed on the note and therefore we want to slide back where the note were calculate the distance c rect rc system parameters info spi getworkarea 0 rc 0 int i dist i total i speed i dist 0 i total m cbeforeslidedposition left i speed m cbeforeslidedposition left 10 while i dist m cbeforeslidedposition left note move window i dist m cbeforeslidedposition top m cbeforeslidedposition right m cbeforeslidedposition bottom sleep 10 i dist i speed correct any error note move window m cbeforeslidedposition left m cbeforeslidedposition top m cbeforeslidedposition right m cbeforeslidedposition bottom m cnoteposition m cbeforeslidedposition show that we have slided the note m bslidedtoleft false m cbeforeslidedposition set rect empty be realy sure it is visible fix note position note cnoteposition restoreslidefromleft pnote cnote cnote pnote crect systemparametersinfo spi_getworkarea idist itotal ispeed idist itotal m_cbeforeslidedposition ispeed m_cbeforeslidedposition idist m_cbeforeslidedposition movewindow idist m_cbeforeslidedposition m_cbeforeslidedposition m_cbeforeslidedposition idist ispeed movewindow m_cbeforeslidedposition m_cbeforeslidedposition m_cbeforeslidedposition m_cbeforeslidedposition m_cnoteposition m_cbeforeslidedposition m_bslidedtoleft m_cbeforeslidedposition setrectempty fixnoteposition void c note position restore slide from right void p note restore the note from a right slide c note note c note p note calculate the distance c rect rc system parameters info spi getworkarea 0 rc 0 int i dist i total i speed i dist m cbeforeslidedposition left i total i dist i speed rc right m cbeforeslidedposition left 10 while rc right i total i dist m cbeforeslidedposition left note move window rc right i total i dist m cbeforeslidedposition top m cbeforeslidedposition right m cbeforeslidedposition bottom sleep 10 i dist i speed correct any error note move window m cbeforeslidedposition left m cbeforeslidedposition top m cbeforeslidedposition right m cbeforeslidedposition bottom m cnoteposition m cbeforeslidedposition show that we have slided the note m bslidedtoright false m cbeforeslidedposition set rect empty be realy sure it is visible fix note position note cnoteposition restoreslidefromright pnote cnote cnote pnote crect systemparametersinfo spi_getworkarea idist itotal ispeed idist m_cbeforeslidedposition itotal idist ispeed m_cbeforeslidedposition itotal idist m_cbeforeslidedposition movewindow itotal idist m_cbeforeslidedposition m_cbeforeslidedposition m_cbeforeslidedposition idist ispeed movewindow m_cbeforeslidedposition m_cbeforeslidedposition m_cbeforeslidedposition m_cbeforeslidedposition m_cnoteposition m_cbeforeslidedposition m_bslidedtoright m_cbeforeslidedposition setrectempty fixnoteposition void c note position set note position display resolution changed void p note c point p screen calculate the new position of the note c note note c note p note float ix iy ix float float m cnoteposition left float m csscreenresolution cx ix float p screen x ix int ix iy float float m cnoteposition top float m csscreenresolution cy iy float p screen y iy int iy m cbeforeslidedposition left m cnoteposition left ix m cbeforeslidedposition top m cnoteposition top iy make sure that the note is still within the monitor if ix m cnoteposition right p screen x ix p screen x m cnoteposition right if iy m cnoteposition bottom p screen y iy p screen y m cnoteposition bottom move the note to it s new position note move window ix iy m cnoteposition right m cnoteposition bottom save the new resolution m csscreenresolution cx p screen x m csscreenresolution cy p screen y cnoteposition setnotepositiondisplayresolutionchanged pnote cpoint pscreen cnote cnote pnote m_cnoteposition m_csscreenresolution pscreen m_cnoteposition m_csscreenresolution pscreen m_cbeforeslidedposition m_cnoteposition m_cbeforeslidedposition m_cnoteposition m_cnoteposition pscreen pscreen m_cnoteposition m_cnoteposition pscreen pscreen m_cnoteposition movewindow m_cnoteposition m_cnoteposition m_csscreenresolution pscreen m_csscreenresolution pscreen void c note position set slided to left bool b slided void p note bool b fix position c note note c note p note m bslidedtoleft b slided if b fix position fix note position note cnoteposition setslidedtoleft bslided pnote bfixposition cnote cnote pnote m_bslidedtoleft bslided bfixposition fixnoteposition void c note position set slided to right bool b slided void p note bool b fix position c note note c note p note m bslidedtoright b slided if b fix position fix note position note cnoteposition setslidedtoright bslided pnote bfixposition cnote cnote pnote m_bslidedtoright bslided bfixposition fixnoteposition void c note position set docked left bool b docked void p note bool b fix position c note note c note p note m bdockedleft b docked if b fix position fix note position note cnoteposition setdockedleft bdocked pnote bfixposition cnote cnote pnote m_bdockedleft bdocked bfixposition fixnoteposition void c note position set docked top bool b docked void p note bool b fix position c note note c note p note m bdockedtop b docked if b fix position fix note position note cnoteposition setdockedtop bdocked pnote bfixposition cnote cnote pnote m_bdockedtop bdocked bfixposition fixnoteposition void c note position set docked right bool b docked void p note bool b fix position c note note c note p note m bdockedright b docked if b fix position fix note position note cnoteposition setdockedright bdocked pnote bfixposition cnote cnote pnote m_bdockedright bdocked bfixposition fixnoteposition void c note position set docked bottom bool b docked void p note bool b fix position c note note c note p note m bdockedbottom b docked if b fix position fix note position note cnoteposition setdockedbottom bdocked pnote bfixposition cnote cnote pnote m_bdockedbottom bdocked bfixposition fixnoteposition void c note position set note position c rect c rect void p note bool b fix position c note note c note p note m cnoteposition c rect if b fix position fix note position note cnoteposition setnoteposition crect crect pnote bfixposition cnote cnote pnote m_cnoteposition crect bfixposition fixnoteposition void c note position set slided note position c rect c rect void p note bool b fix position c note note c note p note m cbeforeslidedposition c rect if b fix position fix note position note cnoteposition setslidednoteposition crect crect pnote bfixposition cnote cnote pnote m_cbeforeslidedposition crect bfixposition fixnoteposition c dialog c dlg set title idd p parent afx data init c dlg set title m sztitle t afx data init cdialog cdlgsettitle pparent afx_data_init cdlgsettitle m_sztitle _t afx_data_init void c dlg set title do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c dlg set title ddx text pdx idc title m sztitle afx data map ddx control pdx idc title m ptitle cdlgsettitle dodataexchange cdataexchange cdialog dodataexchange afx_data_map cdlgsettitle ddx_text idc_title m_sztitle afx_data_map ddx_control idc_title m_ptitle bool c dlg set title on init dialog c dialog on init dialog set correct language text c button get dlg item idok set window text c translate read string 36 ok c button get dlg item idcancel set window text c translate read string 37 cancel c static get dlg item idc static1 set window text c translate read string 38 title set window text c translate read string 39 change title return true return true unless you set the focus to a control exception ocx property pages should return false cdlgsettitle oninitdialog cdialog oninitdialog cbutton getdlgitem setwindowtext ctranslate readstring cbutton getdlgitem setwindowtext ctranslate readstring cstatic getdlgitem idc_static1 setwindowtext ctranslate readstring setwindowtext ctranslate readstring c dialog c dlg set alarm idd p parent afx data init c dlg set alarm m busealarm false m ptime c ole date time get current time afx data init cdialog cdlgsetalarm pparent afx_data_init cdlgsetalarm m_busealarm m_ptime coledatetime getcurrenttime afx_data_init void c dlg set alarm do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c dlg set alarm ddx control pdx idc date m pdate ddx check pdx idc usealarm m busealarm ddx datetimectrl pdx idc time m ptime afx data map cdlgsetalarm dodataexchange cdataexchange cdialog dodataexchange afx_data_map cdlgsetalarm ddx_control idc_date m_pdate ddx_check idc_usealarm m_busealarm ddx_datetimectrl idc_time m_ptime afx_data_map bool c dlg set alarm on init dialog c dialog on init dialog m pdate set cur sel m time m ptime m time update data false set correct language text c button get dlg item idok set window text c translate read string 36 ok c button get dlg item idcancel set window text c translate read string 37 cancel c static get dlg item idc usealarm set window text c translate read string 40 use alarm set window text c translate read string 41 set alarm return true cdlgsetalarm oninitdialog cdialog oninitdialog m_pdate setcursel m_time m_ptime m_time updatedata cbutton getdlgitem setwindowtext ctranslate readstring cbutton getdlgitem setwindowtext ctranslate readstring cstatic getdlgitem idc_usealarm setwindowtext ctranslate readstring setwindowtext ctranslate readstring void c dlg set alarm onok update data true systemtime st m pdate get cur sel st st w hour m ptime get hour st w minute m ptime get minute st w second m ptime get second st w milliseconds 0 m time st weekly monthly c dialog onok cdlgsetalarm updatedata m_pdate getcursel whour m_ptime gethour wminute m_ptime getminute wsecond m_ptime getsecond wmilliseconds m_time cdialog void c dlg set alarm on usealarm update data true toogle if m busealarm c date time ctrl get dlg item idc time enable window true c month cal ctrl get dlg item idc date enable window true else c date time ctrl get dlg item idc time enable window false c month cal ctrl get dlg item idc date enable window false cdlgsetalarm onusealarm updatedata m_busealarm cdatetimectrl getdlgitem idc_time enablewindow cmonthcalctrl getdlgitem idc_date enablewindow cdatetimectrl getdlgitem idc_time enablewindow cmonthcalctrl getdlgitem idc_date enablewindow c mapi recipient c mapi recipient cmapirecipient cmapirecipient c mapi recipient c mapi recipient const c string s address m saddress s address cmapirecipient cmapirecipient cstring saddress m_saddress saddress c mapi recipient c mapi recipient const c string s address const c string s friendly name m saddress s address m sfriendlyname s friendly name cmapirecipient cmapirecipient cstring saddress cstring sfriendlyname m_saddress saddress m_sfriendlyname sfriendlyname c mapi recipient c mapi recipient operator const c mapi recipient recipient m saddress recipient m saddress m sfriendlyname recipient m sfriendlyname return this cmapirecipient cmapirecipient cmapirecipient m_saddress m_saddress m_sfriendlyname m_sfriendlyname bool c mapi message add multiple recipients const c string s recipients recipient type recipient type assert s recipients get length an empty string is now allowed loop through the whole string adding recipients as they are encountered int length s recipients get length tchar buf new tchar length 1 allocate a work area don t touch parameter itself tcscpy buf s recipients for int pos 0 start 0 pos length pos valid separators between addresses are or if buf pos t buf pos t buf pos 0 buf pos 0 redundant when at the end of string but who cares c string s temp buf start now divide the substring into friendly names and e mail address c string s friendly c string s address if s temp get length int n mark s temp find t if n mark 0 s friendly s temp left n mark int n mark2 s temp find t if n mark2 n mark s address s temp mid n mark 1 n mark2 n mark 1 else s address s temp finally add it to the correct array s friendly trim right s friendly trim left s address trim right s address trim left if s friendly is empty if the friendly name is empty then just set it to the address s friendly s address c mapi recipient recipient s friendly s address switch recipient type case to m to add recipient break case cc m cc add recipient break case bcc m bcc add recipient break default assert false break move on to the next position start pos 1 delete buf return true cmapimessage addmultiplerecipients cstring srecipients recipient_type recipienttype srecipients getlength srecipients getlength _tcscpy srecipients _t _t cstring stemp cstring sfriendly cstring saddress stemp getlength nmark stemp _t nmark sfriendly stemp nmark nmark2 stemp _t nmark2 nmark saddress stemp nmark nmark2 nmark saddress stemp sfriendly trimright sfriendly trimleft saddress trimright saddress trimleft sfriendly isempty sfriendly saddress cmapirecipient sfriendly saddress recipienttype m_to m_cc m_bcc c mapi session c mapi session m hsession 0 m nlasterror 0 m hmapi null m lpfnmapilogon null m lpfnmapilogoff null m lpfnmapisendmail null m lpfnmapiresolvename null m lpfnmapifreebuffer null initialise cmapisession cmapisession m_hsession m_nlasterror m_hmapi m_lpfnmapilogon m_lpfnmapilogoff m_lpfnmapisendmail m_lpfnmapiresolvename m_lpfnmapifreebuffer c mapi session c mapi session logoff if logged on logoff unload the mapi dll deinitialise cmapisession cmapisession bool c mapi session logon const c string s profile name const c string s password c wnd p parent wnd for correct operation of the t2a macro see mfc tech note 59 uses conversion assert mapi installed mapi must be installed assert m lpfnmapilogon function pointer must be valid initialise the function return value bool b success false just in case we are already logged in logoff setup the ascii versions of the profile name and password int n profile length s profile name get length int n password length s password get length lpstr psz profile name null lpstr psz password null if n profile length psz profile name t2a lptstr lpctstr s profile name psz password t2a lptstr lpctstr s password setup the flags ui param parameters used in the mapi logon call flags flags 0 ulong nui param 0 if n profile length 0 no profile name given then we must interactively request a profile name if p parent wnd nui param ulong p parent wnd get safe hwnd flags mapi logon ui else no c wnd given just use the main window of the app as the parent window if afx get main wnd nui param ulong afx get main wnd get safe hwnd flags mapi logon ui first try to acquire a new mapi session using the supplied settings using the mapi logon functio ulong n error m lpfnmapilogon nui param psz profile name psz password flags mapi new session 0 m hsession if n error success success n error mapi e user abort failed to create a create mapi session try to acquire a shared mapi session trace t failed to logon to mapi using a new session trying to acquire a shared one n n error m lpfnmapilogon nui param null null 0 0 m hsession if n error success success m nlasterror success success b success true else trace t failed to logon to mapi using a shared session error d n n error m nlasterror n error else if n error success success m nlasterror success success b success true return b success cmapisession cstring sprofilename cstring spassword cwnd pparentwnd uses_conversion mapiinstalled m_lpfnmapilogon bsuccess nprofilelength sprofilename getlength npasswordlength spassword getlength pszprofilename pszpassword nprofilelength pszprofilename sprofilename pszpassword spassword uiparam mapilogon nuiparam nprofilelength pparentwnd nuiparam pparentwnd getsafehwnd mapi_logon_ui cwnd afxgetmainwnd nuiparam afxgetmainwnd getsafehwnd mapi_logon_ui mapilogon nerror m_lpfnmapilogon nuiparam pszprofilename pszpassword mapi_new_session m_hsession nerror success_success nerror mapi_e_user_abort _t nerror m_lpfnmapilogon nuiparam m_hsession nerror success_success m_nlasterror success_success bsuccess _t nerror m_nlasterror nerror nerror success_success m_nlasterror success_success bsuccess bsuccess bool c mapi session shared logon assert mapi installed mapi must be installed assert m lpfnmapilogon function pointer must be valid initialise the function return value bool b success false just in case we are already logged in logoff try to acquire a shared mapi session ulong n error m lpfnmapilogon 0 null null 0 0 m hsession if n error success success m nlasterror success success b success true else m nlasterror n error return b success cmapisession sharedlogon mapiinstalled m_lpfnmapilogon bsuccess nerror m_lpfnmapilogon m_hsession nerror success_success m_nlasterror success_success bsuccess m_nlasterror nerror bsuccess bool c mapi session logged on const return m hsession 0 cmapisession loggedon m_hsession bool c mapi session logoff assert mapi installed mapi must be installed assert m lpfnmapilogoff function pointer must be valid initialise the function return value bool b success false if m hsession call the mapi logoff function ulong n error m lpfnmapilogoff m hsession 0 0 0 if n error success success trace t failed in call to mapi logoff error d n error m nlasterror n error b success true else m nlasterror success success b success true m hsession 0 return b success cmapisession mapiinstalled m_lpfnmapilogoff bsuccess m_hsession mapilogoff nerror m_lpfnmapilogoff m_hsession nerror success_success _t mapilogoff nerror m_nlasterror nerror bsuccess m_nlasterror success_success bsuccess m_hsession bsuccess bool c mapi session send c mapi message message bool b resolve bool b interactive c wnd p parent wnd for correct operation of the t2a macro see mfc tech note 59 uses conversion assert mapi installed mapi must be installed assert m lpfnmapisendmail function pointer must be valid assert m lpfnmapifreebuffer function pointer must be valid initialise the function return value bool b success false create the mapi message structure to match the message parameter send into us mapi message mapi message zero memory mapi message sizeof mapi message mapi message lpsz subject t2a lptstr lpctstr message m ssubject mapi message lpsz note text t2a lptstr lpctstr message m sbody mapi message n recip count message m to get size message m cc get size message m bcc get size assert mapi message n recip count must have at least 1 recipient allocate the recipients array mapi message lp recips new mapi recip desc mapi message n recip count setup the to recipients int n recip index 0 int n to size message m to get size for int i 0 i n to size i mapi recip desc recip mapi message lp recips n recip index zero memory recip sizeof mapi recip desc recip ul recip class mapi to c mapi recipient recipient message m to element at i if b resolve try to resolve the name lp mapi recip desc lp temp recip if resolve recipient m sfriendlyname lp temp recip resolve worked put the resolved name back into the s name recipient m sfriendlyname lp temp recip lpsz name recipient m saddress lp temp recip lpsz address don t forget to free up the memory mapi allocated for us m lpfnmapifreebuffer lp temp recip recip lpsz name t2a lptstr lpctstr recipient m sfriendlyname recip lpsz address t2a lptstr lpctstr recipient m saddress n recip index setup the cc recipients int ncc size message m cc get size for i 0 i ncc size i mapi recip desc recip mapi message lp recips n recip index zero memory recip sizeof mapi recip desc recip ul recip class mapi cc c mapi recipient recipient message m cc element at i if b resolve try to resolve the name lp mapi recip desc lp temp recip if resolve recipient m sfriendlyname lp temp recip resolve worked put the resolved name back into the s name recipient m sfriendlyname lp temp recip lpsz name recipient m saddress lp temp recip lpsz address don t forget to free up the memory mapi allocated for us m lpfnmapifreebuffer lp temp recip recip lpsz name t2a lptstr lpctstr recipient m sfriendlyname recip lpsz address t2a lptstr lpctstr recipient m saddress n recip index setup the bcc recipients int nbcc size message m bcc get size for i 0 i nbcc size i mapi recip desc recip mapi message lp recips n recip index zero memory recip sizeof mapi recip desc recip ul recip class mapi bcc c mapi recipient recipient message m bcc element at i if b resolve try to resolve the name lp mapi recip desc lp temp recip if resolve recipient m sfriendlyname lp temp recip resolve worked put the resolved name back into the s name recipient m sfriendlyname lp temp recip lpsz name recipient m saddress lp temp recip lpsz address don t forget to free up the memory mapi allocated for us m lpfnmapifreebuffer lp temp recip recip lpsz name t2a lptstr lpctstr recipient m sfriendlyname recip lpsz address t2a lptstr lpctstr recipient m saddress n recip index setup the attachments int n attachment size message m attachments get size int n title size message m attachmenttitles get size if n title size assert n title size n attachment size if you are going to set the attachment titles then you must set the attachment title for each attachment if n attachment size mapi message n file count n attachment size mapi message lp files new mapi file desc n attachment size for i 0 i n attachment size i mapi file desc file mapi message lp files i zero memory file sizeof mapi file desc file n position 0xffffffff c string s filename message m attachments element at i file lpsz path name t2a lptstr lpctstr s filename file lpsz file name file lpsz path name if n title size c string s title message m attachmenttitles element at i file lpsz file name t2a lptstr lpctstr s title setup the parameters into the function flags flags 0 ulong ui param 0 if logged on flags mapi logon ui if b interactive flags mapi dialog if p parent wnd ui param ulong p parent wnd get safe hwnd else assert afx get main wnd ui param ulong afx get main wnd get safe hwnd do the actual send using mapi send mail ulong n error m lpfnmapisendmail m hsession ui param mapi message flags 0 if n error success success b success true m nlasterror success success else trace t failed to send mail message error d n n error m nlasterror n error tidy up the attachements if n attachment size delete mapi message lp files free up the recipients memory delete mapi message lp recips return b success cmapisession cmapimessage bresolve binteractive cwnd pparentwnd uses_conversion mapiinstalled m_lpfnmapisendmail m_lpfnmapifreebuffer bsuccess mapimessage mapimessage mapimessage zeromemory mapimessage mapimessage mapimessage lpszsubject m_ssubject mapimessage lpsznotetext m_sbody mapimessage nrecipcount m_to getsize m_cc getsize m_bcc getsize mapimessage nrecipcount mapimessage lprecips mapirecipdesc mapimessage nrecipcount nrecipindex ntosize m_to getsize ntosize mapirecipdesc mapimessage lprecips nrecipindex zeromemory mapirecipdesc ulrecipclass mapi_to cmapirecipient m_to elementat bresolve lpmapirecipdesc lptemprecip m_sfriendlyname lptemprecip sname m_sfriendlyname lptemprecip lpszname m_saddress lptemprecip lpszaddress m_lpfnmapifreebuffer lptemprecip lpszname m_sfriendlyname lpszaddress m_saddress nrecipindex nccsize m_cc getsize nccsize mapirecipdesc mapimessage lprecips nrecipindex zeromemory mapirecipdesc ulrecipclass mapi_cc cmapirecipient m_cc elementat bresolve lpmapirecipdesc lptemprecip m_sfriendlyname lptemprecip sname m_sfriendlyname lptemprecip lpszname m_saddress lptemprecip lpszaddress m_lpfnmapifreebuffer lptemprecip lpszname m_sfriendlyname lpszaddress m_saddress nrecipindex nbccsize m_bcc getsize nbccsize mapirecipdesc mapimessage lprecips nrecipindex zeromemory mapirecipdesc ulrecipclass mapi_bcc cmapirecipient m_bcc elementat bresolve lpmapirecipdesc lptemprecip m_sfriendlyname lptemprecip sname m_sfriendlyname lptemprecip lpszname m_saddress lptemprecip lpszaddress m_lpfnmapifreebuffer lptemprecip lpszname m_sfriendlyname lpszaddress m_saddress nrecipindex nattachmentsize m_attachments getsize ntitlesize m_attachmenttitles getsize ntitlesize ntitlesize nattachmentsize nattachmentsize mapimessage nfilecount nattachmentsize mapimessage lpfiles mapifiledesc nattachmentsize nattachmentsize mapifiledesc mapimessage lpfiles zeromemory mapifiledesc nposition cstring sfilename m_attachments elementat lpszpathname sfilename lpszfilename lpszpathname ntitlesize cstring stitle m_attachmenttitles elementat lpszfilename stitle uiparam loggedon mapi_logon_ui binteractive mapi_dialog pparentwnd uiparam pparentwnd getsafehwnd afxgetmainwnd uiparam afxgetmainwnd getsafehwnd mapisendmail nerror m_lpfnmapisendmail m_hsession uiparam mapimessage nerror success_success bsuccess m_nlasterror success_success _t nerror m_nlasterror nerror nattachmentsize mapimessage lpfiles mapimessage lprecips bsuccess bool c mapi session mapi installed const return m hmapi null cmapisession mapiinstalled m_hmapi ulong c mapi session get last error const return m nlasterror cmapisession getlasterror m_nlasterror void c mapi session initialise first make sure the mapi32 dll is present on the system technically we should be also testing by using the check get profile int t mail t mapi 0 0 also but some installs of mapi screw this entry up bool b mapi installed search path null t mapi32 dll null 0 null null 0 if b mapi installed load up the mapi dll and get the function pointers we are interested in m hmapi load library t mapi32 dll if m hmapi m lpfnmapilogon lpmapilogon get proc address m hmapi mapi logon m lpfnmapilogoff lpmapilogoff get proc address m hmapi mapi logoff m lpfnmapisendmail lpmapisendmail get proc address m hmapi mapi send mail m lpfnmapiresolvename lpmapiresolvename get proc address m hmapi mapi resolve name m lpfnmapifreebuffer lpmapifreebuffer get proc address m hmapi mapi free buffer if any of the functions are not installed then fail the load if m lpfnmapilogon null m lpfnmapilogoff null m lpfnmapisendmail null m lpfnmapiresolvename null m lpfnmapifreebuffer null trace t failed to get one of the functions pointer in mapi32 dll n deinitialise else trace t mapi is not installed on this computer n cmapisession getprofileint _t _t bmapiinstalled searchpath _t bmapiinstalled m_hmapi loadlibrary _t m_hmapi m_lpfnmapilogon getprocaddress m_hmapi mapilogon m_lpfnmapilogoff getprocaddress m_hmapi mapilogoff m_lpfnmapisendmail getprocaddress m_hmapi mapisendmail m_lpfnmapiresolvename getprocaddress m_hmapi mapiresolvename m_lpfnmapifreebuffer getprocaddress m_hmapi mapifreebuffer m_lpfnmapilogon m_lpfnmapilogoff m_lpfnmapisendmail m_lpfnmapiresolvename m_lpfnmapifreebuffer _t _t void c mapi session deinitialise if m hmapi unload the mapi dll and reset the function pointers to null free library m hmapi m hmapi null m lpfnmapilogon null m lpfnmapilogoff null m lpfnmapisendmail null m lpfnmapiresolvename null m lpfnmapifreebuffer null cmapisession m_hmapi freelibrary m_hmapi m_hmapi m_lpfnmapilogon m_lpfnmapilogoff m_lpfnmapisendmail m_lpfnmapiresolvename m_lpfnmapifreebuffer bool c mapi session resolve const c string s name lp mapi recip desc lpp recip for correct operation of the t2a macro see mfc tech note 59 uses conversion assert mapi installed mapi must be installed assert m lpfnmapiresolvename function pointer must be valid assert logged on must be logged on to mapi assert m hsession mapi session handle must be valid call the mapi resolve name function lpstr lpsz ascii name t2a lptstr lpctstr s name ulong n error m lpfnmapiresolvename m hsession 0 lpsz ascii name 0 0 lpp recip if n error success success trace t failed to resolve the name s error d n s name n error m nlasterror n error return n error success success cmapisession cstring sname lpmapirecipdesc lpprecip uses_conversion mapiinstalled m_lpfnmapiresolvename loggedon m_hsession mapiresolvename lpszasciiname sname nerror m_lpfnmapiresolvename m_hsession lpszasciiname lpprecip nerror success_success _t sname nerror m_nlasterror nerror nerror success_success c dialog c dlg delete information idd p parent afx data init c dlg delete information m bshowagain true afx data init cdialog cdlgdeleteinformation pparent afx_data_init cdlgdeleteinformation m_bshowagain afx_data_init void c dlg delete information do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c dlg delete information ddx check pdx idc showagain m bshowagain afx data map cdlgdeleteinformation dodataexchange cdataexchange cdialog dodataexchange afx_data_map cdlgdeleteinformation ddx_check idc_showagain m_bshowagain afx_data_map bool c dlg delete information on init dialog c dialog on init dialog language stuff c button get dlg item idok set window text c translate read string 36 ok c static get dlg item idc static1 set window text c translate read string 42 when you delete a note it will be saved in a file n by selecting the recycle bin in the tray menu you will be nable to either permanently delete a note or restore it c static get dlg item idc static2 set window text c translate read string 43 if you hold the shift button on your keyboard when you press the delete button on a note the note will be permanently erased c button get dlg item idc showagain set window text c translate read string 44 show this warning next time set window text c translate read string 45 delete a note return true return true unless you set the focus to a control exception ocx property pages should return false cdlgdeleteinformation oninitdialog cdialog oninitdialog cbutton getdlgitem setwindowtext ctranslate readstring cstatic getdlgitem idc_static1 setwindowtext ctranslate readstring nby cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring cbutton getdlgitem idc_showagain setwindowtext ctranslate readstring setwindowtext ctranslate readstring csa prefs sub dlg c dlg options general idd p parent afx data init c dlg options general m szdefaulttitle t m bwarnondelete false m bversioncheck false afx data init csaprefssubdlg cdlgoptionsgeneral pparent afx_data_init cdlgoptionsgeneral m_szdefaulttitle _t m_bwarnondelete m_bversioncheck afx_data_init void c dlg options general do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options general ddx text pdx idc defaulttitle m szdefaulttitle ddx check pdx idc warnondelete m bwarnondelete ddx check pdx idc versioncheck m bversioncheck afx data map cdlgoptionsgeneral dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionsgeneral ddx_text idc_defaulttitle m_szdefaulttitle ddx_check idc_warnondelete m_bwarnondelete ddx_check idc_versioncheck m_bversioncheck afx_data_map bool c dlg options general on init dialog csa prefs sub dlg on init dialog language stuff c string sz temp sz temp format t s c translate read string 93 t creation c static get dlg item idc static1 set window text sz temp sz temp format t s c translate read string 94 t delete c static get dlg item idc static2 set window text sz temp sz temp format t s c translate read string 95 t version check c static get dlg item idc static3 set window text sz temp c static get dlg item idc static4 set window text c translate read string 96 t use time for the current time and date for the current date c static get dlg item idc static5 set window text c translate read string 97 t default title c button get dlg item idc warnondelete set window text c translate read string 98 t warn when deleting a note c button get dlg item idc versioncheck set window text c translate read string 99 t see if there are any newer versions of the program return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionsgeneral oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static2 setwindowtext sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static3 setwindowtext sztemp cstatic getdlgitem idc_static4 setwindowtext ctranslate readstring _t cstatic getdlgitem idc_static5 setwindowtext ctranslate readstring _t cbutton getdlgitem idc_warnondelete setwindowtext ctranslate readstring _t cbutton getdlgitem idc_versioncheck setwindowtext ctranslate readstring _t csa prefs sub dlg c dlg options looks idd p parent afx data init c dlg options looks m brndcolor false m bthinborder false afx data init csaprefssubdlg cdlgoptionslooks pparent afx_data_init cdlgoptionslooks m_brndcolor m_bthinborder afx_data_init void c dlg options looks do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options looks ddx check pdx idc rndcolor m brndcolor ddx check pdx idc thinborder m bthinborder afx data map cdlgoptionslooks dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionslooks ddx_check idc_rndcolor m_brndcolor ddx_check idc_thinborder m_bthinborder afx_data_map void c dlg options looks on paint c paintdc dc this device context for painting c brush brush brush create solid brush m cfcolor c brush p old brush c brush dc select object brush dc rectangle 20 47 41 68 dc select object p old brush cdlgoptionslooks onpaint cpaintdc cbrush createsolidbrush m_cfcolor cbrush poldbrush cbrush selectobject selectobject poldbrush void c dlg options looks on changenotecolor c color dialog dlg if dlg do modal idok m cfcolor dlg get color invalidate cdlgoptionslooks onchangenotecolor ccolordialog domodal m_cfcolor getcolor bool c dlg options looks on init dialog csa prefs sub dlg on init dialog langugage stuff c string sz temp sz temp format t s c translate read string 110 t looks c static get dlg item idc static1 set window text sz temp c static get dlg item idc static2 set window text c translate read string 111 t default note color c button get dlg item idc rndcolor set window text c translate read string 112 t randomize the note color c button get dlg item idc thinborder set window text c translate read string 113 t thin border c button get dlg item idc changenotecolor set window text c translate read string 114 t change return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionslooks oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring _t cbutton getdlgitem idc_rndcolor setwindowtext ctranslate readstring _t cbutton getdlgitem idc_thinborder setwindowtext ctranslate readstring _t cbutton getdlgitem idc_changenotecolor setwindowtext ctranslate readstring _t csa prefs sub dlg c dlg options alarm idd p parent afx data init c dlg options alarm m bblink false m bplaysound false m szsoundfile t afx data init csaprefssubdlg cdlgoptionsalarm pparent afx_data_init cdlgoptionsalarm m_bblink m_bplaysound m_szsoundfile _t afx_data_init void c dlg options alarm do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options alarm ddx check pdx idc blink m bblink ddx check pdx idc playsound m bplaysound ddx text pdx idc soundfile m szsoundfile afx data map cdlgoptionsalarm dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionsalarm ddx_check idc_blink m_bblink ddx_check idc_playsound m_bplaysound ddx_text idc_soundfile m_szsoundfile afx_data_map void c dlg options alarm on browse openfilename ofn tchar sz file 260 sz file 0 null zero memory ofn sizeof openfilename ofn l struct size sizeof openfilename ofn hwnd owner m hwnd ofn lpstr file sz file ofn n max file sizeof sz file ofn lpstr filter t sounds wav 0 wav ofn n filter index 1 ofn lpstr file title null ofn n max file title 0 ofn lpstr initial dir null ofn flags ofn pathmustexist ofn filemustexist if get open file name ofn true return m szsoundfile c string ofn lpstr file update data false cdlgoptionsalarm onbrowse szfile szfile zeromemory lstructsize hwndowner m_hwnd lpstrfile szfile nmaxfile szfile lpstrfilter _t nfilterindex lpstrfiletitle nmaxfiletitle lpstrinitialdir ofn_pathmustexist ofn_filemustexist getopenfilename m_szsoundfile cstring lpstrfile updatedata bool c dlg options alarm on init dialog csa prefs sub dlg on init dialog language stuff c string sz temp sz temp format t s c translate read string 68 t alarm c static get dlg item idc static1 set window text sz temp c static get dlg item idc static2 set window text c translate read string 69 sound file c button get dlg item idc blink set window text c translate read string 70 blink the note on alarm c button get dlg item idc playsound set window text c translate read string 71 play a sound on alarm c button get dlg item idc browse set window text c translate read string 72 browse return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionsalarm oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring cbutton getdlgitem idc_blink setwindowtext ctranslate readstring cbutton getdlgitem idc_playsound setwindowtext ctranslate readstring cbutton getdlgitem idc_browse setwindowtext ctranslate readstring csa prefs sub dlg c dlg options database idd p parent afx data init c dlg options database m szpassword t m szusername t m buploaddownload false m szdownloadafter t 0 afx data init csaprefssubdlg cdlgoptionsdatabase pparent afx_data_init cdlgoptionsdatabase m_szpassword _t m_szusername _t m_buploaddownload m_szdownloadafter _t afx_data_init void c dlg options database do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options database ddx text pdx idc password m szpassword ddx text pdx idc username m szusername ddx check pdx idc uploaddownload m buploaddownload ddx text pdx idc downloadafter m szdownloadafter afx data map cdlgoptionsdatabase dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionsdatabase ddx_text idc_password m_szpassword ddx_text idc_username m_szusername ddx_check idc_uploaddownload m_buploaddownload ddx_text idc_downloadafter m_szdownloadafter afx_data_map void c dlg options database on deletenotes c main frame p main c main frame afx get main wnd delete all the notes that the user has on his hers account c string sz temp sz temp format t s n s c translate read string 172 t do you want to delete all of your notes on the server c translate read string 173 t note that the notes on your desktop will not be deleted now if message box sz temp c translate read string 174 t delete notes mb yesno mb iconquestion idno return c string sz path szxml sz data sz path format t ssendnotes php user s password s the app m szserverpath string encode the app m szusername string encode the app m szpassword create the delete xml c xml xml sz data xml get delete xml if p main send the app m szserveraddress sz path sz data szxml c stdio file f if f open get application data path t delete notes at server xml c file mode create c file mode write c error log c error log info t could not open the delete notes xml file return try if defined unicode defined unicode int i length i length sz data get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 wide char to multi byte cp utf8 0 sz data i length pc dest 2 i length null null f write pc dest i length delete pc dest delete pwc unicode else f write sz data sz data get length endif f close catch c file exception e c error log c error log err t could not write the delete notes xml file return end catch c stdio file fp if fp open get application data path t delete notes answer xml c file mode create c file mode write c error log c error log info t could not open the delete notes answer xml file return try if defined unicode defined unicode int i length i length szxml get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 wide char to multi byte cp utf8 0 szxml i length pc dest 2 i length null null fp write pc dest i length delete pc dest delete pwc unicode else fp write szxml szxml get length endif fp close catch c file exception e c error log c error log err t could not write the delete notes answer xml file return end catch afx message box c translate read string 20 t the notes have now been deleted cdlgoptionsdatabase ondeletenotes cmainframe pmain cmainframe afxgetmainwnd cstring sztemp sztemp _t ctranslate readstring _t ctranslate readstring _t messagebox sztemp ctranslate readstring _t mb_yesno mb_iconquestion cstring szpath szdata szpath _t theapp m_szserverpath stringencode theapp m_szusername stringencode theapp m_szpassword cxml szdata getdeletexml pmain theapp m_szserveraddress szpath szdata cstdiofile getapplicationdatapath _t cfile modecreate cfile modewrite cerrorlog cerrorlog _t _unicode ilength ilength szdata getlength pwcunicode ilength pcdest ilength widechartomultibyte cp_utf8 szdata ilength pcdest ilength pcdest ilength pcdest pwcunicode szdata szdata getlength cfileexception cerrorlog cerrorlog _t end_catch cstdiofile getapplicationdatapath _t cfile modecreate cfile modewrite cerrorlog cerrorlog _t _unicode ilength ilength getlength pwcunicode ilength pcdest ilength widechartomultibyte cp_utf8 ilength pcdest ilength pcdest ilength pcdest pwcunicode getlength cfileexception cerrorlog cerrorlog _t end_catch afxmessagebox ctranslate readstring _t bool c dlg options database on init dialog csa prefs sub dlg on init dialog language stuff c string sz temp sz temp format t s c translate read string 81 t user information c static get dlg item idc static1 set window text sz temp c static get dlg item idc static2 set window text c translate read string 82 t user name c static get dlg item idc static3 set window text c translate read string 83 t password sz temp format t s c translate read string 84 t upload download c static get dlg item idc static4 set window text sz temp c static get dlg item idc static5 set window text c translate read string 85 t start to download the notes after seconds c static get dlg item idc static6 set window text c translate read string 86 t delete all my notes that i have on the server c button get dlg item idc uploaddownload set window text c translate read string 87 t download the notes when the program starts and upload them on exit c button get dlg item idc deletenotes set window text c translate read string 88 t delete notes return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionsdatabase oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring _t cstatic getdlgitem idc_static3 setwindowtext ctranslate readstring _t sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static4 setwindowtext sztemp cstatic getdlgitem idc_static5 setwindowtext ctranslate readstring _t cstatic getdlgitem idc_static6 setwindowtext ctranslate readstring _t cbutton getdlgitem idc_uploaddownload setwindowtext ctranslate readstring _t cbutton getdlgitem idc_deletenotes setwindowtext ctranslate readstring _t c dialog c dlg user information idd p parent afx data init c dlg user information m szusername t m szpassword t m szemail t afx data init cdialog cdlguserinformation pparent afx_data_init cdlguserinformation m_szusername _t m_szpassword _t m_szemail _t afx_data_init void c dlg user information do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c dlg user information ddx text pdx idc username m szusername ddx text pdx idc password m szpassword ddx text pdx idc email m szemail afx data map cdlguserinformation dodataexchange cdataexchange cdialog dodataexchange afx_data_map cdlguserinformation ddx_text idc_username m_szusername ddx_text idc_password m_szpassword ddx_text idc_email m_szemail afx_data_map void c dlg user information onok update data true if m szusername is empty m szpassword is empty afx message box c translate read string 21 username and password must be filled in return c dialog onok cdlguserinformation updatedata m_szusername isempty m_szpassword isempty afxmessagebox ctranslate readstring cdialog bool c dlg user information on init dialog c dialog on init dialog language stuff c static get dlg item idc static1 set window text c translate read string 161 user name c static get dlg item idc static2 set window text c translate read string 162 password c static get dlg item idc static3 set window text c translate read string 163 email optional c static get dlg item idc static4 set window text c translate read string 164 note the email will not be shared but only used to send you the password in case you forget it c button get dlg item idok set window text c translate read string 36 ok c button get dlg item idcancel set window text c translate read string 37 cancel set window text c translate read string 165 user information return true return true unless you set the focus to a control exception ocx property pages should return false cdlguserinformation oninitdialog cdialog oninitdialog cstatic getdlgitem idc_static1 setwindowtext ctranslate readstring cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring cstatic getdlgitem idc_static3 setwindowtext ctranslate readstring cstatic getdlgitem idc_static4 setwindowtext ctranslate readstring cbutton getdlgitem setwindowtext ctranslate readstring cbutton getdlgitem setwindowtext ctranslate readstring setwindowtext ctranslate readstring c dialog c dlg use user information idd p parent afx data init c dlg use user information m szusername t m szpassword t afx data init cdialog cdlguseuserinformation pparent afx_data_init cdlguseuserinformation m_szusername _t m_szpassword _t afx_data_init void c dlg use user information do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c dlg use user information ddx text pdx idc username m szusername ddx text pdx idc password m szpassword afx data map cdlguseuserinformation dodataexchange cdataexchange cdialog dodataexchange afx_data_map cdlguseuserinformation ddx_text idc_username m_szusername ddx_text idc_password m_szpassword afx_data_map bool c dlg use user information on init dialog c dialog on init dialog language stuff c static get dlg item idc static1 set window text c translate read string 161 user name c static get dlg item idc static2 set window text c translate read string 162 password c static get dlg item idok set window text c translate read string 36 ok c static get dlg item idcancel set window text c translate read string 37 cancel set window text c translate read string 165 user information return true return true unless you set the focus to a control exception ocx property pages should return false cdlguseuserinformation oninitdialog cdialog oninitdialog cstatic getdlgitem idc_static1 setwindowtext ctranslate readstring cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring cstatic getdlgitem setwindowtext ctranslate readstring cstatic getdlgitem setwindowtext ctranslate readstring setwindowtext ctranslate readstring csa prefs sub dlg c dlg options font idd p parent afx data init c dlg options font afx data init csaprefssubdlg cdlgoptionsfont pparent afx_data_init cdlgoptionsfont afx_data_init void c dlg options font do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options font afx data map cdlgoptionsfont dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionsfont afx_data_map bool c dlg options font on init dialog csa prefs sub dlg on init dialog initialize m ptext create ws child es wantreturn es autovscroll ws tabstop ws visible c rect 20 85 300 110 this 1 charformat c c cb size afx get app get profile int t options font t cb size 0 c dw mask afx get app get profile int t options font t dw mask 0 c dw effects afx get app get profile int t options font t dw effects 0 c y height afx get app get profile int t options font t y height 0 c y offset afx get app get profile int t options font t y offset 0 c cr text color afx get app get profile int t options font t cr text color 0 c b char set afx get app get profile int t options font t b char set 0 c b pitch and family afx get app get profile int t options font t b pitch and family 0 c string sz temp afx get app get profile string t options font t sz face name t tcscpy c sz face name sz temp first time if c cb size 0 m ptext set font get font false else m ptext set sel 0 1 m ptext set selection char format c m ptext set window text c translate read string 92 t this is the font for a new note language stuff sz temp format t s c translate read string 89 t default note font c static get dlg item idc static1 set window text sz temp c static get dlg item idc static2 set window text c translate read string 90 t try here c button get dlg item idc changefont set window text c translate read string 91 t change font return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionsfont oninitdialog csaprefssubdlg oninitdialog m_ptext ws_child es_wantreturn es_autovscroll ws_tabstop ws_visible crect cbsize afxgetapp getprofileint _t _t cbsize dwmask afxgetapp getprofileint _t _t dwmask dweffects afxgetapp getprofileint _t _t dweffects yheight afxgetapp getprofileint _t _t yheight yoffset afxgetapp getprofileint _t _t yoffset crtextcolor afxgetapp getprofileint _t _t crtextcolor bcharset afxgetapp getprofileint _t _t bcharset bpitchandfamily afxgetapp getprofileint _t _t bpitchandfamily cstring sztemp afxgetapp getprofilestring _t _t szfacename _t _tcscpy szfacename sztemp cbsize m_ptext setfont getfont m_ptext setsel m_ptext setselectioncharformat m_ptext setwindowtext ctranslate readstring _t sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring _t cbutton getdlgitem idc_changefont setwindowtext ctranslate readstring _t void c dlg options font on changefont show the change font dialog charformat c c cb size afx get app get profile int t options font t cb size 0 c dw mask afx get app get profile int t options font t dw mask 0 c dw effects afx get app get profile int t options font t dw effects 0 c y height afx get app get profile int t options font t y height 0 c y offset afx get app get profile int t options font t y offset 0 c cr text color afx get app get profile int t options font t cr text color 0 c b char set afx get app get profile int t options font t b char set 0 c b pitch and family afx get app get profile int t options font t b pitch and family 0 c string sz temp afx get app get profile string t options font t sz face name t tcscpy c sz face name sz temp c font dialog dlg c if dlg do modal idok charformat cf dlg get char format cf m ptext set sel 0 1 m ptext set selection char format cf afx get app write profile int t options font t cb size cf cb size afx get app write profile int t options font t dw mask cf dw mask afx get app write profile int t options font t dw effects cf dw effects afx get app write profile int t options font t y height cf y height afx get app write profile int t options font t y offset cf y offset afx get app write profile int t options font t cr text color cf cr text color afx get app write profile int t options font t b char set cf b char set afx get app write profile int t options font t b pitch and family cf b pitch and family afx get app write profile string t options font t sz face name cf sz face name cdlgoptionsfont onchangefont cbsize afxgetapp getprofileint _t _t cbsize dwmask afxgetapp getprofileint _t _t dwmask dweffects afxgetapp getprofileint _t _t dweffects yheight afxgetapp getprofileint _t _t yheight yoffset afxgetapp getprofileint _t _t yoffset crtextcolor afxgetapp getprofileint _t _t crtextcolor bcharset afxgetapp getprofileint _t _t bcharset bpitchandfamily afxgetapp getprofileint _t _t bpitchandfamily cstring sztemp afxgetapp getprofilestring _t _t szfacename _t _tcscpy szfacename sztemp cfontdialog domodal getcharformat m_ptext setsel m_ptext setselectioncharformat afxgetapp writeprofileint _t _t cbsize cbsize afxgetapp writeprofileint _t _t dwmask dwmask afxgetapp writeprofileint _t _t dweffects dweffects afxgetapp writeprofileint _t _t yheight yheight afxgetapp writeprofileint _t _t yoffset yoffset afxgetapp writeprofileint _t _t crtextcolor crtextcolor afxgetapp writeprofileint _t _t bcharset bcharset afxgetapp writeprofileint _t _t bpitchandfamily bpitchandfamily afxgetapp writeprofilestring _t _t szfacename szfacename csa prefs sub dlg c dlg options new note idd p parent afx data init c dlg options new note m bdockbottom false m bdockleft false m bdockright false m bdocktop false m szleft t m sztop t m szwidth t afx data init csaprefssubdlg cdlgoptionsnewnote pparent afx_data_init cdlgoptionsnewnote m_bdockbottom m_bdockleft m_bdockright m_bdocktop m_szleft _t m_sztop _t m_szwidth _t afx_data_init void c dlg options new note do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options new note ddx check pdx idc dockbottom m bdockbottom ddx check pdx idc dockleft m bdockleft ddx check pdx idc dockright m bdockright ddx check pdx idc docktop m bdocktop ddx text pdx idc left m szleft ddx text pdx idc top m sztop ddx text pdx idc width m szwidth afx data map cdlgoptionsnewnote dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionsnewnote ddx_check idc_dockbottom m_bdockbottom ddx_check idc_dockleft m_bdockleft ddx_check idc_dockright m_bdockright ddx_check idc_docktop m_bdocktop ddx_text idc_left m_szleft ddx_text idc_top m_sztop ddx_text idc_width m_szwidth afx_data_map void c dlg options new note on paint c paintdc dc this c pen pen c brush brush pen create pen ps solid 1 rgb 0 0 0 brush create solid brush the app m cfnotecolor c pen p old pen c pen dc select object pen c brush p old brush c brush dc select object brush get monitor width and height c rect rc system parameters info spi getworkarea 0 rc 0 c point tinyscreen 294 137 223 102 calculate where the notes will appear c rect rcnote if m bdockleft rcnote left 0 else rcnote left int float ttoi m szleft float rc width tinyscreen x if m bdocktop rcnote top 0 else rcnote top int float ttoi m sztop float rc height tinyscreen y if m bdockright rcnote left tinyscreen x int float ttoi m szwidth float rc width tinyscreen x if m bdockbottom rcnote top tinyscreen y 10 rcnote right rcnote left int float ttoi m szwidth float rc width tinyscreen x rcnote bottom rcnote top 10 rcnote left 137 rcnote right 137 rcnote top 102 rcnote bottom 102 dc rectangle rcnote clean up dc select object p old pen dc select object p old brush cdlgoptionsnewnote onpaint cpaintdc cpen cbrush createpen ps_solid createsolidbrush theapp m_cfnotecolor cpen poldpen cpen selectobject cbrush poldbrush cbrush selectobject crect systemparametersinfo spi_getworkarea cpoint crect m_bdockleft _ttoi m_szleft m_bdocktop _ttoi m_sztop m_bdockright _ttoi m_szwidth m_bdockbottom _ttoi m_szwidth selectobject poldpen selectobject poldbrush void c dlg options new note on dock click update data true invalidate make some of the controls grey if m bdockleft c button get dlg item idc dockright enable window false else c button get dlg item idc dockright enable window true if m bdocktop c button get dlg item idc dockbottom enable window false else c button get dlg item idc dockbottom enable window true if m bdockright c button get dlg item idc dockleft enable window false else c button get dlg item idc dockleft enable window true if m bdockbottom c button get dlg item idc docktop enable window false else c button get dlg item idc docktop enable window true cdlgoptionsnewnote ondockclick updatedata m_bdockleft cbutton getdlgitem idc_dockright enablewindow cbutton getdlgitem idc_dockright enablewindow m_bdocktop cbutton getdlgitem idc_dockbottom enablewindow cbutton getdlgitem idc_dockbottom enablewindow m_bdockright cbutton getdlgitem idc_dockleft enablewindow cbutton getdlgitem idc_dockleft enablewindow m_bdockbottom cbutton getdlgitem idc_docktop enablewindow cbutton getdlgitem idc_docktop enablewindow bool c dlg options new note on init dialog csa prefs sub dlg on init dialog language stuff c string sz temp sz temp format t s c translate read string 115 t position of new notes c static get dlg item idc static1 set window text sz temp c static get dlg item idc static2 set window text c translate read string 116 t your screen c static get dlg item idc static3 set window text c translate read string 117 t from left c static get dlg item idc static4 set window text c translate read string 118 t from top c static get dlg item idc static5 set window text c translate read string 119 t width c button get dlg item idc dockleft set window text c translate read string 120 t dock left c button get dlg item idc docktop set window text c translate read string 121 t dock top c button get dlg item idc dockright set window text c translate read string 122 t dock right c button get dlg item idc dockbottom set window text c translate read string 123 t dock bottom make some of the controls grey if m bdockleft c button get dlg item idc dockright enable window false else c button get dlg item idc dockright enable window true if m bdocktop c button get dlg item idc dockbottom enable window false else c button get dlg item idc dockbottom enable window true if m bdockright c button get dlg item idc dockleft enable window false else c button get dlg item idc dockleft enable window true if m bdockbottom c button get dlg item idc docktop enable window false else c button get dlg item idc docktop enable window true return true cdlgoptionsnewnote oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring _t cstatic getdlgitem idc_static3 setwindowtext ctranslate readstring _t cstatic getdlgitem idc_static4 setwindowtext ctranslate readstring _t cstatic getdlgitem idc_static5 setwindowtext ctranslate readstring _t cbutton getdlgitem idc_dockleft setwindowtext ctranslate readstring _t cbutton getdlgitem idc_docktop setwindowtext ctranslate readstring _t cbutton getdlgitem idc_dockright setwindowtext ctranslate readstring _t cbutton getdlgitem idc_dockbottom setwindowtext ctranslate readstring _t m_bdockleft cbutton getdlgitem idc_dockright enablewindow cbutton getdlgitem idc_dockright enablewindow m_bdocktop cbutton getdlgitem idc_dockbottom enablewindow cbutton getdlgitem idc_dockbottom enablewindow m_bdockright cbutton getdlgitem idc_dockleft enablewindow cbutton getdlgitem idc_dockleft enablewindow m_bdockbottom cbutton getdlgitem idc_docktop enablewindow cbutton getdlgitem idc_docktop enablewindow csa prefs sub dlg c dlg options transparancy idd p parent afx data init c dlg options transparancy m itransparantnormal 0 m itransparantminimized 0 afx data init csaprefssubdlg cdlgoptionstransparancy pparent afx_data_init cdlgoptionstransparancy m_itransparantnormal m_itransparantminimized afx_data_init void c dlg options transparancy do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options transparancy ddx control pdx idc transparancynormal m ptransparancynormal ddx control pdx idc transparancyminimize m ptransparancyminimized ddx slider pdx idc transparancynormal m itransparantnormal ddx slider pdx idc transparancyminimize m itransparantminimized afx data map cdlgoptionstransparancy dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionstransparancy ddx_control idc_transparancynormal m_ptransparancynormal ddx_control idc_transparancyminimize m_ptransparancyminimized ddx_slider idc_transparancynormal m_itransparantnormal ddx_slider idc_transparancyminimize m_itransparantminimized afx_data_map bool c dlg options transparancy on init dialog csa prefs sub dlg on init dialog language stuff c string sz temp sz temp format t s c translate read string 143 t transparancy only windows 2000 xp c static get dlg item idc static1 set window text sz temp c static get dlg item idc static2 set window text c translate read string 144 t when the notes are in normal mode c static get dlg item idc static3 set window text c translate read string 145 t when the notes are minimized but still visible c slider ctrl get dlg item idc transparancynormal set range 1 100 false c slider ctrl get dlg item idc transparancynormal set pos the app m itransparantnormal c slider ctrl get dlg item idc transparancynormal set tic 50 c slider ctrl get dlg item idc transparancynormal send message wm lbuttondown c slider ctrl get dlg item idc transparancynormal send message wm lbuttonup c slider ctrl get dlg item idc transparancyminimize set range 1 100 false c slider ctrl get dlg item idc transparancyminimize set pos the app m itransparantminimized c slider ctrl get dlg item idc transparancyminimize set tic 50 c slider ctrl get dlg item idc transparancyminimize send message wm lbuttondown c slider ctrl get dlg item idc transparancyminimize send message wm lbuttonup return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionstransparancy oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring _t cstatic getdlgitem idc_static3 setwindowtext ctranslate readstring _t csliderctrl getdlgitem idc_transparancynormal setrange csliderctrl getdlgitem idc_transparancynormal setpos theapp m_itransparantnormal csliderctrl getdlgitem idc_transparancynormal settic csliderctrl getdlgitem idc_transparancynormal sendmessage wm_lbuttondown csliderctrl getdlgitem idc_transparancynormal sendmessage wm_lbuttonup csliderctrl getdlgitem idc_transparancyminimize setrange csliderctrl getdlgitem idc_transparancyminimize setpos theapp m_itransparantminimized csliderctrl getdlgitem idc_transparancyminimize settic csliderctrl getdlgitem idc_transparancyminimize sendmessage wm_lbuttondown csliderctrl getdlgitem idc_transparancyminimize sendmessage wm_lbuttonup void c dlg options transparancy on destroy csa prefs sub dlg on destroy m itransparantnormal m ptransparancynormal get pos m itransparantminimized m ptransparancyminimized get pos cdlgoptionstransparancy ondestroy csaprefssubdlg ondestroy m_itransparantnormal m_ptransparancynormal getpos m_itransparantminimized m_ptransparancyminimized getpos csa prefs sub dlg c dlg options hot key idd p parent afx data init c dlg options hot key m balt false m bctrl false m bshift false m bwin false m busehotkey false m icharacter 0 afx data init csaprefssubdlg cdlgoptionshotkey pparent afx_data_init cdlgoptionshotkey m_balt m_bctrl m_bshift m_bwin m_busehotkey m_icharacter afx_data_init void c dlg options hot key do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options hot key ddx control pdx idc character m pcharacter ddx check pdx idc alt m balt ddx check pdx idc ctrl m bctrl ddx check pdx idc shift m bshift ddx check pdx idc win m bwin ddx check pdx idc usehotkey m busehotkey afx data map cdlgoptionshotkey dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionshotkey ddx_control idc_character m_pcharacter ddx_check idc_alt m_balt ddx_check idc_ctrl m_bctrl ddx_check idc_shift m_bshift ddx_check idc_win m_bwin ddx_check idc_usehotkey m_busehotkey afx_data_map bool c dlg options hot key on init dialog csa prefs sub dlg on init dialog language stuff c string sz temp sz temp format t s c translate read string 100 t hot key c static get dlg item idc static1 set window text sz temp sz temp format t s c translate read string 101 t character c static get dlg item idc static2 set window text sz temp c button get dlg item idc shift set window text c translate read string 102 t shift c button get dlg item idc win set window text c translate read string 103 t win c button get dlg item idc alt set window text c translate read string 104 t alt c button get dlg item idc ctrl set window text c translate read string 105 t ctrl c button get dlg item idc usehotkey set window text c translate read string 106 t use hot key c button get dlg item idc sethotkey set window text c translate read string 109 t set hot key set the combobox to the default value int i index m icharacter m pcharacter getlb text i index sz temp m pcharacter select string 0 sz temp set the controls to the right statement on usehotkey return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionshotkey oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static2 setwindowtext sztemp cbutton getdlgitem idc_shift setwindowtext ctranslate readstring _t cbutton getdlgitem idc_win setwindowtext ctranslate readstring _t cbutton getdlgitem idc_alt setwindowtext ctranslate readstring _t cbutton getdlgitem idc_ctrl setwindowtext ctranslate readstring _t cbutton getdlgitem idc_usehotkey setwindowtext ctranslate readstring _t cbutton getdlgitem idc_sethotkey setwindowtext ctranslate readstring _t iindex m_icharacter m_pcharacter getlbtext iindex sztemp m_pcharacter selectstring sztemp onusehotkey void c dlg options hot key on usehotkey update data c button get dlg item idc shift enable window m busehotkey true false c button get dlg item idc alt enable window m busehotkey true false c button get dlg item idc ctrl enable window m busehotkey true false c button get dlg item idc win enable window m busehotkey true false c button get dlg item idc character enable window m busehotkey true false c button get dlg item idc sethotkey enable window m busehotkey true false cdlgoptionshotkey onusehotkey updatedata cbutton getdlgitem idc_shift enablewindow m_busehotkey cbutton getdlgitem idc_alt enablewindow m_busehotkey cbutton getdlgitem idc_ctrl enablewindow m_busehotkey cbutton getdlgitem idc_win enablewindow m_busehotkey cbutton getdlgitem idc_character enablewindow m_busehotkey cbutton getdlgitem idc_sethotkey enablewindow m_busehotkey void c dlg options hot key on sethotkey update data try to set the hot key m icharacter m pcharacter get cur sel uint i modifiers 0 the app m ihotkeyid global add atom t a note if m bctrl i modifiers mod control if m bshift i modifiers mod shift if m balt i modifiers mod alt if m bwin i modifiers mod win c main frame p main c main frame afx get main wnd if register hot key p main get safe hwnd the app m ihotkeyid i modifiers 65 m icharacter c button get dlg item idc statustext set window text c translate read string 107 t the hot key was set else c button get dlg item idc statustext set window text c translate read string 108 t the combination could not be set show if it worked or not cdlgoptionshotkey onsethotkey updatedata m_icharacter m_pcharacter getcursel imodifiers theapp m_ihotkeyid globaladdatom _t m_bctrl imodifiers mod_control m_bshift imodifiers mod_shift m_balt imodifiers mod_alt m_bwin imodifiers mod_win cmainframe pmain cmainframe afxgetmainwnd registerhotkey pmain getsafehwnd theapp m_ihotkeyid imodifiers m_icharacter cbutton getdlgitem idc_statustext setwindowtext ctranslate readstring _t cbutton getdlgitem idc_statustext setwindowtext ctranslate readstring _t csa prefs sub dlg c dlg options server idd p parent afx data init c dlg options server m szaddress t m szpath t m szport t m busedefaultserver true afx data init csaprefssubdlg cdlgoptionsserver pparent afx_data_init cdlgoptionsserver m_szaddress _t m_szpath _t m_szport _t m_busedefaultserver afx_data_init void c dlg options server do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options server ddx text pdx idc address m szaddress ddx text pdx idc path m szpath ddx text pdx idc port m szport ddx check pdx idc usedefaultserver m busedefaultserver afx data map cdlgoptionsserver dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionsserver ddx_text idc_address m_szaddress ddx_text idc_path m_szpath ddx_text idc_port m_szport ddx_check idc_usedefaultserver m_busedefaultserver afx_data_map void c dlg options server on usedefaultserver either set or make sure that the user can set his hers own server address update data true if m busedefaultserver c button get dlg item idc address enable window false c button get dlg item idc path enable window false c button get dlg item idc port enable window false c button get dlg item idc address set window text t http a note sourceforge net c button get dlg item idc path set window text t c button get dlg item idc port set window text t 80 else c button get dlg item idc address enable window true c button get dlg item idc path enable window true c button get dlg item idc port enable window true cdlgoptionsserver onusedefaultserver updatedata m_busedefaultserver cbutton getdlgitem idc_address enablewindow cbutton getdlgitem idc_path enablewindow cbutton getdlgitem idc_port enablewindow cbutton getdlgitem idc_address setwindowtext _t cbutton getdlgitem idc_path setwindowtext _t cbutton getdlgitem idc_port setwindowtext _t cbutton getdlgitem idc_address enablewindow cbutton getdlgitem idc_path enablewindow cbutton getdlgitem idc_port enablewindow bool c dlg options server on init dialog csa prefs sub dlg on init dialog language stuff c string sz temp sz temp format t s c translate read string 127 t server s address c static get dlg item idc static1 set window text sz temp c static get dlg item idc static2 set window text c translate read string 128 t address http myserver com c static get dlg item idc static3 set window text c translate read string 129 t port http myserver com 8080 c static get dlg item idc static4 set window text c translate read string 130 t path http myserver com mypath must end with c button get dlg item idc usedefaultserver set window text c translate read string 131 t use default server on usedefaultserver return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionsserver oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring _t cstatic getdlgitem idc_static3 setwindowtext ctranslate readstring _t cstatic getdlgitem idc_static4 setwindowtext ctranslate readstring _t cbutton getdlgitem idc_usedefaultserver setwindowtext ctranslate readstring _t onusedefaultserver c dialog c dlg recycle bin idd p parent afx data init c dlg recycle bin note the class wizard will add member initialization here afx data init cdialog cdlgrecyclebin pparent afx_data_init cdlgrecyclebin classwizard afx_data_init void c dlg recycle bin do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c dlg recycle bin ddx control pdx idc titles m ptitle afx data map cdlgrecyclebin dodataexchange cdataexchange cdialog dodataexchange afx_data_map cdlgrecyclebin ddx_control idc_titles m_ptitle afx_data_map void c dlg recycle bin create import xml c string sz file create the import file where the restored note will be in position pos c string szxml sz temp c rect rc1 rc2 if the app m bsortrecyclebindescending pos m pnote get tail position else pos m pnote get head position position delpos int rg index buffersize m ptitle get sel items buffersize rg index int i row 0 int i count 0 c xml xml xml start create recycle bin xml while pos delpos pos tag note note if the app m bsortrecyclebindescending note m pnote get prev pos else note m pnote get next pos if i row rg index i count xml create recycle bin xml note erase this note from the list m pnote remove at delpos i row xml end create recycle bin xml szxml xml get create recycle bin xml save the note now c stdio file fp if fp open sz file c file mode create c file mode write c file mode no truncate c error log c error log info t could not open the import notes xml return try if defined unicode defined unicode int i length i multibyte c string sz result i length szxml get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 i multibyte wide char to multi byte cp utf8 0 szxml i length pc dest 2 i length null null fp write pc dest i length delete pwc unicode delete pc dest else fp write szxml szxml get length endif fp close catch c file exception e c error log c error log err t could not write file import notes xml return end catch cdlgrecyclebin createimportxml cstring szfile cstring sztemp crect theapp m_bsortrecyclebindescending m_pnote gettailposition m_pnote getheadposition rgindex m_ptitle getselitems rgindex irow icount cxml startcreaterecyclebinxml tagnote theapp m_bsortrecyclebindescending m_pnote getprev m_pnote getnext irow rgindex icount createrecyclebinxml m_pnote removeat irow endcreaterecyclebinxml getcreaterecyclebinxml cstdiofile szfile cfile modecreate cfile modewrite cfile modenotruncate cerrorlog cerrorlog _t _unicode ilength imultibyte cstring szresult ilength getlength pwcunicode ilength pcdest ilength imultibyte widechartomultibyte cp_utf8 ilength pcdest ilength pcdest ilength pwcunicode pcdest getlength cfileexception cerrorlog cerrorlog _t end_catch void c dlg recycle bin import notes c string sz file c main frame p main c main frame afx get main wnd to prevent the cursor to jump around on the screen because the notes are minimized we fake that the cursor shouldn t move when the notes are minimized the app m bminimizemovecursor false p main load sz file we alow the cursor to move when the notes are minimized see a bit up in the code here the app m bminimizemovecursor afx get app get profile int t settings options t when minimized move cursor 1 cdlgrecyclebin importnotes cstring szfile cmainframe pmain cmainframe afxgetmainwnd theapp m_bminimizemovecursor pmain szfile theapp m_bminimizemovecursor afxgetapp getprofileint _t _t void c dlg recycle bin delete marked notes position pos if the app m bsortrecyclebindescending pos m pnote get tail position else pos m pnote get head position position delpos int rg index buffersize m ptitle get sel items buffersize rg index int i row 0 int i count 0 while pos delpos pos tag note note if the app m bsortrecyclebindescending note m pnote get prev pos else note m pnote get next pos if i row rg index i count m pnote remove at delpos i count i row cdlgrecyclebin deletemarkednotes theapp m_bsortrecyclebindescending m_pnote gettailposition m_pnote getheadposition rgindex m_ptitle getselitems rgindex irow icount tagnote theapp m_bsortrecyclebindescending m_pnote getprev m_pnote getnext irow rgindex icount m_pnote removeat icount irow void c dlg recycle bin create delete notes xml c string sz file szxml sz temp sz xml start c xml xml c stdio file fp c rect rc1 rc2 position pos pos m pnote get head position create the xml header xml start create recycle bin xml loop through the notes and create the xml while pos tag note note m pnote get next pos xml create recycle bin xml note add the end tag and receive the created xml xml end create recycle bin xml szxml xml get create recycle bin xml save the note now sz file format t s deleted notes xml get application data path delete file sz file if fp open sz file c file mode create c file mode write c file mode no truncate c error log c error log info t could not open the deleted notes xml return try if defined unicode defined unicode int i length i multibyte c string sz result i length szxml get length wchar pwc unicode new wchar sizeof wchar i length 1 char pc dest new char 2 i length 1 to utf 8 i multibyte wide char to multi byte cp utf8 0 szxml i length pc dest 2 i length null null fp write pc dest i length delete pwc unicode delete pc dest else fp write szxml szxml get length endif fp close catch c file exception e c error log c error log err t could not write file deleted notes xml return end catch cdlgrecyclebin createdeletenotesxml cstring szfile sztemp szxmlstart cxml cstdiofile crect m_pnote getheadposition startcreaterecyclebinxml tagnote m_pnote getnext createrecyclebinxml endcreaterecyclebinxml getcreaterecyclebinxml szfile _t getapplicationdatapath deletefile szfile szfile cfile modecreate cfile modewrite cfile modenotruncate cerrorlog cerrorlog _t _unicode ilength imultibyte cstring szresult ilength getlength pwcunicode ilength pcdest ilength imultibyte widechartomultibyte cp_utf8 ilength pcdest ilength pcdest ilength pwcunicode pcdest getlength cfileexception cerrorlog cerrorlog _t end_catch void c dlg recycle bin fill the list erase any title m ptitle reset content m pnote remove all open the deleted notes xml and fill the list with the note s title initialize the xml parser co initialize null hresult hr m pldomdocument create instance clsid domdocument if failed hr c error log c error log err t could not initialize the xml parser return parse the xml and fill the linked list if parsexml return walk through the linked list and fill in the titles in the list box the latest first position pos if the app m bsortrecyclebindescending pos m pnote get tail position else pos m pnote get head position while pos tag note note if the app m bsortrecyclebindescending note m pnote get prev pos else note m pnote get next pos m ptitle add string note sz title cdlgrecyclebin fillthelist m_ptitle resetcontent m_pnote removeall coinitialize m_pldomdocument createinstance clsid_domdocument cerrorlog cerrorlog _t theapp m_bsortrecyclebindescending m_pnote gettailposition m_pnote getheadposition tagnote theapp m_bsortrecyclebindescending m_pnote getprev m_pnote getnext m_ptitle addstring sztitle bool c dlg recycle bin parsexml parse the xml that was received from the server save the xml c string szxml file szxml file format t s deleted notes xml get application data path convert xml file name string to something com can handle bstr bstr t bstr file name bstr file name szxml file alloc sys string call the ixmldom document ptr s load function to load the xml document variant t v result v result m pldomdocument load bstr file name if bool v result true now that the document is loaded we need to initialize the root pointer m pdocroot m pldomdocument document element else c error log c error log err t could not parse the deleted notes xml file in recycle bin return false getxml children m pdocroot return true cdlgrecyclebin cstring szxmlfile szxmlfile _t getapplicationdatapath _bstr_t bstrfilename bstrfilename szxmlfile allocsysstring ixmldomdocumentptr variant_t vresult vresult m_pldomdocument bstrfilename vresult m_pdocroot m_pldomdocument documentelement cerrorlog cerrorlog _t getxmlchildren m_pdocroot void c dlg recycle bin on delete delete the selected notes they will be deleted permanently loop through the linked list and erase the marked notes create then a new delete notes xml fill the title list with the current ones we have to have atleast one title marked if m ptitle get count 0 return do the user wants to delete this notes c string sz temp sz temp format t s n n s c translate read string 151 t do you want to delete the note c translate read string 152 t the note will be deleted permanently if message box sz temp t a note mb iconexclamation mb yesno idno return loop through the linked list and erase the marked note delete marked notes create then a new delete notes xml create delete notes xml fill the title list with the current ones fill the list cdlgrecyclebin ondelete m_ptitle getcount cstring sztemp sztemp _t ctranslate readstring _t ctranslate readstring _t messagebox sztemp _t mb_iconexclamation mb_yesno deletemarkednotes createdeletenotesxml fillthelist void c dlg recycle bin on restore restore the selected notes we have to have atleast one title marked if m ptitle get count 0 return create a temporarilly xml file and import the note c string sz import sz import format t s import xml get application data path create import xml sz import import the notes import notes sz import erase then the xml file delete file sz import erase the restored notes from the list create delete notes xml fill the list cdlgrecyclebin onrestore m_ptitle getcount cstring szimport szimport _t getapplicationdatapath createimportxml szimport importnotes szimport deletefile szimport createdeletenotesxml fillthelist bool c dlg recycle bin on init dialog c dialog on init dialog language stuff c static get dlg item idc static1 set window text c translate read string 146 t title c button get dlg item idc delete set window text c translate read string 147 t delete c button get dlg item idc restore set window text c translate read string 148 t restore c button get dlg item idok set window text c translate read string 149 t close set window text c translate read string 150 t recycle bin see if it s the first time the user uses the recycle bin show the help dialog if afx get app get profile int t settings options t show using recycle bin help 1 1 c dlg recycle bin help dlg dlg do modal afx get app write profile int t settings options t show using recycle bin help dlg m bshownexttime fill the list fill the list return true return true unless you set the focus to a control exception ocx property pages should return false cdlgrecyclebin oninitdialog cdialog oninitdialog cstatic getdlgitem idc_static1 setwindowtext ctranslate readstring _t cbutton getdlgitem idc_delete setwindowtext ctranslate readstring _t cbutton getdlgitem idc_restore setwindowtext ctranslate readstring _t cbutton getdlgitem setwindowtext ctranslate readstring _t setwindowtext ctranslate readstring _t afxgetapp getprofileint _t _t cdlgrecyclebinhelp domodal afxgetapp writeprofileint _t _t m_bshownexttime fillthelist void c dlg recycle bin on dblclk titles to prevent the cursor to jump around on the screen because the notes are minimized we fake that the cursor shouldn t move when the notes are minimized the app m bminimizemovecursor false find the only one that the user double clicked on create that note int i index find the note s title i index m ptitle get caret index walk through the linked list and create the note when found position pos if the app m bsortrecyclebindescending pos m pnote get tail position else pos m pnote get head position while pos tag note note if the app m bsortrecyclebindescending note m pnote get prev pos else note m pnote get next pos are we there yet create the note if i index 0 c note p note new c note p note create idd note this p note set noteid note sz noteid p note set note version note i note version p note set docked left note b docked left false p note set docked top note b docked top false p note set docked right note b docked right false p note set docked bottom note b docked bottom false p note set use alarm note b use alarm p note set title note sz title p note set text note sz text p note set visible note b visible p note set note color note cf note color p note set position note c rect false c ole date time p time p time parse date time note sz alarm time locale nouseroverride p note set alarm p time p note belongs to recycle bin p note set slide left note b slided left false p note set slide right note b slided right false p note set slide position note c rect position false p note initialize i index to prevent the cursor to jump around on the screen because the notes are minimized we fake that the cursor shouldn t move when the notes are minimized the app m bminimizemovecursor true cdlgrecyclebin ondblclktitles theapp m_bminimizemovecursor iindex iindex m_ptitle getcaretindex theapp m_bsortrecyclebindescending m_pnote gettailposition m_pnote getheadposition tagnote theapp m_bsortrecyclebindescending m_pnote getprev m_pnote getnext iindex cnote pnote cnote pnote idd_note pnote setnoteid sznoteid pnote setnoteversion inoteversion pnote setdockedleft bdockedleft pnote setdockedtop bdockedtop pnote setdockedright bdockedright pnote setdockedbottom bdockedbottom pnote setusealarm busealarm pnote settitle sztitle pnote settext sztext pnote setvisible bvisible pnote setnotecolor cfnotecolor pnote setposition crect coledatetime ptime ptime parsedatetime szalarmtime locale_nouseroverride pnote setalarm ptime pnote belongstorecyclebin pnote setslideleft bslidedleft pnote setslideright bslidedright pnote setslideposition crectposition pnote iindex theapp m_bminimizemovecursor csa prefs sub dlg c dlg options recycle bin idd p parent afx data init c dlg options recycle bin m sznumberofnotes t m bsortdescending false afx data init csaprefssubdlg cdlgoptionsrecyclebin pparent afx_data_init cdlgoptionsrecyclebin m_sznumberofnotes _t m_bsortdescending afx_data_init void c dlg options recycle bin do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options recycle bin ddx text pdx idc numberofdeletednotes m sznumberofnotes ddx check pdx idc sortdescending m bsortdescending afx data map cdlgoptionsrecyclebin dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionsrecyclebin ddx_text idc_numberofdeletednotes m_sznumberofnotes ddx_check idc_sortdescending m_bsortdescending afx_data_map bool c dlg options recycle bin on init dialog csa prefs sub dlg on init dialog language stuff c string sz temp sz temp format t s c translate read string 124 t recycle bin c static get dlg item idc static1 set window text sz temp c static get dlg item idc static2 set window text c translate read string 125 t maximum deleted notes that will be saved 0 for infinitive c button get dlg item idc sortdescending set window text c translate read string 126 t sort the notes descending return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionsrecyclebin oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring _t cbutton getdlgitem idc_sortdescending setwindowtext ctranslate readstring _t csa prefs sub dlg c dlg options toolbar idd p parent afx data init c dlg options toolbar note the class wizard will add member initialization here afx data init csaprefssubdlg cdlgoptionstoolbar pparent afx_data_init cdlgoptionstoolbar classwizard afx_data_init void c dlg options toolbar do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options toolbar ddx control pdx idc inuse m pinuse ddx control pdx idc available m pavailable afx data map cdlgoptionstoolbar dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionstoolbar ddx_control idc_inuse m_pinuse ddx_control idc_available m_pavailable afx_data_map void c dlg options toolbar fill list boxes fill the list boxes m pavailable delete all items m pinuse delete all items int ia ii ia ii 0 m ibuttonwidth 20 we always have the close button for int i 1 i 10 i in use if m iinusebold i m pinuse insert item i t c translate read string 135 t bold 0 m ibuttonwidth 20 if m iinuseunderline i m pinuse insert item i t c translate read string 136 t underline 1 m ibuttonwidth 20 if m iinuseitalic i m pinuse insert item i t c translate read string 137 t italic 2 m ibuttonwidth 20 if m iinusebullet i m pinuse insert item i t c translate read string 138 t bullet 3 m ibuttonwidth 20 if m iinuseminimize i m pinuse insert item i t c translate read string 139 t minimize 4 m ibuttonwidth 20 if m iinuseslideleft i m pinuse insert item i t c translate read string 140 t slide left 5 m ibuttonwidth 20 if m iinuseslideright i m pinuse insert item i t c translate read string 141 t slide right 6 m ibuttonwidth 20 if m iinusestrikeout i m pinuse insert item i t c translate read string 142 t strikeout 7 m ibuttonwidth 20 available if m iinusebold 0 m pavailable insert item 0 t c translate read string 135 t bold 0 if m iinuseunderline 0 m pavailable insert item 0 t c translate read string 136 t underline 1 if m iinuseitalic 0 m pavailable insert item 0 t c translate read string 137 t italic 2 if m iinusebullet 0 m pavailable insert item 0 t c translate read string 138 t bullet 3 if m iinuseminimize 0 m pavailable insert item 0 t c translate read string 139 t minimize 4 if m iinuseslideleft 0 m pavailable insert item 0 t c translate read string 140 t slide left 5 if m iinuseslideright 0 m pavailable insert item 0 t c translate read string 141 t slide right 6 if m iinusestrikeout 0 m pavailable insert item 0 t c translate read string 142 t strikeout 7 cdlgoptionstoolbar filllistboxes m_pavailable deleteallitems m_pinuse deleteallitems m_ibuttonwidth m_iinusebold m_pinuse insertitem _t ctranslate readstring _t m_ibuttonwidth m_iinuseunderline m_pinuse insertitem _t ctranslate readstring _t m_ibuttonwidth m_iinuseitalic m_pinuse insertitem _t ctranslate readstring _t m_ibuttonwidth m_iinusebullet m_pinuse insertitem _t ctranslate readstring _t m_ibuttonwidth m_iinuseminimize m_pinuse insertitem _t ctranslate readstring _t m_ibuttonwidth m_iinuseslideleft m_pinuse insertitem _t ctranslate readstring _t m_ibuttonwidth m_iinuseslideright m_pinuse insertitem _t ctranslate readstring _t m_ibuttonwidth m_iinusestrikeout m_pinuse insertitem _t ctranslate readstring _t m_ibuttonwidth m_iinusebold m_pavailable insertitem _t ctranslate readstring _t m_iinuseunderline m_pavailable insertitem _t ctranslate readstring _t m_iinuseitalic m_pavailable insertitem _t ctranslate readstring _t m_iinusebullet m_pavailable insertitem _t ctranslate readstring _t m_iinuseminimize m_pavailable insertitem _t ctranslate readstring _t m_iinuseslideleft m_pavailable insertitem _t ctranslate readstring _t m_iinuseslideright m_pavailable insertitem _t ctranslate readstring _t m_iinusestrikeout m_pavailable insertitem _t ctranslate readstring _t bool c dlg options toolbar on init dialog csa prefs sub dlg on init dialog language stuff c string sz temp sz temp format t s c translate read string 132 t toolbar c static get dlg item idc static1 set window text sz temp c static get dlg item idc static2 set window text c translate read string 133 t available c static get dlg item idc static3 set window text c translate read string 134 t in use c button get dlg item idc up set window text c translate read string 193 t up c button get dlg item idc down set window text c translate read string 194 t down initialize listboxes m imgicon create idb toolbar 16 1 colorref 1 m pavailable set image list m imgicon lvsil small m pinuse set image list m imgicon lvsil small fill the two listboxes fill list boxes return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionstoolbar oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring _t cstatic getdlgitem idc_static3 setwindowtext ctranslate readstring _t cbutton getdlgitem idc_up setwindowtext ctranslate readstring _t cbutton getdlgitem idc_down setwindowtext ctranslate readstring _t m_imgicon idb_toolbar m_pavailable setimagelist m_imgicon lvsil_small m_pinuse setimagelist m_imgicon lvsil_small filllistboxes void c dlg options toolbar on add find out which one that we want to add c string sz item get the text of the button sz item m pavailable get item text m pavailable get selection mark 0 if sz item t c translate read string 135 t bold m iinusebold m pinuse get item count 1 if sz item t c translate read string 136 t underline m iinuseunderline m pinuse get item count 1 if sz item t c translate read string 137 t italic m iinuseitalic m pinuse get item count 1 if sz item t c translate read string 138 t bullet m iinusebullet m pinuse get item count 1 if sz item t c translate read string 139 t minimera m iinuseminimize m pinuse get item count 1 if sz item t c translate read string 140 t slide left m iinuseslideleft m pinuse get item count 1 if sz item t c translate read string 141 t slide right m iinuseslideright m pinuse get item count 1 if sz item t c translate read string 142 t strikeout m iinusestrikeout m pinuse get item count 1 fill list boxes cdlgoptionstoolbar onadd cstring szitem szitem m_pavailable getitemtext m_pavailable getselectionmark szitem _t ctranslate readstring _t m_iinusebold m_pinuse getitemcount szitem _t ctranslate readstring _t m_iinuseunderline m_pinuse getitemcount szitem _t ctranslate readstring _t m_iinuseitalic m_pinuse getitemcount szitem _t ctranslate readstring _t m_iinusebullet m_pinuse getitemcount szitem _t ctranslate readstring _t m_iinuseminimize m_pinuse getitemcount szitem _t ctranslate readstring _t m_iinuseslideleft m_pinuse getitemcount szitem _t ctranslate readstring _t m_iinuseslideright m_pinuse getitemcount szitem _t ctranslate readstring _t m_iinusestrikeout m_pinuse getitemcount filllistboxes void c dlg options toolbar on remove find out which one that we want to remove c string sz item get the text of the button sz item m pinuse get item text m pinuse get selection mark 0 if sz item t c translate read string 135 t bold m iinusebold 0 if sz item t c translate read string 136 t underline m iinuseunderline 0 if sz item t c translate read string 137 t italic m iinuseitalic 0 if sz item t c translate read string 138 t bullet m iinusebullet 0 if sz item t c translate read string 139 t minimera m iinuseminimize 0 if sz item t c translate read string 140 t slide left m iinuseslideleft 0 if sz item t c translate read string 141 t slide right m iinuseslideright 0 if sz item t c translate read string 142 t strikeout m iinusestrikeout 0 fix the buttons int i sel m pinuse get selection mark i sel if m iinusebold i sel m iinusebold if m iinuseunderline i sel m iinuseunderline if m iinuseitalic i sel m iinuseitalic if m iinusebullet i sel m iinusebullet if m iinuseminimize i sel m iinuseminimize if m iinuseslideleft i sel m iinuseslideleft if m iinuseslideright i sel m iinuseslideright if m iinusestrikeout i sel m iinusestrikeout fill list boxes cdlgoptionstoolbar onremove cstring szitem szitem m_pinuse getitemtext m_pinuse getselectionmark szitem _t ctranslate readstring _t m_iinusebold szitem _t ctranslate readstring _t m_iinuseunderline szitem _t ctranslate readstring _t m_iinuseitalic szitem _t ctranslate readstring _t m_iinusebullet szitem _t ctranslate readstring _t m_iinuseminimize szitem _t ctranslate readstring _t m_iinuseslideleft szitem _t ctranslate readstring _t m_iinuseslideright szitem _t ctranslate readstring _t m_iinusestrikeout isel m_pinuse getselectionmark isel m_iinusebold isel m_iinusebold m_iinuseunderline isel m_iinuseunderline m_iinuseitalic isel m_iinuseitalic m_iinusebullet isel m_iinusebullet m_iinuseminimize isel m_iinuseminimize m_iinuseslideleft isel m_iinuseslideleft m_iinuseslideright isel m_iinuseslideright m_iinusestrikeout isel m_iinusestrikeout filllistboxes void c dlg options toolbar on up move the marked toolbarbutton up one step int i sel get the text of the button i sel m pinuse get selection mark i sel we can t move the item at the top or we have to have one selected if i sel 1 i sel 0 return is this the item that we clicked on move it up or if it is the item that should move down do so if m iinusebold i sel m iinusebold else if m iinusebold 1 i sel m iinusebold if m iinuseunderline i sel m iinuseunderline else if m iinuseunderline 1 i sel m iinuseunderline if m iinuseitalic i sel m iinuseitalic else if m iinuseitalic 1 i sel m iinuseitalic if m iinusebullet i sel m iinusebullet else if m iinusebullet 1 i sel m iinusebullet if m iinuseminimize i sel m iinuseminimize else if m iinuseminimize 1 i sel m iinuseminimize if m iinuseslideleft i sel m iinuseslideleft else if m iinuseslideleft 1 i sel m iinuseslideleft if m iinuseslideright i sel m iinuseslideright else if m iinuseslideright 1 i sel m iinuseslideright if m iinusestrikeout i sel m iinusestrikeout else if m iinusestrikeout 1 i sel m iinusestrikeout fill list boxes cdlgoptionstoolbar onup isel isel m_pinuse getselectionmark isel isel isel m_iinusebold isel m_iinusebold m_iinusebold isel m_iinusebold m_iinuseunderline isel m_iinuseunderline m_iinuseunderline isel m_iinuseunderline m_iinuseitalic isel m_iinuseitalic m_iinuseitalic isel m_iinuseitalic m_iinusebullet isel m_iinusebullet m_iinusebullet isel m_iinusebullet m_iinuseminimize isel m_iinuseminimize m_iinuseminimize isel m_iinuseminimize m_iinuseslideleft isel m_iinuseslideleft m_iinuseslideleft isel m_iinuseslideleft m_iinuseslideright isel m_iinuseslideright m_iinuseslideright isel m_iinuseslideright m_iinusestrikeout isel m_iinusestrikeout m_iinusestrikeout isel m_iinusestrikeout filllistboxes void c dlg options toolbar on down move the marked toolbarbutton down one step int i sel get the text of the button i sel m pinuse get selection mark i sel we can t move the item at the top or we have to have one selected if i sel m pinuse get item count i sel 0 return is this the item that we clicked on move it up or if it is the item that should move down do so if m iinusebold i sel m iinusebold else if m iinusebold 1 i sel m iinusebold if m iinuseunderline i sel m iinuseunderline else if m iinuseunderline 1 i sel m iinuseunderline if m iinuseitalic i sel m iinuseitalic else if m iinuseitalic 1 i sel m iinuseitalic if m iinusebullet i sel m iinusebullet else if m iinusebullet 1 i sel m iinusebullet if m iinuseminimize i sel m iinuseminimize else if m iinuseminimize 1 i sel m iinuseminimize if m iinuseslideleft i sel m iinuseslideleft else if m iinuseslideleft 1 i sel m iinuseslideleft if m iinuseslideright i sel m iinuseslideright else if m iinuseslideright 1 i sel m iinuseslideright if m iinusestrikeout i sel m iinusestrikeout else if m iinusestrikeout 1 i sel m iinusestrikeout fill list boxes cdlgoptionstoolbar ondown isel isel m_pinuse getselectionmark isel isel m_pinuse getitemcount isel m_iinusebold isel m_iinusebold m_iinusebold isel m_iinusebold m_iinuseunderline isel m_iinuseunderline m_iinuseunderline isel m_iinuseunderline m_iinuseitalic isel m_iinuseitalic m_iinuseitalic isel m_iinuseitalic m_iinusebullet isel m_iinusebullet m_iinusebullet isel m_iinusebullet m_iinuseminimize isel m_iinuseminimize m_iinuseminimize isel m_iinuseminimize m_iinuseslideleft isel m_iinuseslideleft m_iinuseslideleft isel m_iinuseslideleft m_iinuseslideright isel m_iinuseslideright m_iinuseslideright isel m_iinuseslideright m_iinusestrikeout isel m_iinusestrikeout m_iinusestrikeout isel m_iinusestrikeout filllistboxes void c dlg options toolbar on dblclk available nmhdr pnmhdr lresult p result on add p result 0 cdlgoptionstoolbar ondblclkavailable presult onadd presult void c dlg options toolbar on dblclk inuse nmhdr pnmhdr lresult p result on remove p result 0 cdlgoptionstoolbar ondblclkinuse presult onremove presult csa prefs sub dlg c dlg options behaviour idd p parent afx data init c dlg options behaviour m bhideonminimize false m bdockable false m bdoubleclickontitlebar false m bminimizemovecursor false m iclickonce 1 afx data init csaprefssubdlg cdlgoptionsbehaviour pparent afx_data_init cdlgoptionsbehaviour m_bhideonminimize m_bdockable m_bdoubleclickontitlebar m_bminimizemovecursor m_iclickonce afx_data_init void c dlg options behaviour do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options behaviour ddx check pdx idc hideonminimize m bhideonminimize ddx check pdx idc dockable m bdockable ddx check pdx idc doubleclicktitlebar m bdoubleclickontitlebar ddx check pdx idc minimizemovecursor m bminimizemovecursor ddx radio pdx idc clickonce m iclickonce afx data map cdlgoptionsbehaviour dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionsbehaviour ddx_check idc_hideonminimize m_bhideonminimize ddx_check idc_dockable m_bdockable ddx_check idc_doubleclicktitlebar m_bdoubleclickontitlebar ddx_check idc_minimizemovecursor m_bminimizemovecursor ddx_radio idc_clickonce m_iclickonce afx_data_map bool c dlg options behaviour on init dialog csa prefs sub dlg on init dialog language stuff c string sz temp sz temp format t s c translate read string 73 t behaviour c static get dlg item idc static4 set window text sz temp c static get dlg item idc static3 set window text c translate read string 74 what happens when you click once on the tray icon c button get dlg item idc clickonce set window text c translate read string 75 create a new note c button get dlg item idc radio2 set window text c translate read string 76 hide and show the notes c button get dlg item idc doubleclicktitlebar set window text c translate read string 77 doubleclick on titlebar restore minimize the note c button get dlg item idc minimizemovecursor set window text c translate read string 78 when minimized move the cursor to minimize button c button get dlg item idc dockable set window text c translate read string 79 dockable c button get dlg item idc hideonminimize set window text c translate read string 80 when minimized show only the titlebar return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionsbehaviour oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static4 setwindowtext sztemp cstatic getdlgitem idc_static3 setwindowtext ctranslate readstring cbutton getdlgitem idc_clickonce setwindowtext ctranslate readstring cbutton getdlgitem idc_radio2 setwindowtext ctranslate readstring cbutton getdlgitem idc_doubleclicktitlebar setwindowtext ctranslate readstring cbutton getdlgitem idc_minimizemovecursor setwindowtext ctranslate readstring cbutton getdlgitem idc_dockable setwindowtext ctranslate readstring cbutton getdlgitem idc_hideonminimize setwindowtext ctranslate readstring csa prefs sub dlg c dlg options language idd p parent afx data init c dlg options language note the class wizard will add member initialization here afx data init csaprefssubdlg cdlgoptionslanguage pparent afx_data_init cdlgoptionslanguage classwizard afx_data_init void c dlg options language do data exchange c data exchange pdx csa prefs sub dlg do data exchange pdx afx data map c dlg options language ddx control pdx idc language m planguage afx data map cdlgoptionslanguage dodataexchange cdataexchange csaprefssubdlg dodataexchange afx_data_map cdlgoptionslanguage ddx_control idc_language m_planguage afx_data_map bool c dlg options language on init dialog csa prefs sub dlg on init dialog language stuff c string sz temp sz temp format t s c translate read string 50 t language c static get dlg item idc static1 set window text sz temp c static get dlg item idc static2 set window text c translate read string 51 t select language c button get dlg item idc editlanguage set window text c translate read string 52 t edit language c button get dlg item idc addlanguage set window text c translate read string 53 t add language fill the combobox with languages handle h search win32 find data file data bool b done c string sz path sz path get program path h search find first file sz path t language ini file data if h search invalid handle value b done true else b done false while b done false m planguage add string file data c file name if find next file h search file data b done true find close h search m planguage set item height 0 17 select the language we are using by default english ini m planguage select string 0 m szlanguageini change the font logfont lf memset lf 0 sizeof logfont lf lf height 15 lf lf weight fw extralight tcscpy lf lf face name t microsoft sans serif m font create font indirect lf m planguage set font m font return true return true unless you set the focus to a control exception ocx property pages should return false cdlgoptionslanguage oninitdialog csaprefssubdlg oninitdialog cstring sztemp sztemp _t ctranslate readstring _t cstatic getdlgitem idc_static1 setwindowtext sztemp cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring _t cbutton getdlgitem idc_editlanguage setwindowtext ctranslate readstring _t cbutton getdlgitem idc_addlanguage setwindowtext ctranslate readstring _t hsearch win32_find_data filedata bdone cstring szpath szpath getprogrampath hsearch findfirstfile szpath _t filedata hsearch invalid_handle_value bdone bdone bdone m_planguage addstring filedata cfilename findnextfile hsearch filedata bdone findclose hsearch m_planguage setitemheight m_planguage selectstring m_szlanguageini lfheight lfweight fw_extralight _tcscpy lffacename _t m_font createfontindirect m_planguage setfont m_font void c dlg options language on selchange language remember the ini file the user has selected int i index m planguage get cur sel m planguage getlb text i index m szlanguageini cdlgoptionslanguage onselchangelanguage iindex m_planguage getcursel m_planguage getlbtext iindex m_szlanguageini void c dlg options language on editlanguage c dlg language dlg dlg do modal cdlgoptionslanguage oneditlanguage cdlglanguage domodal void c dlg options language on addlanguage let the user enter the new language c dlg create new language d if d do modal idcancel return c dlg language dlg dlg m szlanguageini d m szinifile dlg do modal we have created a new ini file make sure that exist in the combobox m planguage add string d m szinifile t ini cdlgoptionslanguage onaddlanguage cdlgcreatenewlanguage domodal cdlglanguage m_szlanguageini m_szinifile domodal m_planguage addstring m_szinifile _t c dialog c dlg language idd p parent m irow 1 m bchanged false m szlanguageini the app m szlanguageini m basktosave false afx data init c dlg language m szotherlanguage t afx data init cdialog cdlglanguage pparent m_irow m_bchanged m_szlanguageini theapp m_szlanguageini m_basktosave afx_data_init cdlglanguage m_szotherlanguage _t afx_data_init void c dlg language do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c dlg language ddx control pdx idc language m planguage ddx control pdx idc english m penglish ddx text pdx idc otherlanguage m szotherlanguage afx data map cdlglanguage dodataexchange cdataexchange cdialog dodataexchange afx_data_map cdlglanguage ddx_control idc_language m_planguage ddx_control idc_english m_penglish ddx_text idc_otherlanguage m_szotherlanguage afx_data_map void c dlg language email ini files email alla ini files to a note s creator create the message c mapi message message setup the all the recipient types for this message message add multiple recipients t brummelisa users sourceforge net c mapi message to add the subject and body c string sz text message m sbody t i have changed in one of the ini files and wishes to send them to the author of a note message m ssubject t language file updated search after all ini files and add them handle h search win32 find data file data bool b done c string sz path sz path get program path h search find first file sz path t language ini file data if h search invalid handle value b done true else b done false while b done false message m attachments add sz path t language file data c file name if find next file h search file data b done true find close h search connect to server c mapi session connection bool b logon false b logon connection shared logon if b logon else send the message bool b success false if connection send message 1 1 this c string s msg s msg format t s n error d c translate read string 25 couldn t send message connection get last error afx message box s msg mb iconstop cdlglanguage emailinifiles cmapimessage addmultiplerecipients _t cmapimessage cstring sztext m_sbody _t m_ssubject _t hsearch win32_find_data filedata bdone cstring szpath szpath getprogrampath hsearch findfirstfile szpath _t filedata hsearch invalid_handle_value bdone bdone bdone m_attachments szpath _t filedata cfilename findnextfile hsearch filedata bdone findclose hsearch cmapisession blogon blogon sharedlogon blogon bsuccess cstring smsg smsg _t nerror ctranslate readstring getlasterror afxmessagebox smsg mb_iconstop bool c dlg language on init dialog c dialog on init dialog language stuff c static get dlg item idc static1 set window text c translate read string 184 english c button get dlg item idok set window text c translate read string 36 ok set window text c translate read string 185 edit language initialize the listbox long l style m penglish send message lvm getextendedlistviewstyle l style lvs ex fullrowselect m penglish send message lvm setextendedlistviewstyle 0 lparam l style m penglish insert column 0 t information lvcfmt left 800 0 fill the english list for int i 0 i text size i m penglish insert item i translate text i fill the combobox with languages handle h search win32 find data file data bool b done c string sz path sz path get program path h search find first file sz path language ini file data if h search invalid handle value b done true else b done false while b done false m planguage add string file data c file name if find next file h search file data b done true find close h search m planguage set item height 0 17 select the language we are using by default english ini if m szlanguageini english ini m planguage select string 0 file data c file name else m planguage select string 0 m szlanguageini change the font logfont lf memset lf 0 sizeof logfont lf lf height 15 lf lf weight fw extralight tcscpy strcpy lf lf face name t microsoft sans serif m font create font indirect lf m planguage set font m font return true return true unless you set the focus to a control exception ocx property pages should return false cdlglanguage oninitdialog cdialog oninitdialog cstatic getdlgitem idc_static1 setwindowtext ctranslate readstring cbutton getdlgitem setwindowtext ctranslate readstring setwindowtext ctranslate readstring lstyle m_penglish sendmessage lvm_getextendedlistviewstyle lstyle lvs_ex_fullrowselect m_penglish sendmessage lvm_setextendedlistviewstyle lstyle m_penglish insertcolumn _t lvcfmt_left textsize m_penglish insertitem translatetext hsearch win32_find_data filedata bdone cstring szpath szpath getprogrampath hsearch findfirstfile szpath filedata hsearch invalid_handle_value bdone bdone bdone m_planguage addstring filedata cfilename findnextfile hsearch filedata bdone findclose hsearch m_planguage setitemheight m_szlanguageini m_planguage selectstring filedata cfilename m_planguage selectstring m_szlanguageini lfheight lfweight fw_extralight _tcscpy lffacename _t m_font createfontindirect m_planguage setfont m_font void c dlg language on click english nmhdr pnmhdr lresult p result we have selected an english word show the translated word m irow m penglish get next item 1 lvni selected m szotherlanguage c translate read string m irow get program path language m szlanguageini update data false p result 0 cdlglanguage onclickenglish presult m_irow m_penglish getnextitem lvni_selected m_szotherlanguage ctranslate readstring m_irow getprogrampath m_szlanguageini updatedata presult void c dlg language on change otherlanguage we have updated the control if m irow 1 return m basktosave true m bchanged true cdlglanguage onchangeotherlanguage m_irow m_basktosave m_bchanged void c dlg language on killfocus otherlanguage check if we have updated the control and written in it save the new word if m bchanged update the row update data c translate save string m irow m szotherlanguage get program path language m szlanguageini m szinifile m bchanged false cdlglanguage onkillfocusotherlanguage m_bchanged updatedata ctranslate savestring m_irow m_szotherlanguage getprogrampath m_szlanguageini m_szinifile m_bchanged void c dlg language on selchange language remember the ini file the user has selected int i index m planguage get cur sel m planguage getlb text i index m szlanguageini cdlglanguage onselchangelanguage iindex m_planguage getcursel m_planguage getlbtext iindex m_szlanguageini void c dlg language onok on killfocus otherlanguage should we email the ini files if m basktosave c string sz temp sz temp format t s n s n n s c translate read string 188 t since you have changed one or more language ini files we at a note would appreciate it very much if you want to share the file with us c translate read string 189 t by doing so other of users may use your language file c translate read string 190 t do you want to send your language ini files to a note s author if message box sz temp t a note mb yesno idyes email ini files c dialog onok cdlglanguage onkillfocusotherlanguage m_basktosave cstring sztemp sztemp _t ctranslate readstring _t ctranslate readstring _t ctranslate readstring _t messagebox sztemp _t mb_yesno emailinifiles cdialog c hyper link c hyper link m hlinkcursor null no cursor as yet m crlinkcolour the app m cfhyperlinkcolor m crvisitedcolour the app m cfhypervisitedcolor m crhovercolour the app m cfhyperhovercolor 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 empty m ntimerid 100 chyperlink chyperlink m_hlinkcursor m_crlinkcolour theapp m_cfhyperlinkcolor m_crvisitedcolour theapp m_cfhypervisitedcolor m_crhovercolour theapp m_cfhyperhovercolor m_bovercontrol m_bvisited m_nunderline ulhover m_badjusttofit m_strurl m_ntimerid c hyper link c hyper link m underlinefont delete object chyperlink chyperlink m_underlinefont deleteobject void c 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 chyperlink cstring m_strurl iswindow getsafehwnd positionwindow m_tooltip updatetiptext tooltip_id c string c hyper link geturl const return m strurl cstring chyperlink 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 c hyper link get link colour const return m crlinkcolour chyperlink getlinkcolour m_crlinkcolour colorref c hyper link get visited colour const return m crvisitedcolour chyperlink getvisitedcolour m_crvisitedcolour colorref c hyper link get hover colour const return m crhovercolour chyperlink gethovercolour m_crhovercolour void c hyper link set visited bool b visited true m bvisited b visited if is window get safe hwnd invalidate chyperlink setvisited bvisited m_bvisited bvisited iswindow getsafehwnd bool c hyper link get visited const return m bvisited chyperlink getvisited m_bvisited void c hyper link set link cursor hcursor h cursor m hlinkcursor h cursor if m hlinkcursor null set default cursor chyperlink setlinkcursor hcursor m_hlinkcursor hcursor m_hlinkcursor setdefaultcursor hcursor c hyper link get link cursor const return m hlinkcursor chyperlink getlinkcursor m_hlinkcursor void c 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 chyperlink setunderline nunderline ulhover m_nunderline nunderline iswindow getsafehwnd nunderline ulalways setfont m_underlinefont setfont m_stdfont m_nunderline nunderline int c hyper link get underline const return m nunderline chyperlink getunderline m_nunderline void c hyper link set auto size bool b auto size true m badjusttofit b auto size if is window get safe hwnd position window chyperlink setautosize bautosize m_badjusttofit bautosize iswindow getsafehwnd positionwindow bool c hyper link get auto size const return m badjusttofit chyperlink getautosize m_badjusttofit bool c hyper link pre translate message msg p msg m tooltip relay event p msg return c static pre translate message p msg chyperlink pretranslatemessage pmsg m_tooltip relayevent pmsg cstatic pretranslatemessage pmsg bool c hyper link destroy window kill timer m ntimerid return c static destroy window chyperlink destroywindow killtimer m_ntimerid cstatic destroywindow void c 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 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 chyperlink 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 crect getclientrect m_tooltip m_tooltip addtool m_strurl tooltip_id cstatic presubclasswindow hinstance c hyper link gotourl lpctstr url int showcmd tchar key max path max path first try shell execute hinstance result shell execute null t open 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 lstrcat 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 lstrlen key 1 else pos 0 remove the parameter else pos 0 remove the parameter lstrcat pos t lstrcat pos url uses conversion result hinstance win exec t2a key showcmd return result chyperlink max_path max_path shellexecute shellexecute _t hinstance_error getregkey hkey_classes_root _t error_success _t getregkey hkey_classes_root error_success _tcsstr _t _tcsstr _t _t uses_conversion winexec void c hyper link report error int n 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 chyperlink reporterror nerror 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 long c 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 lstrcpy retdata data reg close key hkey return retval chyperlink getregkey regopenkeyex key_query_value error_success max_path max_path regqueryvalue regclosekey void c 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 chyperlink 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 c hyper link set default cursor if m hlinkcursor null no cursor handle load our own 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 chyperlink setdefaultcursor m_hlinkcursor 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 hbrush c hyper link ctl color cdc pdc uint n ctl color 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 return hbrush get stock object null brush chyperlink ctlcolor nctlcolor nctlcolor ctlcolor_static m_bovercontrol settextcolor m_crhovercolour m_bvisited settextcolor m_crvisitedcolour settextcolor m_crlinkcolour setbkmode getstockobject null_brush bool c 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 chyperlink onsetcursor cwnd pwnd nhittest m_hlinkcursor setcursor m_hlinkcursor void c 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 chyperlink onmousemove nflags cpoint m_bovercontrol m_bovercontrol m_nunderline ulhover setfont m_underlinefont settimer m_ntimerid cstatic onmousemove nflags void c 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 chyperlink ontimer nidevent cpoint getmessagepos screentoclient crect getclientrect ptinrect m_bovercontrol killtimer m_ntimerid m_nunderline ulalways setfont m_stdfont invalidaterect cstatic ontimer nidevent bool c hyper link on erase bkgnd cdc pdc c rect rect get client rect rect pdc fill solid rect rect get sys color color 3dface return true chyperlink onerasebkgnd crect getclientrect fillsolidrect getsyscolor color_3dface void c hyper link on clicked m bovercontrol false int result int gotourl m strurl sw show 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 chyperlink onclicked m_bovercontrol m_strurl sw_show m_bvisited hinstance_error m_bvisited messagebeep mb_iconexclamation reporterror setvisited c dialog c dlg recycle bin help idd p parent afx data init c dlg recycle bin help m bshownexttime false afx data init cdialog cdlgrecyclebinhelp pparent afx_data_init cdlgrecyclebinhelp m_bshownexttime afx_data_init void c dlg recycle bin help do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c dlg recycle bin help ddx check pdx idc check1 m bshownexttime afx data map cdlgrecyclebinhelp dodataexchange cdataexchange cdialog dodataexchange afx_data_map cdlgrecyclebinhelp ddx_check idc_check1 m_bshownexttime afx_data_map bool c dlg recycle bin help on init dialog c dialog on init dialog language stuff c static get dlg item idc static1 set window text c translate read string 153 the notes title will appear in a box if you want to look at that note you simply doubleclick on it and the note will be created as it were when you deleted it c static get dlg item idc static2 set window text c translate read string 154 if you want to restore a note you simply select one or multiple with shift and ctrl and then restore it with the restore button the same goes for delete c static get dlg item idc static3 set window text c translate read string 155 note if you delete one or several notes they will be deleted permanently c button get dlg item idc check1 set window text c translate read string 156 show time message next time c button get dlg item idok set window text c translate read string 36 ok set window text c translate read string 157 recycle bin help return true return true unless you set the focus to a control exception ocx property pages should return false cdlgrecyclebinhelp oninitdialog cdialog oninitdialog cstatic getdlgitem idc_static1 setwindowtext ctranslate readstring cstatic getdlgitem idc_static2 setwindowtext ctranslate readstring cstatic getdlgitem idc_static3 setwindowtext ctranslate readstring cbutton getdlgitem idc_check1 setwindowtext ctranslate readstring cbutton getdlgitem setwindowtext ctranslate readstring setwindowtext ctranslate readstring c dialog c dlg create new language idd p parent afx data init c dlg create new language m szinifile t m szenglishname t afx data init cdialog cdlgcreatenewlanguage pparent afx_data_init cdlgcreatenewlanguage m_szinifile _t m_szenglishname _t afx_data_init void c dlg create new language do data exchange c data exchange pdx c dialog do data exchange pdx afx data map c dlg create new language ddx text pdx idc inifile m szinifile ddx text pdx idc englishname m szenglishname afx data map cdlgcreatenewlanguage dodataexchange cdataexchange cdialog dodataexchange afx_data_map cdlgcreatenewlanguage ddx_text idc_inifile m_szinifile ddx_text idc_englishname m_szenglishname afx_data_map void c dlg create new language onok update data check so the fields are note empty if m szinifile is empty m szenglishname is empty afx message box c translate read string 192 you must enter both a language you want to create and the english name for it return create the ini file c string sz file m szini m szini m szinifile m szinifile m szini ini sz file format t s language s get program path m szinifile write the language in the ini file write private profile string t language t language m szenglishname sz file update data false c dialog onok cdlgcreatenewlanguage updatedata m_szinifile isempty m_szenglishname isempty afxmessagebox ctranslate readstring cstring szfile m_szini m_szini m_szinifile m_szinifile m_szini szfile _t getprogrampath m_szinifile writeprivateprofilestring _t _t m_szenglishname szfile updatedata cdialog