- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Is there an example of displaying a bitmap in a button for a windows api project?
In the button properties - style tab, there is a check box for bitmap.
Is there an example, or can anyone tell me how to do it.
Thanks,
David
In the button properties - style tab, there is a check box for bitmap.
Is there an example, or can anyone tell me how to do it.
Thanks,
David
Link copiado
3 Respostas
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
After some searching I found some code to try, but it doesn't work.
I'm sure why, there is probably a small error with the code.
On the SendDlgItemMessage, I get an error 1421- "Control ID not found"
is that hIDDlgItem, or hImagen that it cannot find, they seam to be OK?
Thanks,
David
I'm sure why, there is probably a small error with the code.
On the SendDlgItemMessage, I get an error 1421- "Control ID not found"
is that hIDDlgItem, or hImagen that it cannot find, they seam to be OK?
hIDDlgItem=GetDlgItem(hWnd,IDC_BUTTON1) FileName="c:MyBitmap.bmp"//char(0) hImagen=LoadImage(hInst,FileName,IMAGE_BITMAP,32,32,LR_DEFAULTSIZE.OR.LR_LOADFROMFILE) iret=SendDlgItemMessage(hwnd,hIDDlgItem,BM_SETIMAGE,IMAGE_BITMAP,hImagen) iret=GetLastError()
Thanks,
David
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Second argument to SendDlgItemMessage is control's ID, not handle ;-).
Also, don't forget to add BS_BITMAP style to your button.
Jugoslav
Also, don't forget to add BS_BITMAP style to your button.
Jugoslav
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Thanks for the quick response, that fixed it.
I simplified it a bit more by having the bitmap as a resource rather than specify the file name.
I simplified it a bit more by having the bitmap as a resource rather than specify the file name.
hImage=LoadImage(hInst,IDB_MYBITMAP,IMAGE_BITMAP,32,32,LR_DEFAULTSIZE) iret=SendDlgItemMessage(hwnd,IDC_BUTTON1,BM_SETIMAGE,IMAGE_BITMAP,hImage)
Responder
Opções do tópico
- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora