Hello, I have a problem regarding scrollbars that disappear when trying to display a CMetaFile object. I'm using VC++ 6.0 Enterprise Edition, and here's some code from the situation:
Please take in count two facts: First, the working code was already done, I'm just trying to extend it in the way you'll see below. Second, I'm also clumsy regarding VC++. **blush** That's why I badly need your help, folks.
CMetaFile mf;
CWnd *tele = GetDlgItem(IDC_TELE); // IDC_TELE is a Picture object, defined within a dialog
CWindowDC dc(tele);
CDC *hereWePaint;
hereWePaint = &dc;
// ...
// Here we load the .wmf file successfully, and store it into mf
// ...
CRect dim_tele;
tele->GetClientRect(&dim_tele);
mf.Display(hereWePaint, dim_tele);
So far, so good... the loaded wmf file is displayed correctly inside the "tele" object.
But now I need to display it zoomed, and provide the user the ability to scroll the zoomed view. Let's say 2x. For that, in a first attempt, I'm just displaying the metafile inside a larger CRect object:
int zoomHrz = dim_tele.right * 2; // For 2x zoom
int zoomVrt = dim_tele.bottom * 2; // For 2x zoom
int xMaxScroll, yMaxScroll;
CRect zoom_tele = new CRect(0, 0, zoomHrz, zoomVrt);
SCROLLINFO si;
// both xCurrentScroll and yCurrentScroll are defined in the containing class as int
xMaxScroll = max(zoomHrz - dim_tele.right, 0);
xCurrentScroll = min(xCurrentScroll, xMaxScroll);
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
si.nMin = 0;
si.nMax = xMaxScroll;
si.nPage = dim_tele.right;
si.nPos = xCurrentScroll;
tele->SetScrollInfo(SB_HORZ, &si, TRUE);
yMaxScroll = max(zoomVrt - dim_tele.bottom, 0);
yCurrentScroll = min(yCurrentScroll, yMaxScroll);
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
si.nMin = 0;
si.nMax = yMaxScroll;
si.nPage = dim_tele.bottom;
si.nPos = yCurrentScroll;
tele->SetScrollInfo(SB_VERT, &si, TRUE);
tele->EnableScrollBarCtrl(SB_BOTH, TRUE);
mf.Display(hereWePaint, zoom_tele);
The metafile is indeed displayed with the desired zoom. However, the scrollbars aren't displayed at all, or either just flicker, or either are displayed but are unusable (i.e., they just appear as "painted" and not working at all).
Thanks in advance for any help you can provide.
- A

Disappearing scrollbars...
Doug Peck
I think, instead of this:
you should try this:
I hope it helps.
rad2319
Hello
Re question:
Such questions (on VC6) are outside the scope of this forum - for the scope of the VC General forum please look at: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=19445&SiteID=1
For such issues please use an appropriate newsgroup, potentially one at http://msdn.microsoft.com/newsgroups.
OTP
Thanks
Damien
Kamii47
Thank you, but it didn't work... in fact when I zoom the view, it grows up and "eats" the whole right and bottom part of the window where it is located.
And no sign of the scrollbars either... which is what matters the most for me at the time.
- A