Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

resizing dialog boxes

rswy
Beginner
310 Views
Hi,
I have an application where I place a bitmap at a particular position on a dialog box.The problem is that the size of the dialog box changes on different machines depending on the pitch/font size.The GetDialogBaseUnits function returns different values on different machines but I am not sure how to use these values to resize the bitmap.I am not concerned about the dialog box appearing large/small but I want to be sure that the bitmap is always placed the same way on it no matter how the dialog box is.
Any pointers as to how I can solve this problem ?
-rswy
0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
310 Views
Are you saying that you want the bitmap control having a fixed relative size to the dialog (and the bitmap itself stretched as necessary)?

You can achieve that by not specifying bitmap ID in the resource editor, but loading the appropriately sized bitmap at run-time. Create a dialog-initialization callback (DlgSetSub(Dlg, IDD_DIALOG, OnDlgInit)) and place the following code into it:
...
INTEGER::      ID, iEvent, i, hBmp
TYPE(T_RECT):: Rect

INCLUDE "Resource.fd"

i = GetClientRect(GetDlgItem(Dlg%hWnd, IDC_BITMAP), Rect)
hbmp = LoadImage(GetModuleHandle(0), IDB_BITMAP1, &
   IMAGE_BITMAP, Rect%Right, Rect%Bottom, LR_DEFAULTCOLOR)
i = SendMessage(GetDlgItem(Dlg%hWnd, IDC_BITMAP), STM_SETIMAGE, IMAGE_BITMAP, hBmp)
Stretched images tend to look a tad ugly. Alternatively, you can play with combinations of "Center image" and "Real size image" styles -- that will cause the bitmap to be clipped if too big though.

Jugoslav
0 Kudos
Reply