Exemplo n.º 1
0
PWBOBJ wbCreateMenu(PWBOBJ pwboParent, PWBITEM pitem[], int nItems)
{
	int i;
	MENUITEMINFO mi;
	PWBOBJ pwbo;
	HMENU hMenu, hPopup = NULL;
	LPCTSTR pszLastPopup = NULL;

	if(!pwboParent || !pwboParent->hwnd || !IsWindow(pwboParent->hwnd))
		return NULL;

	// Start building the menu

	hMenu = CreateMenu();

	for(i = 0; i < nItems; i++) {

		if(!pitem[i]) {

			AppendMenu(hPopup, MF_SEPARATOR, 0, NULL);

		} else if(!pitem[i]->id) {

			if(pitem[i]->pszCaption && *pitem[i]->pszCaption) {		// Attach a pop-up menu to a top-level menu
				if(hPopup && pszLastPopup) {
					AppendMenu(hMenu, MF_POPUP, (UINT)hPopup, pszLastPopup);
				}
				hPopup = CreateMenu();
				pszLastPopup = pitem[i]->pszCaption;
			} else {												// Separator
				AppendMenu(hPopup, MF_SEPARATOR, 0, NULL);
			}

		} else {

			if(pitem[i]->pszCaption && *pitem[i]->pszCaption) {		// Create a submenu item
				AppendMenu(hPopup, MF_STRING, pitem[i]->id, pitem[i]->pszCaption);
				if(pitem[i]->pszImage && *pitem[i]->pszImage) {
					HBITMAP hImage = wbLoadImage(pitem[i]->pszImage, 0, 0);

					if(hImage)
						SetMenuItemBitmaps(hPopup, pitem[i]->id, MF_BYCOMMAND, hImage, hImage);
				}
			}
		}
	}

	// Create last first-level menu

	if(hPopup && pszLastPopup) {
		AppendMenu(hMenu, MF_POPUP, (UINT)hPopup, pszLastPopup);
	}

	// Attach the menu to the window

	pwbo = wbMalloc(sizeof(WBOBJ));
	pwbo->hwnd = (HWND)hMenu;
	pwbo->id = 0;
	pwbo->uClass = Menu;
	pwbo->item = -1;
	pwbo->subitem = -1;
	pwbo->style = 0;
	pwbo->pszCallBackFn = NULL;
	pwbo->pszCallBackObj = NULL;
	pwbo->lparam = 0;
	pwbo->parent = pwboParent;

	// ********* DOESN'T WORK
	mi.dwItemData = (DWORD)pwbo;
	SetMenuItemInfo((HMENU)pwbo->hwnd, 0, TRUE, &mi);
	// ********* DOESN'T WORK

	SetMenu(pwboParent->hwnd, hMenu);
	return pwbo;
}
Exemplo n.º 2
0
		} else {
			size = wbGetImageDimensions((HBITMAP)source->value.lval);
		}

	} else if(source->type == IS_STRING) {

		// Is source an image file?

		if(strchr(source->value.str.val, '.') && (strstr(source->value.str.val, ".bmp") || strstr(source->value.str.val, ".ico") || strstr(source->value.str.val, ".icl") ||
		  strstr(source->value.str.val, ".dll") || strstr(source->value.str.val, ".exe"))) {

			HBITMAP hbm;

			wcs = Utf82WideChar(source->value.str.val, source->value.str.len);
			hbm = wbLoadImage(wcs, 0, 0);
			if(hbm)
				//size = wbGetImageDimensions(wbLoadImage(source->value.str.val, 0, 0));
				size = wbGetImageDimensions(hbm);
		} else {

			SIZE siz;
			wcs = Utf82WideChar(source->value.str.val, source->value.str.len);
			if(wbGetTextSize(&siz, wcs, lparam))
				size = (DWORD)MAKELONG(siz.cx, siz.cy);
			else
				size = 0;
		}

	} else {
		zend_error(E_WARNING, "Invalid parameter type passed to function %s()",
Exemplo n.º 3
0
			}

		} else {
			size = wbGetImageDimensions((HBITMAP)source->value.lval);
		}

	} else if(source->type == IS_STRING) {

		// Is source an image file?

		if(strchr(source->value.str.val, '.') && (strstr(source->value.str.val, ".bmp") || strstr(source->value.str.val, ".ico") || strstr(source->value.str.val, ".icl") ||
		  strstr(source->value.str.val, ".dll") || strstr(source->value.str.val, ".exe"))) {

			HBITMAP hbm;

			hbm = wbLoadImage(source->value.str.val, 0, 0);
			if(hbm)
				size = wbGetImageDimensions(wbLoadImage(source->value.str.val, 0, 0));
		} else {

			SIZE siz;

			if(wbGetTextSize(&siz, source->value.str.val, lparam))
				size = (DWORD)MAKELONG(siz.cx, siz.cy);
			else
				size = 0;
		}

	} else {
		zend_error(E_WARNING, "Invalid parameter type passed to function %s()",
		  get_active_function_name(TSRMLS_C));