I'm building a kind of dock, and I struggle at finding how to save things like "Run", "Search", "Help", "Printers" and reopen them after that.
I tried this :
CComPtr<IShellFolder> pDF;
SHGetDesktopFolder(&pDF);
LPITEMIDLIST pidlPrintersAndFaxes=0;
hr=pDF->ParseDisplayName(0, 0, L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{2227A280-3AEA-1069-A2DE-08002B30309D}", 0, &pidlPrintersAndFaxes, NULL);
CComPtr<IShellFolder> pSF;
hr=pDF->BindToObject(pidlPrintersAndFaxes, 0, IID_IShellFolder, (void**)&pSF);
LPITEMIDLIST pidlPrinter=0;
hr=pSF->ParseDisplayName(0, 0, L"PDFCreator", 0, &pidlPrinter, NULL);
CComPtr<IContextMenu> pPrinterCtxMenu;
hr=pSF->GetUIObjectOf(0, 1, (LPCITEMIDLIST*)&pidlPrinter, IID_IContextMenu, 0, (void**)&pPrinterCtxMenu);
CMINVOKECOMMANDINFO cmd={0};
cmd.cbSize=sizeof(CMINVOKECOMMANDINFO);
cmd.lpVerb=MAKEINTRESOURCE(0);
cmd.nShow=SW_SHOWNORMAL;
hr=pPrinterCtxMenu->InvokeCommand(&cmd);
Whatever I try InvokeCommand on the last line always return E_INVALIDARG. I tried it with ShellExecuteEx and got the same error.
I tried every possible verbs.
I tried to enumerate the verbs and got E_INVALIDARG.
I can't make it work but on normal filesystem path like "c:\" and clsid on folders. What did I miss ?
I found the solution. I must create a context menu, then QueryContextMenu to fill it, get the default item with GetDefaultMenuItem() and invoke it with InvokeCommand.
It is necessary to substract the index of the first item given to QueryContextMenu from the default menu item, because otherwise you'll have an offset.
This was very helpful : http://blogs.msdn.com/oldnewthing/archive/2004/09/30/236133.aspx
Related
I would like to put a specific color to a svg that i insert in a PDF thanks to TCPDF
this color will allow a printer to cut automatically
I know i would have to use spotcolors.
as here: https://tcpdf.org/examples/example_037/
the SetFillSpotColor function works perfectly for text or a rectangle
but when I use ImageSVG this has no effect
i add name CutContour directly in svg, example :
<path fill="CutContour" d="M271.44,849.229c-1.254,0.174-2.604,0.489-3,0.701...
but not works too.
example my code PHP:
$pdf->AddSpotColor('CutContour', 0, 0, 0, 100);
$pdf->ImageSVG( $filename_svg , 0, 0, $largeurmm, $hauteurmm, 'CutContour', false, false, 0, false);
I can't find a solution,
can you help me?
I'm guessing you can't get away with using cutcontour as the spot color name, correct? The ImageSVG parser appears to force the color name to lowercase, which means it doesn't match against the CutContour name when it goes to look for it in the TCPDF instance's list of added spot colors.
If that guess is correct, try adding the color to the predefined list in the TCPDF_COLORS class (see spotcolor static property), either by editing include/tcpdf_colors.php or adding a line like this to your script.
TCPDF_COLORS::$spotcolor['cutcontour'] = array( 0, 0, 0, 100, 'CutContour');
$pdf->AddSpotColor('CutContour', 0, 0, 0, 100);
This way, when it goes to look for the lowercase name, it'll find a match and return the proper spot color array. (Note: Tested in TCPDF 6.2.17)
I need to create ID2D1DCRenderTarget, because I need compability with GDI. I do it with the following code:
ID2D1Factory* factory;
ID2D1DCRenderTarget* target;
ID2D1SolidColorBrush* brush;
using namespace D2D1;
D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &factory);
D2D1_RENDER_TARGET_PROPERTIES rtp = RenderTargetProperties();
rtp.usage = D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE;
factory->CreateDCRenderTarget(&rtp, &target);
target->CreateSolidColorBrush(ColorF(ColorF::White), &brush);
Program crashes in the last line. But when I try to similarily create ID2D1HwndRenderTarget everything works fine. Could anyone help me?
As I checked it, it appears that problem is with RenderTargetProperties(), beacuse if D2D1_RENDER_TARGET_PROPERTIES is filled for example like that:
D2D1_RENDER_TARGET_PROPERTIES rtp = D2D1::RenderTargetProperties(
D2D1_RENDER_TARGET_TYPE_DEFAULT,
D2D1::PixelFormat(
DXGI_FORMAT_B8G8R8A8_UNORM,
D2D1_ALPHA_MODE_IGNORE),
0,
0,
D2D1_RENDER_TARGET_USAGE_NONE,
D2D1_FEATURE_LEVEL_DEFAULT
);
everything works.
I faced a problem with my dojo 1.6.1 EnhancedGrid. I'm trying to use paging and single selection mode like this :
<div id="theId" data-dojo-type="dojox.grid.EnhancedGrid"
data-dojo-props="selectionMode:'single', plugins: { indirectSelection: true, pagination: {pageSizes: ['1'], description: true,sizeSwitch: true,pageStepper: true, gotoButton: true, maxPageStep: 4, position: 'bottom'}}">
Everything goes fine except when I select a row and then click on next page button the selection remains while the objects has changed. I have to do a dirty hack to fix this :
/**Let's hack it a bit **/
grid.pagination.plugin.nextPageHook = grid.pagination.plugin.nextPage;
grid.pagination.plugin.nextPage = function(src) {
this.grid.selection.select(-1);
this.nextPageHook();
};
This guy does his jobb.
And the seccond problem is that I am not able to set default items number it's always 25. No matter which number I pass to the plugin parameters with defaultPageSize. And even more, there is no such field in the object grid.pagination.plugin .
But still I can hack it like this :
grid.pagination.plugin.pageSize = 1;
grid.startup();
I hope I'm missing some thing and you can help me find out what. Thanks.
Sadly, it is a famous problem with Datagrid, it is kinda related to this also : http://bugs.dojotoolkit.org/ticket/13432
For the number of rows, you have to use rowsPerPage (or rowPerPage don't remember exactly) property
Also make sure the correct headers are sent in the request (range, start count, etc)
I have using recursiveTreeNodesAdaptor in seam. And I want to add child this tree via contextMenu and when user click right node of tree open context menu and click left then open modal panel. I want to do this.
When I try to write selenium test this flow I dont click to rigt and open contextMenu. I try to selenium.contextmenu(xpath) but i'm fail.
So, How can I click to right
I tried to simulate right click with user extension. My function is below:
Selenium.prototype.doContextMenuClick = function(element){
var evt = document.createEvent('MouseEvents');
var RIGHT_CLICK_BUTTON_CODE = 2; // the same for FF and IE
evt.initMouseEvent('contextmenu', true, true,
document.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, RIGHT_CLICK_BUTTON_CODE, null);
if (document.createEventObject){
// dispatch for IE
return document.fireEvent('onclick', evt);
}
else{
// dispatch for firefox + others
return !document.dispatchEvent(evt);
}};
I managed to call the function from IDE. But, now, I get the error "this.waitForCondition is not a function". What's wrong? Do you have any idea?
Thanks in advance.
Try using fireEvent on that element.
You should also take a look at this post which seems to be about the same issue.
The latest selenium has a namespace called OpenQA.Selenium.Interactions Namespace. check it out here.
see my other post here
This code used to work in WSS 3.0 / MOSS 2007 in FeatureReceiver.FeatureActivated:
using (SPLimitedWebPartManager limitedWebPartManager = Site.GetLimitedWebPartManager("default.aspx", PersonalizationScope.Shared)) {
ListViewWebPart listViewWebPart = new ListViewWebPart {
Title = title,
ListName = list.ID.ToString("B").ToUpper(),
ViewGuid = view.ID.ToString("B").ToUpper()
};
limitedWebPartManager.AddWebPart(listViewWebPart, zone, position);
}
I'm trying to convert to SharePoint 2010 and it now fails with:
System.ArgumentException: The specified view is invalid.
at Microsoft.SharePoint.SPViewCollection.get_Item(Guid guid)
at Microsoft.SharePoint.WebPartPages.ListViewWebPart.EnsureListAndView(Boolean requireFullBlownViewSchema)
at Microsoft.SharePoint.WebPartPages.ListViewWebPart.get_AppropriateBaseViewId()
at Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartInternal(SPSupersetWebPart superset, Boolean throwIfLocked)
at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPartInternal(WebPart webPart, String zoneId, Int32 zoneIndex, Boolean throwIfLocked)
at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPart(WebPart webPart, String zoneId, Int32 zoneIndex)
Interestingly enough when I run it from a unit test it works, it only fails in FeatureActivated. When I debug with Reflector it is failing on this line:
this.view = this.list.LightweightViews[new Guid(this.ViewGuid)];
list.LightweightViews only returns one view, the default view, even though list.Views returns all of them. When running from a unit test LightweightViews returns all of my views. I have no idea what LightweightViews is supposed to mean and I'm running out of ideas. Anyone else got any?
To make it work, just do the following:
Do not set the viewguid property of the listviewwebpart object (leave it blank)
call the AddWebpart method
It will generate a new viewguid associated to a new hidden view.
Then if you want to customize this view, retrieve it from the list and customize it.
Hopefully no one ever has this problem or even sees this question. In the unfortunate event you get the same problem I have no specific solution. It eventually just started to work for me (8 hour later). I can tell you what I did right before it started working and hopefully it will help:
I went in through the UI and set the view that I was trying to set the list view web part to as the default view. I believe that's what fixed it and I have no idea why.
Some other notes on the problem:
I create all my lists and views through code
RunWithElevatedPrivileges did not help
Instantiating a new SPWeb in feature activated did not help
Setting ListViewXml = view.HtmlSchemaXml instead of setting ViewGuid made it not crash but the view was wrong when this code executed in FeatureActivated but correct when executed in a unit test.
Best I can do, sorry. If you're having this problem, good luck!
After reading this and this articles I found even more easiest solution.
When you add listviewwebpart to an any page, webpart automatically creates new hidden view in list, which is associated with this webpart (you can check it in SharePoint Manager).
When you switch view for listviewwebpart throw UI, it simply get copy of fields from selected view and push it in his hidden view.
All you need is get this view by ID, add\remove necessary fields and update view. Something like this:
var wpMngr = web.GetLimitedWebPartManager(workspaceWeb.Url + "/default.aspx", PersonalizationScope.Shared);
var attendeeListViewWebPart =
(ListViewWebPart)wpMngr.WebParts.Cast<WebPart>().FirstOrDefault(w => w.Title == Lists.AttendeesList);
var list = workspaceWeb.Lists[Lists.AttendeesList];
var view = list.Views.Cast<SPView>().FirstOrDefault(w => w.ID.ToString("B").Equals(attendeeListViewWebPart.ViewGuid, StringComparison.OrdinalIgnoreCase));
view.ViewFields.DeleteAll();
view.ViewFields.Add...
view.Update();
According to articles, you cann't update ViewGuid property for listviewwebpart.
I have been fighting with this today also.
For some odd reasons the code that you provided works for some cases but not in others.
I haven't had time to investigate more about that but what I can say is that if you are willing to use the XsltListViewWebPart (which is the replacement of the ListViewWebPart in SharePoint 2010), you will get rid of this annoying "bug".
I have just tested in myself.
Hope it helps!
I was getting this same error with an XsltListViewWebPart:
Exception: System.ArgumentException: The specified view is invalid.
at Microsoft.SharePoint.SPViewCollection.get_Item(Guid guid)
at Microsoft.SharePoint.SPList.GetView(Guid viewGuid)
at Microsoft.SharePoint.SPList.GetView(String viewGuid)
at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.EnsureView()
at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.get_AppropriateBaseViewId()
at Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartInternal(SPSupersetWebPart superset, Boolean throwIfLocked)
at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPartInternal(WebPart webPart, String zoneId, Int32 zoneIndex, Boolean throwIfLocked)
at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPart(WebPart webPart, String zoneId, Int32 zoneIndex)
Since SPList.GetView is a public method, I tried it in Powershell using the Guid from my new view. It worked fine.
I figured out that the problem was the context. I had been creating my view right before the ViewGuid assignment. When I moved the creation of my view outside of the SPLimitedWebPartManager, the code ran without any errors:
SPView view = CreateHiddenView(list);
using (SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(PersonalizationScope.Shared))
{
try
{
XsltListViewWebPart webpart = new XsltListViewWebPart();
webpart.ListName = list.ID.ToString("B").ToUpperInvariant();
webpart.TitleUrl = list.DefaultViewUrl;
webpart.WebId = list.ParentWeb.ID;
webpart.Title = list.Title;
webpart.ViewGuid = view.ID.ToString("B").ToUpperInvariant();
manager.AddWebPart(webpart, "Right", 1);
}
finally
{
manager.Web.Dispose();
}
}