青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

woaidongmao

文章均收錄自他人博客,但不喜標題前加-[轉貼],因其丑陋,見諒!~
隨筆 - 1469, 文章 - 0, 評論 - 661, 引用 - 0
數(shù)據(jù)加載中……

VC++ 項目中使用 FLEX

1, http://hi.baidu.com/qinpc/blog/item/58253df3f9a04654352acc36.html

復雜的界面有多層窗口組成,當windows在窗口改變大小的時候是先重畫父窗口,然后重畫子窗口,子父窗口重畫的過程一般無法在一個刷新周期內完成,所以會呈現(xiàn)閃爍。我們知道父窗口上被子窗口擋住的部分其實沒必要重畫的。

 

解決方法:給窗口加個風格 WS_CLIPCHILDREN ,這樣父窗口上被子窗口擋住的部分就不會重畫了。如果同級窗口之間有重疊,那么需要再加上 WS_CLIPSIBLINGS 風格

 

我趕緊到項目中把Flash對話框的窗口風格加上WS_CLIPCHILDREN,編譯后運行,成功了!感謝作者,讓我終于睡了一個安穩(wěn)覺。

 

四、DEBUG狀態(tài)是總是報Assertion失敗。

這個問題困擾了我一整天。我的系統(tǒng)上安裝了Flex SDK,因此,注冊的Flash控件是調試版。不知什么原因,在每次關閉對話框之后,系統(tǒng)總是報cmdtarget.cpp文件中的控件引用值不為1錯誤,從而造成斷言失敗。

我以為是代碼的問題,重建了一個項目,什么代碼都沒寫。運行,關閉,斷言錯誤。因為之前的VC出現(xiàn)了一個奇怪的問題:打開對話框命令總是出現(xiàn)非法操作。反復重裝VC都不能解決,最后在網(wǎng)上看到可能是安裝的visio 2003沖突,卸載visio 2003后問題解決。我開始懷疑是不是我之前的折騰把系統(tǒng)搞亂掉了。我又重裝了一次VC,再次編譯運行,問題再次出現(xiàn)。我都快瘋了。

在沒瘋之前,我決定到同事的電腦上試一下。生成的程序運行沒有問題。把我生成的代碼拷貝過去運行,沒有問題。我突然意識到,是不是Flash控件的問題。卸載重裝后,問題解決。我的天!

(待續(xù)。。。)

同大多數(shù)的ActiveX控件一樣,VCFlash實現(xiàn)了一個CWnd的包裝:CShockwaveFlash,該類實現(xiàn)了Flash ActiveX控件的所有功能。在AS3問世之前,Flash同宿主之間的通訊只有FSCommand一種方式,而且是異步的,更沒有返回值可言。因為項目中需要VCFlash提供大量的數(shù)據(jù)庫查詢,返回結果通過XML進行傳遞。因此,FSCommand無疑是不方便的。

AS3推出的外部API調用方式:ExternalInterface,極大的簡化了編程方式。ExternaleInterface是同步的調用,并可以返回調用結果。需要說明的是,同步調用是以犧牲性能為代價的,因為這涉及到大量的CPU周期占用)。我曾經(jīng)在Flex項目中,利用ExternalInterface實現(xiàn)了IFrameFlash的嵌入調用,從而達到在Flash中顯示HTML的問題。

CShockwaveFlashExternalInterface提供了一個事件接收器(event sink):FlashCallFlashCall事件只有一個參數(shù):request,而且我們會發(fā)現(xiàn),在Flash中通過ExternalInterface的調用,是通過XML的方式進行封裝,然后傳遞到request中的。為了獲得調用的方法名和參數(shù),你必須解析request封裝的XML包。

不過奇怪的是,處理FlashCall事件的是一個void方法。要返回數(shù)據(jù),你需要調用SetReturnValue方法。返回的數(shù)據(jù)也必須是XML格式,且必須符合Flash的規(guī)范。如果要返回XML結果集,把XML封裝到<string></string>中,然后在Flash中通過new XML(str)的方式動態(tài)生成。

 

二、屏蔽Flash的右鍵菜單

這是個惱人的問題,我不希望用戶在軟件界面中彈出Flash右鍵菜單。在VC中,雖然Flash控件提供了SetMenu方法,通過傳入FALSE屏蔽大部分的菜單項,但遺憾的是,關于設置菜單無法去掉。

為了實現(xiàn)這個功能,我查閱了大量的資料。按照一般的想法,右鍵菜單的生成應該經(jīng)過某種消息處理的流程。我先是重載了CShockwaveFlash類的WndProc方法,并在其中跟蹤消息流,結果造成IDE死機。我做出了一個錯誤的決定,我認為這個消息一定可以在其它地方截獲,于是我又費了很大的周折,特意實現(xiàn)了自己的CControlSite類,結果依然讓人失望。

后來下載了一個Delphi下的TShockwaveFlashEx組件,才發(fā)現(xiàn)該組件是通過截獲組件的WM_RBUTTONDOWN消息實現(xiàn)的菜單屏蔽。這就是說,讓用戶的右鍵消息干脆不傳到Flash控件中去。簡單而直接的方法。

VC中實現(xiàn)起來更簡單些。直接從CShockwaveFlash派生自己的類(不建議直接修改CShowwaveFlash類),然后捕獲WM_RBUTTONDOWN消息,直接在消息處理函數(shù)中注釋掉父類的方法調用。然后修改Flash對象的類型為你的派生類即可。

甚至可以更簡單些。直接在對話框中響應WM_MOUSEACTIVATE消息,然后在處理函數(shù)中判斷message參數(shù)的值,如果是WM_RBUTTONDOWN,則返回MA_ACTIVATEANDEAT(激活控件,吃掉消息。http://msdn2.microsoft.com/en-us/library/ms645612.aspx)。

 

三、調整窗口大小時防止Flash控件閃爍

DialogWM_SIZE響應中,把Flash控件布滿整個窗口。可是這個簡單的實現(xiàn)卻造成了Flash界面的頻繁閃爍。在DelphiTShockwaveFlashEx組件中,作者是通過覆蓋組件的CreateWnd方法實現(xiàn)的,在對話框Resize事件中,調用這個重載的CreateWnd方法。

可是,在VC中如何實現(xiàn)呢?為此,我在google上苦苦搜索了好幾天。關于ActiveX控件閃爍的問題,網(wǎng)上有很多的解決方案。很多方案都是建議同時重載控件和對話框擦除背景事件,然后寫一些代碼防止控件重繪自身。也有一些方法是通過GDI的思路,在內存中通過bitblt的方式避免閃爍。看到最后很傷心,怎么會這么麻煩呢。

2.  http://anirudhs.chaosnet.org/blog/2008.03.13.html (Flex C++ Bridge)

Ely Greenfield's Flex Ajax Bridge is a beautiful piece of work. It impressed me so much that I translated the javascript part of it to C++. Just like FABridge for javascript, the Flex C++ bridge allows you to do most of the things you can do with actionscript via C++. Of course, the syntax is not as pretty as it would be in javascript but it does let you develop C++ applications with a Flex UI.

What?

Nothing explains it like code. Take a look at the following C++ snippet1:

//addeventlistener to call a cpp function

oRootObj.Call("getbutton1").Call("addEventListener", "click", SampleCallback);

 

//where SampleCallback is:

void SampleCallback(CASObject& obj, CFlexBridge* pBridge)

{

    CASObject oRootObj;

    pBridge->Root(oRootObj);

    oRootObj.Call("getpanel1").Call("settitle", "Title from CPP");

}

 

//c++ way of saying Alert.show("StaticClassCalled")

pBridge->ClassRef("mx.controls.Alert").Call("show", "StaticClassCalled");

 

//create a datagrid and add it to the flex app

CASObject oDGrid = pBridge->Create("mx.controls.DataGrid");

oRootObj.Call("addChild", oDGrid);

Flex C++ Bridge is a C++ library that lets you communicate with Flex in a manner more suited for the normal C++ programmer, i.e, you can communicate to flex from c++ by writing code like shown above.

Once you put the Flex Ajax bridge into a Flex application, it is exposed to scripting in the browser. You can use a slightly modified version of the same FABridge.as2 (or even the same one) on the actionscript side and the flex application is exposed to the Flex C++ Bridge.

Flex is for the web, AIR is for the desktop. What is this for?

This is for C++ applications that need an awesome UI but do not want to re-write their existing c++ code and libraries to actionscript / javascript. It's a normal desktop application, you can interact with all your favorite C++ libraries and APIs and still have all the rich expressiveness that flex can deliver.

You could do all this before as well, but the bridge makes it really easy to use Flex from C++. A lot of the reasons for FABridge applies to this as well, but this is outside the browser realm so those reasons have to be filtered to suit that particular fact.

Where can I get it from?

The project is licensed under MPL 1.1 and both the C++ and actionscript source code is available at code.google.com.

It's open source, so feel free to participate and contribute to it.

Sample Applications

Note: The source (both flex and cpp) is available for all the examples.

AdvancedDataGrid that supports Excel formulae computation:

clip_image001

Here, each individual cells in the ADG are editable. You can type in any Excel formula into it and hit the "Compute" button. The application invokes Excel using COM, computes the results and populates the result into the ADG.

Scan images right into flexbook:

clip_image001

When the Scan button is clicked, a TWAIN dialog pops up letting you use your scanner to scan images directly into the pages of the flexbook component.

Sample app showing two flash player instances each with a flex application:

clip_image001

The bridge supports multiple flash player instances. It can talk to each instance in a different manner. If you look at the screenshot, both the instances are loading the same swf file. But the C++ code for one instance adds a datagrid and removes an element shown in the pie chart.

How does it work?

The flash player ActiveX control is added to a MFC dialog. Now the content in the flash player can talk to the C++ application via ExternalInterface. ExternalInterface.call("fnname") will dispatch a FlashCall message on the C++ side which will have the arguments passed to call() in XML. This XML has to be parsed to understand what the message was from the actionscript side.

All this complexity is hidden by the bridge. The bridge talks with the actionscript side of Ely's FABridge and facilitates calling and referencing to actionscript objects, classes and methods.

There are multiple worker threads waiting to process incoming or outgoing flash requests so that the main MFC thread does not block. The bridge can even support multiple flash player instances each with it's own bridge back to the C++ application.

Also, Actionscript exceptions are serialized and thrown on the C++ side.

C++ Syntax Rules

To start off, you need the root object which is the main application object of your flex application. Now you can access the public methods and properties of your application.

Getters and setters are treated differently: A property "width" will be translated to "getwidth" for retrieving the value and "setwidth" for setting the value. Ely's FABridge had camel casing here, but that has been removed so that constants like MOUSE_DOWN don't confuse the bridge.

The "Call" method shown in the snippets above take a string as the first argument that is the name of the method or property (suitably modified using above defined rules) and the arguments for it. Common types like string, int, reference to an AS object, custom anonymous AS object etc are converted internally to an ASObject thanks to copy constructors and operator overloads.

For more examples of the syntax, take a look at the Worker() method in ASWorkSample.cpp.

FABridge did not originally have support for accessing methods and variables of static classes. This was added by Devin Garner and I have incorporated his code into FABridge.as along with some of my changes.

Fine Print

Currently, it supports only Windows since it embeds the internet explorer flash ActiveX control in a MFC dialog.

But it's an open source project and I hope I'll get contributors to help me make it more platform agnostic.

I'd love to know what you guys think about this and how it's being used.

CategoryFlexCPPBridge Comment(s)

 


[1] Now, this is a better way to communicate rather than saying m_Shockwave.CallFunction("asfnname") where asfnname has to be exposed by using ExternalInterface.addCallback on the actionscript side.
[2] Minor changes to support passing of primitives from me and additional support for accessing static classes, variables and methods thanks to Devin Garner)

 

