2014年1月7日 星期二

[Java, Windows 8] How to transform Java List to Store apps C++/CX?

Java codes:

private static List<String> vv = new ArrayList<String>();

vv.add("area");
vv.add("base");
vv.add("basefont");
vv.add("br");
vv.add("col");
vv.add("frame");
vv.add("hr");
vv.add("img");
vv.add("input");
vv.add("isindex");
vv.add("link");
vv.add("meta");
vv.add("param");

String ss = "hr";
if (vv.contains(ss))
{
/* vv contains ss */
}
else
{
/* vv does not contain xx */
}

==> Store apps C++/CX
Platform::Collections::Vector<Platform::String^>^ vv = ref new Vector<Platform::String^>();

vv->Append("area");
vv->Append("base");
vv->Append("basefont");
vv->Append("br");
vv->Append("col");
vv->Append("frame");
vv->Append("hr");
vv->Append("img");
vv->Append("input");
vv->Append("isindex");
vv->Append("link");
vv->Append("meta");
vv->Append("param");

unsigned int index = 0;
String^ ss = "hr";
if (vv->IndexOf(ss, &index))
{
/* vv contains ss */
else
{
/* vv does not contain xx */
}

2014年1月1日 星期三

[Windows 8] How to show ... when string is long in textBlock.

Add TextTrimming="WordEllipsis" in XAML

[Windows 8] How to covert Platform::String to char and fix C2440 Error with C++

Covert Platform::String to char
        Platform::String ^SrcString = "abc";
        std::wstring tmpW(SrcString ->Begin());
std::string tmpA(tmpW.begin(), tmpW.end());
char* DstString = tmpA.c_str();     // Error C2240

fix C2440 Error
        Platform::String ^SrcString = "abc";
        std::wstring tmpW(SrcString ->Begin());
std::string tmpA(tmpW.begin(), tmpW.end());
const char* DstString = tmpA.c_str();

[VC++] 如何在Edit control移動編輯位置至最後一行加入文字

TCHAR tmp[MAX_PATH];
ZeroMemory(tmp, sizeof(TCHAR) * MAX_PATH);
wsprintf(tmp, L"[Count]: %d\r\n", nCount);
m_oResult.SetSel(0, -1);
m_oResult.SetSel(-1);
m_oResult.ReplaceSel(tmp);

[Win32] 如何列印 %f 的資訊

先用ANSI code function, 再轉成Unicode, 如下:

char tmp[MAX_PATH];
ZeroMemory(tmp, sizeof(char) * MAX_PATH);
sprintf_s(tmp, "[Time Elapsed]: %f sec\n", dwTimeElapsed / 1000.0);
TCHAR tmp1[MAX_PATH];
ZeroMemory(tmp1, sizeof(TCHAR) * MAX_PATH);
wsprintf(tmp1, L"%S", tmp);
OutputDebugString(tmp1);

[Android Studio] 如何增加編輯器顯示行數和類別成員的區分

1. Open Settings Dialog in File\Settings...
2. Select IDE Settings\Editor\Appearance
3. Choose "Show line numbers" and "Show member separators"


[Android Studio] How to change the edit font in Android Studio

1. Open Settings Dialog in File\Settings...
2. Select IDE Settings\Editor\Colors & Fonts\Font
3. Press Save As...
4. Input name in popup dialog and Save
5. Remove Selected fonts and select new Available fonts
6. Press OK.