I have compiled the sample code "EmptyPanel" of the sdk, then made my own version with a control bar and some buttons.
I would like to add bitmaps to the buttons, adding the BS_BITMAP style to the native windows buttons then sending
hInst = (HINSTANCE)GetWindowLongPtr((HWND)ctrlBarPlatformWindow, GWLP_HINSTANCE);
hBmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1));
hBmp hInst are global to the plugin class. hBmp returns 0;
SendMessage((HWND)hwndButtonPrevious, (UINT)BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBmp);
The function is called in the CtrlBarWindowProc between two Push/Pop AppContext otherwise not working.
Buttons are responding normally to command and make the job.
But I never had any image on it!
I tried many variations, but nothing happen.
I guess something wrong with hInst, hBmp, or the place where I Send the BM_SETIMAGE message
The LoadBitmap call is failing (hBmp is NULL), because you are using the application HINSTANCE rather than the one for your plugin (dll). Add a DllMain function to your plugin and store the HINSTANCE.
HINSTANCE hDll = NULL;
BOOL APIENTRY DllMain( HINSTANCE hinstDLL, DWORD ul_reason, LPVOID reserved)
if (DLL_PROCESS_ATTACH == ul_reason)
hDll = hinstDLL;