VerySource

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3492|回复: 3

2021-06-02本站资源调价、积分奖励调整通知

[复制链接]

11

主题

68

帖子

349.00

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
349.00
发表于 2021-6-2 10:26:50 | 显示全部楼层 |阅读模式
为了更好地为网友服务,同时也为增加网站的人气,本站于2021-06-02再次对资源价格和积分规则作出调整如下:

1、资源价格由5个金币上调至10个金币;
2、积分规则新增每日博客自动奖励:
  • 在线时间超过1小时的用户,只要发布符合要求的博客,都可获得系统自动奖励的10个金币,实时到帐,每日最多奖励一次;
  • 在线时间不到1小时的新用户,系统会通知管理员手动审核奖励,平时工作时间,审核时间在5-10分钟左右,其他时间审核时间不确定;
3、原发布下载资源获得积分规则不变;

积分规则详细信息,请看:http://bbs.verysource.com/thread-3625-1-1.html
已通过验证用户开通博客,请访问:http://blog.verysource.com/create_blog.php








Losing My Religion.
回复

使用道具 举报

0

主题

1

帖子

4.00

积分

新手上路

Rank: 1

积分
4.00
发表于 2022-11-19 10:08:42 | 显示全部楼层
到底写博客跟积分有什么关系呢?
回复

使用道具 举报

0

主题

1

帖子

2.00

积分

新手上路

Rank: 1

积分
2.00
发表于 2023-1-30 16:51:27 | 显示全部楼层
可以只写你好博客字样吗?
回复

使用道具 举报

1

主题

2

帖子

2.00

积分

新手上路

Rank: 1

积分
2.00
发表于 2023-10-1 22:21:34 | 显示全部楼层
Ribbon Images in Excel 2007/2010 using a Delphi COM DLL

This problem has been bubbling away for more than a year. I’ve pick it up every now and then tried some fixes, found they didn’t work and put it down again. However last night I found the solution to the whole problem and I want to write it down so others can benefit from this knowledge.

If you review most of the knowledge on Office Ribbon controls, the examples are always in Visual Studio where some things are done in the background for you. With Delphi you need to understand all the nitty gritty to get the solution working.

What I’m going to do is describe the solution in pieces and point out the problems I had to over come and why they were a problem.

First up is to enable your custom Ribbon to ask for images. This is done in two parts. Firstly, by adding a loadImage tag to the customUI element as follows:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="RibbonLoaded" loadImage="GetImage">
Where GetImage is the name of the call back function in my COM DLL.

Secondly, we add image tags to the button elements of the custom ribbon as follows:

<button id="EidolonAbout" label="About" onAction="RibbonClick" image="EidolonAbout" keytip="A" screentip="Display the About dialogue" supertip="This option displays the about dialogue so that you can get Eidolon's version number for support."/>
Where “EidolonAbout” is the name that will be passed to the GetImage() function.

Before we get to the GetImage() implementation in the COM DLL, lets make sure we have some images to work with. I prefer to have the images created externally with any package (GIMP or the Borland Image Editor) and put them in a windows resource file using a resource script. Below is a portion of the RC script for these images:

...
EidolonNewQueryImage          ICON "Images\Toolbar Images\EidolonNewQueryImage.ico"
EidolonNewPivotTableImage     ICON "Images\Toolbar Images\EidolonNewPivotTableImage.ico"
EidolonEditQueryPivotImage    ICON "Images\Toolbar Images\EidolonEditQueryPivotImage.ico"
EidolonUpdateQueryPivotImage  ICON "Images\Toolbar Images\EidolonUpdateQueryPivotImage.ico"
...
If you bind this into your project then it will be checked and compiled with your project. This then allow us to load the images from the DLL and not have to maintain additional external files.

You will notice I’ve used icon files for the images rather than bitmaps. When I tried bitmaps, they didn’t behave the same as in Delphi with the bottom left pixel being used as the transparent colour. There is probably something I’m missing here. As an aside, I’ve added the name “Image” to the end of all the icon files as I have a lot of images in my DLL for different components and so wanted to make sure there were no name clashes.

So now we come to the tricky bit, the implementation of GetImage().

First we need to added a method to the COM DLL’s automation class as follows:

  IEidolonAddin = interface(IDispatch)
    ['{25F65BDF-36E0-4A51-B222-8A86AC4CCCCB}']
    Procedure RibbonClick(Const control: IRibbonControl); safecall;
    Procedure RibbonLoaded(Const RibbonUI: IRibbonUI); safecall;
    function GetImage(Const imageName: WideString): IPictureDisp; safecall;
  end;

  IEidolonAddinDisp = dispinterface
    ['{25F65BDF-36E0-4A51-B222-8A86AC4CCCCB}']
    Procedure RibbonClick(Const control: IRibbonControl); DispID 201;
    Procedure RibbonLoaded(Const RibbonUI: IRibbonUI); DispID 202;
    function GetImage(Const imageName: WideString): IPictureDisp; DispID 203;
  end;
Now I always thought that this information was synchronised with the RIDL file but for me its not. We’ll come to the RIDL file at the end.

Obviously this then means the method needs to be implemented in the automation class as follows:

    TEidolonAddin = Class(TAutoObject, IUnknown, IDispatch, IEidolonAddin,
      IDTExtensibility2, IRibbonExtensibility)
      ...
    Public
      ...
      Function GetImage(Const imageName: WideString): IPictureDisp; Safecall;
    End;

  Function TEidolonAddin.GetImage(Const imageName: WideString): IPictureDisp;

  Var
    PictureDesc : TPictDesc;

  Begin
    Result := Nil;
    PictureDesc.cbSizeofstruct := SizeOf(PictureDesc);
    PictureDesc.picType := PICTYPE_ICON;
    PictureDesc.hIcon := LoadIcon(HInstance, PWideChar(imageName + 'Image'));
    If PictureDesc.hIcon <> 0 Then
      Case OleCreatePictureIndirect(PictureDesc, ActiveX.IPicture, True, Result) Of
        E_NOINTERFACE: OutputDebugString('Picture NO INTERFACE');
        E_POINTER:     OutputDebugString('Picture NO POINTER');
        S_OK:          OutputDebugString('Picture OK');
      Else
        OutputDebugString('Picture Unknown');
      End;
  End;
This method is surprisingly simple. It gets the icon images from the DLL resource and and passes this to the OLECreatePictureIndirect method to create the image to be passed to Excel. You will notice that there is some debugging code in here. I needed to step through this code to understand whether the reason the image was not appearing the Excel was because it was not being created in Delphi properly.

As it happened this code was not the actual problem. The method was called and ran okay but as soon as the execution passed out of the function Excel locked up or AVed depending on whether it was Excel 2007 or 2010. This started me thinking about the definition on the type library element associated with this call.

I wrongly thought that you only had available the items that were in the drop down lists so my definition was as follows:

IPicture* _stdcall GetImage([in] BSTR imageName);
I looked on the internet to see if anyone had posted a solution to this and found a Russian website (Delphi Masters) that had. Unfortunately my Russian is non-existent BUT by methodically looking at the code I found the probably. It was because the above RIDL definition was wrong and it should have been as below.

HRESULT _stdcall GetImage([in] BSTR imageName, [out, retval] IPictureDisp** aImage);
I run the code (with at the time very like hope that it would work) and I tried to click on Excel after stepping through the code to see if it was responding and to my supprise there was a little image next to one of my buttons
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

快速回复 返回顶部 返回列表