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

woaidongmao

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

VC++ 項目中使用 FLEX

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

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

 

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

 

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

 

四、DEBUG狀態是總是報Assertion失敗。

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

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

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

(待續。。。)

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

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

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

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

 

二、屏蔽Flash的右鍵菜單

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

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

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

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

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

 

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

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

可是,在VC中如何實現呢?為此,我在google上苦苦搜索了好幾天。關于ActiveX控件閃爍的問題,網上有很多的解決方案。很多方案都是建議同時重載控件和對話框擦除背景事件,然后寫一些代碼防止控件重繪自身。也有一些方法是通過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
項目中要實現Flex打開文件夾選擇框(Flex做為桌面程序的UI),沒辦法,如果不用AIR只能在下面加一層Container了。網上搜來搜去差不多都是講FSCommand怎樣與VC++交互,可是FSCommand不能及時返回值呀。經過一番摸索,終于調通了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插件,網上有很多例子。另外Flex也要寫好代碼,這里略掉。
添加一個ExternalInterface的事件處理函數,對于Flash player來講就是FlashCall事件(跟FSCommand不同的),這里的事件處理函數是void CMyBicapDlg::OnFlashCallShockwaveflash1(LPCTSTR request)。沒有返回值(下面會講到),參數是一個XML格式的字符串。格式是"<invoke name='%s' returntype='xml'><arguments><string>%s</string></arguments></invoke>",去查查幫助就知道了。
處理request:標準C++沒有處理XML的庫,我去下載了tinyxml,小巧好用。下面就是按照個人需要處理request了,我這里是,打開一個文件夾選擇對話框然后選擇一個路徑。
返回值。事件處理函數是沒有返回值的,但是flash player提供了一個方法:m_FlashPlayer.SetReturnValue(re_value.c_str());,專門傳遞返回值,格式是<string>%s</string>(也可以是別的AS結構,具體看幫助)。
需要提醒的是,在處理期間要blockFlexExternalInterface.call是有返回值的,如果不阻塞Flex,可能返回就是NULL,呵呵,不知道深層原因。另外,反過來調用格式也是一樣的。
調試環境:win xp, VC++6.0, Flex builder 2.0

 

