Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to load file.bmp with macro MAKEINTRESOURCE(IDB_BITMAP) with Qt Creator
Forum Updated to NodeBB v4.3 + New Features

how to load file.bmp with macro MAKEINTRESOURCE(IDB_BITMAP) with Qt Creator

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 438 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Domenico
    wrote on last edited by Domenico
    #1

    Hi Guys, I need advice, which codes can I use to upload a .bitmap file and upload it to MAKEINTRESOURCE (IDB_BITMAP) for the function:

    HBITMAP bitMap = (HBITMAP)LoadImageA(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_BITMAP),IMAGE_BITMAP,16,16,LR_LOADFROMFILE);

    i tried with: #define IDB_BITMAP 1000

    in resource.h

    resource.rc
    IDB_BITMAP BITMAP "file.bmp"

    but it is not possible because Qt creator does not create file resource.rc but resource.qrc which is very different from resource.rc. what codes can I use to automatically load the .bmp file in the macro MAKEINTRESOURCE (IDB_BITMAP)??
    thank you for those who help me

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Domenico
      wrote on last edited by
      #2

      I solved the same way:

      #include "afxwin.h"
      #include <qt_windows.h>
      #include <QtWinExtras/qwinfunctions.h>

      QT_BEGIN_NAMESPACE
      Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0);

      QPixmap pixmap(":/resources/images/file.bmp");
      if(!pixmap.isNull())
      {
      pixmap = pixmap.scaled(16,16);
      }
      HBITMAP bitMap = qt_pixmapToWinHBITMAP(pixmap);

      thanks all the same for those who wanted to help me!!

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved