• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Add a bitmap to a button

Community Beginner ,
Jun 08, 2017 Jun 08, 2017

Copy link to clipboard

Copied

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;

then

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

Any idea?

Pierre

TOPICS
SDK

Views

318

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Jun 09, 2017 Jun 09, 2017

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;

  return TRUE;

}

Votes

Translate

Translate
Adobe
Advocate ,
Jun 09, 2017 Jun 09, 2017

Copy link to clipboard

Copied

LATEST

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;

  return TRUE;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines