版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
案例2:可擴展的對話框2023/10/171案例2:可擴展的對話框需求與目標(biāo)這個功能類似QQ的顯示聊天記錄當(dāng)用戶要顯示一些過多的選擇時,對話框自動擴展其大小,將隱藏的部分顯示出來2023/10/172案例2:可擴展的對話框效果2023/10/173案例2:可擴展的對話框效果2023/10/174案例2:可擴展的對話框手段利用CDialog類的SetRect函數(shù)來設(shè)定對話框的大小2023/10/175案例2:可擴展的對話框手段利用CDialog類的SetRect函數(shù)來設(shè)定對話框的大小調(diào)用MoveWindow函數(shù)來實現(xiàn)改變對話框的大小2023/10/176案例2:可擴展的對話框編程步驟(1)使用AppWizard創(chuàng)建一個基于對話框的應(yīng)用程序2023/10/177案例2:可擴展的對話框編程步驟(2)為對話框添加一些控件2023/10/178案例2:可擴展的對話框編程步驟(2)2023/10/179案例2:可擴展的對話框編程步驟(2)2023/10/1710案例2:可擴展的對話框編程步驟(3)為對話框添加3個成員變量:BOOLm_bExpand;//記錄是否已經(jīng)擴展對話框UINTm_nExpandedHeight;//擴展后對話框的高度UINTm_nNormalHeight;//擴展前對話框的高度2023/10/1711案例2:可擴展的對話框BOOLtypedefintBOOL;typedeflongBOOL;ABooleanvalue.
2023/10/1712案例2:可擴展的對話框UINT
typedefunsignedintUINT;A16-bitunsignedintegeronWindowsversions3.0and3.1;a32-bitunsignedintegeronWin32.
2023/10/1713案例2:可擴展的對話框編程步驟(4)在對話框的OnInitDialog函數(shù)中加入以下代碼: m_bExpand=FALSE; CRectrcDlg,rcMarker; GetWindowRect(rcDlg); m_nExpandedHeight=rcDlg.Height(); GetDlgItem(IDC_BORDER)->GetWindowRect(rcMarker); m_nNormalHeight=(rcMarker.top-rcDlg.top); rcDlg.SetRect(rcDlg.left,rcDlg.top,rcDlg.left+rcDlg.Width(),rcDlg.top+m_nNormalHeight); MoveWindow(rcDlg,TRUE);2023/10/1714案例2:可擴展的對話框CWnd::GetWindowRectvoid
GetWindowRect(
LPRECT
lpRect
)
const;
lpRectPointstoaCRectobjectoraRECTstructurethatwillreceivethescreencoordinatesoftheupper-leftandlower-rightcorners.RemarksCopiesthedimensionsoftheboundingrectangleoftheCWndobjecttothestructurepointedtobylpRect.Thedimensionsaregiveninscreencoordinatesrelativetotheupper-leftcornerofthedisplayscreen.Thedimensionsofthecaption,border,andscrollbars,ifpresent,areincluded.2023/10/1715案例2:可擴展的對話框RECT、LPRECTtypedefstructtagRECT{LONGleft;LONGtop;LONGright;LONGbottom;}RECT,*PRECT,NEAR*NPRECT,FAR*LPRECT;2023/10/1716案例2:可擴展的對話框CRectclassCRect:publictagRECT{public:…… //retrievesthewidth intWidth()const; //returnstheheight intHeight()const;……}2023/10/1717案例2:可擴展的對話框CWnd::GetDlgItem
CWnd*
GetDlgItem(
int
nID
)
const;nIDSpecifiestheidentifierofthecontrolorchildwindowtoberetrieved.ReturnValueApointertothegivencontrolorchildwindow.IfnocontrolwiththeintegerIDgivenbythenIDparameterexists,thevalueisNULL.Thereturnedpointermaybetemporaryandshouldnotbestoredforlateruse.RemarksRetrievesapointertothespecifiedcontrolorchildwindowinadialogboxorotherwindow.ThepointerreturnedisusuallycasttothetypeofcontrolidentifiedbynID.2023/10/1718案例2:可擴展的對話框控件IDresource.h#defineIDC_BORDER1000#defineIDC_EXPAND10012023/10/1719案例2:可擴展的對話框CRect::SetRectvoid
SetRect(
int
x1,
int
y1,
int
x2,
int
y2
);x1Specifiesthex-coordinateoftheupper-leftcorner.y1Specifiesthey-coordinateoftheupper-leftcorner.x2Specifiesthex-coordinateofthelower-rightcorner.y2Specifiesthey-coordinateofthelower-rightcorner.RemarksSetsthedimensionsofCRecttothespecifiedcoordinates.2023/10/1720案例2:可擴展的對話框CWnd::MoveWindowvoid
MoveWindow(
LPCRECT
lpRect,BOOL
bRepaint=TRUE
);lpRectTheCRectobjectorRECTstructurethatspecifiesthenewsizeandposition.bRepaintSpecifieswhetherCWndistoberepainted.RemarksChangesthepositionanddimensions.Foratop-levelCWndobject,thexandyparametersarerelativetotheupper-leftcornerofthescreen.ForachildCWndobject,theyarerelativetotheupper-leftcorneroftheparentwindow’sclientarea.2023/10/1721案例2:可擴展的對話框編程步驟(5)為“隱藏”按鈕添加單擊響應(yīng)函數(shù)OnExpand:2023/10/1722案例2:可擴展的對話框編程步驟(5)為“隱藏”按鈕添加單擊響應(yīng)函數(shù)OnExpand:voidCExpandDlgDlg::OnExpand(){ m_bExpand=!m_bExpand;
CRectrcDlg; GetWindowRect(rcDlg);2023/10/1723案例2:可擴展的對話框編程步驟(5) if(m_bExpand) { rcDlg.SetRect(rcDlg.left,rcDlg.top,rcDlg.left+rcDlg.Width(),rcDlg.top+m_nExpandedHeight); m_expand.SetWindowText("隱藏"); } else { rcDlg.SetRect(rcDlg.left,rcDlg.top,rcDlg.left+rcDlg.Width(),rcDlg.top+m_nNormalHeight); m_expand.SetWindowText("顯示"); } MoveWindow(rcDlg,TRUE);}2023/10/1724案例2:可擴展的對話框CWnd::SetWindowTextvoid
SetWindowText(
LPCTSTR
lpszString
);lpszStringPointstoaCStringobjectornull-terminatedstringtobeusedasthenewtitleorcontroltext.RemarksSetsthewindow’stitletothespecifie
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 休閑農(nóng)業(yè)服務(wù)員保密意識知識考核試卷含答案
- 電聲振動件制造工安全意識強化評優(yōu)考核試卷含答案
- 玻纖拉絲工崗前決策力考核試卷含答案
- 丙酮氰醇裝置操作工崗前設(shè)備考核試卷含答案
- 印染成品定等工改進競賽考核試卷含答案
- 樹脂采收工安全管理水平考核試卷含答案
- 2024年廣州民航職業(yè)技術(shù)學(xué)院馬克思主義基本原理概論期末考試題附答案
- 2024年星海音樂學(xué)院輔導(dǎo)員考試筆試真題匯編附答案
- 數(shù)控研磨工安全綜合模擬考核試卷含答案
- 2024年通化醫(yī)藥健康職業(yè)學(xué)院輔導(dǎo)員考試參考題庫附答案
- 砌體工程監(jiān)理實施細(xì)則及操作規(guī)范
- 2025年瑞眾保險全國校園招聘150人考試練習(xí)題庫(含答案)
- 以房抵工程款合同協(xié)議6篇
- 通信設(shè)備用電安全培訓(xùn)課件
- 方太企業(yè)培訓(xùn)課件
- 水上平臺施工安全培訓(xùn)課件
- 中秋福利采購項目方案投標(biāo)文件(技術(shù)方案)
- 手術(shù)部(室)醫(yī)院感染控制標(biāo)準(zhǔn)WST855-2025解讀課件
- 二氧化硅氣凝膠的制備技術(shù)
- 湖南省岳陽市平江縣2024-2025學(xué)年高二上學(xué)期期末考試語文試題(解析版)
- 2024-2025學(xué)年湖北省武漢市江漢區(qū)七年級(下)期末數(shù)學(xué)試卷
評論
0/150
提交評論