3.

關鍵字: flex win32 vc++ vc externalinterface
項目中要實現(xiàn)Flex打開文件夾選擇框(Flex做為桌面程序的UI),沒辦法,如果不用AIR只能在下面加一層Container了。網(wǎng)上搜來搜去差不多都是講FSCommand怎樣與VC++交互,可是FSCommand不能及時返回值呀。經(jīng)過一番摸索,終于調通了ExternalInterfaceVC++中的處理流程,看代碼。
 
Cpp
代碼
void CMyBicapDlg::OnFlashCallShockwaveflash1(LPCTSTR request)  

    // TODO: Add your control notification handler code here 
    // "<invoke name='%s' returntype='xml'><arguments><string>%s</string></arguments></invoke>" 
     
    // parse request 
    TiXmlDocument request_xml; 
    request_xml.Parse(request); 
    const char* request_name = request_xml.RootElement()->Attribute("name"); 
     
    if (strcmp(request_name,"savedVideosDirectory") == 0 || strcmp(request_name,"bufferDirectory") == 0 || strcmp(request_name,"preferredExportDirectory") == 0) 
    { 
        // choose path 
        CoInitialize(NULL); 
        BROWSEINFO bi; 
        bi.hwndOwner = this->GetSafeHwnd(); 
        bi.pidlRoot = NULL; 
        bi.pszDisplayName = NULL; 
        bi.lpszTitle = NULL; 
        bi.ulFlags = BIF_BROWSEFORCOMPUTER|BIF_RETURNONLYFSDIRS|BIF_STATUSTEXT; 
        bi.lpfn = NULL; 
        LPCITEMIDLIST pidl = SHBrowseForFolder(&bi); 
        if(pidl != NULL) 
        { 
            TCHAR tpath[MAX_PATH] = _T(""); 
            BOOL bresult = SHGetPathFromIDList(pidl, tpath); 
            if (bresult) 
            { 
                std::string re_value = "<string>"; 
                re_value = re_value+tpath+"</string>"; 
                m_FlashPlayer.SetReturnValue(re_value.c_str()); 
            } 
        } 
 
        CoUninitialize(); 
    } 
     

 
首先,需要在項目中嵌入Flash player插件,網(wǎng)上有很多例子。另外Flex也要寫好代碼,這里略掉。
添加一個ExternalInterface的事件處理函數(shù),對于Flash player來講就是FlashCall事件(跟FSCommand不同的),這里的事件處理函數(shù)是void CMyBicapDlg::OnFlashCallShockwaveflash1(LPCTSTR request)。沒有返回值(下面會講到),參數(shù)是一個XML格式的字符串。格式是"<invoke name='%s' returntype='xml'><arguments><string>%s</string></arguments></invoke>",去查查幫助就知道了。
處理request:標準C++沒有處理XML的庫,我去下載了tinyxml,小巧好用。下面就是按照個人需要處理request了,我這里是,打開一個文件夾選擇對話框然后選擇一個路徑。
返回值。事件處理函數(shù)是沒有返回值的,但是flash player提供了一個方法:m_FlashPlayer.SetReturnValue(re_value.c_str());,專門傳遞返回值,格式是<string>%s</string>(也可以是別的AS結構,具體看幫助)。
需要提醒的是,在處理期間要blockFlexExternalInterface.call是有返回值的,如果不阻塞Flex,可能返回就是NULL,呵呵,不知道深層原因。另外,反過來調用格式也是一樣的。
調試環(huán)境:win xp, VC++6.0, Flex builder 2.0

 

posted on 2010-12-08 15:44 肥仔 閱讀(2672) 評論(3)  編輯 收藏 引用 所屬分類: Flash & Flex

評論

# re: VC++ 項目中使用 FLEX  回復  更多評論   

