• <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>

            Error

            C++博客 首頁 新隨筆 聯(lián)系 聚合 管理
              217 Posts :: 61 Stories :: 32 Comments :: 0 Trackbacks

            #

            // 函數(shù)重載寫法
             //    (return_arg-type(*)(arg1-type,grg2-type,...))&function
                module(L)
                [
                    def("greet", (void(*)(void))&greet),
              def("greet", (void(*)(long))&greet),
              def("greet", (long(*)(long,float))&greet)
                ];

             // 成員函數(shù)重載用法
             // (return_arg-type (classname::*)(arg1-type,grg2-type,...))&classname::class_memberfunction

            posted @ 2014-01-10 11:58 Enic 閱讀(510) | 評論 (0)編輯 收藏

            首先數(shù)據(jù)庫定位分幾塊:機(jī)器名-實(shí)例名-數(shù)據(jù)庫名

            但是安裝完成之后發(fā)現(xiàn)連不上08的數(shù)據(jù)庫,最開始是應(yīng)為沒有填寫實(shí)例名字,后來用ip/實(shí)例名還是連不上,但是pcname/實(shí)例名能連上。

            排查之后是08的服務(wù)器沒有打開tcp/ip
            打開以后發(fā)現(xiàn)服務(wù)啟動不了,應(yīng)為端口沖突了,解決以后發(fā)現(xiàn)程序能上但是查詢分析器不能上

            查詢分析器連接字符串應(yīng)該是ip,port/實(shí)例




            posted @ 2014-01-08 11:36 Enic 閱讀(185) | 評論 (0)編輯 收藏

            #include <iostream>
            extern "C"
            {
            #include "lua.h"
            #include "lauxlib.h"
            #include "lualib.h"
            }
            #include <luabind/luabind.hpp>
            using namespace luabind;
            class TestClass
            {
            public:
            TestClass(int a,int b);
            static TestClass* Singleton();
            int add();
            virtual void ShowTest(std::string& strMsg);
            private:
            static TestClass* mSingleton;
            int __a,__b;
            };
            void TestClass::ShowTest(std::string& strMsg)
            {
            std::cout << __FUNCTION__ << std::endl;
            std::cout << strMsg.c_str() << std::endl;
            strMsg += "000";
            }
            TestClass* TestClass::mSingleton = NULL;
            TestClass::TestClass(int a,int b)
            {
            __a = a;
            __b = b;
            mSingleton = this;
            }
            TestClass* TestClass::Singleton()
            {
            if(TestClass::mSingleton == NULL)
            {
            return new TestClass(0,0);
            }
            else
            {
            return mSingleton;
            }
            }
            int TestClass::add()
            {
            std::cout << __FUNCTION__ << std::endl;
            return __a+__b;
            }
            int bindClass(lua_State* L)
            {
            open(L);
            module(L)
            [
            class_<TestClass>("TestClass")
            //.def(constructor<int,int>())
            .def("add", &TestClass::add)
            .def("ShowTest", &TestClass::ShowTest),
            def("Singleton", &TestClass::Singleton)
            ];
            return 0;
            }
            int LuaErrorCallBack(lua_State *L)
            {
            std::cout << __FUNCTION__ << std::endl;
            return 0;
            }
            int main(int argc, char* argv[])
            {
            luabind::set_pcall_callback(&LuaErrorCallBack);
            TestClass testClass(10,5);
            lua_State* L = lua_open();  
            luaL_openlibs(L);
            std::cout << "init lua system" << std::endl;
            bindClass(L);
            std::cout << "do lua file" << std::endl;
            try
            {
            std::string strFileName = "add.lua.ini";
            int iRet = luaL_dofile(L, "add.lua.ini");
            if (iRet != 0)
            {
            std::cout<<"loadfile error[file: " << strFileName.c_str() << "]: "<<lua_tostring(L, -1)<<std::endl;
            }
            //if (luaL_loadfile(L, strFileName.c_str()) != 0) {
            // std::cout<<"loadfile error[file: " << strFileName.c_str() << "]"<<lua_tostring(L, -1)<<std::endl;
            //}
            //if (lua_pcall(L, 0, LUA_MULTRET, 0) != 0) {
            // std::cout<<"pcall error[file: " << strFileName.c_str() << "]" <<lua_tostring(L, -1)<<std::endl;
            //}
            std::cout << "end" << std::endl;
            //getchar();
            }
            catch(std::exception& ex)
            {
            std::cout << ex.what() << std::endl;
            }
            catch(luabind::error er)
            {
            std::cout << er.what() << std::endl;
            }
            lua_close(L);
            return 0;
            }


            print("This is valid")
            print(1234)
            bad_function()
            a = "meow"
            b = 7
            c = a + b
            testClass = Singleton()
            a = testClass:add()
            print(a)
            local valMsg = '中文'
            testClass:ShowTest(valMsg)
            print(valMsg)
            posted @ 2014-01-06 16:49 Enic 閱讀(246) | 評論 (0)編輯 收藏

            // boost_test.cpp : Defines the entry point for the console application.
            //
            #include "stdafx.h"
            #include <iostream>
            #include <vector>
            #include <boost/smart_ptr.hpp>
            #include <boost/bind.hpp>
            #include <boost/function.hpp>
            class CTest
            {
            public:
            virtual void TestShow()
            {
            std::cout << __FUNCTION__ << std::endl;
            }
            };
            int _tmain(int argc, _TCHAR* argv[])
            {
            typedef boost::function<void()> TVoidEvent;
            std::vector<TVoidEvent> vVoidEvent;
            for (int i = 0; i < 9; ++i)
            {
            boost::shared_ptr<CTest> spTest = boost::make_shared<CTest>();
            boost::weak_ptr<CTest> wpTest(spTest);
            //TVoidEvent voidEvent = boost::bind(
            // [/*wpTest*/]()
            // {
            // //boost::shared_ptr<CTest> spTestTem = wpTest.lock();
            // //if(spTestTem)
            // //{
            // // spTestTem->TestShow();
            // //}
            // std::cout << __FUNCTION__ << std::endl;
            // }
            // );
            //TVoidEvent voidEvent = [spTest]
            // {
            // if (spTest)
            // {
            // spTest->TestShow();
            // }
            // };
            // bind配合weak_ptr使用
            //TVoidEvent voidEvent = [wpTest]
            //{
            // boost::shared_ptr<CTest> spTem = wpTest.lock();
            // if (spTem)
            // {
            // spTem->TestShow();
            // }
            //};
            // 直接把lambda和bind一起用編譯有問題
            TVoidEvent voidEvent = boost::bind(
            [wpTest]
            {
            boost::shared_ptr<CTest> spTem = wpTest.lock();
            if (spTem)
            {
            spTem->TestShow();
            }
            }
            );
            vVoidEvent.push_back(voidEvent);
            }
            std::for_each(vVoidEvent.begin(), vVoidEvent.end(),
            [](TVoidEvent& voidEvent)
            {
            voidEvent();
            });
            return 0;
            }


            上面能過,下面就過不了,,,模板V5
                           []{std::cout << __FUNCTION__ << std::endl;}();
            boost::bind([]{std::cout << __FUNCTION__ << std::endl;});
            posted @ 2013-12-31 17:02 Enic 閱讀(462) | 評論 (0)編輯 收藏

            記憶中獲取dib位圖是有順序一說的,,,今天被坑了一把確實(shí)是有一說,是和圖像的格式相關(guān)的,MSDN上這樣描述:

            A pointer to the bitmap buffer. If the bitmap is a bottom-up DIB, the pointer points near the end of the buffer. If the bitmap is a top-down DIB, the pointer points to the first byte of the buffer.

            摘錄網(wǎng)上查到的筆記:

            CImage類提供了GetBits()函數(shù)來讀取數(shù)據(jù)區(qū),GetBits()函數(shù)返回的是圖片最后一行第一個(gè)像素的地址,網(wǎng)上有人說返回指針的起始位置是不同的,有些圖片返回的是左上角像素的地址,有些是左下角像素的地址,跟圖片內(nèi)部順序有關(guān)。這里我們不必關(guān)心起始位置,只要很另外兩個(gè)函數(shù)GetPitch()和GetHeight()一起使用就可以得到圖片數(shù)據(jù)取得起始位置,定義數(shù)據(jù)區(qū)指針為BYTE* img_Data

            img_Data=(BYTE *)m_Image.GetBits()+(m_Image.GetPitch()*(m_Image.GetHeight()-1));

            這樣,img_Data就是圖片數(shù)據(jù)區(qū)的起始位置,這個(gè)公式是從codeproject里看到的,介紹的很精辟,可以從google里搜索到。其中GetHeight()函數(shù)返回圖片的高度(以像素為單位)。GetPitch()返回圖像的斜度,如果圖像的順序是從下到上(也就是GetBits()返回左上角像素的地址),這時(shí)GetPitch()返回一個(gè)負(fù)值,大小為圖像寬所占有的字節(jié)數(shù),例如24位800*600的圖片,返回值應(yīng)該是正或負(fù)的800*3。這樣用每一行的字節(jié)數(shù)乘行數(shù)就可以得到起始位置了。

             

            以上是使用CImage獲取的時(shí)候遇到的坑爹,相信直接使用位圖相關(guān)的api也是一樣,msdn描述:

            Device-Independent Bitmaps

            There are two varieties of DIBs:

            • A bottom-up DIB, in which the origin lies at the lower-left corner.
            • A top-down DIB, in which the origin lies at the upper-left corner.

            使用gdiplus的時(shí)候BitmapData也是類似:

            Stride
            INT
            Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up.

             

            兩個(gè)關(guān)鍵屬性:

            GetPitch( )

            Stride

             

            還有泥馬一個(gè)被微軟坑了的壞習(xí)慣,DWORD用習(xí)慣了,調(diào)試了一天都沒看出來這兩個(gè)值我取到的是負(fù)的,,,坑啊,,,

            posted @ 2013-12-30 22:26 Enic 閱讀(1086) | 評論 (0)編輯 收藏

            image

            posted @ 2013-12-28 14:47 Enic 閱讀(206) | 評論 (0)編輯 收藏

            UI線程無故進(jìn)入死循環(huán):
            父子窗口重回
            子窗口和父窗口重繪的相關(guān)關(guān)系:
            WS_CLIPCHILDREN


            標(biāo)題欄閃動提示:
            任務(wù)欄提示:
            任務(wù)欄閃動
            FlashWindowEx()
            posted @ 2013-12-25 19:02 Enic 閱讀(182) | 評論 (0)編輯 收藏

            首先一個(gè)大觀點(diǎn):這tmd的根本就和IE控件或者網(wǎng)頁控件無關(guān),本身就是網(wǎng)頁渲染器的效果。更直接的說就是網(wǎng)頁本身的問題。

            網(wǎng)絡(luò)上一溜的解決方案大部分都是要把IE控件這個(gè)接口實(shí)現(xiàn)以下那個(gè)數(shù)據(jù)動一下,最終大概有兩種辦法:1.還是間接的修改了html;2.通過修改窗口rgn來達(dá)到目的。

             

            其實(shí)關(guān)鍵的html就在這兩句:

            <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
            <style type="text/css">
            body{
            border:0px;
            overflow:hidden;
            }
            </style>

             

             

            轉(zhuǎn)載一下靠譜的方法:

            如何去除Webbrowser滾動條、邊框的方法

            2010-05-22 13:34:44|  分類: Delphi、軟件|字號 訂閱

            在使用delphi開發(fā)軟件的時(shí)候,有時(shí)只需要顯示webbrowser的網(wǎng)頁內(nèi)容,而不希望顯示webbrowser滾動條或邊框,那么我們?nèi)绾螌?shí)現(xiàn)這個(gè)效果呢?
                其實(shí),這個(gè)問題不是webbrowser控件的問題,而是網(wǎng)頁自身的css控制問題。我們通過調(diào)整目標(biāo)網(wǎng)頁的css效果就可以實(shí)現(xiàn)了。
            webbrowser去除滾動條的方法
            將 <body> 改成 <body scroll="no"> 即可。
            webbrowser去除3D邊框的方法
                在網(wǎng)頁的head區(qū)域的css部分加上如下代碼即可:
            <style type="text/css">
            body{
            border:0px;
            overflow:hidden;
            }
            </style>
                同時(shí),將網(wǎng)頁的頂部聲明DOCTYPE改成 :
            <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
                而不是 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 等其他這樣的形式。

             

            后來看了下優(yōu)庫的主頁更牛逼:

            <!DOCTYPE html>直接就沒有

            博客園的:

            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

            163的:<!DOCTYPE html>

            qqgame: <!DOCTYPE HTML>

             

             

            好了,網(wǎng)站開發(fā)的卻是不夠敬業(yè)

            posted @ 2013-12-24 00:11 Enic 閱讀(465) | 評論 (0)編輯 收藏

            QT的Event機(jī)制里邊,所有的Event都是派生于QEvent類,然后Event派發(fā)的時(shí)候都是通過一個(gè)函數(shù):event(QEvent*),通過QEvent::Type()獲取到真實(shí)的類型,然后使用static_cast轉(zhuǎn)換到實(shí)際的類型再派發(fā)到QXXEvent函數(shù)去處理。

            這里是利用了CPP的rtii機(jī)制,但是為什么沒有用dynamic_cast呢?猜測是為了效率。

            但是這樣有一個(gè)缺陷,就是當(dāng)Type取到的類型和實(shí)際類型不一致的時(shí)候沒有rtii的檢測,可能導(dǎo)致類型不匹配,然后崩潰掉。。。

            效率是一個(gè)原因,但是個(gè)人覺得,穩(wěn)定性有限于效率。

            即使測試了一下,500000次轉(zhuǎn)換效率也不會太弱,繼承數(shù)深度也不是和效率呈線型關(guān)系的:

            class CRoot
            {
            public:
                virtual ~CRoot(){}
            };
            
            class CTest : public CRoot
            {
            public:
                virtual void ShowFunctionName()
                {
                    std::cout << __FUNCTION__ << std::endl;
                }
            };
            
            class CTestEx : public CTest
            {
            public:
                virtual void ShowFunctionName()
                {
                    std::cout << __FUNCTION__ << std::endl;
                }
                
                virtual void ShowOnlyForEx()
                {
                    std::cout << __FUNCTION__ << std::endl;
                }
            };
            
            
            void Func(CTestEx *pTestEx)
            {
                pTestEx->ShowOnlyForEx();
            }
            
            void Func(CTest *pTest)
            {
                try
                {
                    CRoot *pRoot = new CTestEx;
            
                    boost::timer timerTest;
            
                    timerTest.restart();
            
                    for (int i = 0; i < 500000; i++)
                    {
                        CTestEx *pTextEx = nullptr;
                        pTextEx = dynamic_cast<CTestEx*>(pRoot);
                    }
            
                    double dTime = timerTest.elapsed();
                    std::cout << dTime << std::endl;
            
                    timerTest.restart();
            
                    for (int i = 0; i < 500000; i++)
                    {
                        CTest *pText = nullptr;
                        pText = dynamic_cast<CTest*>(pRoot);
                    }
            
                    dTime = timerTest.elapsed();
                    std::cout << dTime << std::endl;
                    //Func(dynamic_cast<CTestEx*>(pRoot));
                    //Func((CTestEx*)pRoot);
            
                    timerTest.restart();
            
                    for (int i = 0; i < 500000; i++)
                    {
                        CTestEx *pTextEx = nullptr;
                        pTextEx = static_cast<CTestEx*>(pRoot);
                    }
            
                    dTime = timerTest.elapsed();
                    std::cout << dTime << std::endl;
                }
                catch(std::exception& refException)
                {
                    std::cout << refException.what() << std::endl;
                }
                catch(std::bad_cast)
                {
                    std::cout << __FUNCTION__ << std::endl;
                }
                catch(...)
                {
                    std::cout << __FUNCTION__ << std::endl;
                }
            }
            
            void Test()
            {
                CTest *pTest = new CTest;
                Func(pTest);
            }
            

            0.031

            0.033

            0.001

            debug模式下運(yùn)行,感覺這個(gè)速度應(yīng)該是能接受的。

            向下類型轉(zhuǎn)換的時(shí)候使用dynamic_cast應(yīng)該是有必要的,所有咱們就這樣用了吧,,,

            posted @ 2013-12-22 21:11 Enic 閱讀(218) | 評論 (0)編輯 收藏

            1.為什么要自己擼一個(gè)UI庫?

            就好比做菜
            從原材料做任何菜本來都很簡單
            非在別人做好的菜上來改
            改來改去達(dá)不到效果說太難了

            你丫有種你用紅燒肉改一回鍋肉試試?
            世界上總有這么一批賤B
            就想撿現(xiàn)成
            越撿路越難還不知道反省

            話說有一人拜師學(xué)廚
            他想做道回鍋肉給他老娘吃
            徒弟:師傅,我想做道回鍋肉,該怎么辦呢?
            師傅:你準(zhǔn)備點(diǎn)五花肉,煮一下切來炒熟就好了
            徒弟:可是那個(gè)難度太高了,再說時(shí)間太緊了,師傅,這盤
                  紅燒肉也是五花的,我初學(xué),你還是教我怎么從紅燒
                  肉改回鍋肉吧。等以后我水平提高了,有閑功夫了,
                  再系統(tǒng)學(xué)習(xí)從生肉開始做回鍋肉!
            師傅:..................................

             

            2.咱肯定是站在巨人的肩膀上,自己擼道行不夠還不知道擼個(gè)什么出來。所以呢,一開始打算直接擼duilib,結(jié)果發(fā)現(xiàn)可能這貨不夠巨人雖然看起來所有功能都有了,但是用起來總覺得差了點(diǎn)什么。然后在喵上了chromium,泥馬折騰好久發(fā)現(xiàn)提出一個(gè)ui庫是不是太麻煩了,,,也投降了,然后瞅上了skia這貨,有硬件加速啊,泥馬結(jié)果能力還是欠缺了點(diǎn),一口不能吃成胖子,,,然后開始擼uileeihcy,這個(gè)思想夠豐富的庫。發(fā)現(xiàn)也不是不能直接用。

            好吧,我確實(shí)欠抽,,,

            然后開始失敗了無數(shù)次,放棄了無數(shù)次的自己擼一個(gè)想法又出現(xiàn)了,這次實(shí)事求是的擼吧。

             

            今天主要看了下大概,不管是duilib、chromium、uileeihcy,他們都是把ui抽象出了一個(gè)基類:duilib的control chromium的view uileeihcy的object,不同的是有些control不是container,有些具有這些功能。chromium和uileeihcy都具base都具有container的功能,那咱就也要有這功能。chromium和uileeihcy的基類中有具有的功能:

            1.屬性;2.container;3.eventtarget;4.layout management;5.個(gè)控件的私有消息是自己檢查產(chǎn)生派發(fā)的。

             

            初步看起來都有一個(gè)共性,就是控件的消息自己處理,不過uileeihcy里邊有的設(shè)計(jì)比較有特點(diǎn),需要進(jìn)一步分析以便理解他的設(shè)計(jì)思想:

            image

            posted @ 2013-12-02 00:15 Enic 閱讀(767) | 評論 (2)編輯 收藏

            僅列出標(biāo)題
            共22頁: First 10 11 12 13 14 15 16 17 18 Last 
            久久99精品久久久大学生| 精品久久一区二区| 亚洲精品WWW久久久久久 | 一级女性全黄久久生活片免费 | 久久久精品波多野结衣| 久久综合狠狠色综合伊人| 亚洲国产婷婷香蕉久久久久久| 日本精品久久久久影院日本| 久久亚洲国产成人精品无码区| 一本久久a久久精品亚洲| 国产精品一久久香蕉产线看| 理论片午午伦夜理片久久| 人妻精品久久无码区| 久久久久亚洲AV成人网人人网站| 婷婷国产天堂久久综合五月| 久久久久女人精品毛片| 久久精品免费全国观看国产| 久久精品国产亚洲AV无码娇色| 欧美激情精品久久久久久| 色88久久久久高潮综合影院| 久久精品中文字幕一区| 久久99国产精品久久99| 亚洲AV乱码久久精品蜜桃| 热RE99久久精品国产66热| 国产高清国内精品福利99久久| 久久精品国产亚洲AV香蕉| 久久久WWW免费人成精品| 999久久久无码国产精品| 久久天天躁狠狠躁夜夜躁2O2O| 午夜视频久久久久一区| 91精品国产综合久久精品| 久久香蕉超碰97国产精品| 久久久久高潮毛片免费全部播放 | 精品久久久久久| 久久久久久久女国产乱让韩| 色偷偷91久久综合噜噜噜噜| 久久国产精品免费| 国产精品成人99久久久久 | 久久免费国产精品| 97精品伊人久久久大香线蕉| 国产免费久久久久久无码|