コード例 #1
1
ファイル: DockingBar.cpp プロジェクト: mikekov/ExifPro
bool CDockingBar::Create(CWnd* parent, CFramePages* pages, bool show)
{
	ASSERT(parent);
	ASSERT(pages);

	pages_ = pages;

	if (wnd_class_.IsEmpty())
		wnd_class_ = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, ::LoadCursor(NULL, IDC_ARROW));

	CDC dc;
	dc.CreateIC(_T("DISPLAY"), 0, 0, 0);
	dc.SelectStockObject(DEFAULT_GUI_FONT);
	TEXTMETRIC tm;
	dc.GetTextMetrics(&tm);
	int line_height= tm.tmHeight + tm.tmInternalLeading + tm.tmExternalLeading;
	int bar_height= ((line_height + 6) & ~1) + 1;	// ensure height is odd

	// create docking bar; width will be reset by frame wnd
	if (!CWnd::CreateEx(0, wnd_class_, _T(""), WS_CHILD | (show ? WS_VISIBLE : 0) | WS_CLIPCHILDREN,
		CRect(0, 0, 200, bar_height), parent, -1))
		return false;

	HINSTANCE inst= AfxFindResourceHandle(MAKEINTRESOURCE(IDB_DOCK_BAR), RT_BITMAP);
	image_list_.Attach(ImageList_LoadImage(inst, MAKEINTRESOURCE(IDB_DOCK_BAR),
		16, 0, RGB(192,192,192), IMAGE_BITMAP, LR_CREATEDIBSECTION));

	image_list_.SetBkColor(CLR_NONE);

	Refresh(true);

	return true;
}
コード例 #2
0
ファイル: ToolBarEx.cpp プロジェクト: moodboom/Reusable
void CToolBarEx::SetIconOptions( EIconOptions eIconOptions, bool bUpdate /*=true*/ )
{
    ASSERT( ::IsWindow( m_hWnd ) );
    ASSERT( IsIconOptionAvailable( eIconOptions ) );

    m_eIconOptions = eIconOptions;

    // Set image list(s) and icon size for selected icon options
    CToolBarCtrl& tbCtrl = GetToolBarCtrl();
    tbCtrl.SetImageList( 0 );
    tbCtrl.SetHotImageList( 0 );
    tbCtrl.SetDisabledImageList( 0 );

    CSize szIcon = ( eIconOptions == ioSmallIcons ) ? m_szImageSmall : m_szImageLarge;
	 VERIFY( tbCtrl.SetBitmapSize( szIcon ) );

    UINT nIDCold     = ( eIconOptions == ioSmallIcons ) ? m_nIDSmallCold     : m_nIDLargeCold;
    UINT nIDHot      = ( eIconOptions == ioSmallIcons ) ? m_nIDSmallHot      : m_nIDLargeHot;
    UINT nIDDisabled = ( eIconOptions == ioSmallIcons ) ? m_nIDSmallDisabled : m_nIDLargeDisabled;
    ASSERT( nIDCold != ( UINT )-1 );    // at least there must be "cold" imagelist

    LPCTSTR lpResName = MAKEINTRESOURCE( nIDCold );
    HINSTANCE hInst = AfxFindResourceHandle( lpResName, RT_BITMAP );

    m_imageListCold.DeleteImageList();
    VERIFY( m_imageListCold.Attach( ImageList_LoadImage( hInst, lpResName,
        szIcon.cx, 0, m_clrMask, IMAGE_BITMAP, LR_CREATEDIBSECTION ) ) );
    tbCtrl.SetImageList( &m_imageListCold );

    if ( nIDHot != ( UINT )-1 ) // "hot" imagelist is optional
    {
        lpResName = MAKEINTRESOURCE( nIDHot );
        hInst = AfxFindResourceHandle( lpResName, RT_BITMAP );

        m_imageListHot.DeleteImageList();
        VERIFY( m_imageListHot.Attach( ImageList_LoadImage( hInst, lpResName,
            szIcon.cx, 0, m_clrMask, IMAGE_BITMAP, LR_CREATEDIBSECTION ) ) );
        tbCtrl.SetHotImageList( &m_imageListHot );
    }

    if ( nIDDisabled != ( UINT )-1 ) // "disabled" imagelist is optional
    {
        lpResName = MAKEINTRESOURCE( nIDDisabled );
        hInst = AfxFindResourceHandle( lpResName, RT_BITMAP );

        m_imageListDisabled.DeleteImageList();
        VERIFY( m_imageListDisabled.Attach( ImageList_LoadImage( hInst, lpResName,
            szIcon.cx, 0, m_clrMask, IMAGE_BITMAP, LR_CREATEDIBSECTION ) ) );
        tbCtrl.SetDisabledImageList( &m_imageListDisabled );
    }

    // If requested, reflect changes immediately
    if ( bUpdate )
    {
        ReloadButtons();
        UpdateParentBandInfo();
    }
}
コード例 #3
0
ファイル: KEYBOARD.CPP プロジェクト: jcbaar/BCC
// Constructor.
KeyboardPage::KeyboardPage() 
{
	// Setup icon.
	m_nIcon = IDI_KEYBOARD;

	// Load bitmaps.
	m_hImages = ImageList_LoadImage( ClsGetResourceHandle(), MAKEINTRESOURCE( IDB_CLIST ), 16, 0, RGB( 255, 0, 255 ), IMAGE_BITMAP, LR_CREATEDIBSECTION);
	m_hDisImages = ImageList_LoadImage( ClsGetResourceHandle(), MAKEINTRESOURCE( IDB_CLIST_GRAY ), 16, 0, RGB( 255, 0, 255 ), IMAGE_BITMAP, LR_CREATEDIBSECTION);
}
コード例 #4
0
ファイル: Searchbar.c プロジェクト: HTshandou/HexEdit
HWND CreateEmptyToolbar(HWND hwndParent, int nBitmapIdx, int nBitmapWidth, int nCtrlId, DWORD dwExtraStyle)
{
	HWND	   hwndTB;
	HIMAGELIST hImgList;
	
	hwndTB = CreateToolbarEx (hwndParent,
			TOOLBAR_STYLE|dwExtraStyle,
			nCtrlId, 0,
			0,
			0,
			NULL,
			0,
			0, 0, 0, 0,
			sizeof(TBBUTTON) );

	//hImgList = ImageList_LoadBitmap(GetModuleHandle(0), MAKEINTRESOURCE(nBitmapIdx), 
	//								nBitmapWidth, 16, RGB(255,0,255));
	hImgList = ImageList_LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(nBitmapIdx), 
									nBitmapWidth, 16, RGB(255,0,255), IMAGE_BITMAP, LR_CREATEDIBSECTION);

	SendMessage(hwndTB, TB_SETIMAGELIST, 0, (LPARAM)hImgList);

	return hwndTB;

	return CreateWindowEx(0, TOOLBARCLASSNAME,0,WS_VISIBLE|WS_CHILD|TBSTYLE_FLAT|
		TBSTYLE_TRANSPARENT |CCS_NORESIZE|CCS_NODIVIDER,
		0,0,0,0,hwndParent,0,0,0);

  //SendMessage(hToolBar, TB_SETSTYLE, 0, SendMessage(hToolBar, TB_GETSTYLE, 0,0 )
