[問題] MFC Dialog控制view顯示圖片
開發平台(Platform): (Ex: Win10, Linux, ...)
Win10
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
VS2017
問題(Question):
各位好
我在一個view中放了button與picture control
透過點擊按鈕可顯示bitmap圖片 程式碼如下圖
https://imgur.com/a/JWW2W
現在我要透過Dialog的按鈕讓同個view顯示圖片
試過在雙擊按鈕自動產生的BN_CLICKE事件中加入程式 但有錯誤訊息
https://imgur.com/a/NUin1
也試過對按鈕加入event handler
我在class list選該view
在function中試著跳出一個messagebox 不過卻沒反應
https://imgur.com/a/mlTFM
(也試過把顯示圖片程式碼放上去 也沒反應)
是不是少了什麼步驟?
請各位前輩指導
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 202.39.226.12
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1519352685.A.69F.html
推
02/23 13:36,
6年前
, 1F
02/23 13:36, 1F
原來要換ID, 不過改了之後還是一樣的情況, view的button沒問題, Dialog依舊無法, 或者需要宣告什麼嗎?
→
02/23 14:41,
6年前
, 2F
02/23 14:41, 2F
我把picture control的ID改成IDC_PICTURE來使用
→
02/23 15:10,
6年前
, 3F
02/23 15:10, 3F
→
02/23 15:10,
6年前
, 4F
02/23 15:10, 4F
我在dialog button的code與第一張圖片相同(顯示bitmap的程式碼)
→
02/23 15:47,
6年前
, 5F
02/23 15:47, 5F
CODE:
void CDialogTEST1::OnBnClickedButton2()
{
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BITMAP1);
CStatic *p = (CStatic *)GetDlgItem(IDC_PICTURE);
p->ModifyStyle(0xf, SS_BITMAP | SS_CENTERIMAGE);
p->SetBitmap(bitmap);
}
※ 編輯: OPliao (202.39.226.12), 02/23/2018 15:50:38
→
02/23 17:17,
6年前
, 6F
02/23 17:17, 6F
→
02/26 17:40,
6年前
, 7F
02/26 17:40, 7F
→
02/26 17:41,
6年前
, 8F
02/26 17:41, 8F
→
02/26 17:44,
6年前
, 9F
02/26 17:44, 9F
→
02/26 17:46,
6年前
, 10F
02/26 17:46, 10F
→
02/26 17:47,
6年前
, 11F
02/26 17:47, 11F