invalid handle

hi frds
   i m very new in vc++ and i m founding too much difficulty in this so
plz can any one solve this
 problem ....
     actully i m inserting a image in list box using this code ........
  everything is returning write thing
   still it is saying invalid handle after
ImageList_Add(hList,m_hBmpNew,0); when i m going to dibug
 it
 plz help me


	BOOL Fun()
{
	// Create 256 color image lists
	HIMAGELIST hList = ImageList_Create(32,32, ILC_COLOR8 , 8, 1);




HBITMAP	  m_hBmpNew = (HBITMAP) LoadImage(
	   AfxGetInstanceHandle(),   // handle to instance
	   "c:\\img.bmp",
								// say, "C:\\NewFolder\\1.bmp"
	  IMAGE_BITMAP,             // image types
	  32,     // desired width
	  32,     // desired height
	  LR_LOADFROMFILE );


     CImageList* pImglist=new CImageList();


      ImageList_Add(hList,m_hBmpNew,0);

      int i=GetLastError();///it is givg invalid handle

     pImglist->Attach(hList);


	 LV_ITEM lvItem;

			lvItem.mask =  LVIF_TEXT | LVIF_IMAGE;
			lvItem.iImage = 0;
			lvItem.iItem =  i;
			lvItem.iSubItem = 0;
			lvItem.pszText = " ";
			m_listctl.InsertItem(&lvItem);
			m_listctl.SetImageList(pImglist,LVSIL_SMALL);

			
           	return TRUE;
}

0
12/1/2006 6:34:15 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
1258 Views

Similar Articles

[PageSpeed] 27

Hi Nandan,

I see you're starting to get it right :o)

This link about using image lists may help you too.  You can do everything 
you need with the CImageList class.  You don't need to call the SDK 
functions and CImageList functions intermixed:

http://members.tripod.com/digitaldawn/section17/section17.html

If you are trying to display pictures this article might be interesting to 
you as well:

http://www.codeproject.com/listctrl/ThumbsViewer.asp

Tom

<nandan.mehra@gmail.com> wrote in message 
news:1164954854.963549.267100@j44g2000cwa.googlegroups.com...
>
> hi frds
>   i m very new in vc++ and i m founding too much difficulty in this so
> plz can any one solve this
> problem ....
>     actully i m inserting a image in list box using this code ........
>  everything is returning write thing
>   still it is saying invalid handle after
> ImageList_Add(hList,m_hBmpNew,0); when i m going to dibug
> it
> plz help me
>
>
> BOOL Fun()
> {
> // Create 256 color image lists
> HIMAGELIST hList = ImageList_Create(32,32, ILC_COLOR8 , 8, 1);
>
>
>
>
> HBITMAP   m_hBmpNew = (HBITMAP) LoadImage(
>    AfxGetInstanceHandle(),   // handle to instance
>    "c:\\img.bmp",
> // say, "C:\\NewFolder\\1.bmp"
>   IMAGE_BITMAP,             // image types
>   32,     // desired width
>   32,     // desired height
>   LR_LOADFROMFILE );
>
>
>     CImageList* pImglist=new CImageList();
>
>
>      ImageList_Add(hList,m_hBmpNew,0);
>
>      int i=GetLastError();///it is givg invalid handle
>
>     pImglist->Attach(hList);
>
>
> LV_ITEM lvItem;
>
> lvItem.mask =  LVIF_TEXT | LVIF_IMAGE;
> lvItem.iImage = 0;
> lvItem.iItem =  i;
> lvItem.iSubItem = 0;
> lvItem.pszText = " ";
> m_listctl.InsertItem(&lvItem);
> m_listctl.SetImageList(pImglist,LVSIL_SMALL);
>
>
>           return TRUE;
> }
> 


0
tserface (3860)
12/1/2006 3:33:31 PM
See below...
On 30 Nov 2006 22:34:15 -0800, "nandan.mehra@gmail.com" <nandan.mehra@gmail.com> wrote:

>
>hi frds
>   i m very new in vc++ and i m founding too much difficulty in this so
>plz can any one solve this
> problem ....
>     actully i m inserting a image in list box using this code ........
>  everything is returning write thing
>   still it is saying invalid handle after
>ImageList_Add(hList,m_hBmpNew,0); when i m going to dibug
> it
> plz help me
>
>
>	BOOL Fun()
>{
>	// Create 256 color image lists
>	HIMAGELIST hList = ImageList_Create(32,32, ILC_COLOR8 , 8, 1);
>
>
>
>
>HBITMAP	  m_hBmpNew = (HBITMAP) LoadImage(
>	   AfxGetInstanceHandle(),   // handle to instance
>	   "c:\\img.bmp",
>								// say, "C:\\NewFolder\\1.bmp"
>	  IMAGE_BITMAP,             // image types
>	  32,     // desired width
>	  32,     // desired height
>	  LR_LOADFROMFILE );
>
>
>     CImageList* pImglist=new CImageList();
>
>
>      ImageList_Add(hList,m_hBmpNew,0);
>
>      int i=GetLastError();///it is givg invalid handle
****
Since you did not check the result of ImageList_Add, you have no idea whether GetLastError
is meaningful.  A successful API call generally does NOT change ::GetLastError, so you
could be getting some error from some API that executed ten minutes ago!

With rare, carefully documented exceptions, ::GetLastError returns a meaningful value ONLY
if the most recent API FAILED.  If it succeeded, the meaning of ::GetLastError is unknown!
				joe
****
>
>     pImglist->Attach(hList);
>
>
>	 LV_ITEM lvItem;
>
>			lvItem.mask =  LVIF_TEXT | LVIF_IMAGE;
>			lvItem.iImage = 0;
>			lvItem.iItem =  i;
>			lvItem.iSubItem = 0;
>			lvItem.pszText = " ";
>			m_listctl.InsertItem(&lvItem);
>			m_listctl.SetImageList(pImglist,LVSIL_SMALL);
>
>			
>           	return TRUE;
>}
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
12/1/2006 7:16:04 PM
Reply:

Similar Artilces:

Invalid File Format
When I start Excel I get an initial message that says ssipro97.dot is an invalid format. Any idea why this would come up? It doesn't seem to affect how Excel works, it's just annoyint. ...

