Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/139.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C++; 我知道如何在C++中画一个按钮,但是我怎么在上面做图标呢?通过SendMessage()或如果不是那样,请粘贴 如果您使用MFC,那么我建议您使用以下CButton方法SetIcon: CButton myButton; // Create an icon button. myButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_ICON, CRect(10,10,60,50), pParentWnd, 1); // Set the icon of the button to be the system question mark icon. myButton.SetIcon( ::LoadIcon(NULL, IDI_QUESTION) );_C++_Winapi_Button_Reference_Icons - Fatal编程技术网

如何在C++; 我知道如何在C++中画一个按钮,但是我怎么在上面做图标呢?通过SendMessage()或如果不是那样,请粘贴 如果您使用MFC,那么我建议您使用以下CButton方法SetIcon: CButton myButton; // Create an icon button. myButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_ICON, CRect(10,10,60,50), pParentWnd, 1); // Set the icon of the button to be the system question mark icon. myButton.SetIcon( ::LoadIcon(NULL, IDI_QUESTION) );

如何在C++; 我知道如何在C++中画一个按钮,但是我怎么在上面做图标呢?通过SendMessage()或如果不是那样,请粘贴 如果您使用MFC,那么我建议您使用以下CButton方法SetIcon: CButton myButton; // Create an icon button. myButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_ICON, CRect(10,10,60,50), pParentWnd, 1); // Set the icon of the button to be the system question mark icon. myButton.SetIcon( ::LoadIcon(NULL, IDI_QUESTION) );,c++,winapi,button,reference,icons,C++,Winapi,Button,Reference,Icons,这非常有效。由于您是新手,您可能还希望查阅MSDN库。您可以找到有关的信息(具体请参见BS图标和BS位图样式)和。发送BM_SETIMAGE消息,并将加载的图像句柄传递给LPRAM button1 = CreateWindowW(L"BUTTON", L"&Button", WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_BITMAP, 20, 50, 80, 25, hwnd, (HMENU) 600, NULL, NULL); hImg = Load

这非常有效。

由于您是新手,您可能还希望查阅MSDN库。您可以找到有关的信息(具体请参见BS图标和BS位图样式)和。

发送BM_SETIMAGE消息,并将加载的图像句柄传递给LPRAM

button1 = CreateWindowW(L"BUTTON", L"&Button", WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_BITMAP, 20, 50, 80, 25, hwnd, (HMENU) 600, NULL, NULL);

hImg = LoadImageW(NULL, L"test123.bmp", IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_LOADFROMFILE);
SendMessageW(button1, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hImg);

注意:当CreateWindow()时,您需要使用BS_位图标志。

请指定您正在使用的GUI API。Win32?MFC?Qt?我假设您的SendMessage评论中有win32。但请澄清。我想我们可以根据您的公认答案假设您正在使用MFC:-)说声谢谢很好。一路上丢失了标点符号?