Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentoolbar.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Applications Manager 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: base/applications/rapps/toolbar.c 00005 * PURPOSE: ToolBar functions 00006 * PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org) 00007 */ 00008 00009 #include "rapps.h" 00010 00011 #define TOOLBAR_HEIGHT 24 00012 00013 HWND hToolBar; 00014 HWND hSearchBar; 00015 00016 static WCHAR szInstallBtn[MAX_STR_LEN]; 00017 static WCHAR szUninstallBtn[MAX_STR_LEN]; 00018 static WCHAR szModifyBtn[MAX_STR_LEN]; 00019 00020 /* Toolbar buttons */ 00021 static const TBBUTTON Buttons[] = 00022 { /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */ 00023 { 0, ID_INSTALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, {0}, 0, (INT_PTR)szInstallBtn}, 00024 { 1, ID_UNINSTALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, {0}, 0, (INT_PTR)szUninstallBtn}, 00025 { 2, ID_MODIFY, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, {0}, 0, (INT_PTR)szModifyBtn}, 00026 { 5, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, 00027 { 3, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, {0}, 0, 0}, 00028 { 5, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, 00029 { 4, ID_SETTINGS, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, {0}, 0, 0}, 00030 { 5, ID_EXIT, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, {0}, 0, 0} 00031 }; 00032 00033 00034 VOID 00035 ToolBarOnGetDispInfo(LPTOOLTIPTEXT lpttt) 00036 { 00037 UINT idButton = (UINT)lpttt->hdr.idFrom; 00038 00039 switch (idButton) 00040 { 00041 case ID_EXIT: 00042 lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EXIT); 00043 break; 00044 00045 case ID_INSTALL: 00046 lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_INSTALL); 00047 break; 00048 00049 case ID_UNINSTALL: 00050 lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_UNINSTALL); 00051 break; 00052 00053 case ID_MODIFY: 00054 lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_MODIFY); 00055 break; 00056 00057 case ID_SETTINGS: 00058 lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SETTINGS); 00059 break; 00060 00061 case ID_REFRESH: 00062 lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_REFRESH); 00063 break; 00064 } 00065 } 00066 00067 VOID 00068 AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex) 00069 { 00070 HANDLE hImage; 00071 00072 if (!(hImage = LoadImage(hInst, 00073 MAKEINTRESOURCE(ImageIndex), 00074 IMAGE_ICON, 00075 TOOLBAR_HEIGHT, 00076 TOOLBAR_HEIGHT, 00077 0))) 00078 { 00079 /* TODO: Error message */ 00080 } 00081 00082 ImageList_AddIcon(hImageList, hImage); 00083 DeleteObject(hImage); 00084 } 00085 00086 HIMAGELIST 00087 InitImageList(VOID) 00088 { 00089 HIMAGELIST hImageList; 00090 00091 /* Create the toolbar icon image list */ 00092 hImageList = ImageList_Create(TOOLBAR_HEIGHT,//GetSystemMetrics(SM_CXSMICON), 00093 TOOLBAR_HEIGHT,//GetSystemMetrics(SM_CYSMICON), 00094 ILC_MASK | GetSystemColorDepth(), 00095 1, 00096 1); 00097 if (!hImageList) 00098 { 00099 /* TODO: Error message */ 00100 return NULL; 00101 } 00102 00103 AddImageToImageList(hImageList, IDI_INSTALL); 00104 AddImageToImageList(hImageList, IDI_UNINSTALL); 00105 AddImageToImageList(hImageList, IDI_MODIFY); 00106 AddImageToImageList(hImageList, IDI_REFRESH); 00107 AddImageToImageList(hImageList, IDI_SETTINGS); 00108 AddImageToImageList(hImageList, IDI_EXIT); 00109 00110 return hImageList; 00111 } 00112 00113 static 00114 BOOL 00115 CreateSearchBar(VOID) 00116 { 00117 WCHAR szBuf[MAX_STR_LEN]; 00118 00119 hSearchBar = CreateWindowExW(WS_EX_CLIENTEDGE, 00120 L"Edit", 00121 NULL, 00122 WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOVSCROLL, 00123 0, 00124 5, 00125 200, 00126 22, 00127 hToolBar, 00128 (HMENU)0, 00129 hInst, 00130 0); 00131 00132 SendMessageW(hSearchBar, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); 00133 00134 LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, sizeof(szBuf) / sizeof(WCHAR)); 00135 SetWindowTextW(hSearchBar, szBuf); 00136 00137 SetParent(hSearchBar, hToolBar); 00138 00139 return TRUE; 00140 } 00141 00142 BOOL 00143 CreateToolBar(HWND hwnd) 00144 { 00145 INT NumButtons = sizeof(Buttons) / sizeof(Buttons[0]); 00146 HIMAGELIST hImageList; 00147 00148 LoadStringW(hInst, IDS_INSTALL, szInstallBtn, sizeof(szInstallBtn) / sizeof(WCHAR)); 00149 LoadStringW(hInst, IDS_UNINSTALL, szUninstallBtn, sizeof(szUninstallBtn) / sizeof(WCHAR)); 00150 LoadStringW(hInst, IDS_MODIFY, szModifyBtn, sizeof(szModifyBtn) / sizeof(WCHAR)); 00151 00152 hToolBar = CreateWindowExW(0, 00153 TOOLBARCLASSNAMEW, 00154 NULL, 00155 WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_LIST, 00156 0, 0, 0, 0, 00157 hwnd, 00158 0, 00159 hInst, 00160 NULL); 00161 00162 if (!hToolBar) 00163 { 00164 /* TODO: Show error message */ 00165 return FALSE; 00166 } 00167 00168 SendMessageW(hToolBar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_HIDECLIPPEDBUTTONS); 00169 SendMessageW(hToolBar, TB_BUTTONSTRUCTSIZE, sizeof(Buttons[0]), 0); 00170 00171 hImageList = InitImageList(); 00172 00173 if (!hImageList) 00174 { 00175 /* TODO: Show error message */ 00176 return FALSE; 00177 } 00178 00179 ImageList_Destroy((HIMAGELIST)SendMessageW(hToolBar, 00180 TB_SETIMAGELIST, 00181 0, 00182 (LPARAM)hImageList)); 00183 00184 SendMessageW(hToolBar, TB_ADDBUTTONS, NumButtons, (LPARAM)Buttons); 00185 00186 CreateSearchBar(); 00187 00188 return TRUE; 00189 } Generated on Thu May 24 2012 04:17:33 for ReactOS by
1.7.6.1
|