Click here to Skip to main content
15,908,112 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Please how do I make an image of my own choosing to be a button.Like a disket image for instance
Posted
Comments
Sergey Alexandrovich Kryukov 20-Nov-13 16:27pm    
Interesting, why diskettes? As if they were ever used... Anyway, development of custom button rendering depends on UI/Graphics library/framework or application type you want to use. Before you add some tags describing it, we don't have a subject for discussion.
Thank you.
—SA

You might have a look at this CodeProject's article: Owner-draw icon buttons in plain C (no MFC)[^].
 
Share this answer
 
Comments
Maciej Los 20-Nov-13 16:54pm    
5ed!
CPallini 20-Nov-13 17:03pm    
Thank you.
There are several ways to create Custom-Buttons for Windows in C++.

Here are two of the most common:

// Load Bitmap for Button
hBitmap = (HBITMAP)LoadImage (GetModuleHandle (NULL), L"BMButton.bmp", IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);

// Version1: BS_BITMAP
hBButton1 = CreateWindow( TEXT("button"), TEXT(""),
          WS_CHILD | WS_VISIBLE | BS_FLAT | BS_BITMAP,
          50,50,BWIDTH,BHIGHT,  // pos x, pos y, width, height
          hwnd, (HMENU)ID_BBUTTON1,
          hInstGlobal, NULL);      // hInstGlobal see  ((LPCREATESTRUCT) lParam)->hInstance,

SendMessage(hBButton1, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)(HANDLE)hBitmap);

// Version2: BS_OWNERDRAW
hBButton2 = CreateWindow(TEXT("button"),TEXT(""),
          WS_CHILD | WS_VISIBLE | BS_OWNERDRAW | BS_PUSHBUTTON,
          50,170,BWIDTH,BHIGHT,  // pos x, pos y, width, height
          hwnd,(HMENU)ID_BBUTTON2,
          hInstGlobal, NULL);
return 0 ;


Version2 is more complicate because you have to do the drawing yourself in WM_DRAWITEM.

I suggest using Version1.
 
Share this answer
 
v2
there are rare information provided to say how. at least you should specify which UI framework you are using, for instance, mfc, wxwidgets..Net, GTK+, QT or anything else. different framework provides different approach for developers to create custom UI elements, however, at most cases, you just simply derived from the element the framework provide, and rewrite your own paint function or eventhandler.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900