Can CListCtrl display dynamic width images









up vote
0
down vote

favorite












CListCtrl can show image with image list like following code.



m_imList.Create(64,64,ILC_COLOR24,10,20);
CBitmap * pBmp = NULL;
pBmp = new CBitmap();
pBmp->LoadBitmapW(IDB_BITMAP1);
m_imList.Add(pBmp,RGB(0,0,0));
delete pBmp;
m_list.SetImageList(&m_imList,LVSIL_SMALL);


But can i show variable width size image?










share|improve this question



















  • 1




    I think you are looking for custom draw CListCtrl, where you manually draw each image, for example to preview an image directory.
    – Barmak Shemirani
    Nov 11 at 5:59







  • 1




    You don't give much information about your use case. A sketch of what you want the result to look like, could be helpful. I'm assuming you want to show thumbnails of a set of images. Create the image list with the maximum size of the thumbnails. Before adding each image to the image list, scale it proportionally so that it "fills" the dimensions of the thumbnail image in the best possible way without clipping. Fill the remaining space with a background color or set the alpha value to zero to make it "transparent".
    – zett42
    Nov 11 at 17:35






  • 1




    Say original image size = 1024 x 768, max. thumbnail size = 50 x 50. Scaled image width = 50, scaled image height = 50 * 768 / 1024 = 37. BitBlt() scaled image of 50 x 37 to temporary image of 50 x 50, centering it. Fill border on top and bottom with background color or set alpha value to zero. Add temporary image to image list.
    – zett42
    Nov 11 at 17:46















up vote
0
down vote

favorite












CListCtrl can show image with image list like following code.



m_imList.Create(64,64,ILC_COLOR24,10,20);
CBitmap * pBmp = NULL;
pBmp = new CBitmap();
pBmp->LoadBitmapW(IDB_BITMAP1);
m_imList.Add(pBmp,RGB(0,0,0));
delete pBmp;
m_list.SetImageList(&m_imList,LVSIL_SMALL);


But can i show variable width size image?










share|improve this question



















  • 1




    I think you are looking for custom draw CListCtrl, where you manually draw each image, for example to preview an image directory.
    – Barmak Shemirani
    Nov 11 at 5:59







  • 1




    You don't give much information about your use case. A sketch of what you want the result to look like, could be helpful. I'm assuming you want to show thumbnails of a set of images. Create the image list with the maximum size of the thumbnails. Before adding each image to the image list, scale it proportionally so that it "fills" the dimensions of the thumbnail image in the best possible way without clipping. Fill the remaining space with a background color or set the alpha value to zero to make it "transparent".
    – zett42
    Nov 11 at 17:35






  • 1




    Say original image size = 1024 x 768, max. thumbnail size = 50 x 50. Scaled image width = 50, scaled image height = 50 * 768 / 1024 = 37. BitBlt() scaled image of 50 x 37 to temporary image of 50 x 50, centering it. Fill border on top and bottom with background color or set alpha value to zero. Add temporary image to image list.
    – zett42
    Nov 11 at 17:46













up vote
0
down vote

favorite









up vote
0
down vote

favorite











CListCtrl can show image with image list like following code.



m_imList.Create(64,64,ILC_COLOR24,10,20);
CBitmap * pBmp = NULL;
pBmp = new CBitmap();
pBmp->LoadBitmapW(IDB_BITMAP1);
m_imList.Add(pBmp,RGB(0,0,0));
delete pBmp;
m_list.SetImageList(&m_imList,LVSIL_SMALL);


But can i show variable width size image?










share|improve this question















CListCtrl can show image with image list like following code.



m_imList.Create(64,64,ILC_COLOR24,10,20);
CBitmap * pBmp = NULL;
pBmp = new CBitmap();
pBmp->LoadBitmapW(IDB_BITMAP1);
m_imList.Add(pBmp,RGB(0,0,0));
delete pBmp;
m_list.SetImageList(&m_imList,LVSIL_SMALL);


But can i show variable width size image?







mfc clistctrl






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 5:19

























asked Nov 11 at 4:51









MomAndDad

3181414




3181414







  • 1




    I think you are looking for custom draw CListCtrl, where you manually draw each image, for example to preview an image directory.
    – Barmak Shemirani
    Nov 11 at 5:59







  • 1




    You don't give much information about your use case. A sketch of what you want the result to look like, could be helpful. I'm assuming you want to show thumbnails of a set of images. Create the image list with the maximum size of the thumbnails. Before adding each image to the image list, scale it proportionally so that it "fills" the dimensions of the thumbnail image in the best possible way without clipping. Fill the remaining space with a background color or set the alpha value to zero to make it "transparent".
    – zett42
    Nov 11 at 17:35






  • 1




    Say original image size = 1024 x 768, max. thumbnail size = 50 x 50. Scaled image width = 50, scaled image height = 50 * 768 / 1024 = 37. BitBlt() scaled image of 50 x 37 to temporary image of 50 x 50, centering it. Fill border on top and bottom with background color or set alpha value to zero. Add temporary image to image list.
    – zett42
    Nov 11 at 17:46













  • 1




    I think you are looking for custom draw CListCtrl, where you manually draw each image, for example to preview an image directory.
    – Barmak Shemirani
    Nov 11 at 5:59







  • 1




    You don't give much information about your use case. A sketch of what you want the result to look like, could be helpful. I'm assuming you want to show thumbnails of a set of images. Create the image list with the maximum size of the thumbnails. Before adding each image to the image list, scale it proportionally so that it "fills" the dimensions of the thumbnail image in the best possible way without clipping. Fill the remaining space with a background color or set the alpha value to zero to make it "transparent".
    – zett42
    Nov 11 at 17:35






  • 1




    Say original image size = 1024 x 768, max. thumbnail size = 50 x 50. Scaled image width = 50, scaled image height = 50 * 768 / 1024 = 37. BitBlt() scaled image of 50 x 37 to temporary image of 50 x 50, centering it. Fill border on top and bottom with background color or set alpha value to zero. Add temporary image to image list.
    – zett42
    Nov 11 at 17:46








1




1




I think you are looking for custom draw CListCtrl, where you manually draw each image, for example to preview an image directory.
– Barmak Shemirani
Nov 11 at 5:59





I think you are looking for custom draw CListCtrl, where you manually draw each image, for example to preview an image directory.
– Barmak Shemirani
Nov 11 at 5:59





1




1




You don't give much information about your use case. A sketch of what you want the result to look like, could be helpful. I'm assuming you want to show thumbnails of a set of images. Create the image list with the maximum size of the thumbnails. Before adding each image to the image list, scale it proportionally so that it "fills" the dimensions of the thumbnail image in the best possible way without clipping. Fill the remaining space with a background color or set the alpha value to zero to make it "transparent".
– zett42
Nov 11 at 17:35




You don't give much information about your use case. A sketch of what you want the result to look like, could be helpful. I'm assuming you want to show thumbnails of a set of images. Create the image list with the maximum size of the thumbnails. Before adding each image to the image list, scale it proportionally so that it "fills" the dimensions of the thumbnail image in the best possible way without clipping. Fill the remaining space with a background color or set the alpha value to zero to make it "transparent".
– zett42
Nov 11 at 17:35




1




1




Say original image size = 1024 x 768, max. thumbnail size = 50 x 50. Scaled image width = 50, scaled image height = 50 * 768 / 1024 = 37. BitBlt() scaled image of 50 x 37 to temporary image of 50 x 50, centering it. Fill border on top and bottom with background color or set alpha value to zero. Add temporary image to image list.
– zett42
Nov 11 at 17:46





Say original image size = 1024 x 768, max. thumbnail size = 50 x 50. Scaled image width = 50, scaled image height = 50 * 768 / 1024 = 37. BitBlt() scaled image of 50 x 37 to temporary image of 50 x 50, centering it. Fill border on top and bottom with background color or set alpha value to zero. Add temporary image to image list.
– zett42
Nov 11 at 17:46


















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245948%2fcan-clistctrl-display-dynamic-width-images%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245948%2fcan-clistctrl-display-dynamic-width-images%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3