posted on 2010-12-08 15:44 肥仔 閱讀(2658) 評論(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>
            夜夜精品视频一区二区| 一本色道久久综合| 毛片基地黄久久久久久天堂| 亚洲一区二区免费在线| 一区二区三区日韩精品| 亚洲精品资源美女情侣酒店| 亚洲精品一区二区三区樱花| 欧美国产综合一区二区| 亚洲国产精品一区制服丝袜| 欧美华人在线视频| 亚洲精品在线视频观看| 夜夜嗨av一区二区三区四季av| 日韩视频永久免费| 亚洲一区999| 欧美一区二区三区在线观看| 久久精品网址| 欧美激情在线狂野欧美精品| 欧美特黄a级高清免费大片a级| 欧美精品日韩一本| 欧美午夜在线观看| 国产一区二区中文| 亚洲欧美日韩在线高清直播| 亚洲精品欧美日韩| 欧美黄色成人网| 欧美日韩视频专区在线播放| 久久综合久久综合九色| 欧美成人一区二区三区| 国产精品成av人在线视午夜片| 国产精品成人免费精品自在线观看| 国产精品国产成人国产三级| 国产一区91| 日韩一区二区精品视频| 午夜一区不卡| 亚洲国产精品999| 亚洲一二三四久久| 欧美freesex交免费视频| 国产精品嫩草99av在线| 欧美婷婷久久| 亚洲欧美日韩国产综合在线| 亚洲欧美日韩在线| 国产精品日本精品| 国产裸体写真av一区二区| 久久久久久久尹人综合网亚洲 | 国内精品视频在线观看| 亚洲乱码国产乱码精品精天堂| 亚洲女性喷水在线观看一区| 欧美不卡高清| 亚洲免费在线| 欧美精品一区视频| 狠久久av成人天堂| 午夜伦理片一区| 免费人成网站在线观看欧美高清| 亚洲国产日韩欧美综合久久| 99精品国产在热久久下载| 欧美中文字幕精品| 亚洲国产日韩欧美在线图片| 久久久av毛片精品| 国产亚洲欧美日韩日本| 久久国产精品第一页| 亚洲一区美女视频在线观看免费| 欧美日韩久久不卡| 91久久精品国产91久久性色tv| 久久躁狠狠躁夜夜爽| 欧美一区二区三区四区在线观看地址 | 在线观看精品视频| 欧美日韩视频在线第一区| 日韩一区二区精品葵司在线| 欧美成人免费全部| 免费在线播放第一区高清av| 一区在线电影| 久久久夜色精品亚洲| 美女精品一区| 午夜精品视频在线观看一区二区 | 亚洲欧美日韩国产另类专区| 欧美精品日韩综合在线| 亚洲国产三级| 欧美国产一区二区在线观看| 久久久久久91香蕉国产| 久久嫩草精品久久久久| 亚洲第一色中文字幕| 久久亚洲国产成人| 欧美一区二区三区四区视频| 国产视频观看一区| 欧美中文在线视频| 先锋亚洲精品| 国内成+人亚洲+欧美+综合在线| 性欧美video另类hd性玩具| 一区二区三区精品国产| 国产精品有限公司| 亚洲男人的天堂在线| 韩国成人理伦片免费播放| 亚洲视频在线观看网站| 亚洲欧洲精品一区| 欧美人牲a欧美精品| 亚洲精品国产系列| 亚洲欧洲日本一区二区三区| 欧美日韩在线免费| 亚洲一区二区在线| 午夜久久美女| 欧美视频第二页| 久久久久看片| 欧美aa在线视频| 一区二区av在线| 亚洲婷婷国产精品电影人久久| 国产精品乱码人人做人人爱| 欧美一区二粉嫩精品国产一线天| 午夜国产精品影院在线观看| 国产综合久久久久久| 亚洲影院在线| 亚洲无线视频| 黄色成人片子| 亚洲九九精品| 国产婷婷色综合av蜜臀av| 麻豆成人av| 国产精品v欧美精品v日本精品动漫| 欧美一级视频一区二区| 一本久久知道综合久久| 亚洲高清激情| 亚洲一区二区高清| 伊人蜜桃色噜噜激情综合| 亚洲综合日韩中文字幕v在线| 欧美在线免费看| 99精品视频网| 亚洲精品久久久久中文字幕欢迎你 | 免费成人高清| 欧美激情第一页xxx| 亚洲欧美视频一区| 欧美日韩情趣电影| 女同性一区二区三区人了人一 | 久久精品主播| 久久精品99久久香蕉国产色戒| 亚洲欧美日韩精品久久久久| 中文精品在线| 久久久久久国产精品mv| 另类亚洲自拍| 欧美高清在线一区| 欧美日韩国产成人高清视频| 欧美精品久久久久久久| 欧美视频在线一区| 亚洲精品一区中文| 亚洲午夜精品网| 久久精品国产清自在天天线| 宅男在线国产精品| 久久免费高清视频| 欧美日韩亚洲视频| 亚洲一区二区三区高清不卡| 久久亚洲精品一区| 国产综合婷婷| 日韩午夜黄色| 日韩午夜视频在线观看| 欧美一区二区三区四区在线观看| 日韩午夜在线| 欧美激情在线观看| 欧美激情精品久久久六区热门 | 亚洲高清不卡一区| 精品动漫一区二区| 欧美亚洲一级片| 欧美中文字幕精品| 国产美女精品一区二区三区 | 亚洲国产精品嫩草影院| 在线国产日韩| 久久久综合香蕉尹人综合网| 久久久蜜桃精品| 国产亚洲亚洲| 欧美在线综合| 亚洲欧美国产制服动漫| 欧美精品少妇一区二区三区| 亚洲第一页中文字幕| av成人免费在线| 欧美日韩精品欧美日韩精品| 亚洲免费观看在线视频| 夜夜嗨av色一区二区不卡| 欧美日韩美女在线| 一区二区欧美国产| 欧美一级片久久久久久久| 国产精品丝袜白浆摸在线| 亚洲一区视频| 欧美在线3区| 亚洲大片一区二区三区| 欧美国产91| 99视频+国产日韩欧美| 午夜久久久久久| 国产一区二区三区网站| 亚洲综合电影| 亚洲日本欧美天堂| 欧美影视一区| 亚洲国产欧美精品| 欧美日韩中文字幕综合视频| 午夜精品www| 欧美黑人多人双交| 亚洲男人第一网站| 免费不卡在线观看av| 亚洲国产天堂久久综合网| 中日韩午夜理伦电影免费| 国产日韩精品在线播放| 欧美韩国在线| 性欧美1819sex性高清| 欧美国产日韩一区二区在线观看| 亚洲一区在线播放| 亚洲国产精品va在线看黑人动漫|