MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / CreateBars

Function CreateBars

src/Notepad2.c:1333–1483  ·  view source on GitHub ↗

============================================================================= CreateBars() - Create Toolbar and Statusbar

Source from the content-addressed store, hash-verified

1331//
1332//
1333void CreateBars ( HWND hwnd, HINSTANCE hInstance )
1334{
1335 RECT rc;
1336 REBARINFO rbi;
1337 REBARBANDINFO rbBand;
1338 BITMAP bmp;
1339 HBITMAP hbmp, hbmpCopy = NULL;
1340 HIMAGELIST himl;
1341 WCHAR szTmp[MAX_PATH];
1342 BOOL bExternalBitmap = FALSE;
1343 DWORD dwToolbarStyle = WS_TOOLBAR;
1344 DWORD dwStatusbarStyle = WS_CHILD | WS_CLIPSIBLINGS;
1345 DWORD dwReBarStyle = WS_REBAR;
1346 BOOL bIsAppThemed = PrivateIsAppThemed();
1347 int i, n;
1348 WCHAR tchDesc[256];
1349 WCHAR tchIndex[256];
1350 WCHAR *pIniSection = NULL;
1351 int cchIniSection = 0;
1352 if ( bShowToolbar ) {
1353 dwReBarStyle |= WS_VISIBLE;
1354 }
1355 hwndToolbar = CreateWindowEx ( 0, TOOLBARCLASSNAME, NULL, dwToolbarStyle,
1356 0, 0, 0, 0, hwnd, ( HMENU ) IDC_TOOLBAR, hInstance, NULL );
1357 SendMessage ( hwndToolbar, TB_BUTTONSTRUCTSIZE, ( WPARAM ) sizeof ( TBBUTTON ), 0 );
1358 // Add normal Toolbar Bitmap
1359 hbmp = NULL;
1360 if ( lstrlen ( tchToolbarBitmap ) ) {
1361 if ( !SearchPath ( NULL, tchToolbarBitmap, NULL, COUNTOF ( szTmp ), szTmp, NULL ) ) {
1362 lstrcpy ( szTmp, tchToolbarBitmap );
1363 }
1364 hbmp = LoadImage ( NULL, szTmp, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE );
1365 }
1366 if ( hbmp ) {
1367 bExternalBitmap = TRUE;
1368 } else {
1369 hbmp = LoadImage ( hInstance, MAKEINTRESOURCE ( IDR_MAINWND ), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );
1370 hbmpCopy = CopyImage ( hbmp, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );
1371 }
1372 GetObject ( hbmp, sizeof ( BITMAP ), &bmp );
1373 if ( !IsXP() ) {
1374 BitmapMergeAlpha ( hbmp, GetSysColor ( COLOR_3DFACE ) );
1375 }
1376 himl = ImageList_Create ( bmp.bmWidth / NUMTOOLBITMAPS, bmp.bmHeight, ILC_COLOR32 | ILC_MASK, 0, 0 );
1377 ImageList_AddMasked ( himl, hbmp, CLR_DEFAULT );
1378 DeleteObject ( hbmp );
1379 SendMessage ( hwndToolbar, TB_SETIMAGELIST, 0, ( LPARAM ) himl );
1380 // Optionally add hot Toolbar Bitmap
1381 hbmp = NULL;
1382 if ( lstrlen ( tchToolbarBitmapHot ) ) {
1383 if ( !SearchPath ( NULL, tchToolbarBitmapHot, NULL, COUNTOF ( szTmp ), szTmp, NULL ) ) {
1384 lstrcpy ( szTmp, tchToolbarBitmapHot );
1385 }
1386 if ( hbmp = LoadImage ( NULL, szTmp, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE ) ) {
1387 GetObject ( hbmp, sizeof ( BITMAP ), &bmp );
1388 himl = ImageList_Create ( bmp.bmWidth / NUMTOOLBITMAPS, bmp.bmHeight, ILC_COLOR32 | ILC_MASK, 0, 0 );
1389 ImageList_AddMasked ( himl, hbmp, CLR_DEFAULT );
1390 DeleteObject ( hbmp );

Callers 2

MsgCreateFunction · 0.85
MsgThemeChangedFunction · 0.85

Calls 6

PrivateIsAppThemedFunction · 0.85
BitmapMergeAlphaFunction · 0.85
BitmapAlphaBlendFunction · 0.85
BitmapGrayScaleFunction · 0.85
IniSectionGetStringFunction · 0.85
Toolbar_SetButtonsFunction · 0.85

Tested by

no test coverage detected