顯示具有 text 標籤的文章。 顯示所有文章
顯示具有 text 標籤的文章。 顯示所有文章

2016年4月26日 星期二

[C++] Messagebox with int/long value , or text 如何顯示?

Debug時候,有時需要使用Messagebox,

但是要加入特定文字,或是變數該怎麼讓他顯示呢?

先從文字開始:

MessageBox(HWND hwnd, LPCWSTR lpText,LPCWSTR lpCation , UINT uType);

hwnd因為不需要特別設定 = 0

LPCWSTR  lpText是Box內想說的話 --->    _T("我想說的話")

LPCWSTR  lpCation是Box的標題 --->    _T("我的標題")

UINT uType 就是可以讓他選OK cancel等按鈕,這邊是填入MB_OK(可以自行調整)





我要填入ulong / int  怎麼辦??

CString msg;
msg.Format(_T("%d").變數名稱);
AfxMessageBox(msg);


這樣就可以囉!


END






2015年5月11日 星期一

[iOS] 可輸入文字(textfield)之警告視窗(alertview)

又遇到問題,於是找了方法來解決


android上面的alertview十分簡單(custom的部份)

iOS呢?是否一樣簡單?

[ iOS 7 + Xcode 6.3.1 ]


第一次看別人的code:


    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"輸入IP" message:@" " delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"確認",nil];
    UITextField * txt = [[UITextField alloc] init];
    txt.backgroundColor = [UIColor whiteColor];
    txt.frame = CGRectMake(alert.center.x+65,alert.center.y+48, 150,23);
    [alert addSubview:txt];

    [alert show];

結果有跳出警告視窗,但是沒有可以輸入的阿!

於是就繼續查,才發現要加上

alert.alertViewStyle = UIAlertViewStylePlainTextInput;


正確版本:

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"輸入IP" message:@" " delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"確認",nil];
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    UITextField * txt = [[UITextField alloc] init];
    txt.backgroundColor = [UIColor whiteColor];
    txt.frame = CGRectMake(alert.center.x+65,alert.center.y+48, 150,23);
    [alert addSubview:txt];
    [alert show];

當然style也有password/default(無法顯示)/login..之類的,大家可以自行嘗試喔!

end