//& ~ TBSTYLE_TRANSPARENT);
}
コード例 #5
0
ファイル: CCImageList.cpp プロジェクト: thenfour/Volumizer
HRESULT CCImageList::CreateFromFile(PCWSTR wszFile, int cx, COLORREF cMask)
{
	Destroy();
    m_hImageList = ImageList_LoadImage(NULL, wszFile,
        cx, 10, cMask, IMAGE_BITMAP, LR_LOADFROMFILE);

    if(m_hImageList == NULL) return E_FAIL;

    return S_OK;
}
コード例 #6
0
ファイル: CCImageList.cpp プロジェクト: thenfour/Volumizer
HRESULT CCImageList::CreateFromResource(
    HINSTANCE hInstance, PWSTR wszResource, int cx, COLORREF cMask)
{
	Destroy();
    m_hImageList = ImageList_LoadImage(hInstance, wszResource,
        cx, 10, cMask, IMAGE_BITMAP, 0);

    if(m_hImageList == NULL) return E_FAIL;

    return S_OK;
}
コード例 #7
0
ファイル: ex_mditab.c プロジェクト: ArmstrongJ/mctrl
int APIENTRY
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASS wc = { 0 };
    HWND hWnd;
    MSG msg;

    mcMditab_Initialize();

    /* Prevent linker from ignoring comctl32.dll */
    InitCommonControls();

    hInst = hInstance;

    /* Register main window class */
    wc.style = 0;
    wc.lpfnWndProc = WndProc;
    wc.hInstance = hInst;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
    wc.lpszClassName = _T("main_window");
    RegisterClass(&wc);

    /* Load image list */
    hImgList = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDL_IMGLIST),
                    16, 1, RGB(255,0,255), IMAGE_BITMAP, LR_CREATEDIBSECTION);

    /* Create main window */
    hWnd = CreateWindow(_T("main_window"), _T("mCtrl Example: MDITAB Control"),
            WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_SYSMENU,
            CW_USEDEFAULT, CW_USEDEFAULT, MINIMAL_WIDTH, MINIMAL_HEIGHT,
            NULL, NULL, hInst, NULL);
    SendMessage(hWnd, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),
            MAKELPARAM(TRUE, 0));
    ShowWindow(hWnd, nCmdShow);

    /* Message loop */
    while(GetMessage(&msg, NULL, 0, 0)) {
        if(IsDialogMessage(hWnd, &msg))
            continue;

        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    mcMditab_Terminate();

    /* Return exit code of WM_QUIT */
    return (int)msg.wParam;
}
コード例 #8
0
ファイル: DlgHighlight.c プロジェクト: 4aiman/HexEdit
HWND PrepGridView2(HWND hwndParent, int ctrlId)
{
	GVCOLUMN gvcol = { 0 };
	HFONT hFont, hBold;
	HIMAGELIST hImgList;

	HWND hwndGridView;

	hwndGridView = CreateGridView(hwndParent, ctrlId, 0, WS_EX_CLIENTEDGE);


	hBold = CreateFont(-14,0,0,0,FW_BOLD,0,0,0,0,0,0,0,0, TEXT("Segoe UI"));

	hFont = CreateFont(-14,0,0,0,0,0,0,0,0,0,0,0,0, TEXT("Verdana"));
	//SendMessage(hwndGridView, WM_SETFONT, (WPARAM)hFont, 0);

	GridView_SetFont(hwndGridView, hFont, 0);
	GridView_SetFont(hwndGridView, hBold, 1);

	gvcol.xWidth = 300;
	gvcol.pszText = TEXT("Name");
	gvcol.uState = 0;//GVCS_BLENDIMAGE;
	GridView_InsertColumn(hwndGridView, 0, &gvcol);

	gvcol.hFont = hFont;
	gvcol.xWidth  = 300;
	gvcol.pszText = TEXT("Offset");
	gvcol.uState  = 0;//GVISGVCS_ALIGN_RIGHT;
	GridView_InsertColumn(hwndGridView, 1, &gvcol);

	gvcol.xWidth = 400;
	gvcol.pszText = TEXT("Annotation");
	gvcol.uState  = 0;
	GridView_InsertColumn(hwndGridView, 2, &gvcol);

	//hImgList = ImageList_LoadBitmap(GetModuleHandle(0), MAKEINTRESOURCE(IDB_BITMAP15), 16, 0, RGB(255,0,255));
	hImgList = ImageList_LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(IDB_BITMAP15), 16, 0, 
		CLR_DEFAULT, //RGB(255,0,255), 
		IMAGE_BITMAP, 
		
		LR_CREATEDIBSECTION );//
		//|		LR_LOADTRANSPARENT);
	GridView_SetImageList(hwndGridView, hImgList);

	return hwndGridView;
}
コード例 #9
0
ファイル: Globals.cpp プロジェクト: pbarounis/ActiveBar2
HIMAGELIST Globals::GetSizer()
{
	EnterCriticalSection(&m_csGlobals);
	if (NULL == m_ilSizer)
	{
		#define OBM_BTSIZE 32761
		m_ilSizer = ImageList_LoadImage(NULL, 
										MAKEINTRESOURCE(OBM_BTSIZE), 
										16, 
										0, 
										RGB(192, 192, 192), 
										IMAGE_BITMAP, 
										LR_DEFAULTCOLOR);
	}
	LeaveCriticalSection(&m_csGlobals);
	return m_ilSizer;
}
コード例 #10
0
ファイル: icons.cpp プロジェクト: tweimer/miranda-ng
void InitIcons(void)
{
	char szId[20];

	/* register icons */
	SKINICONDESC sid = {};
	sid.pszName = szId;
	sid.cx = GetSystemMetrics(SM_CXSMICON);
	sid.cy = GetSystemMetrics(SM_CYSMICON);
	sid.flags = SIDF_SORTED;
	sid.section.a = "Country Flags";

	/* all those flag icons do not need any transparency mask (flags are always opaque),
	 * storing them in a large bitmap to reduce file size */
	HIMAGELIST himl = ImageList_LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_FLAGS), sid.cx, 0, CLR_NONE, IMAGE_BITMAP, LR_CREATEDIBSECTION);
	if (himl != nullptr) {
		phIconHandles = (HANDLE*)mir_alloc(nCountriesCount * sizeof(HANDLE));
		if (phIconHandles != nullptr) {
			for (int i = 0; i < nCountriesCount; ++i) {
				sid.description.a = (char*)countries[i].szName;

				/* create identifier */
				mir_snprintf(szId, (countries[i].id == 0xFFFF) ? "%s0x%X" : "%s%i", "flags_", countries[i].id); /* buffer safe */
				int index = CountryNumberToBitmapIndex(countries[i].id);
				/* create icon */
				HICON hIcon = ImageList_GetIcon(himl, index, ILD_NORMAL);
				if (hIcon) {
					sid.hDefaultIcon = ResizeIconCentered(hIcon, sid.cx, sid.cy);
					DestroyIcon(hIcon);
				}
				else sid.hDefaultIcon = nullptr;
				index = CountryNumberToIndex(countries[i].id);
				phIconHandles[index] = g_plugin.addIcon(&sid);
				if (sid.hDefaultIcon != nullptr)
					DestroyIcon(sid.hDefaultIcon);
			}
		}
		ImageList_Destroy(himl);
	}

	/* create services */
	CreateServiceFunction(MS_FLAGS_LOADFLAGICON, ServiceLoadFlagIcon);
	CreateServiceFunction(MS_FLAGS_CREATEMERGEDFLAGICON, ServiceCreateMergedFlagIcon);
}
コード例 #11
0
ファイル: MsgViewFromLog.cpp プロジェクト: jangchan/TR2
int CMsgViewFromLog::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CListView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	//GetDocument()->m_pMsgViewFromLog = this;

	CListCtrl& listCtl = GetListCtrl();
	if ( !IsWindow( listCtl.GetSafeHwnd() ) )	return -1;
	m_pListCtrl = &listCtl;
	listCtl.InsertColumn( 0,"시간",LVCFMT_LEFT,150 );
	listCtl.InsertColumn( 1,"종류",LVCFMT_LEFT,50 );
	listCtl.InsertColumn( 2,"등급",LVCFMT_LEFT,130 );
	listCtl.InsertColumn( 3,"받은곳",LVCFMT_LEFT,100 );
	listCtl.InsertColumn( 4,"위치",LVCFMT_LEFT,200 );
	listCtl.InsertColumn( 5,"메세지",LVCFMT_LEFT,700 );
	
	listCtl.SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE,
						LVS_EX_FULLROWSELECT |
						LVS_EX_GRIDLINES |
						LVS_EX_TWOCLICKACTIVATE |
						LVS_EX_SUBITEMIMAGES,
						LVS_EX_FULLROWSELECT |
						LVS_EX_GRIDLINES |
						LVS_EX_TWOCLICKACTIVATE |
						LVS_EX_SUBITEMIMAGES 
						);
	
	HIMAGELIST hImgList;
	
	hImgList = ImageList_LoadImage( ::AfxGetInstanceHandle() , MAKEINTRESOURCE( IDB_BITMAP1 ) , 17 
		, 1 , RGB( 255,255,255 ) , IMAGE_BITMAP , 0 );
	
	m_pImageList->Attach( hImgList );

	listCtl.SetImageList( m_pImageList , LVSIL_SMALL );
	
	return 0;
}
コード例 #12
0
ファイル: UIHelper.cpp プロジェクト: kjk/ars-framework
HIMAGELIST HIDPI_ImageList_LoadImage(
    HINSTANCE hinst,
    LPCTSTR lpbmp,
    int cx,
    int cGrow,
    COLORREF crMask,
    UINT uType,
    UINT uFlags
    )
{
    HBITMAP hbmImage = NULL;
    HIMAGELIST piml = NULL;
    BITMAP bm;
    int cImages, cxImage, cy;
    int BmpLogPixelsX, BmpLogPixelsY;
    UINT flags;

    if ((uType != IMAGE_BITMAP) ||  // Image type is not IMAGE_BITMAP
        (cx == 0))                  // Caller doesn't care about the dimensions of the image - assumes the ones in the file
    {
        piml = ImageList_LoadImage(hinst, lpbmp, cx, cGrow, crMask, uType, uFlags);
        goto cleanup;
    }

    if (!HIDPI_GetBitmapLogPixels(hinst, lpbmp, &BmpLogPixelsX, &BmpLogPixelsY))
    {
        goto cleanup;
    }

    hbmImage = (HBITMAP)LoadImage(hinst, lpbmp, uType, 0, 0, uFlags);
    if (!hbmImage || (sizeof(bm) != GetObject(hbmImage, sizeof(bm), &bm)))
    {
        goto cleanup;
    }
    
    // do we need to scale this image?
    if (BmpLogPixelsX == g_HIDPI_LogPixelsX)
    {
        piml = ImageList_LoadImage(hinst, lpbmp, cx, cGrow, crMask, uType, uFlags);
        goto cleanup;
    }
    
    cxImage = HIDPIMulDiv(cx, BmpLogPixelsX, g_HIDPI_LogPixelsX);

    // Bitmap width should be multiple integral of image width.
    // If not, that means either your bitmap is wrong or passed in cx is wrong.
    // ASSERT((bm.bmWidth % cxImage) == 0);

    cImages = bm.bmWidth / cxImage;

    cy = HIDPIMulDiv(bm.bmHeight, g_HIDPI_LogPixelsY, BmpLogPixelsY);

    if ((g_HIDPI_LogPixelsX % BmpLogPixelsX) == 0)
    {
        HIDPI_StretchBitmap(&hbmImage, cx * cImages, cy, 1, 1);
    }
    else
    {
        // Here means the DPI is not integral multiple of standard DPI (96DPI).
        // So if we stretch entire bitmap together, we are not sure each indivisual
        //   image will be stretch to right place. It is controled by StretchBlt().
        //   (for example, a 16 pixel icon, the first one might be stretch to 22 pixels
        //    and next one might be stretched to 20 pixels)
        // What we have to do here is stretching indivisual image separately to make sure
        //   every one is stretched properly.
        HIDPI_StretchBitmap(&hbmImage, cx, cy, cImages, 1);
    }

    flags = 0;
    // ILC_MASK is important for supporting CLR_DEFAULT
    if (crMask != CLR_NONE)
    {
        flags |= ILC_MASK;
    }
    // ILC_COLORMASK bits are important if we ever want to Merge ImageLists
    if (bm.bmBits)
    {
        flags |= (bm.bmBitsPixel & ILC_COLORMASK);
    }

    // bitmap MUST be de-selected from the DC
    // create the image list of the size asked for.
    piml = ImageList_Create(cx, cy, flags, cImages, cGrow);
        
    if (piml)
    {
        int added;
        
        if (crMask == CLR_NONE)
        {
            added = ImageList_Add(piml, hbmImage, NULL);
        }
        else
        {
            added = ImageList_AddMasked(piml, hbmImage, crMask);
        }
            
        if (added < 0)
        {
            ImageList_Destroy(piml);
            piml = NULL;
        }
    }

cleanup:
    DeleteObject(hbmImage);
    return piml;
}
コード例 #13
0
ファイル: main.c プロジェクト: killbug2004/WinObjEx64
/*
* WinObjExMain
*
* Purpose:
*
* Actual program entry point.
*
*/
void WinObjExMain()
{
	MSG						msg1;
	WNDCLASSEX				wincls;
	BOOL					IsFullAdmin = FALSE, rv = TRUE, cond = FALSE;
	ATOM					class_atom = 0;
	INITCOMMONCONTROLSEX	icc;
	LVCOLUMNW				col;
	SHSTOCKICONINFO			sii;
	HMENU					hMenu;
	HACCEL					hAccTable = 0;
	WCHAR					szWindowTitle[100];
	HANDLE					tmpb;


#ifdef _DEBUG
	TestPrivateNamespace();
	//TestIoCompletion();
	//TestTimer();
	//TestTransaction();
#endif

	pHtmlHelpW = NULL;
	CurrentObjectPath = NULL;
	bSortInverse = FALSE;
	g_hInstance = GetModuleHandle(NULL);
	RtlSecureZeroMemory(szWindowTitle, sizeof(szWindowTitle));

	//clear dialogs array
	RtlSecureZeroMemory(g_wobjDialogs, sizeof(g_wobjDialogs));

	// do not move anywhere
	IsFullAdmin = supUserIsFullAdmin();
	supInit(IsFullAdmin);

	//create main window and it components
	wincls.cbSize = sizeof(WNDCLASSEX);
	wincls.style = 0;
	wincls.lpfnWndProc = &MainWindowProc;
	wincls.cbClsExtra = 0;
	wincls.cbWndExtra = 0;
	wincls.hInstance = g_hInstance;
	wincls.hIcon = (HICON)LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_MAIN), IMAGE_ICON, 0, 0, LR_SHARED);
	wincls.hCursor = (HCURSOR)LoadImage(NULL, MAKEINTRESOURCE(OCR_SIZEWE), IMAGE_CURSOR, 0, 0, LR_SHARED);
	wincls.hbrBackground = NULL;
	wincls.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
	wincls.lpszClassName = MAINWINDOWCLASSNAME;
	wincls.hIconSm = 0;

	do {
		class_atom = RegisterClassEx(&wincls);
		if (class_atom == 0)
			break;

		_strcpy(szWindowTitle, PROGRAM_NAME);
		if (IsFullAdmin != FALSE) {
			_strcat(szWindowTitle, L" (Administrator)");
		}

		MainWindow = CreateWindowEx(0, MAKEINTATOM(class_atom), szWindowTitle,
			WS_VISIBLE | WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, g_hInstance, NULL);
		if (MainWindow == NULL)
			break;

		icc.dwSize = sizeof(icc);
		icc.dwICC = ICC_LISTVIEW_CLASSES | ICC_TREEVIEW_CLASSES | ICC_BAR_CLASSES | ICC_TAB_CLASSES;
		if (!InitCommonControlsEx(&icc))
			break;

		StatusBar = CreateWindowEx(0, STATUSCLASSNAME, NULL,
			WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, MainWindow, (HMENU)1001, g_hInstance, NULL);

		ObjectTree = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL,
			WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_DISABLEDRAGDROP | TVS_HASBUTTONS | 
			TVS_HASLINES | TVS_LINESATROOT, 0, 0, 0, 0, MainWindow, (HMENU)1002, g_hInstance, NULL);

		if (ObjectTree == NULL)
			break;

		ObjectList = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL,
			WS_VISIBLE | WS_CHILD | WS_TABSTOP | LVS_AUTOARRANGE | LVS_REPORT | 
			LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_SHAREIMAGELISTS, 0, 0, 0, 0, 
			MainWindow, (HMENU)1003, g_hInstance, NULL);

		if (ObjectList == NULL)
			break;

		ToolBar1 = CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
			WS_VISIBLE | WS_CHILD | CCS_TOP | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | 
			TBSTYLE_TOOLTIPS, 0, 0, 0, 0, MainWindow, (HMENU)1004, g_hInstance, NULL);

		if (ToolBar1 == NULL)
			break;

		Splitter = CreateWindowEx(0, WC_STATIC, NULL,
			WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, MainWindow, (HMENU)1005, g_hInstance, NULL);

		// initialization of views
		SendMessage(MainWindow, WM_SIZE, 0, 0);
		ListView_SetExtendedListViewStyle(ObjectList, 
			LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_DOUBLEBUFFER);

		// set tree imagelist
		TreeViewImages = supLoadImageList(g_hInstance, IDI_ICON_VIEW_DEFAULT, IDI_ICON_VIEW_SELECTED);
		if (TreeViewImages) {
			TreeView_SetImageList(ObjectTree, TreeViewImages, TVSIL_NORMAL);
		}

		//insert run as admin menu entry
		if (IsFullAdmin == FALSE) {
			hMenu = GetSubMenu(GetMenu(MainWindow), 0);
			InsertMenu(hMenu, 0, MF_BYPOSITION, ID_FILE_RUNASADMIN, T_RUNASADMIN);
			InsertMenu(hMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
			//set menu shield icon
			RtlSecureZeroMemory(&sii, sizeof(sii));
			sii.cbSize = sizeof(sii);
			if (SHGetStockIconInfo(SIID_SHIELD, SHGSI_ICON | SHGFI_SMALLICON, &sii) == S_OK) {
				supSetMenuIcon(hMenu, ID_FILE_RUNASADMIN, (ULONG_PTR)sii.hIcon);
			}
		}

		//load listview images
		ListViewImages = supLoadImageList(g_hInstance, IDI_ICON_DEVICE, IDI_ICON_UNKNOWN);
		if (ListViewImages) {
			tmpb = LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_SORTUP), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
			if (tmpb) {
				ImageList_ReplaceIcon(ListViewImages, -1, tmpb);
				DestroyIcon(tmpb);
			}
			tmpb = LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_SORTDOWN), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
			if (tmpb) {
				ImageList_ReplaceIcon(ListViewImages, -1, tmpb);
				DestroyIcon(tmpb);
			}
			ListView_SetImageList(ObjectList, ListViewImages, LVSIL_SMALL);
		}

		//load toolbar images
		ToolBarMenuImages = ImageList_LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_BITMAP1), 
			16, 7, CLR_DEFAULT, IMAGE_BITMAP, LR_CREATEDIBSECTION);

		if (ToolBarMenuImages) {

			supCreateToolbarButtons(ToolBar1);

			//set menu icons
			hMenu = GetSubMenu(GetMenu(MainWindow), 1);
			if (hMenu) {
				supSetMenuIcon(hMenu, ID_VIEW_REFRESH,
					(ULONG_PTR)ImageList_ExtractIcon(g_hInstance, ToolBarMenuImages, 1));
			}
			hMenu = GetSubMenu(GetMenu(MainWindow), 2);
			if (hMenu && ListViewImages) {
				supSetMenuIcon(hMenu, ID_OBJECT_PROPERTIES,
					(ULONG_PTR)ImageList_ExtractIcon(g_hInstance, ToolBarMenuImages, 0));
				supSetMenuIcon(hMenu, ID_OBJECT_GOTOLINKTARGET,
					(ULONG_PTR)ImageList_ExtractIcon(g_hInstance, ListViewImages, 
					ID_FROM_VALUE(IDI_ICON_SYMLINK)));
			}

			//set object -> find object menu image
			hMenu = GetSubMenu(GetMenu(MainWindow), 3);
			if (hMenu) {
				supSetMenuIcon(hMenu, ID_FIND_FINDOBJECT,
					(ULONG_PTR)ImageList_ExtractIcon(g_hInstance, ToolBarMenuImages, 2));
			}

			//set extras-pipe menu image
			hMenu = GetSubMenu(GetMenu(MainWindow), 4);
			if (hMenu) {
				supSetMenuIcon(hMenu, ID_EXTRAS_PIPES,
					(ULONG_PTR)ImageList_ExtractIcon(g_hInstance, ToolBarMenuImages, 6));
			}

			//set help menu image
			hMenu = GetSubMenu(GetMenu(MainWindow), 5);
			if (hMenu) {
				supSetMenuIcon(hMenu, ID_HELP_HELP,
					(ULONG_PTR)ImageList_ExtractIcon(g_hInstance, ToolBarMenuImages, 3));
			}

		}

		hAccTable = LoadAccelerators(g_hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));

		//create ObjectList columns
		RtlSecureZeroMemory(&col, sizeof(col));
		col.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT | LVCF_WIDTH | LVCF_ORDER | LVCF_IMAGE;
		col.iSubItem = 1;
		col.pszText = L"Name";
		col.fmt = LVCFMT_LEFT | LVCFMT_BITMAP_ON_RIGHT;
		col.iOrder = 0;
		col.iImage = -1;
		if (ListViewImages) {
			col.iImage = ImageList_GetImageCount(ListViewImages) - 1;
		}
		col.cx = 300;
		ListView_InsertColumn(ObjectList, 1, &col);

		col.iSubItem = 2;
		col.pszText = L"Type";
		col.iOrder = 1;
		col.iImage = -1;
		col.cx = 100;
		ListView_InsertColumn(ObjectList, 2, &col);

		col.iSubItem = 3;
		col.pszText = L"Additional Information";
		col.iOrder = 2;
		col.iImage = -1;
		col.cx = 170;
		ListView_InsertColumn(ObjectList, 3, &col);

		ListObjectDirectoryTree(L"\\", NULL, NULL);

		TreeView_SelectItem(ObjectTree, TreeView_GetRoot(ObjectTree));
		SetFocus(ObjectTree);

		do {
			rv = GetMessage(&msg1, NULL, 0, 0);

			if (rv == -1)
				break;

			if (MainDlgMsgHandler(msg1)) 
				continue;

			if (IsDialogMessage(MainWindow, &msg1)) {
				TranslateAccelerator(MainWindow, hAccTable, &msg1);
				continue;
			}

			TranslateMessage(&msg1);
			DispatchMessage(&msg1);
		} while (rv != 0);

	} while (cond);

	if (class_atom != 0)
		UnregisterClass(MAKEINTATOM(class_atom), g_hInstance);

	//do not move anywhere
	
	supShutdown();

#ifdef _DEBUG
	if (hObject) NtClose(hObject);

	if (g_hMutex != NULL) {
		CloseHandle(g_hMutex);
	}
	if (g_hNamespace != NULL) {
		ClosePrivateNamespace(g_hNamespace, PRIVATE_NAMESPACE_FLAG_DESTROY);
	}

#endif
}
コード例 #14
0
ファイル: ex_menubar.c プロジェクト: clonly/mctrl
/* Create the menubar control */
static void
CreateMenuBar(HWND hWnd)
{
    REBARBANDINFO band = {0};
    SIZE szIdeal;
    DWORD dwBtnSize;
    HWND hwndToolbar;
    HIMAGELIST hImgList;
    int i;

    /* Create ReBar window */
    hwndRebar = CreateWindowEx(WS_EX_TOOLWINDOW, _T("ReBarWindow32"), _T(""),
            WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_BORDER |
            CCS_NODIVIDER | CCS_TOP | RBS_VARHEIGHT | RBS_BANDBORDERS | RBS_AUTOSIZE,
            0, 0, 0, 0, hWnd, (HMENU) 1000, hInst, NULL);

    /* Create the menubar control */
    hwndMenubar = CreateWindow(MC_WC_MENUBAR, _T(""), WS_CHILD | WS_VISIBLE |
            WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NORESIZE | CCS_NOPARENTALIGN,
            0, 0, 0, 0, hwndRebar, (HMENU) 1001, hInst, (LPVOID) hMenu);
    SendMessage(hwndMenubar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_HIDECLIPPEDBUTTONS);
    SendMessage(hwndMenubar, TB_GETIDEALSIZE, FALSE, (LPARAM) &szIdeal);

    /* Embed the menubar in the ReBar */
    band.cbSize = sizeof(REBARBANDINFO);
    band.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_ID;
    band.fStyle = RBBS_GRIPPERALWAYS | RBBS_TOPALIGN | RBBS_USECHEVRON | RBBS_VARIABLEHEIGHT;
    band.hwndChild = hwndMenubar;
    dwBtnSize = (DWORD)SendMessage(band.hwndChild, TB_GETBUTTONSIZE, 0,0);
    band.cyChild = HIWORD(dwBtnSize);
    band.cxMinChild = 0;
    band.cyMinChild = HIWORD(dwBtnSize);
    band.cyMaxChild = HIWORD(dwBtnSize);
    band.cyIntegral = HIWORD(dwBtnSize);
    band.cx = 240;
    band.cxIdeal = szIdeal.cx;
    band.wID = BAND_MENUBAR;
    SendMessage(hwndRebar, RB_INSERTBAND, -1, (LPARAM) &band);

    /* Create yet another ReBar band with a dummy toolbar, so user can play by
     * positioning the two bands. */
    hwndToolbar = CreateWindow(TOOLBARCLASSNAME, _T(""), WS_CHILD | WS_VISIBLE |
            WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NORESIZE | CCS_NOPARENTALIGN |
            CCS_NODIVIDER | TBSTYLE_TRANSPARENT | TBSTYLE_FLAT,
            0, 0, 0, 0, hwndRebar, (HMENU) 1002, hInst, 0);
    hImgList = ImageList_LoadImage(hInst, MAKEINTRESOURCE(ID_IMGLIST),
                    16, 1, RGB(255,0,255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
    SendMessage(hwndToolbar, TB_SETIMAGELIST, 0, (LPARAM) hImgList);
    for(i = 0; i < 6; i++) {
        TBBUTTON button = { 0 };
        button.iBitmap = i;
        button.idCommand = 300 + i;
        button.fsState = TBSTATE_ENABLED;
        SendMessage(hwndToolbar, TB_ADDBUTTONS, 1, (LPARAM) &button);
    }

    /* Embed the toolbar in the ReBar */
    band.hwndChild = hwndToolbar;
    dwBtnSize = (DWORD)SendMessage(band.hwndChild, TB_GETBUTTONSIZE, 0,0);
    band.cyChild = HIWORD(dwBtnSize);
    band.cxMinChild = 6 * LOWORD(dwBtnSize);
    band.cyMinChild = HIWORD(dwBtnSize);
    band.cyMaxChild = HIWORD(dwBtnSize);
    band.cyIntegral = HIWORD(dwBtnSize);
    band.cx = 16 * LOWORD(dwBtnSize);
    band.wID = BAND_TOOLBAR;
    SendMessage(hwndRebar, RB_INSERTBAND, -1, (LPARAM) &band);
}
コード例 #15
0
ファイル: bcpview.c プロジェクト: AdrienTD/wktools
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	TVINSERTSTRUCT tins; HTREEITEM hti; RECT rect; int i; char *s, *s2; SYSTEMTIME t;
	switch(uMsg)
	{
		case WM_CREATE:
			hstatus = CreateWindowEx(0, STATUSCLASSNAME, "Click on File then on Open... to open a file.", WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hWnd, (HMENU)1000, hinst, 0);
			GetClientRect(hstatus, &rect);
			statusheight = rect.bottom;
			GetClientRect(hWnd, &rect);
			htree = CreateWindowEx(0, WC_TREEVIEW, "Tree View", WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS,
					0, 0, rect.right, rect.bottom-statusheight, hWnd, NULL, hinst, NULL);
			himl = ImageList_LoadImage(hinst, MAKEINTRESOURCE(IDB_ICONS), 16, 5, 0xFF00FF, IMAGE_BITMAP, LR_CREATEDIBSECTION);
			TreeView_SetImageList(htree, himl, TVSIL_NORMAL);
			break;
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case IDM_OPEN:
					if(GetOpenFileName(&ofn))
						LoadBCP(ofnname);
					break;
				case IDM_CLOSE:
					CloseBCP(); break;
				case IDM_EXTRACTALL:
					i = MessageBox(hwnd, "Are you sure you want to extract all the files from this archive to the bcpxtract directory?\nThis can take a lot of time depending on the size of the archive.", title, 48 | MB_YESNO);
					if(i == IDYES)
					{
						ExtractAll();
						MessageBox(hwnd, "All files were extracted to the bcpxtract directory.", title, 64);
					}
					break;
				case IDM_ABOUT:
					MessageBox(hWnd, "BCP Viewer\nVersion: " VERSION "\n(C) 2015-2017 AdrienTD\nLicensed under the MIT license.", title, 64); break;
				case IDM_QUIT:
					DestroyWindow(hWnd); break;
			} break;
		case WM_NOTIFY:
			switch(((LPNMHDR)lParam)->code)
			{
				case NM_DBLCLK:
					if(((LPNMHDR)lParam)->hwndFrom == htree)
					{
						fti.mask = TVIF_PARAM | TVIF_TEXT;
						fti.hItem = TreeView_GetSelection(htree);
						if(!fti.hItem) break;
						fti.pszText = cfname; fti.cchTextMax = 255;
						TreeView_GetItem(htree, &fti);
						if(fti.lParam == -1) break;
						ExtractFile(fti.lParam, fti.pszText);
						MessageBox(hWnd, "File extracted!", title, 64);
					}
					break;
				case TVN_SELCHANGED:
					if(((LPNMHDR)lParam)->hwndFrom == htree)
					{
						i = ((LPNMTREEVIEW)lParam)->itemNew.lParam;
						if(i == -1) {SetWindowText(hstatus, "Directory"); break;}
						FileTimeToSystemTime(&(fetime[i]), &t);
						s = malloc(256); s2 = malloc(256); s[255] = s2[255] = 0;
						GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &t, NULL, s, 255);
						GetTimeFormat(LOCALE_USER_DEFAULT, 0, &t, NULL, s2, 255);
						_snprintf(ubuf, 256, "Offset: 0x%08X, Archived size: %u, Uncompressed size: %u, Format: %u, Date: %s, Time: %s", fent[i].offset, fent[i].endos - fent[i].offset, fent[i].size, fent[i].form, s, s2);
						SetWindowText(hstatus, ubuf);
						free(s); free(s2);
					}
					break;
				case NM_RCLICK:
					if(((LPNMHDR)lParam)->hwndFrom == htree)
					{
						hti = TreeView_GetSelection(htree);
						if(!hti) break;
						s = GetItemPath(hti);
						if(s) CopyText(s);
					}
					break;
			}
			break;
#ifdef VIP_SHORTCUT
		case WM_CHAR:
			if(tolower(wParam) == 'l')
				LoadBCP("C:\\Program Files (x86)\\Empire Interactive\\Warrior Kings - Battles\\data_o.bcp");
			if(tolower(wParam) == 'x')
				ExtractAll();
			break;
#endif
		case WM_SIZE:
			MoveWindow(htree, 0, 0, LOWORD(lParam), HIWORD(lParam)-statusheight, FALSE);
			SendMessage(hstatus, WM_SIZE, 0, 0);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
		default:
			return DefWindowProc(hWnd, uMsg, wParam, lParam);
	}
	return 0;
}
コード例 #16
0
ファイル: Searchbar.c プロジェクト: HTshandou/HexEdit
HWND CreateSearchBar(HWND hwndParent)
{
	HWND hwndPanel;
	HWND hwndTB1;
	HWND hwndTB2;
	HWND hwndTB3;
	HWND hwndTB4;
	HWND hwndCombo1;
	HWND hwndCombo2;

	int tbheight;

	HIMAGELIST hImgList;
	COMBOBOXEXITEM cbxi = { CBEIF_IMAGE|CBEIF_SELECTEDIMAGE|CBEIF_TEXT };

	//
	//	Create the base tool panel
	//
	hwndPanel = ToolPanel_Create(hwndParent, oof);
	
//ToolPanel_AddGripper(hwndPanel);

	//
	//	Create the 3rd toolbar (search buttons)
	//
	hwndTB3   = CreateEmptyToolbar(hwndPanel, IDB_BITMAP3, 15, 668, TBSTYLE_LIST|TBSTYLE_TRANSPARENT);
	SendMessage(hwndTB3, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS|TBSTYLE_EX_DRAWDDARROWS );
	SendMessage(hwndTB3, TB_SETBUTTONSIZE, 0, MAKELPARAM(32, 42));
	//AddButton(hwndTB3, IDM_FILE_OPEN, 8,   TBSTYLE_BUTTON|TBSTYLE_DROPDOWN , TEXT("Ascii"));
	AddButton(hwndTB3, IDM_FILE_NEW, 5,  TBSTYLE_BUTTON, TEXT("Prev"));	
	AddButton(hwndTB3, IDM_FILE_SAVE, 2,   TBSTYLE_BUTTON , TEXT("Next"));// »"));
	ResizeToolbar(hwndTB3);

	ToolPanel_AddItem(hwndPanel, hwndTB3, 0);

	//
	//	Create the search combobox
	//
	hwndCombo2 = CreateChild(0, WS_TABSTOP|WS_CHILD|WS_VISIBLE|CBS_DROPDOWN, TEXT("ComboBoxEx32"), hwndPanel, 6666);
	
	// meh
	hImgList = ImageList_LoadImage(GetModuleHandle(0),
		MAKEINTRESOURCE(IDB_BITMAP7), 16, 10, RGB(255,0,255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
	//SendMessage(hwndCombo2, CBEM_SETIMAGELIST, 0, (LPARAM)hImgList);

	cbxi.iImage = 8;
	cbxi.iSelectedImage = 8;
	cbxi.iItem = 0;
	cbxi.pszText = TEXT("Hello World");
	cbxi.cchTextMax = 10;

	//iSelectedImage
	//SendMessage(hwndCombo2, CBEM_SETITEM, 0, (LPARAM)&cbxi);
	//SendMessage(hwndCombo2, CBEM_INSERTITEM, 0, (LPARAM)&cbxi);



	SetWindowSize(hwndCombo2, 200, 200, NULL);
	ToolPanel_AddItem(hwndPanel, hwndCombo2, 0);

	//
	//	Create the 'type' button
	//
	hwndTB4 = CreateEmptyToolbar(hwndPanel, IDB_BITMAP4, 16, 668, TBSTYLE_LIST);
	SendMessage(hwndTB4, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS|TBSTYLE_EX_DRAWDDARROWS );
	AddButton(hwndTB4, IDM_FILE_OPEN, 8,   TBSTYLE_BUTTON|TBSTYLE_DROPDOWN , TEXT("Ascii"));
	tbheight = ResizeToolbar(hwndTB4);
	ToolPanel_AddItem(hwndPanel, hwndTB4, 0);



	//
	//	Create the 1st toolbar (the "Goto" button)
	//
	ToolPanel_AddGripper(hwndPanel);

	hwndTB1   = CreateEmptyToolbar(hwndPanel, IDB_BITMAP3, 15, 666, TBSTYLE_LIST);
	SendMessage(hwndTB1, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS|TBSTYLE_EX_DRAWDDARROWS);

	GetWindowWidth(hwndTB1);
	AddButton(hwndTB1, -0, 3, TBSTYLE_BUTTON, TEXT("Goto »"));
	GetWindowWidth(hwndTB1);
	ResizeToolbar(hwndTB1);
	GetWindowWidth(hwndTB1);
	ToolPanel_AddItem(hwndPanel, hwndTB1, 0);

	//
	//	Create the goto-combo box
	//

	//hwndCombo1 = CreateChild(0, WS_CHILD|WS_VISIBLE|CBS_DROPDOWN, "COMBOBOX", hwndPanel);
	hwndCombo1 = CreateChild(0, WS_TABSTOP|WS_CHILD|WS_VISIBLE|CBS_DROPDOWN, TEXT("ComboBoxEx32"), hwndPanel, 0);
	SetWindowSize(hwndCombo1, 100, 200, NULL);
	ToolPanel_AddItem(hwndPanel, hwndCombo1, 0);

	//
	//	Create the 2nd toolbar (bookmark buttons)
	//
	hwndTB2   = CreateEmptyToolbar(hwndPanel, IDB_BITMAP2, 15, 667, TBSTYLE_LIST);
	SendMessage(hwndTB2, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS|TBSTYLE_EX_DRAWDDARROWS);
	//SendMessage(hwndTB1, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
	SendMessage(hwndTB2, TB_SETBUTTONSIZE, 0, MAKELPARAM(32, 32));
	AddButton(hwndTB2, IDM_SEARCH_REPLACE, 7, TBSTYLE_DROPDOWN|TBSTYLE_BUTTON|TBSTYLE_CHECK, 0);//TEXT("Highlight"));
	ResizeToolbar(hwndTB2);
	AddButton(hwndTB2, 0, 1, TBSTYLE_BUTTON, TEXT("Bookmark"));
	

	ToolPanel_AddItem(hwndPanel, hwndTB2, 0);
	ToolPanel_AddNewLine(hwndPanel, 0);

	ToolPanel_AutoSize(hwndPanel);

	ShowWindow(hwndPanel, SW_SHOW);

	return hwndPanel;
}
コード例 #17
0
ファイル: main.c プロジェクト: songbei6/WinObjEx64
/*
* WinObjExMain
*
* Purpose:
*
* Actual program entry point.
*
*/
void WinObjExMain()
{
    MSG                     msg1;
    WNDCLASSEX              wincls;
    BOOL                    IsFullAdmin = FALSE, IsWine = FALSE, rv = TRUE, cond = FALSE;
    ATOM                    class_atom = 0;
    INITCOMMONCONTROLSEX    icc;   
    LVCOLUMN                col;
    SHSTOCKICONINFO         sii;
    HMENU                   hMenu;
    HACCEL                  hAccTable = 0;
    WCHAR                   szWindowTitle[100];
    HANDLE                  hIcon;
    HIMAGELIST              TreeViewImages;

    if (!WinObjInitGlobals())
        return;

    // do not move anywhere
    IsFullAdmin = supUserIsFullAdmin();

    // check compatibility
    IsWine = supIsWine();
    if (IsWine != FALSE) {
        IsFullAdmin = FALSE;
    }

    supInit(IsFullAdmin, IsWine);

    // do not move anywhere
    // g_kdctx variable initialized BEFORE this.
    // if you move these lines anywhere above they will be zeroed during kdInit
    g_kdctx.IsWine = IsWine;
    g_kdctx.IsFullAdmin = IsFullAdmin;

#ifdef _DEBUG
    TestStart();
#endif

    do {
        //
        // Create main window and it components.
        //
        wincls.cbSize = sizeof(WNDCLASSEX);
        wincls.style = 0;
        wincls.lpfnWndProc = &MainWindowProc;
        wincls.cbClsExtra = 0;
        wincls.cbWndExtra = 0;
        wincls.hInstance = g_WinObj.hInstance;
        wincls.hIcon = (HICON)LoadImage(g_WinObj.hInstance, MAKEINTRESOURCE(IDI_ICON_MAIN), IMAGE_ICON, 0, 0, LR_SHARED);
        wincls.hCursor = (HCURSOR)LoadImage(NULL, MAKEINTRESOURCE(OCR_SIZEWE), IMAGE_CURSOR, 0, 0, LR_SHARED);
        wincls.hbrBackground = NULL;
        wincls.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
        wincls.lpszClassName = MAINWINDOWCLASSNAME;
        wincls.hIconSm = 0;

        class_atom = RegisterClassEx(&wincls);
        if (class_atom == 0)
            break;
        
        RtlSecureZeroMemory(szWindowTitle, sizeof(szWindowTitle));
        _strcpy(szWindowTitle, PROGRAM_NAME);
        if (IsFullAdmin != FALSE) {
            _strcat(szWindowTitle, L" (Administrator)");
        }

        if (IsWine != FALSE) {
            _strcat(szWindowTitle, L" (Wine emulation)");
        }

        MainWindow = CreateWindowEx(0, MAKEINTATOM(class_atom), szWindowTitle,
            WS_VISIBLE | WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, g_WinObj.hInstance, NULL);
        if (MainWindow == NULL)
            break;

        icc.dwSize = sizeof(icc);
        icc.dwICC = ICC_LISTVIEW_CLASSES | ICC_TREEVIEW_CLASSES | ICC_BAR_CLASSES | ICC_TAB_CLASSES;
        if (!InitCommonControlsEx(&icc))
            break;

        hwndStatusBar = CreateWindowEx(0, STATUSCLASSNAME, NULL,
            WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, MainWindow, NULL, g_WinObj.hInstance, NULL);

        g_hwndObjectTree = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL,
            WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_DISABLEDRAGDROP | TVS_HASBUTTONS |
            TVS_HASLINES | TVS_LINESATROOT, 0, 0, 0, 0, MainWindow, (HMENU)1002, g_WinObj.hInstance, NULL);

        if (g_hwndObjectTree == NULL)
            break;

        g_hwndObjectList = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL,
            WS_VISIBLE | WS_CHILD | WS_TABSTOP | LVS_AUTOARRANGE | LVS_REPORT |
            LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_SHAREIMAGELISTS, 0, 0, 0, 0,
            MainWindow, (HMENU)1003, g_WinObj.hInstance, NULL);

        if (g_hwndObjectList == NULL)
            break;

        hwndToolBar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
            WS_VISIBLE | WS_CHILD | CCS_TOP | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT |
            TBSTYLE_TOOLTIPS, 0, 0, 0, 0, MainWindow, (HMENU)1004, g_WinObj.hInstance, NULL);

        if (hwndToolBar == NULL)
            break;

        hwndSplitter = CreateWindowEx(0, WC_STATIC, NULL,
            WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, MainWindow, (HMENU)1005, g_WinObj.hInstance, NULL);

        // initialization of views
        SendMessage(MainWindow, WM_SIZE, 0, 0);
        ListView_SetExtendedListViewStyle(g_hwndObjectList,
            LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_DOUBLEBUFFER);

        // set tree imagelist
        TreeViewImages = supLoadImageList(g_WinObj.hInstance, IDI_ICON_VIEW_DEFAULT, IDI_ICON_VIEW_SELECTED);
        if (TreeViewImages) {
            TreeView_SetImageList(g_hwndObjectTree, TreeViewImages, TVSIL_NORMAL);
        }

        //not enough user rights, insert run as admin menu entry and hide admin only stuff
        if ((IsFullAdmin == FALSE) && (g_kdctx.IsWine == FALSE)) {
            hMenu = GetSubMenu(GetMenu(MainWindow), 0);
            InsertMenu(hMenu, 0, MF_BYPOSITION, ID_FILE_RUNASADMIN, T_RUNASADMIN);
            InsertMenu(hMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
            //set menu shield icon
            RtlSecureZeroMemory(&sii, sizeof(sii));
            sii.cbSize = sizeof(sii);
            if (SHGetStockIconInfo(SIID_SHIELD, SHGSI_ICON | SHGFI_SMALLICON, &sii) == S_OK) {
                supSetMenuIcon(hMenu, ID_FILE_RUNASADMIN, (ULONG_PTR)sii.hIcon);
            }
        }

        if (g_kdctx.hDevice == NULL) {
            //require driver usage, remove
            DeleteMenu(GetSubMenu(GetMenu(MainWindow), 4), ID_EXTRAS_SSDT, MF_BYCOMMAND);
            DeleteMenu(GetSubMenu(GetMenu(MainWindow), 4), ID_EXTRAS_PRIVATENAMESPACES, MF_BYCOMMAND);
        }

        //unsupported
        if (g_WinObj.osver.dwBuildNumber > 10240) {
            DeleteMenu(GetSubMenu(GetMenu(MainWindow), 4), ID_EXTRAS_PRIVATENAMESPACES, MF_BYCOMMAND);
        }

        //wine unsupported
        if (g_kdctx.IsWine != FALSE) {
            DeleteMenu(GetSubMenu(GetMenu(MainWindow), 4), ID_EXTRAS_DRIVERS, MF_BYCOMMAND);
        }

        //load listview images
        g_ListViewImages = supLoadImageList(g_WinObj.hInstance, IDI_ICON_DEVICE, IDI_ICON_UNKNOWN);
        if (g_ListViewImages) {
            hIcon = LoadImage(g_WinObj.hInstance, MAKEINTRESOURCE(IDI_ICON_SORTUP), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
            if (hIcon) {
                ImageList_ReplaceIcon(g_ListViewImages, -1, hIcon);
                DestroyIcon(hIcon);
            }
            hIcon = LoadImage(g_WinObj.hInstance, MAKEINTRESOURCE(IDI_ICON_SORTDOWN), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
            if (hIcon) {
                ImageList_ReplaceIcon(g_ListViewImages, -1, hIcon);
                DestroyIcon(hIcon);
            }
            ListView_SetImageList(g_hwndObjectList, g_ListViewImages, LVSIL_SMALL);
        }

        //load toolbar images
        g_ToolBarMenuImages = ImageList_LoadImage(g_WinObj.hInstance, MAKEINTRESOURCE(IDB_BITMAP1),
            16, 7, CLR_DEFAULT, IMAGE_BITMAP, LR_CREATEDIBSECTION);

        if (g_ToolBarMenuImages) {

            supCreateToolbarButtons(hwndToolBar);

            //set menu icons
            hMenu = GetSubMenu(GetMenu(MainWindow), 1);
            if (hMenu) {
                supSetMenuIcon(hMenu, ID_VIEW_REFRESH,
                    (ULONG_PTR)ImageList_ExtractIcon(g_WinObj.hInstance, g_ToolBarMenuImages, 1));
            }
            hMenu = GetSubMenu(GetMenu(MainWindow), 2);
            if (hMenu && g_ListViewImages) {
                supSetMenuIcon(hMenu, ID_OBJECT_PROPERTIES,
                    (ULONG_PTR)ImageList_ExtractIcon(g_WinObj.hInstance, g_ToolBarMenuImages, 0));
                supSetMenuIcon(hMenu, ID_OBJECT_GOTOLINKTARGET,
                    (ULONG_PTR)ImageList_ExtractIcon(g_WinObj.hInstance, g_ListViewImages,
                        ID_FROM_VALUE(IDI_ICON_SYMLINK)));
            }

            //set object -> find object menu image
            hMenu = GetSubMenu(GetMenu(MainWindow), 3);
            if (hMenu) {
                supSetMenuIcon(hMenu, ID_FIND_FINDOBJECT,
                    (ULONG_PTR)ImageList_ExtractIcon(g_WinObj.hInstance, g_ToolBarMenuImages, 2));
            }

            //set extras-mailslots/pipes menu image
            hMenu = GetSubMenu(GetMenu(MainWindow), 4);
            if (hMenu) {
                supSetMenuIcon(hMenu, ID_EXTRAS_MAILSLOTS,
                    (ULONG_PTR)ImageList_ExtractIcon(g_WinObj.hInstance, g_ToolBarMenuImages, 5));
                supSetMenuIcon(hMenu, ID_EXTRAS_PIPES,
                    (ULONG_PTR)ImageList_ExtractIcon(g_WinObj.hInstance, g_ToolBarMenuImages, 6));
            }

            //set help menu image
            hMenu = GetSubMenu(GetMenu(MainWindow), 5);
            if (hMenu) {
                supSetMenuIcon(hMenu, ID_HELP_HELP,
                    (ULONG_PTR)ImageList_ExtractIcon(g_WinObj.hInstance, g_ToolBarMenuImages, 3));
            }

        }

        hAccTable = LoadAccelerators(g_WinObj.hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));

        //create ObjectList columns
        RtlSecureZeroMemory(&col, sizeof(col));
        col.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT | LVCF_WIDTH | LVCF_ORDER | LVCF_IMAGE;
        col.iSubItem = 1;
        col.pszText = TEXT("Name");
        col.fmt = LVCFMT_LEFT | LVCFMT_BITMAP_ON_RIGHT;
        col.iOrder = 0;
        col.iImage = -1;
        if (g_ListViewImages) {
            col.iImage = ImageList_GetImageCount(g_ListViewImages) - 1;
        }
        col.cx = 300;
        ListView_InsertColumn(g_hwndObjectList, 1, &col);

        col.iSubItem = 2;
        col.pszText = TEXT("Type");
        col.iOrder = 1;
        col.iImage = -1;
        col.cx = 100;
        ListView_InsertColumn(g_hwndObjectList, 2, &col);

        col.iSubItem = 3;
        col.pszText = TEXT("Additional Information");
        col.iOrder = 2;
        col.iImage = -1;
        col.cx = 170;
        ListView_InsertColumn(g_hwndObjectList, 3, &col);

        ListObjectDirectoryTree(L"\\", NULL, NULL);

        TreeView_SelectItem(g_hwndObjectTree, TreeView_GetRoot(g_hwndObjectTree));
        SetFocus(g_hwndObjectTree);

        do {
            rv = GetMessage(&msg1, NULL, 0, 0);

            if (rv == -1)
                break;

            if (MainDlgMsgHandler(msg1))
                continue;

            if (IsDialogMessage(MainWindow, &msg1)) {
                TranslateAccelerator(MainWindow, hAccTable, &msg1);
                continue;
            }

            TranslateMessage(&msg1);
            DispatchMessage(&msg1);
        } while (rv != 0);

    } while (cond);

    if (class_atom != 0)
        UnregisterClass(MAKEINTATOM(class_atom), g_WinObj.hInstance);

    //do not move anywhere

    supShutdown();

#ifdef _DEBUG
    TestStop();
#endif

}
コード例 #18
0
ファイル: rebar.c プロジェクト: WASSUM/longene_travel
static void layout_test(void)
{
    HWND hRebar = NULL;
    REBARBANDINFO rbi;
    HIMAGELIST himl;
    REBARINFO ri;

    rebuild_rebar(&hRebar);
    check_sizes();
    rbi.cbSize = sizeof(rbi);
    rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
    rbi.cx = 200;
    rbi.cxMinChild = 100;
    rbi.cyMinChild = 30;
    rbi.hwndChild = NULL;
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    rbi.fMask |= RBBIM_STYLE;
    rbi.fStyle = RBBS_CHILDEDGE;
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    rbi.fStyle = 0;
    rbi.cx = 200;
    rbi.cxMinChild = 30;
    rbi.cyMinChild = 30;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    rbi.fStyle = RBBS_CHILDEDGE;
    rbi.cx = 68;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    SetWindowLong(hRebar, GWL_STYLE, GetWindowLong(hRebar, GWL_STYLE) | RBS_BANDBORDERS);
    check_sizes();      /* a style change won't start a relayout */
    rbi.fMask = RBBIM_SIZE;
    rbi.cx = 66;
    SendMessageA(hRebar, RB_SETBANDINFO, 3, (LPARAM)&rbi);
    check_sizes();      /* here it will be relayouted */

    /* this will force a new row */
    rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
    rbi.cx = 200;
    rbi.cxMinChild = 400;
    rbi.cyMinChild = 30;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, 1, (LPARAM)&rbi);
    check_sizes();

    rbi.fMask = RBBIM_STYLE;
    rbi.fStyle = RBBS_HIDDEN;
    SendMessageA(hRebar, RB_SETBANDINFO, 2, (LPARAM)&rbi);
    check_sizes();

    SendMessageA(hRebar, RB_DELETEBAND, 2, 0);
    check_sizes();
    SendMessageA(hRebar, RB_DELETEBAND, 0, 0);
    check_sizes();
    SendMessageA(hRebar, RB_DELETEBAND, 1, 0);
    check_sizes();

    rebuild_rebar(&hRebar);
    add_band_w(hRebar, "ABC",     70,  40, 100);
    add_band_w(hRebar, NULL,      40,  70, 100);
    add_band_w(hRebar, NULL,     170, 240, 100);
    add_band_w(hRebar, "MMMMMMM", 60,  60, 100);
    add_band_w(hRebar, NULL,     200, 200, 100);
    check_sizes();
    SendMessageA(hRebar, RB_MAXIMIZEBAND, 1, TRUE);
    check_sizes();
    SendMessageA(hRebar, RB_MAXIMIZEBAND, 1, TRUE);
    check_sizes();
    SendMessageA(hRebar, RB_MAXIMIZEBAND, 2, FALSE);
    check_sizes();
    SendMessageA(hRebar, RB_MINIMIZEBAND, 2, 0);
    check_sizes();
    SendMessageA(hRebar, RB_MINIMIZEBAND, 0, 0);
    check_sizes();

    /* an image will increase the band height */
    himl = ImageList_LoadImage(LoadLibrary("comctl32"), MAKEINTRESOURCE(121), 24, 2, CLR_NONE, IMAGE_BITMAP, LR_DEFAULTCOLOR);
    ri.cbSize = sizeof(ri);
    ri.fMask = RBIM_IMAGELIST;
    ri.himl = himl;
    ok(SendMessage(hRebar, RB_SETBARINFO, 0, (LPARAM)&ri), "RB_SETBARINFO failed\n");
    rbi.fMask = RBBIM_IMAGE;
    rbi.iImage = 1;
    SendMessage(hRebar, RB_SETBANDINFO, 1, (LPARAM)&rbi);
    check_sizes();

    /* after removing it everything is back to normal*/
    rbi.iImage = -1;
    SendMessage(hRebar, RB_SETBANDINFO, 1, (LPARAM)&rbi);
    check_sizes();

    /* Only -1 means that the image is not present. Other invalid values increase the height */
    rbi.iImage = -2;
    SendMessage(hRebar, RB_SETBANDINFO, 1, (LPARAM)&rbi);
    check_sizes();

    /* VARHEIGHT resizing test on a horizontal rebar */
    rebuild_rebar(&hRebar);
    SetWindowLong(hRebar, GWL_STYLE, GetWindowLong(hRebar, GWL_STYLE) | RBS_AUTOSIZE);
    check_sizes();
    rbi.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE;
    rbi.fStyle = RBBS_VARIABLEHEIGHT;
    rbi.cxMinChild = 50;
    rbi.cyMinChild = 10;
    rbi.cyIntegral = 11;
    rbi.cyChild = 70;
    rbi.cyMaxChild = 200;
    rbi.cx = 90;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);

    rbi.cyChild = 50;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);

    rbi.cyMinChild = 40;
    rbi.cyChild = 50;
    rbi.cyIntegral = 5;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    /* VARHEIGHT resizing on a vertical rebar */
    rebuild_rebar(&hRebar);
    SetWindowLong(hRebar, GWL_STYLE, GetWindowLong(hRebar, GWL_STYLE) | CCS_VERT | RBS_AUTOSIZE);
    check_sizes();
    rbi.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE;
    rbi.fStyle = RBBS_VARIABLEHEIGHT;
    rbi.cxMinChild = 50;
    rbi.cyMinChild = 10;
    rbi.cyIntegral = 11;
    rbi.cyChild = 70;
    rbi.cyMaxChild = 90;
    rbi.cx = 90;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    rbi.cyChild = 50;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    rbi.cyMinChild = 40;
    rbi.cyChild = 50;
    rbi.cyIntegral = 5;
    rbi.hwndChild = build_toolbar(0, hRebar);
    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
    check_sizes();

    DestroyWindow(hRebar);
}
コード例 #19
0
ファイル: toolbar.cpp プロジェクト: kichik/nsis-1
void CreateToolBar()
{
  static TBBUTTON tbButton[BUTTONCOUNT];
  tbButton[TBB_LOADSCRIPT]  = CreateToolBarButton(IDB_LOADSCRIPT,    IDM_LOADSCRIPT, TBSTATE_ENABLED,        TBSTYLE_BUTTON,   0, 0);
  tbButton[TBB_SAVE]        = CreateToolBarButton(IDB_SAVE,          IDM_SAVE,       TBSTATE_ENABLED,        TBSTYLE_BUTTON,   0, 0);
  tbButton[TBB_SEP1]        = CreateToolBarButton(0,                 0,              TBSTATE_ENABLED,        TBSTYLE_SEP,      0, 0);
  tbButton[TBB_COPY]        = CreateToolBarButton(IDB_COPY,          IDM_COPY,       TBSTATE_INDETERMINATE,  TBSTYLE_BUTTON,   0, 0);
  tbButton[TBB_FIND]        = CreateToolBarButton(IDB_FIND,          IDM_FIND,       TBSTATE_ENABLED,        TBSTYLE_BUTTON,   0, 0);
  tbButton[TBB_CLEARLOG]    = CreateToolBarButton(IDB_CLEARLOG,      IDM_CLEARLOG,   TBSTATE_ENABLED,        TBSTYLE_BUTTON,   0, 0);
  tbButton[TBB_SEP2]        = CreateToolBarButton(0,                 0,              TBSTATE_ENABLED,        TBSTYLE_SEP,      0, 0);
  tbButton[TBB_RECOMPILE]   = CreateToolBarButton(IDB_RECOMPILE,     IDM_RECOMPILE,  TBSTATE_INDETERMINATE,  TBSTYLE_BUTTON,   0, 0);
  tbButton[TBB_COMPRESSOR]  = CreateToolBarButton(IDB_COMPRESSOR,    IDM_COMPRESSOR, TBSTATE_ENABLED,        TBSTYLE_DROPDOWN, 0, 0);
  tbButton[TBB_TEST]        = CreateToolBarButton(IDB_TEST,          IDM_TEST,       TBSTATE_INDETERMINATE,  TBSTYLE_BUTTON,   0, 0);
  tbButton[TBB_EDITSCRIPT]  = CreateToolBarButton(IDB_EDITSCRIPT,    IDM_EDITSCRIPT, TBSTATE_INDETERMINATE,  TBSTYLE_BUTTON,   0, 0);
  tbButton[TBB_BROWSESCR]   = CreateToolBarButton(IDB_BROWSESCR,     IDM_BROWSESCR,  TBSTATE_INDETERMINATE,  TBSTYLE_BUTTON,   0, 0);
  tbButton[TBB_SEP3]        = CreateToolBarButton(0,                 0,              TBSTATE_ENABLED,        TBSTYLE_SEP,      0, 0);
  tbButton[TBB_NSISHOME]    = CreateToolBarButton(IDB_NSISHOME,      IDM_NSISHOME,   TBSTATE_ENABLED,        TBSTYLE_BUTTON,   0, 0);
  tbButton[TBB_DOCS]        = CreateToolBarButton(IDB_DOCS,          IDM_DOCS,       TBSTATE_ENABLED,        TBSTYLE_BUTTON,   0, 0);

  g_toolbar.hwnd = CreateWindowEx (
    0L,
    TOOLBARCLASSNAME,
    _T(""),
    WS_CHILD | WS_VISIBLE | TBSTYLE_TRANSPARENT | TBSTYLE_FLAT,
    0, 0, 0, 30,
    g_sdata.hwnd,
    (HMENU) TOOLBAR_ID,
    g_sdata.hInstance,
    NULL );
  
  SendMessage(g_toolbar.hwnd, TB_BUTTONSTRUCTSIZE, sizeof(tbButton[0]), 0);
  SendMessage(g_toolbar.hwnd, TB_ADDBUTTONS, BUTTONCOUNT, (LONG) &tbButton);

  // For Comctl32.dll version detection
  HMODULE hMod = GetModuleHandle(_T("comctl32.dll"));

  if (GetProcAddress(hMod, "InitCommonControlsEx")) { // Version 4.70
    // Modern toolbar, 24-bit bitmaps

    g_toolbar.imagelist = ImageList_LoadImage(g_sdata.hInstance, MAKEINTRESOURCE(IDB_TOOLBAR24), 16, 0, RGB(255, 0, 255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
    g_toolbar.imagelistd = ImageList_LoadImage(g_sdata.hInstance, MAKEINTRESOURCE(IDB_TOOLBAR24D), 16, 0, RGB(255, 0, 255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
    g_toolbar.imagelisth = ImageList_LoadImage(g_sdata.hInstance, MAKEINTRESOURCE(IDB_TOOLBAR24H),  16, 0, RGB(255, 0, 255), IMAGE_BITMAP, LR_CREATEDIBSECTION);

    SendMessage(g_toolbar.hwnd, TB_SETIMAGELIST, 0, (LPARAM) g_toolbar.imagelist);
    SendMessage(g_toolbar.hwnd, TB_SETDISABLEDIMAGELIST, 0, (LPARAM) g_toolbar.imagelistd);
    SendMessage(g_toolbar.hwnd, TB_SETHOTIMAGELIST, 0, (LPARAM) g_toolbar.imagelisth);

    // Version 4.71
    if (GetProcAddress(hMod, "DllGetVersion")) {
      SendMessage(g_toolbar.hwnd, TB_SETEXTENDEDSTYLE, 0, (LPARAM) (DWORD) TBSTYLE_EX_DRAWDDARROWS);
    }
      
  }
  else
  {
    // Old Windows 95 toolbar, 256 color bitmap with system palette

    TBADDBITMAP tbBitmap;

    tbBitmap.hInst = g_sdata.hInstance;
    tbBitmap.nID = IDB_TOOLBAR;
  
    SendMessage(g_toolbar.hwnd, TB_ADDBITMAP, IMAGECOUNT, (LONG) &tbBitmap);
  }

  HMENU toolmenu = FindSubMenu(g_sdata.menu, IDM_SCRIPT);
  g_toolbar.dropdownmenu = FindSubMenu(toolmenu, IDM_COMPRESSOR_SUBMENU);
  RECT rect;
  SendMessage(g_toolbar.hwnd, TB_GETITEMRECT, TBB_COMPRESSOR, (LPARAM) (LPRECT) &rect);
  g_toolbar.dropdownpoint.x = rect.left;
  g_toolbar.dropdownpoint.y = rect.bottom+1;
}
コード例 #20
0
ファイル: Neatpad.c プロジェクト: MakiseKurisu/Neatpad
//
//	Main window procedure
//
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	int width, height, heightsb;
	HIMAGELIST hImgList;
	RECT rect;
	HDWP hdwp;
	NMHDR *nmhdr;
	TCHAR msgstr[MAX_PATH+200];

	switch(msg)
	{
	case WM_CREATE:
		g_hwndTextView  = CreateTextView(hwnd);
		g_hwndStatusbar = CreateStatusBar(hwnd);

		TextView_SetContextMenu(g_hwndTextView, GetSubMenu(LoadMenu(GetModuleHandle(0),
			MAKEINTRESOURCE(IDR_MENU2)), 0));

		// load the image list
		hImgList = ImageList_LoadImage(
			GetModuleHandle(0), 
			MAKEINTRESOURCE(IDB_BITMAP1), 
			16, 0, 
			RGB(255,0,255),
			IMAGE_BITMAP,
			LR_LOADTRANSPARENT|LR_CREATEDIBSECTION
			);
		
		TextView_SetImageList(g_hwndTextView, hImgList);

		// highlight specific lines with image-index "1"
		//TextView_SetLineImage(g_hwndTextView, 16, 1);
		//TextView_SetLineImage(g_hwndTextView, 5,  1);
		//TextView_SetLineImage(g_hwndTextView, 36, 1);
		//TextView_SetLineImage(g_hwndTextView, 11, 1);

		// tell windows that we can handle drag+drop'd files
		DragAcceptFiles(hwnd, TRUE);
		return 0;

	case WM_DROPFILES:
		HandleDropFiles(hwnd, (HDROP)wParam);
		return 0;

	case WM_DESTROY:
		SaveFileData(g_szFileName, hwnd);
		PostQuitMessage(0);
		DeleteObject(g_hFont);
		return 0;

	//case WM_NCCALCSIZE:
	//	return NcCalcSize(hwnd, wParam, lParam);

	case WM_INITMENU:
		CheckMenuCommand((HMENU)wParam, IDM_VIEW_LINENUMBERS,	g_fLineNumbers);
		CheckMenuCommand((HMENU)wParam, IDM_VIEW_LONGLINES,		g_fLongLines);
		CheckMenuCommand((HMENU)wParam, IDM_VIEW_SAVEEXIT,		g_fSaveOnExit);
		CheckMenuCommand((HMENU)wParam, IDM_VIEW_STATUSBAR,		g_fShowStatusbar);
		//CheckMenuCommand((HMENU)wParam, IDM_VIEW_SEARCHBAR,		g_hwndSearchBar ? TRUE : FALSE);

		EnableMenuCommand((HMENU)wParam, IDM_EDIT_UNDO,		TextView_CanUndo(g_hwndTextView));
		EnableMenuCommand((HMENU)wParam, IDM_EDIT_REDO,		TextView_CanRedo(g_hwndTextView));
		EnableMenuCommand((HMENU)wParam, IDM_EDIT_PASTE,	IsClipboardFormatAvailable(CF_TEXT));
		EnableMenuCommand((HMENU)wParam, IDM_EDIT_COPY,		TextView_GetSelSize(g_hwndTextView));
		EnableMenuCommand((HMENU)wParam, IDM_EDIT_CUT,		TextView_GetSelSize(g_hwndTextView));
		EnableMenuCommand((HMENU)wParam, IDM_EDIT_DELETE,	TextView_GetSelSize(g_hwndTextView));

		return 0;

	//case WM_USER:
	//	wsprintf(msgstr, _T("%s\n\nThis file has been modified outside of Neatpad.")
	//					 _T("Do you wish to reload it?"), g_szFileName);
	//	MessageBox(hwnd, msgstr, _T("Neatpad"), MB_ICONQUESTION|MB_YESNO);
	//
	//	return 0;

	case WM_ENABLE:

		// keep the modeless find/replace dialog in the same enabled state as the main window
		EnableWindow(g_hwndSearchDlg, (BOOL)wParam);
		return 0;

	case WM_MENUSELECT:
		StatusBarMenuSelect(hwnd, g_hwndStatusbar, wParam, lParam);
		return 0;

	case WM_NOTIFY:
		nmhdr = (NMHDR *)lParam;
		
		if(nmhdr->hwndFrom == g_hwndTextView)
			return TextViewNotifyHandler(hwnd, nmhdr);
		else
			return NotifyHandler(hwnd, nmhdr);

	case WM_COMMAND:
		return CommandHandler(hwnd, LOWORD(wParam), HIWORD(wParam), (HWND)lParam);

	case WM_SETFOCUS:
		SetFocus(g_hwndTextView);
		return 0;

	case WM_CLOSE:
		
		// does the file need saving?
		if(TextView_CanUndo(g_hwndTextView))
		{
			UINT r;
			wsprintf(msgstr, _T("Do you want to save changes to\r\n%s?"), g_szFileName);
			r = MessageBox(hwnd, msgstr, APP_TITLE, MB_YESNOCANCEL | MB_ICONQUESTION);

			if(r == IDCANCEL)
				return 0;
		}

		DestroyWindow(hwnd);
		return 0;

	case WM_SIZE:

		// resize the TextView and StatusBar to fit within the main window's client area
		width  = (short)LOWORD(lParam);
		height = (short)HIWORD(lParam);
		
		GetWindowRect(g_hwndStatusbar, &rect);
		heightsb = rect.bottom-rect.top;

		hdwp = BeginDeferWindowPos(3);
		
		if(g_fShowStatusbar)
		{
			DeferWindowPos(hdwp, g_hwndStatusbar, 0, 0, height - heightsb, width, heightsb, SWP_SHOWWINDOW);
		//	MoveWindow(g_hwndStatusbar, 0, height - heightsb, width, heightsb, TRUE);
			height -= heightsb;
		}

		DeferWindowPos(hdwp, g_hwndTextView, 0,  0, 0, width, height, SWP_SHOWWINDOW);
		//MoveWindow(g_hwndTextView, 0, 0, width, height, TRUE);

		EndDeferWindowPos(hdwp);

		SetStatusBarParts(g_hwndStatusbar);

		return 0;

	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
コード例 #21
0
BOOL CFlashPlayerDlg::PreTranslateMessage(MSG* pMsg)
{
	int const wmId = LOWORD(pMsg->wParam);
	if (pMsg->message == s_uTBBC)
	{
		if (!g_pTaskbarList)
		{
			HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&g_pTaskbarList));
			if (SUCCEEDED(hr))
			{
				hr = g_pTaskbarList->HrInit();
				if (FAILED(hr))
				{
					g_pTaskbarList->Release();
					g_pTaskbarList = NULL;
				}

				if(g_pTaskbarList) {
					hImglist = ImageList_LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP_96),
						16, 0, RGB(255,0,255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
					if (hImglist)
					{
						hr = g_pTaskbarList->ThumbBarSetImageList(this->m_hWnd, hImglist);
						if (SUCCEEDED(hr))
						{
							THUMBBUTTON buttons[2] = {};

							buttons[0].dwMask = THB_BITMAP | THB_FLAGS;
							buttons[0].dwFlags = THBF_ENABLED;
							buttons[0].iId = IDTB_PLAY_PAUSE;

							if(IsFlashPlaying())
								buttons[0].iBitmap = 1;
							else
								buttons[0].iBitmap = 0;

							g_pTaskbarList->ThumbBarAddButtons(this->m_hWnd, 1, buttons);
						}
						g_pTaskbarList->SetProgressState(this->m_hWnd, TBPF_NORMAL);
						ImageList_Destroy(hImglist);
					}
				}
			}
		}
	} else if(pMsg->message == WM_COMMAND && (wmId == IDTB_PLAY_PAUSE)) {
		if(IsFlashPlaying())
			pFlashPtr->Stop();
		else
			pFlashPtr->Play();
		UpdateThumbnailToolbar(m_hWnd);
	} else {
		switch(pMsg->message)
		{
		case WM_NCRBUTTONDOWN:
			{
				if(pMsg->wParam == HTMAXBUTTON || pMsg->wParam == HTMINBUTTON || pMsg->wParam == HTCLOSE)
					break;
				m_popmenu.GetSubMenu(0).TrackPopupMenu(TPM_LEFTALIGN, LOWORD(pMsg->lParam), HIWORD(pMsg->lParam), m_hWnd);
				return TRUE;
			}
		case WM_SYSCHAR:
			if (pMsg->wParam == 13)
				FullScreen();
			break;
		case   WM_KEYDOWN:
			SendMessage(CMD_KEYDOWN, CMD_KEY, pMsg->wParam );
			if(pMsg->wParam == 13)
				return TRUE;
			break;
		case   WM_LBUTTONDOWN:
			POINT point;
			GetCursorPos(&point);
			if(m_fs && m_showctrl)
			{
				if(point.y < m_scr_height - 16)
					break;
				if(point.x < 5 || point.x > m_scr_width - 5)
					break;
				m_changing = true;
				double pos = (double)(point.x - 5) / (double) (m_scr_width - 10);
				pFlashPtr->GotoFrame((long)(m_fnumber * pos));
				pFlashPtr->Play();
				m_changing = false;
				return TRUE;
			}
			break;
		case  WM_RBUTTONDOWN:
			if(!m_rmenu)
			{
				SendMessage(CMD_KEYDOWN, CMD_KEY, WM_RBUTTONDOWN );
				return TRUE;
			}
			break;
		case  WM_MOUSEMOVE:
			{
				if(!m_fs)
					break;
				ShowCursor(TRUE);
				SetTimer(TIMER_HIDE_CURSOR, 2000, NULL);
				POINT point;
				GetCursorPos(&point);
				if(!m_showctrl && point.y >= m_scr_height - 20)
				{
					m_control.MoveWindow(0,m_scr_height - 16,m_scr_width,20);
					m_showctrl = true;
				}
				else if(m_showctrl && point.y < m_scr_height - 20)
				{
					m_control.MoveWindow(0,m_scr_height,m_scr_width,20);
					m_showctrl = false;
				}
				break;
			}
		}
	}
	return CWindow::IsDialogMessage(pMsg);
}
コード例 #22
0
ファイル: example-html.c プロジェクト: mity/mctrl
/* Main window procedure */
static LRESULT CALLBACK
WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch(uMsg) {
        case WM_NOTIFY:
            return HandleNotify(hwnd, (NMHDR*) lParam);

        case WM_SIZE:
            if(wParam == SIZE_RESTORED  ||  wParam == SIZE_MAXIMIZED)
                HandleResize(hwnd, LOWORD(lParam), HIWORD(lParam));
            return 0;

        case WM_SETFOCUS:
            SetFocus(hwndHtml);
            return 0;

        case WM_COMMAND:
            switch(LOWORD(wParam)) {
                case IDM_BACK:    SendMessage(hwndHtml, MC_HM_GOBACK, TRUE, 0); break;
                case IDM_FORWARD: SendMessage(hwndHtml, MC_HM_GOBACK, FALSE, 0); break;
            }
            break;

        case WM_CREATE:
        {
            HIMAGELIST tbImgList;
            TBBUTTON tbButtons[2];

            /* Create the html control */
            hwndHtml = CreateWindow(MC_WC_HTML, INITIAL_URL, WS_CHILD | WS_VISIBLE | WS_TABSTOP,
                                    0, 0, 0, 0, hwnd, (HMENU) ID_HTML, hInst, NULL);

            /* Create toolbar control. It provides the 'back' and 'forward'
             * buttons for walking the browser history. */
            hwndToolbar = CreateWindow(TOOLBARCLASSNAME, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE,
                                    0, 0, 0, 0, hwnd, (HMENU) ID_TOOLBAR, hInst, NULL);
            SendMessage(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
            memset(tbButtons, 0, sizeof(tbButtons));
            tbButtons[0].iBitmap = 0;
            tbButtons[0].idCommand = IDM_BACK;
            tbButtons[0].fsStyle = BTNS_BUTTON;
            tbButtons[1].iBitmap = 1;
            tbButtons[1].idCommand = IDM_FORWARD;
            tbButtons[1].fsStyle = BTNS_BUTTON;
            SendMessage(hwndToolbar, TB_ADDBUTTONS, 2, (LPARAM) tbButtons);
            tbImgList = ImageList_LoadImage(hInst, _T("toolbar"), 24, 1, RGB(255,0,255),
                                    IMAGE_BITMAP, LR_CREATEDIBSECTION);
            SendMessage(hwndToolbar, TB_SETIMAGELIST, 0, (LPARAM) tbImgList);

            /* Create status control. We show status info the HTML control
             * sends to us via WM_NOTIFY. */
            hwndStatus = CreateWindow(STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
                                    0, 0, 0, 0, hwnd, (HMENU) ID_STATUS, hInst, NULL);
            return 0;
        }

        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
    }

    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}