EvoTalk

Posts Tagged ‘mfc

如何使 vc6 MFC 程式具有 WinXP 外觀?

Create a Manifest File

view plain

XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<assembly xmlns="urn:schemas-microsoft-com:asm.v1"

                 manifestVersion="1.0">

<assemblyIdentity

    version="1.0.0.0"

    processorArchitecture="X86"

    name="Microsoft.Windows.YourApplication"

    type="win32"

/>

<description>YourApplication</description>

<dependency>

    <dependentAssembly>

        <assemblyIdentity

            type="win32"

            name="Microsoft.Windows.Common-Controls"

            version="6.0.0.0"

    [...]

Tags: ,

07 七月, 2006

Some MFC Snippet Code

Posted by: asd In: C++| Code Snippet| 程式設計

Create modeless dialog
CDlgGrm dlg = new CDlgGrm;
dlg->Create(IDD_DIALOG_GRM);
dlg->ShowWindow(1);
Playing wav in resource
view plain

C++:

// 假設 wave file 已匯入資源,resource id 為 IDR_WAVE_BEEP

char *pcBeepWav;

HRSRC h1 = FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_WAVE_BEEP),"WAVE");

HGLOBAL h2 = LoadResource(AfxGetResourceHandle(), h1);

pcBeepWav = (char *)LockResource(h2);

sndPlaySound(m_pcBeepWav , SND_MEMORY | SND_SYNC);

Enum each line in multiline edit box
view plain

C++:

int nline;

CString sLine;

 

nline = m_edit.GetLineCount();

for (i = 0; i <nline; i++)

{

// get the line.

m_edit.GetLine( [...]

Tags:

08 十二月, 2005

MFC Tips

Posted by: asd In: C++| Code Snippet| 程式設計

* Split token
view plain

C++:

strData: splited token

strText : input string

',' : 以 ',' 為分隔的符號

CString strData;

for (int idx=0; AfxExtractSubString(strData, strText, idx, ',');idx++)

printf("%sn",(LPCTSTR)strData);

* CString 轉 wchar_t *
view plain

C++:

BSTR b = strText.AllocSysString();

// do something using b

SysFreeString(b);

wchar_t * 轉CString
CString strText = (CString) b;

Tags:

08 十二月, 2005

MFC Notes

Posted by: asd In: C++| Code Snippet| 程式設計

Tabbed window
簡介:每個tab都是一個獨立的dialog,再把這些dialog集合起來
ComboListCtrl
簡介:sub-item editable、set read-only column、combo embedded
validate input data(ex:只允許輸入數字)

Tags:

確定control的 style有LVS_EDITLABELS 若無則programmatically加入
//arg1:移除狀態,arg2:加入狀態
m_lstKey.ModifyStyle(0 ,LVS_EDITLABELS );
使edit變成編輯狀態
m_listctrl.SetFocus();
m_listctrl.EditLabel(nItem);
或是
m_listctrl.SendMessage(LVM_EDITLABEL, nCurSel, 0);

Tags:

Page 2 of 212