Invalid syntax
I get the error invalid syntax for the following line : ( summing up figures in case GetBonus = Yes) Bonus : iif(getBonus = -1;nz(BonusL1;0)+ NZ([BonusL2];0)+ NZ([BonusL3];0) could you help ? -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200712/1 Ditch the semicolons. iif( Formula to test,results if true, results if false.) I would guess you want iif(getBonus = -1,nz(BonusL1;0)+ NZ([BonusL2];0)+ NZ([BonusL3],0) peljo via AccessMonster.com wrote: > I get the error invalid syntax for the following line : ( summing up figures...

Exchange 2K to 2K3 migration
I'd like to get some advice on the best approach to handle the STM file during an Inter-Org mailbox move. The Exchange migration wizard will handle the the mailbox but how do you handle the content in the STM file? Thanks. You don't need to worry about it. Mailbox data is stored in both the EDB and STM files. Typically, message content from the Internet will be in the STM file. I'd suspect that when you migrate the mailboxes, all data will be converted to native MAPI format (moved to EDB file) and will then be moved to the new mailbox. -- Ben Winzenz Exchange MVP Me...

Handle to an ActiveX control
Hi... What if I use GetModuleHandle(L"abc.ocx") in the InitInstance() of the of the App class derived from 'COleControlModule'...of the ActiveX control "abc.ocx" ? Will I get the Handle or it will return NULL....? I have encountered controls, in some of them..handle is found and in others its NULL... Wat is the reason behind this behavior..? Can any one explain? "Abby++" <asthana.abhinav@gmail.com> wrote in message news:1174308443.062622.51500@b75g2000hsg.googlegroups.com... > What if I use GetModuleHandle(L"abc.ocx") in the InitI...

invalid handle
hi frds i m very new in vc++ and i m founding too much difficulty in this so plz can any one solve this problem .... actully i m inserting a image in list box using this code ........ everything is returning write thing still it is saying invalid handle after ImageList_Add(hList,m_hBmpNew,0); when i m going to dibug it plz help me BOOL Fun() { // Create 256 color image lists HIMAGELIST hList = ImageList_Create(32,32, ILC_COLOR8 , 8, 1); HBITMAP m_hBmpNew = (HBITMAP) LoadImage( AfxGetInstanceHandle(), // handle to instance "c:\\img.bmp", /...

Invalid Property Value
I have a macro that uses an input form to populate a spreadsheet. There are various validations that run prior to the data populating. On one validation if an incorrect choice has been made from a drop down box a error message prompts the user to select again form the drop down box and will not populate until a valid selection has been made. I am now getting an Excel warning message (exclamation message) saying 'Invalid Property Value' after the spreadsheet has populated which only happens if an invalid selection has been made and corrected from the drop down box. If the ...

OFX
When doing an update from my broker I get the message cannot establish secure communication with the server. Digital certificate is invalid. OFXIE12038. This is new happening in last month. Broker support says problem is Money 2002 not supported so I installed Money 2005 (with some qualms) and of course, still get the same message. I can access the brokerage website OK from Money, just cannot get statement downloads. -- Bill ...

Invalid Procedure Call on Forms
Hello, any suggestions are appreciated! I imported tables from our media database into our membership database. I was going to combine the information so that I could streamline orders with lookup fields but my supervisor didn't like it so... I went back to the media database and now NONE of the form buttons are working. The forms open, and all the reports, queries, and tables open without incident. However, when I click any button on any form (to call up a report, query or another form), I receive an error: "Invalid Procedure Call or Arguement". I tried creating a...

Invalid Operation 425
I know there are a few other threads pretaining to "Invalid Operation 425, Cash Drawer locked by another application" but the solutions given there have not solved our problem. We have multiple store locations with the exact same set-up but only one is having this problem . The problem happens most of the time but not always. Our set up is RMS version 2.0 Printer - Epson Tm-881V Cash Drawer - APG VB320 OPOS ADK 2.6 Running on Windows XP Pro Any body have an idea? -- Many thanks Jack Master Jack - Without taking time to go back against all old posts and see what is liste...

Renamed invalid sheet name
I have a routine that opens a workbook to access data and then closes it. It has worked fine for years with XP and Excel 2000. Since changing to Win 7 and Excel 2003 it will no longer automatically open. A warning box appears "Repairs to 'Workbook'" and the message "Renamed invalid sheet name". After closing the message box it renames the worksheet to "Recovered_Sheet 1" and opens the workbook. However, this is a manual process and I need it to be automated as before. What I have found (I believe) is that if the file name includes "...

Invalid object name when I try to create a scaler udf in a stored procedure.
I am trying to create a report that shows a company name, all the advisors in that company, then the company's stats (there should be one row for each company). Each of these come from a different table. The advisors are currently being listed as one per line, which means the company name and the stats are all being repeated unneccesarily. I want to concatinate the advisors, so that all the ones that belong to the same company show in the same cell. I wrote this UDF which is located right before my SP: CREATE FUNCTION [dbo].[ConcatAdvisorNames](@Company as varchar(20)) RETURNS VA...

Refreshing data results in "invalid cell reference"
I imported some data from a CSV into a worksheet. On another worksheet (named Chapel) I referenced the data in a formula: {=SUM(IF(Chapel!$A$1:Chapel!$A$1000=Categories!$A1, IF(Chapel!$C$1:Chapel!$C$1000=Categories!A$30,1,0),0))} This formula works fine. Now, if I go and refresh my data I get invalid references in my formula: {=SUM(IF(Chapel!$A$1:Chapel!#REF!=Categories!$A1, IF(Chapel!$E$1:Chapel!$E$1000=Categories!A$30,1,0),0))} Is there some way to make this work? And why do some references to Chapel change but others do not? Notice that the first reference to $A$1000 is now invalid...

how to use invalidate and validate
I am using DrawRectangle and SetPixel and some other drawing functions over an image displayed in the background. I'm wondering what exactly I should be doing to make sure that when my application regains focus that things were like they were when focus was lost. I'm not quite sure what the Validate functions do, which is part of the problem. -- to reply, remove Big10 from address Andrew, There is only one way to make sure that the drawing is persistant even after another application has been activated (or indeed anything else forcing a redraw, such as the display of a dialogbox)...

Question about the handle of dlg
I get a handle of window from a system application now, for example, the handle of the Clock Control in "Date and Time Properties". Can I create a new window(looks like the Clock Control) in my own application with this handle? How to? Thanks a lot. -- No..Its not possible "valkYrie" <zhao.tong@yellowsheepriver.com> wrote in message news:eRJAgQp7GHA.3916@TK2MSFTNGP04.phx.gbl... >I get a handle of window from a system application now, for example, the >handle of the Clock Control in "Date and Time Properties". > > Can I create a new ...

Invalidate
Hi, I added a control to a View. So, I believe, that when I call Invalidate(), it effects the control and I get flicker. I am not erasing the background. BOOL CViewX::OnEraseBkgnd(CDC* pDC) { return TRUE; // return CView::OnEraseBkgnd(pDC); } Is there anything else that might be causing it? Thanks, -- dbgrpt.c -1 Computer wrote: > Hi, > > I added a control to a View. > So, I believe, that when I call Invalidate(), > it effects the control and I get flicker. > > I am not erasing the background. > BOOL CViewX::OnEraseBkgnd(CDC* pDC) > { > return TRUE; ...

The user Id is invalid.
I have been utterly unable to get the SDK to work for me, trying any permutation of credentials, explicit permissions and I always get the 'Server was unable to process request.' error message. I'm trying to access the CRM webservice from another machine, and web references are setup (I hope) correctly. On closer inspection this is the InnerXML field in the details of the exception: <error> <code>0x80041d1f</code> <description>The user Id is invalid.</description> <type>Platform</type> </error> The code that generates it? se...

Invalid Domain Name. Domain name invalid or unreachable
Hi, I am getting following error in MS CRM 4.0 when using Deployment Manager: "Invalid Domain Name. Domain name is either invalid or unreachable". Also when using the Plug-in registration tool, I am getting the same error. And I am not able to register any plug-in. Request you to please provide your inputs. Thanks in advance, help appreciated. Bharat ...

what does an "invalid sam id" meen in Outlook 2007?
I'm trying to import a .csv to Outlook. I keep getting "invalid sam id" message. the error with act3.sam translator message appears also. SAM = Security Access Manager and is not an Outlook related issue. Invalid SAM ID indicates a connection failure with your servers - something changed in your environment which made the SAM ID for the machine you are using invalid between the server and workstation. Are you using BCM? -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.c...

Invalid Database
I am running a small network (3-5 clients) with 1 POS lane. Each of the other computers has the RMS software installed. The master database is located ont the same computer that runs the POS. Here's the problem: When I test the database conncetion through Administrator Config. on any other computer, it says "Connection to the database is made but the database appears to be blank or not a valid Store Operations database." I don't understand how the database could be invalid if the POS is able to run from it. Secondly: When I try to open Store Operations...

Can RMS handle lottery ticket winnings?
Selling a ticket I am sure is easy. The twist is when a person wins on the ticket and wants to be paid cash. Any pointers would be helpful. Thank you. The way that we use it to keep track of everything is I do a payout with reason code lottery payout and staple the payout receipt with the lottery winning receipt. No matter if they want money back or a new ticker. If they decide they want a another lotter ticket I just scan the new lottery ticket and treat it as they gave me cash after the payout is done this way I can keep track of lottery ticket inventory. I just wish I could do a pay...

Invalid Domain Name. Domain name invalid or unreachable #2
Hi, I am getting following error in MS CRM 4.0 when using Deployment Manager: "Invalid Domain Name. Domain name is either invalid or unreachable". Also when using the Plug-in registration tool, I am getting the same error. And I am not able to register any plug-in. Request you to please provide your inputs. Thanks in advance, help appreciated. Bharat On this posting there is some code to help you list the domains active from the machine you wish to install CRM 4.0 on. create this inside a .vbs file and run it using cscript from the system32 folder and it listed mine correctl...

invalid from address
Any external mail sent with invalid from address (eg. blank from address or email address not available in Active directory) are not going out through the smtp connector. Instead it is getting routed back to the internal exchange 5.5 server and being NDR'ed. Any help in this regard. Regards GP In news:erdWgmjgFHA.3788@tk2msftngp13.phx.gbl, GP <vguru@yahoo.com> typed: > Any external mail sent with invalid from address (eg. blank from > address or email address not available in Active directory) are not > going out through the smtp connector. Instead it is getting ...

Path name is invalid
I use Money 2006 on a laptop with Visa 32 bit. When I sign out of money it asks if i want to back up now. I reply yes and get a message path name is invalid pleaase use a valid path name. Can anyone help with this problem. tia tia, Evidently the settings for automatic backup are pointing to an invalid path. I don't quite remember where the settings are in M2006 but they are probably under something like Tools > Settings > Backup settings. A Settings dialog box should open. Make sure that the path in the Save in: section(s) is valid. -Kevin "heshey" <heshey@dis...

All of my RMS 2.0 Serial Numbers invalid
This morning when my stores opened, all of my Pos stations and HQ won't load RMS - they all state the serial numbers are invalid. The busiest week of the year and none of my RMS software works. Any ideas? Never mind, it was a Windows update. I went to the stores and rebooted twice and now everything works. "Hobby Central" wrote: > This morning when my stores opened, all of my Pos stations and HQ won't load > RMS - they all state the serial numbers are invalid. The busiest week of the > year and none of my RMS software works. Any ideas? Still,...

Handling Windows Messages In An MFC App
We can use the PeekMessage function in a polling fashion to handle Windows messages to an MFC app. I was wondering if there was a more efficient way to do this using threads and events. What I envision is that my MFC app creates a thread which is suspended until Windows sends the app a message. Then once the message comes in, the thread wakes up, handles the message and then goes to sleep again. Can somebody tell me if this is possible and point to a link which explains how to code this? >We can use the PeekMessage function in a polling fashion to handle Windows >messages to a...