Click here to Skip to main content
16,004,977 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Multithreading using _beginthread Pin
Gary R. Wheeler11-Dec-03 10:21
Gary R. Wheeler11-Dec-03 10:21 
GeneralRe: Multithreading using _beginthread Pin
David Crow11-Dec-03 10:24
David Crow11-Dec-03 10:24 
General(int() function vs (int) cast - comments please Pin
FearlessBurner10-Dec-03 4:48
FearlessBurner10-Dec-03 4:48 
GeneralRe: (int() function vs (int) cast - comments please Pin
Alexander M.,10-Dec-03 5:25
Alexander M.,10-Dec-03 5:25 
GeneralRe: (int() function vs (int) cast - comments please Pin
Ian Darling10-Dec-03 5:27
Ian Darling10-Dec-03 5:27 
GeneralScrollbar in listctrl Pin
super10-Dec-03 3:35
professionalsuper10-Dec-03 3:35 
GeneralRe: Scrollbar in listctrl Pin
David Crow10-Dec-03 7:56
David Crow10-Dec-03 7:56 
GeneralLoadImage returns handle instead of NULL Pin
mexicanchili10-Dec-03 3:27
mexicanchili10-Dec-03 3:27 
Hallo,

has anybody ever encountered a strange problem with LoadImage?

When our application finds bitmap-files with appropriate filenames within a certain directory it wants to use these symbols as treeview icons. We're doing this:

HBITMAP hBitmap = NULL;
CBitmap bmpCmd; 

CString strBitmapFile; 
strBitmapFile = strCurrentFile.Left( strCurrentFile.GetLength()
                                    -CString(".igl").GetLength()); 
strBitmapFile += CString(".bmp"); 
hBitmap = reinterpret_cast<HBITMAP>(LoadImage(NULL, 
                                    LPCTSTR(strBitmapFile), 
                                    IMAGE_BITMAP, 
                                    ImageSize32.cx, 
                                    ImageSize32.cy, 
                                    LR_LOADFROMFILE)); 
if (hBitmap) 
{ 
  bmpCmd.Attach(hBitmap); 
  CmdBitmapId=m_ImageList.Add(&bmpCmd, rgbMask); 
  bmpCmd.DeleteObject(); 
} 

// otherwise take some default bitmap 


This usually works fine. However, when we start this application from another application with ShellExecute() a few items in the treeview will be displayed without any icons at all. It turned out that LoadImage returned a handle although there was no file with the filename strBitmapFile. The invalid Bitmap was then noted by CImageList::Add which returned an index of -1.

Does anybody has an idea whether we are doing something wrong or whether there is a bug in LoadImage? MSDN reported no such bug.

The workaround is quite easy, I check whether the File exists and attempt to load the bitmap just in this case. This works fine, but still one wonders.

Thanks in advance
GeneralRe: LoadImage returns handle instead of NULL Pin
Alexander M.,10-Dec-03 5:18
Alexander M.,10-Dec-03 5:18 
GeneralRe: LoadImage returns handle instead of NULL Pin
David Crow10-Dec-03 8:06
David Crow10-Dec-03 8:06 
GeneralRe: LoadImage returns handle instead of NULL Pin
Tim Smith10-Dec-03 16:08
Tim Smith10-Dec-03 16:08 
GeneralRe: LoadImage returns handle instead of NULL Pin
mexicanchili11-Dec-03 3:24
mexicanchili11-Dec-03 3:24 
QuestionShould I be using struct instead? Pin
b_girl10-Dec-03 3:23
b_girl10-Dec-03 3:23 
AnswerRe: Should I be using struct instead? Pin
Antti Keskinen10-Dec-03 3:39
Antti Keskinen10-Dec-03 3:39 
GeneralRe: Should I be using struct instead? Pin
b_girl10-Dec-03 4:25
b_girl10-Dec-03 4:25 
GeneralRe: Should I be using struct instead? Pin
Antti Keskinen10-Dec-03 7:43
Antti Keskinen10-Dec-03 7:43 
AnswerRe: Should I be using struct instead? Pin
Navin10-Dec-03 4:49
Navin10-Dec-03 4:49 
GeneralRe: Should I be using struct instead? Pin
b_girl10-Dec-03 5:04
b_girl10-Dec-03 5:04 
GeneralRe: Should I be using struct instead? Pin
Big Art10-Dec-03 6:02
Big Art10-Dec-03 6:02 
GeneralRe: Should I be using struct instead? Pin
b_girl10-Dec-03 6:10
b_girl10-Dec-03 6:10 
QuestionHow to interpret Call stack window message ? Pin
Deepak Samuel10-Dec-03 2:35
Deepak Samuel10-Dec-03 2:35 
AnswerRe: How to interpret Call stack window message ? Pin
Mike Dimmick10-Dec-03 2:41
Mike Dimmick10-Dec-03 2:41 
GeneralDLL Dialog Pin
macmac3810-Dec-03 2:18
macmac3810-Dec-03 2:18 
GeneralRe: DLL Dialog Pin
Antti Keskinen10-Dec-03 3:04
Antti Keskinen10-Dec-03 3:04 
GeneralRe: DLL Dialog Pin
macmac3810-Dec-03 4:46
macmac3810-Dec-03 4:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.