0

在visual studio 2010下使用c++。

我有一个对话框创建部分

IDD_LOGON DIALOGEX 0, 0, 265, 70
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
CAPTION "Log On to Windows"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN 
  EDITTEXT        IDC_NAME,61,9,127,14,ES_AUTOSCROLL
  EDITTEXT        IDC_PASSWORD,61,29,127,14,ES_PASSWORD | ES_AUTOSCROLL
  EDITTEXT        IDC_DOMAIN,61,49,127,14,ES_AUTOSCROLL
  DEFPUSHBUTTON   "OK",IDOK,204,8,50,14
  PUSHBUTTON      "Cancel",IDCANCEL,204,25,50,14
  LTEXT           "Domain:",IDC_STATIC,21,52,27,8
  LTEXT           "Password:",IDC_STATIC,21,32,34,8
  LTEXT           "User Name:",IDC_STATIC,17,12,38,8
  PUSHBUTTON      "Shutdown",IDC_SHUTDOWN,204,49,50,14
END

我想在这个对话框的背景中有一张图片。

我将如何执行此操作?

谢谢你

4

3 回答 3

4

在您的OnInitDialog()使用中:

this->SetBackgroundImage(IDB_BITMAP1, BACKGR_TOPLEFT, TRUE);

有关更多信息,请参阅:CDialogEx::SetBackgroundImage

于 2015-05-21T07:07:23.097 回答
1

没有办法通过对话框模板/设计器来做到这一点。您需要在对话框中处理 WM_ERASEBKGND 消息并自己绘制背景。

这是一些信息: http: //www.codeproject.com/Articles/18967/Bitmap-Backgrounds-For-Dialog-Boxes

于 2013-05-09T13:32:47.877 回答
0

quick answer... i dropped the image control on the dialog, set the image... then... i went into the code and placed it at the TOP of the stack, and it was painted with no issues. the transparent portion of the other controls was failing, so i grouped them all into an area of the same background color on the image, and walla - all done. thank you

于 2013-05-21T15:06:18.763 回答