2020年9月25日 星期五

[C#]建立文件,寫檔,刪除文件

         protected void CreateFile()

        {

            String strTxt = ".\\" TEST.txt";

            String strData = @"123456789";

            // Delete a file by using File class static method...

            if (System.IO.File.Exists(strTxt))

            {

                // Use a try block to catch IOExceptions, to

                // handle the case of the file already being

                // opened by another process.

                try

                {

                    System.IO.File.Delete(strTxt);

                }

                catch (System.IO.IOException e)

                {

                    Console.WriteLine(e.Message);

                    return;

                }

            }

            FileStream fileStream = new FileStream(strTxt, FileMode.Create);


            fileStream.Close();   //切記開了要關,不然會被佔用而無法修改喔!!!


            using (StreamWriter sw = new StreamWriter(strTxt,false))//覆寫檔案

            {

                // 欲寫入的文字資料 ~


                sw.Write(strData );

                //sw.WriteLine(DateTime.Now);

            }


        }

[c#]建創資料夾 取得目前檔案路徑資料夾

         protected void CreateDataTemp()

        {

            string TempPath = System.Windows.Forms.Application.StartupPath + @"\要建立資料夾名稱\";

            if (Directory.Exists(TempPath))

            {

                //資料夾存在

            }

            else

            {

                //新增資料夾

                Directory.CreateDirectory(TempPath);

            }

        }

[C#]Tip提示文字

         

           String strData= @"說明";

            EditBoxInitTip(tb_TEST, strData);


protected void EditBoxInitTip(Control cTB, String strData)

        {

            //ToolTip:當游標停滯在某個控制項時,就會跳出一個小視窗

            ToolTip toolTip1 = new ToolTip();

            //SetToolTip:定義控制項會跳出提示的文字

            toolTip1.SetToolTip(cTB, strData);

            //以下為提示視窗的設定(通常會設定的部分)

            //ToolTipIcon:設定顯示在提示視窗的圖示類型。

            toolTip1.ToolTipIcon = ToolTipIcon.Info;

            //ForeColor:顧名思義就是前景顏色,你懂的!!XD

            toolTip1.ForeColor = Color.Blue;

            //BackColor:顧名思義就是背景顏色,你也懂的!!XD

            toolTip1.BackColor = Color.Gray;

            //AutoPopDelay:當游標停滯在控制項,顯示提示視窗的時間。(以毫秒為單位)

            toolTip1.AutoPopDelay = 1000;

            //ToolTipTitle:設定提示視窗的標題。

            toolTip1.ToolTipTitle = "提示訊息";

        }

2020年6月18日 星期四

[BCB]messagebox


AnsiString str = BoolToStr( o_chkTXT->Checked );
Application->MessageBox(s.c_str(), "Test", 32+3);

 char* c_str()

 AnsiString str = "Hello World!";
  MessageBox(NULL,str.c_str(),"",MB_OK);   //顯示一個消息框

2020年4月9日 星期四

git常用指令

git 指令筆記

git clone + clone網址


git fetch
git pull origin


git status

git diff
(關閉案q)


git add --all
git commit
    enter + i
    編輯完畢後 esc + wq


git push origin head

(edit commit)-----

git commit --amend
git push -f


2019年11月25日 星期一

[工具]Visual studio 初始化 (回到初始設定)

在windows中找到安裝目錄"Visual Studio Tools"下的 "vs2xxx開發人員命令"

並輸入以下 注意空白鍵
devenv.exe /setup /resetuserdata /resetsettings

2019年10月22日 星期二

[C++]MFC按鈕添加提示文字

宣告在 *.h
CToolTipCtrl m_ctrlTT;

定義內容: *.cpp
BOOL SerialDlg::OnInitDialog() 
{
        ......
 //prompt
 EnableToolTips(TRUE);//enable use it
 m_ctrlTT.Create(this);
 m_ctrlTT.Activate(TRUE);
 m_ctrlTT.SetDelayTime(150);//delayTime
 //IDC_BUTTON_SEND2 為要添加的控建IDC ,"Hello"為想添加的提示
 m_ctrlTT.AddTool(GetDlgItem(IDC_BUTTON_SEND2), (LPCTSTR)"Hello");

 return TRUE;  
}

添加虛擬函示(ClassWizard中選擇虛擬函式 PreTranslateMessage)

BOOL SerialDlg::PreTranslateMessage(MSG* pMsg)
{
 // TODO: 在此加入特定的程式碼和 (或) 呼叫基底類別
 m_ctrlTT.RelayEvent(pMsg);
 return CDialog::PreTranslateMessage(pMsg);
}


測試環境 MFC VC2015

[SQL]顯示千分位與小數顯示

  CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) CONVERT style參數說明 1  (expression為 money 或 smallmoney型別): 0 : 預設,保留小數位後兩位,並四捨...