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

woaidongmao

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

VC++ 項(xiàng)目中使用 FLEX

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

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

 

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

 

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

 

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

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

我以為是代碼的問題,重建了一個(gè)項(xiàng)目,什么代碼都沒寫。運(yùn)行,關(guān)閉,斷言錯(cuò)誤。因?yàn)橹暗?span style="color: #c60a00" lang="EN-US">VC出現(xiàn)了一個(gè)奇怪的問題:打開對(duì)話框命令總是出現(xiàn)非法操作。反復(fù)重裝VC都不能解決,最后在網(wǎng)上看到可能是安裝的visio 2003沖突,卸載visio 2003后問題解決。我開始懷疑是不是我之前的折騰把系統(tǒng)搞亂掉了。我又重裝了一次VC,再次編譯運(yùn)行,問題再次出現(xiàn)。我都快瘋了。

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

(待續(xù)。。。)

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

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

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

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

 

二、屏蔽Flash的右鍵菜單

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

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

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

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

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

 

三、調(diào)整窗口大小時(shí)防止Flash控件閃爍

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

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

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.

關(guān)鍵字: flex win32 vc++ vc externalinterface
項(xiàng)目中要實(shí)現(xiàn)Flex打開文件夾選擇框(Flex做為桌面程序的UI),沒辦法,如果不用AIR只能在下面加一層Container了。網(wǎng)上搜來搜去差不多都是講FSCommand怎樣與VC++交互,可是FSCommand不能及時(shí)返回值呀。經(jīng)過一番摸索,終于調(diào)通了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(); 
    } 
     

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

 

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

評(píng)論

