IFLOGM Dialogs & Images

IFLOGM Dialogs & Images

I was wanting to have some buttons on windows dialogs  that have images rather than text. In the resource editor a button has Options Bitmap true/false and also  Icon true/false  under 'Appearance'. I have spend the last 30 minutes looking at MSDN for a clue on how to use these and failed. Which makes me even less hopeful for Fortran...

Has anyone got any experiance and tips on if this,  is it possible and if so what needs to be set where and how?

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I found some clues in this code snippet  so It will have a play and see what I can do:

HWND button=CreateWindow("BUTTON","Test button",BS_BITMAP | WS_VISIBLE | WS_CHILD,10,10,34,34,hwnd,NULL,hThisInstance,NULL);

There are some examples on the Xeffort page.

I have never delved into xeffort though I believe there is some very useful stuff there.  I made a simple fortran routine to apply a bitmap resource to a dialog button resource which seems to work (I haven't tried to break it yet....). It was quite simple to do, the problem is finding information what you need to do....  I have attached  some souce which might help others:

subroutine set_button_image(dlg_hwnd,Button_ID,BITMAP_ID,BM_width,BM_height) !apply bitmap to dialog button
 !unsure of limitations (e.g. BM bigger than button etc), limited testing 
 use ifwin, only : handle, LoadImage, GetModuleHandle, MAKEINTRESOURCE,LR_DEFAULTCOLOR, NULL,&
 integer(handle), intent(in) :: dlg_hwnd !handle of dialog
 integer(4),intent(in) :: Button_ID !resouce ID to apply bitmap to,resource needs accept bitmap .true. in dialog editor
 integer(4),intent(in) :: BITMAP_ID !resouce ID of the bitmap
 integer(handle),intent(in) :: BM_width, BM_height !size in pixel of bitmap (size we want but only tested with want=actual)
 integer(handle) :: button_hwnd, hbitmap_hwnd
 integer(lresult) :: lres
 integer(word) :: bmid !is is an integer(2)
 bmid = BITMAP_ID !note integer(4) to (2)
 ! note, bitmap_width & height are MSDN type wparam > uint_ptr > handle (wparam not defined if ifwin)
 ! get the handle of the button and bitmap and then sendmessage to button
 button_hwnd = GetDlgItem(dlg_hwnd, Button_ID)
 !HANDLE WINAPI LoadImage(_In_opt_ HINSTANCE hinst,_In_ LPCTSTR lpszName,_In_ UINT uType,_In_ int cxDesired,
 ! _In_ int cyDesired,_In_ UINT fuLoad);
 hbitmap_hwnd = LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(BMID),IMAGE_BITMAP,BM_width,BM_height,LR_DEFAULTCOLOR)
 !LRESULT WINAPI SendMessage(_In_ HWND hWnd,_In_ UINT Msg,_In_ WPARAM wParam,_In_ LPARAM lParam);
 Lres = SendMessage(button_hwnd,BM_SETIMAGE,IMAGE_BITMAP,hbitmap_hwnd)
end subroutine

Leave a Comment

Please sign in to add a comment. Not a member? Join today