A kind of important information about this good post. The very good custom writings and the ability to buy an essay just about this post is offered by term paper writing services.
2012-03-18 17:53 | NITA31JEFFERSON
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久成人人人人精品欧| 国产精品伦一区| 亚洲国产精品久久精品怡红院| 永久免费精品影视网站| 麻豆久久精品| 亚洲精品国产视频| 亚洲永久免费视频| 黄色综合网站| 欧美黑人多人双交| 亚洲午夜女主播在线直播| 久久久国产91| 一区二区欧美在线| 国产视频精品免费播放| 女主播福利一区| 99re热这里只有精品视频| 欧美一区国产二区| 亚洲激情在线播放| 国产精品日日摸夜夜摸av| 久久综合色8888| 亚洲小说欧美另类社区| 美女久久一区| 亚洲视频在线二区| 在线成人激情| 欧美视频在线一区| 久久国内精品视频| 日韩一本二本av| 蜜臀久久99精品久久久久久9| 亚洲精品影院在线观看| 国产视频一区在线观看| 欧美激情一区二区三区高清视频| 亚洲视频免费| 亚洲激情综合| 久久精品一区二区三区中文字幕 | 国产美女精品一区二区三区| 久久久水蜜桃av免费网站| 一区二区三区黄色| 亚洲国产日韩欧美在线99| 欧美在线日韩| 亚洲一区二区三区中文字幕在线 | 欧美日韩免费看| 久热精品在线视频| 欧美一区二区三区在线| 一区二区三区久久久| 亚洲国产精品一区制服丝袜 | 久久精品人人做人人综合| 99视频超级精品| 亚洲第一视频网站| 久久夜色精品国产欧美乱极品| 在线午夜精品自拍| 亚洲精品一区二区网址| 极品少妇一区二区三区| 国产精品主播| 国产精品亚洲产品| 国产精品久久久久久模特| 欧美日韩xxxxx| 欧美成人精品高清在线播放| 久久精品国产成人| 欧美一区二区视频免费观看| 正在播放亚洲一区| 国产精品99久久久久久人| 亚洲精品影视| 亚洲精品一区二区三区四区高清| 久久久人成影片一区二区三区| 午夜精品福利在线| 亚洲一区二区三区高清不卡| 中文av字幕一区| 亚洲图片欧洲图片av| 一区二区三区欧美激情| 国产精品99久久久久久久vr| 亚洲毛片在线| 中日韩在线视频| 亚洲一区一卡| 亚洲一区影院| 亚洲欧美在线另类| 亚洲免费在线精品一区| 小处雏高清一区二区三区| 欧美一区二区高清在线观看| 香蕉久久夜色精品| 久久另类ts人妖一区二区| 久久免费高清视频| 欧美xxxx在线观看| 欧美国产一区二区在线观看 | 午夜视频在线观看一区| 欧美一区二区视频97| 久久久久国产精品人| 老色批av在线精品| 欧美国产丝袜视频| 国产精品美腿一区在线看| 国产精品久久久久婷婷| 国产日韩精品一区| 亚洲国产一区二区三区青草影视 | 亚洲一区二区免费在线| 午夜精品在线观看| 久久青草久久| 欧美日韩国产一级片| 欧美性开放视频| 国产日韩欧美在线视频观看| 激情视频一区二区| 99精品国产在热久久婷婷| 亚洲图中文字幕| 久久精品视频在线| 亚洲激情啪啪| 亚洲欧美日韩直播| 老司机成人网| 国产精品va| 亚洲第一精品在线| 亚洲视频自拍偷拍| 久久综合99re88久久爱| 日韩视频免费在线| 欧美在线免费观看亚洲| 欧美韩日亚洲| 国产性做久久久久久| 亚洲国产一区二区三区在线播| 99在线精品观看| 久久久久在线观看| 夜夜嗨av一区二区三区网站四季av| 亚洲欧美日韩国产中文在线| 免费欧美日韩国产三级电影| 国产精品日韩一区二区| 亚洲国产成人久久| 欧美伊人久久久久久午夜久久久久| 亚洲第一精品久久忘忧草社区| 亚洲永久精品国产| 欧美精品18+| 国外成人在线视频网站| 亚洲一本大道在线| 欧美激情小视频| 欧美一区深夜视频| 欧美午夜精品| 日韩午夜av电影| 麻豆成人在线| 亚洲欧美一区二区三区极速播放| 欧美国产丝袜视频| 亚洲高清资源| 老司机凹凸av亚洲导航| 亚洲视频欧美在线| 欧美片在线观看| 亚洲国产精品一区二区三区| 欧美在线视频一区二区三区| 99伊人成综合| 欧美精品一区二区三区很污很色的 | 欧美在线短视频| 99精品99| 欧美国产精品一区| 亚洲国产日韩在线一区模特| 久久精品91久久香蕉加勒比| 亚洲性夜色噜噜噜7777| 欧美区日韩区| 亚洲免费黄色| 亚洲电影专区| 免费观看日韩| 91久久久亚洲精品| 亚洲电影欧美电影有声小说| 久久久噜噜噜久久人人看| 国产一区二区中文| 久久国产精品久久精品国产| 亚洲一区二区三区四区中文| 欧美性猛交xxxx乱大交蜜桃| 一本色道久久综合狠狠躁篇怎么玩| 亚洲成色777777女色窝| 美国成人直播| 亚洲精品你懂的| 亚洲人成网在线播放| 欧美精品一区二区高清在线观看| 日韩亚洲欧美高清| 亚洲免费大片| 国产精品红桃| 欧美一区二区在线| 欧美一级精品大片| 国内久久精品| 麻豆精品视频在线观看| 美脚丝袜一区二区三区在线观看| 亚洲高清av| 亚洲全黄一级网站| 欧美体内she精视频| 亚洲免费在线视频一区 二区| 亚洲夜间福利| 狠狠色丁香久久婷婷综合_中| 蜜臀a∨国产成人精品| 欧美二区不卡| 亚洲欧美一区二区在线观看| 欧美一区二区三区在线视频 | 亚洲欧洲精品一区二区| 欧美日韩在线观看一区二区三区| 亚洲一区二区三区在线看| 欧美亚洲一区二区在线| 精品不卡视频| 亚洲人成免费| 国产精品美女久久福利网站| 久久精品九九| 欧美激情一区二区三区不卡| 亚洲在线播放| 久久亚洲综合色一区二区三区| 99re6这里只有精品视频在线观看| 亚洲图片欧美一区| 在线观看日韩一区| 这里只有精品视频| 在线观看欧美黄色| 亚洲视频精品| 最近中文字幕日韩精品|