# re: VC++ 項(xiàng)目中使用 FLEX  回復(fù)  更多評(píng)論   

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>
            国产精品va| 国产丝袜美腿一区二区三区| 欧美国产日本在线| 久久综合激情| 免费欧美网站| 欧美日韩国产综合视频在线观看| 欧美日韩精品在线| 国产精品h在线观看| 国产精品主播| 国内精品久久久| 亚洲激情av| 亚洲视频综合在线| 欧美在线观看一区二区三区| 久久久亚洲人| 亚洲成人在线视频播放| 亚洲全黄一级网站| 亚洲视频免费看| 欧美在线视频二区| 久久久久9999亚洲精品| 欧美成人中文| 国产精品成人一区| 国产综合色精品一区二区三区| 一区在线视频| 中文在线一区| 久久精品一区四区| 亚洲国产日韩在线一区模特| 99香蕉国产精品偷在线观看| 亚洲欧美日韩另类精品一区二区三区 | 久久精品日韩欧美| 欧美电影专区| 国产精品影片在线观看| 樱桃视频在线观看一区| 在线综合视频| 久久夜色精品一区| 亚洲免费av电影| 久久精品女人的天堂av| 欧美日韩精品欧美日韩精品一 | 久久综合成人精品亚洲另类欧美| 欧美激情精品久久久久久免费印度 | 欧美国产欧美亚洲国产日韩mv天天看完整| 欧美日韩国产欧| 国产夜色精品一区二区av| 亚洲剧情一区二区| 久久久久一区| 一区二区三区欧美在线观看| 久久亚洲风情| 国产伦精品一区二区三区照片91 | 一区二区免费在线播放| 久久久久久久97| 日韩亚洲国产精品| 久久视频在线免费观看| 国产精品卡一卡二| 亚洲精品资源美女情侣酒店| 久久精品人人做人人爽电影蜜月| 亚洲精品免费一二三区| 久久久久青草大香线综合精品| 欧美日韩一区在线播放| 亚洲国产视频直播| 久久精品国产第一区二区三区| 亚洲美女毛片| 久久中文久久字幕| 国产一区久久| 亚洲欧美色婷婷| 亚洲国产欧美国产综合一区| 久久精品噜噜噜成人av农村| 国产精品美女午夜av| 日韩亚洲欧美成人一区| 欧美大片在线观看一区二区| 午夜精品一区二区三区电影天堂 | 亚洲一区二区三区涩| 亚洲国产精品久久| 久久九九免费视频| 国产午夜精品理论片a级探花| 亚洲在线视频| aa成人免费视频| 欧美片在线播放| 亚洲日本中文| 欧美激情综合色| 久久色中文字幕| 激情偷拍久久| 久久综合国产精品| 久久国产精品72免费观看| 国产欧美精品日韩区二区麻豆天美| 亚洲午夜av电影| 日韩视频第一页| 欧美日韩中文字幕综合视频 | 在线免费观看日本一区| 久久久久久亚洲综合影院红桃| 亚洲女人天堂av| 国产精品久久久久影院亚瑟| 中文在线资源观看网站视频免费不卡 | 亚洲高清视频一区| 欧美成人高清| aⅴ色国产欧美| 亚洲精品小视频| 欧美日韩国产系列| 亚洲午夜免费视频| 一区二区三区波多野结衣在线观看| 欧美日韩精品一本二本三本| 夜夜爽99久久国产综合精品女不卡| 亚洲国产精品久久| 欧美精品在线观看一区二区| 一区二区三区精品国产| 99这里有精品| 国产精品国产三级国产专区53 | 免费一区视频| 欧美成人在线影院| 一区二区三区国产在线观看| 一本色道久久88综合亚洲精品ⅰ | 你懂的网址国产 欧美| 久久久久久亚洲综合影院红桃 | 欧美日韩国产系列| 亚洲欧美日韩另类| 欧美亚洲综合另类| 激情综合自拍| 亚洲激情第一页| 欧美视频在线视频| 欧美一区视频| 久久天堂精品| 宅男精品视频| 香蕉久久国产| 亚洲国产高潮在线观看| 日韩视频二区| 国产日本欧美一区二区三区在线| 久久综合狠狠综合久久激情| 欧美成人中文| 欧美一区二视频| 玖玖玖国产精品| 亚洲午夜一区二区三区| 欧美亚洲视频| 亚洲精品乱码久久久久久| 亚洲视频免费观看| 在线精品视频在线观看高清| 亚洲精品中文字幕女同| 国产精品揄拍500视频| 欧美xart系列在线观看| 欧美天堂在线观看| 久久伊人亚洲| 欧美日产国产成人免费图片| 欧美在线999| 欧美好吊妞视频| 久久狠狠亚洲综合| 欧美福利视频| 久久精品中文字幕一区| 欧美国产日韩a欧美在线观看| 亚洲欧美精品在线| 美脚丝袜一区二区三区在线观看| 亚洲一区二区三区色| 久久婷婷蜜乳一本欲蜜臀| 亚洲综合导航| 蜜臀va亚洲va欧美va天堂| 欧美一区成人| 欧美二区在线| 久久久午夜电影| 欧美性色综合| 欧美激情导航| 国产综合自拍| 亚洲私人影院| 亚洲精品在线免费观看视频| 欧美一区二区三区喷汁尤物| 中文一区在线| 你懂的成人av| 久久综合久久久久88| 国产精品私房写真福利视频| 亚洲激情av在线| 在线精品视频在线观看高清| 亚洲综合首页| 夜夜爽99久久国产综合精品女不卡| 久久精品99无色码中文字幕| 午夜精品久久久久影视 | 日韩一级大片在线| 久久婷婷麻豆| 久久久夜夜夜| 国产精品午夜电影| 一区二区三区欧美在线| 日韩视频免费观看高清完整版| 久久午夜视频| 久久婷婷色综合| 国产偷久久久精品专区| 亚洲一区中文| 亚洲在线1234| 欧美日韩一视频区二区| 亚洲激情啪啪| 亚洲精品乱码久久久久久黑人| 久久蜜臀精品av| 久久久在线视频| 国产在线一区二区三区四区 | 欧美激情第二页| 欧美国产欧美亚洲国产日韩mv天天看完整| 国产日韩欧美在线一区| 亚洲一区二区三区视频| 亚洲欧美国内爽妇网| 欧美三级电影网| 99精品视频一区二区三区| 一区二区欧美在线| 欧美日韩国产免费观看| 亚洲精品视频在线观看网站| 99av国产精品欲麻豆| 欧美另类videos死尸| 亚洲人成啪啪网站|