0

嘿,
我已经使用 ResEdit 创建了一个无模式对话框,以完全模仿窗口的颜色选择对话框的功能,该对话框存在于默认的 Windows“Paint”应用程序中。
我这样做是我的 C++ WINAPI 研究的一部分。
(在这里看到:http: //i233.photobucket.com/albums/ee74/Lightfooted/Public/colorDialog.jpg

我目前遇到的问题是,在“WM_CTLCOLORSTATIC”处理期间,我似乎无法为“PictureBox”控件的背景着色。我不知道为什么,但是,当我尝试处理 WM_CTLCOLORSTATIC 时,我收到系统错误消息“访问被拒绝”。

我的代码如下所示:

DWORD   dwLastError;
TCHAR   lpBuffer[256];

switch(msg)
{

[...]

case WM_CTLCOLORSTATIC:

if(dwLastError != 0)    // Don't want to see a "operation done successfully" error ;-)
::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,                 // It´s a system error
                 NULL,                                      // No string to be formatted needed
                 dwLastError,                               // Hey Windows: Please explain this error!
                 MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),  // Do it in the standard language
                 lpBuffer,              // Put the message here
                 lpBuffer -1,                     // Number of bytes to store the message
                 NULL);
[...]
}

甚至没有任何“WM_CTLCOLORSTATIC 的情况”,并且我收到系统错误“访问被拒绝”作为响应。

我不知道是什么原因造成的。

4

1 回答 1

1

这是错误:

 lpBuffer -1,     

将其更改为sizeof(lpBuffer)/sizeof(TCHAR) - 1

于 2014-01-03T16:06:30.350 回答