2014年1月21日 星期二

Astyle(程式語言排版工具)

官網:
http://astyle.sourceforge.net/

指令說明:
http://astyle.sourceforge.net/astyle.html

與Visual Studio整合:
    1. Visual Studio->Tools->External Tools->Add
    2. Add:
        Title: AStyle
        Command: C:\Program Files\AStyle\bin\AStyle.exe #執行檔位置
        Arguments: --style=linux -T -xl -C -S -N -L -Y -p -U -y -n $(ItemFileName)$(ItemExt) #請參考指令說明
        Initial directory: $(ItemDir)
    3. OK:
    4. Add shortcut:
        a: Click right button of mouse in toolbar->Customize
        b: Tools->drag "external commandx" to toolbar
        P.S. x is the order of your command.

參考網站:
http://infiniteengine.blogspot.tw/2011/08/artistic-style.html
http://blog.csdn.net/xiaotao2004/article/details/1560538

指令參考:
--style=linux / --style=knf / -A8

--indent=force-tab / -T

--attach-inlines / -xl

--indent-classes / -C
--indent-switches / -S
--indent-namespaces / -N
--indent-labels / -L
--indent-col1-comments / -Y

--pad-oper / -p
--unpad-paren / -U

//--align-pointer=type / -k1
//--align-reference=type / -W1

--break-closing-brackets / -y

--suffix=none / -n    不產生備份檔.orig

--style=linux -T -xl -C -S -N -L -Y -p -U -y -n $(ItemFileName)$(ItemExt)

2014年1月20日 星期一

C++/CLI download a webpage

Please check the under link:
http://www.digitalcoding.com/Code-Snippets/CPP-CLI/C-CLI-Code-Snippet-Download-HTML-Web-Page.html

http://stackoverflow.com/questions/7523013/c-cli-url-download-to-file

Get correct encoding:
http://stackoverflow.com/questions/227575/encoding-problem-with-httpwebresponse

C++/CLI call MessageBox(Unmanaged)

using namespace System;
using namespace System::Runtime::InteropServices;

//typedef void* HWND;
[DllImport("User32.dll", EntryPoint = "FindWindow")]
extern "C" Int32 SW32Api_FindWindow (String^ lpClassName,String^ lpWindowName);
[DllImport("User32.dll", EntryPoint = "SendMessage")]
extern "C" Int32 SW32Api_SendMessage(Int32 hWnd, UInt32 Msg, Int32 wParam, Int32 lParam);
[DllImport("User32.dll", EntryPoint = "MessageBox", CharSet=CharSet::Auto)]
extern "C" Int32 SW32Api_MessageBox(Int32 hwnd, String^ Contain, String^ caption, UInt32 type);