Hi,
I'm new at Win32 Programming and I'm trying to write my first program with a GUI.
I have create the main window and some Buttons and Static controls.
The problem is when I try to display an Icon from the resource in a Static.
I looked at the MSDN Library for the functions I should use and I came up with this code (I created a new class for the window for ease):
WinMain.Cpp
Code:
//create the control
//HWND hMain is defined in WinMain.h
//HWND hImgClip is defined in WinMain.h
hImgClip = CreateWindow(L"STATIC", TEXT(""), (SS_ICON | WS_VISIBLE | WS_CHILD | SS_BLACKFRAME | SS_REALSIZEIMAGE), 121, 60, 16, 16, hMain, NULL, (HINSTANCE)GetWindowLong(hMain, GWL_HINSTANCE), NULL);
//send the SetImage message
if (SendMessage(hImgClip, STM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_STATUS_INACTIVE /* Resource ID: 404 */)))==0)
{
LPVOID lpMsgBuf;
FormatMessage((FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS), NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL);
MessageBox(NULL, (LPCTSTR)lpMsgBuf, TEXT("Error"), MB_OK);
LocalFree(lpMsgBuf);
}
When I run the program I get an error message (Unable to find item).
Can anybody help me?