CComboBox problem #2

I have a perfectly fine working application (Ap1). And a 2nd
application (Ap2), that i want to use one of the dialogs from Ap1 one
in.

So I copied the relevant data from Ap1.rc to Ap2.rc. Plus the class
files for the dialog from Ap1. (i'm not sure of the correct way to copy
over a dialog).

Anyway, things appeared to be working fine.. Until in OnInitDlg()

((CComboBox*)GetDlgItem(IDC_FIXANG1))->SetCurSel(0);

There is an unhandled exception:

_AFXWIN_INLINE int CComboBox::SetCurSel(int nSelect)
	{ ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd,
CB_SETCURSEL, nSelect, 0); }

It appears that: 0x00000000 (CComboBox hWnd = ????)

What have I done wrong?

0
Hamish.Dean (174)
8/28/2006 11:06:40 AM
vc.mfc 33608 articles. 0 followers. Follow

11 Replies
626 Views

Similar Articles

[PageSpeed] 46

Did you call the base class in OnInitDialog before calling
GetDlgItem()? Also, to copy resources from one project to another, open
both projects in a workspace or solution and then you can drag
resources across projects.

---
Ajay

hamishd wrote:
> I have a perfectly fine working application (Ap1). And a 2nd
> application (Ap2), that i want to use one of the dialogs from Ap1 one
> in.
>
> So I copied the relevant data from Ap1.rc to Ap2.rc. Plus the class
> files for the dialog from Ap1. (i'm not sure of the correct way to copy
> over a dialog).
>
> Anyway, things appeared to be working fine.. Until in OnInitDlg()
>
> ((CComboBox*)GetDlgItem(IDC_FIXANG1))->SetCurSel(0);
>
> There is an unhandled exception:
>
> _AFXWIN_INLINE int CComboBox::SetCurSel(int nSelect)
> 	{ ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd,
> CB_SETCURSEL, nSelect, 0); }
>
> It appears that: 0x00000000 (CComboBox hWnd = ????)
> 
> What have I done wrong?

0
ajaykalra (6842)
8/28/2006 1:29:25 PM
An obvious question, but work asking... is IDC_FIXANG1 a valid ID? 
Sometimes they get renamed or deleted.

Tom

"hamishd" <Hamish.Dean@gmail.com> wrote in message 
news:1156763199.908600.135510@m79g2000cwm.googlegroups.com...
>I have a perfectly fine working application (Ap1). And a 2nd
> application (Ap2), that i want to use one of the dialogs from Ap1 one
> in.
>
> So I copied the relevant data from Ap1.rc to Ap2.rc. Plus the class
> files for the dialog from Ap1. (i'm not sure of the correct way to copy
> over a dialog).
>
> Anyway, things appeared to be working fine.. Until in OnInitDlg()
>
> ((CComboBox*)GetDlgItem(IDC_FIXANG1))->SetCurSel(0);
>
> There is an unhandled exception:
>
> _AFXWIN_INLINE int CComboBox::SetCurSel(int nSelect)
> { ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd,
> CB_SETCURSEL, nSelect, 0); }
>
> It appears that: 0x00000000 (CComboBox hWnd = ????)
>
> What have I done wrong?
> 


0
tserface (3860)
8/28/2006 3:21:40 PM
> An obvious question, but work asking... is IDC_FIXANG1 a valid ID?
> Sometimes they get renamed or deleted.

It's valid.

0
Hamish.Dean (174)
8/28/2006 10:12:29 PM
> Did you call the base class in OnInitDialog before calling
> GetDlgItem()?

Yes.

Also, to copy resources from one project to another, open
> both projects in a workspace or solution and then you can drag
> resources across projects.

This doesn't work. I'm using MSVC6.0. I'm clicking on the original
dialog in the dialogs folder of the resourceview, and dragging it to
the resourceview of the destination project. It's not being allowed.

0
Hamish.Dean (174)
8/28/2006 10:17:23 PM
Well... hmmm.  The GetDlgItem() call is return a null pointer which would 
happen if that ID was invalid, but ...

Did Ajay's idea of calling OnInitDialog() in the base class first work?  I'm 
not sure why that would make a difference for GetDlgItem, but...

Another idea would be to add a control variable (like m_cComboBox) and use 
DDX to get the control:

m_cComboBox.SetWindowText(...);

Tom

"hamishd" <Hamish.Dean@gmail.com> wrote in message 
news:1156803148.958008.119510@75g2000cwc.googlegroups.com...
>> An obvious question, but work asking... is IDC_FIXANG1 a valid ID?
>> Sometimes they get renamed or deleted.
>
> It's valid.
> 


0
tserface (3860)
8/28/2006 10:28:46 PM
You have to open both projects as "files".  Open the first .RC file and then 
the other and they should both appear in windows.  I typically split the 
windows horizontally, but you could do it vertically as well.  Then you can 
drag from one RC file to the other.  Remember not to save the original file 
when you close it since this actually drags the resources away from the 
original.

Tom

"hamishd" <Hamish.Dean@gmail.com> wrote in message 
news:1156803443.586787.265410@h48g2000cwc.googlegroups.com...
>> Did you call the base class in OnInitDialog before calling
>> GetDlgItem()?
>
> Yes.
>
> Also, to copy resources from one project to another, open
>> both projects in a workspace or solution and then you can drag
>> resources across projects.
>
> This doesn't work. I'm using MSVC6.0. I'm clicking on the original
> dialog in the dialogs folder of the resourceview, and dragging it to
> the resourceview of the destination project. It's not being allowed.
> 


0
tserface (3860)
8/28/2006 10:31:50 PM
> You have to open both projects as "files".  Open the first .RC file and then
> the other and they should both appear in windows.  I typically split the
> windows horizontally, but you could do it vertically as well.  Then you can
> drag from one RC file to the other.  Remember not to save the original file
> when you close it since this actually drags the resources away from the
> original.

Thanks. Unfortunately it is still not working, I've copied the
resource, and the access violation is still occurring.

I think I'm going to have to re-make the dialog from scratch :(

0
Hamish.Dean (174)
8/28/2006 11:32:19 PM
> I think I'm going to have to re-make the dialog from scratch :(

This is killing me. Same error !

0
Hamish.Dean (174)
8/29/2006 12:00:44 AM
> This doesn't work. I'm using MSVC6.0. I'm clicking on the original
> dialog in the dialogs folder of the resourceview, and dragging it to
> the resourceview of the destination project. It's not being allowed.

What does "not being allowed" means? Perhaps your resource files are
messed up with all this cutting and pasting. It works fine. You can
experiment in a different project.

---
Ajay

0
ajaykalra (6842)
8/29/2006 12:03:44 AM
Hmmm.  It sounds like you're saying it allows you to copy to resource, you 
just can't access it from the project to which it was copied.  If I remember 
right, the access violation was a result of the GetDlgItem() returning NULL 
which would indicate that the control is not there at run time.

Tom

"hamishd" <Hamish.Dean@gmail.com> wrote in message 
news:1156807939.848690.248320@m73g2000cwd.googlegroups.com...
>> You have to open both projects as "files".  Open the first .RC file and 
>> then
>> the other and they should both appear in windows.  I typically split the
>> windows horizontally, but you could do it vertically as well.  Then you 
>> can
>> drag from one RC file to the other.  Remember not to save the original 
>> file
>> when you close it since this actually drags the resources away from the
>> original.
>
> Thanks. Unfortunately it is still not working, I've copied the
> resource, and the access violation is still occurring.
>
> I think I'm going to have to re-make the dialog from scratch :(
> 


0
tserface (3860)
8/29/2006 4:02:56 PM
You may want to simply create a small dialog and try it out just to see if 
that works.  Then, if it does, you can try recreating the dialog.  It 
probably would have taken you less time than fixing it in this case.

Tom

"hamishd" <Hamish.Dean@gmail.com> wrote in message 
news:1156809644.634706.191090@h48g2000cwc.googlegroups.com...
>> I think I'm going to have to re-make the dialog from scratch :(
>
> This is killing me. Same error !
> 


0
tserface (3860)
8/29/2006 4:03:43 PM
Reply:

Similar Artilces:

How to open 2 excel instances by using XP schedule tasks?
I am using XP with SP3 and Excel 2003, when I setup a schedule task to open file1.xls at 9 am, and open file2.xls at 9:15 am, does anyone know whether schedule task will 2 excel instances or 1 excel instance? Thanks in advance for any suggestions Eric Dunno.... But have you tried setting up a shedule to open file1 in 5 minutes from now and file2 in, say 7 minutes? There are, I think at least 3 ways that you can see how many instances you are running: 1) I think its true in 2003 that when they are both open, if you look in Windows/switch windows only the file running in t...

strange imap connection problems
My imap connections seem to be flaky (only imap, pop3 is fine) the first time i load outlook and send/recieve it works fine. then every time after that my machine fails on the dns lookup of the mail server. (even nslookup in console fails) any ideas whats causing this? cheers, -ciaron ...

problems with formulas
I am trying to create a formula to count the number of people in a table between a set of age values (3 to 14) i have data in 3 columns for forename, suname, age, but over 2500 entries to extract the data from.. Please can you help Mike try something like =sumproduct((agerange>=3)*(agerange<=14)) -- Don Guillett SalesAid Software dguillett1@austin.rr.com "Mike Lowe" <Mike Lowe@discussions.microsoft.com> wrote in message news:B23A76B8-2928-406D-996C-10F6DC436D6B@microsoft.com... >I am trying to create a formula to count the number of people in a table > betw...

CTreeCtrl : 2 or more overlays
Hi, I use CTreeCtrl::SetItemState to show overlayed images for a tree item icon. For different states of object different overlays are used. My question is: can I use two overlayed images simultaneously? I tried, the last one just overwrites the first one. Of course I can create third image that combines those two. I just want to make sure there is no other way to implement this. (Prefer to code rather than paint). Regards, ~Peter To the best of my knowledge, no. It is also hard to come up with overlays that Play Well Together under these conditions. I'd suggest the third-image appr...

Problem Changing an Investment Name
I am trying to change an investment name and Money 2006 tells me "The name or symbol 'TRP Spectrum Income' has already been used for a deleted investment. Please enter a different name." When I go to delete investments the name does not appear! Any ideas on how I get Money to accept the name change? This is the first time I have run into this situation and I have made numerous name changes in Money over the years. In microsoft.public.money, Ken wrote: >I am trying to change an investment name and Money 2006 tells me "The name >or symbol 'TRP Spec...

Problems with CComboBox
Hi all! I'm trying to use CComboBox, but I have some problems. I've inserted a tring like this "First;second" in the "Data" field of the Combo Box in the Dialog Editor. Launching the Test, the dialog seems to work, but launching the program, I have nothing inside the combo box. Just appear a black line when I press the arrow, instead of the list "First;second" that appears in the Test. Any help is welcome :-) Bye! Alex This is a common problem. In resource editor, select the combo box and click the drop-down arrow on the combo box. You will now s...

Problem with Modal dialog
Hi there, I have a strange problem. If I DoModal a dialog it refuses any input. It just sits on top of my application and I cannot do anything. To activate the dialog I need to change to another application (Alt+Tab) and switch back to my app. Then everything is fine and I can use the dialog. I guess I have the problem because of the way I call DoModal. I do it so, when I right click on a view I get a popup and one option in there triggers the execution of the dialog. Maybe that is someting I shouldn't do. Can someone please help me out? I have no problems with the dialog when I put an o...

Commerce Bank problems
I have been trying to setup a friend's Commerce Bank account with no success. I've contacted Commerce's support, but they're no help. The problem always comes up during the setup saying the financial institution has encountered an error - no me help than that. I've also contact Microsoft, and they didn't have any advice. We have the account numbers and pins correct, but still no go. There are two Commerce's in the list, and we've tried both (Even though we're told to only use the PA, NJ, DE one.) Does anyone else use this bank with success? Some of ...

Clipart in Publisher 2002 #2
Hello, Somone used my Publisher 2002 and now all the Clipart is in a foreign language. How do I get the Clipart back to being in English? Thanks, Jasmine Huh? Do you mean someone used your computer and changed your settings? Where are you seeing a foreign language? <anonymous@discussions.microsoft.com> wrote in message news:27c401c3e102$3e707f10$a501280a@phx.gbl... > Hello, > > Somone used my Publisher 2002 and now all the Clipart is in > a foreign language. How do I get the Clipart back to being > in English? > > Thanks, > > Jasmine Go to the Clip...

CString Problem !!!
Hello Friends, I am using char* everywhere in one of my application. one of my friend suggested using CString class instead. I searched for it in MSDN and find it a lot easier due to operators attached with it. But my problem is i can free a Char* anytime i want and i am sure it will be free. but how do i know how CString is maintained internally. What it's internal implementation is and when will it free the memory. Any help will be appreciated. TIA Sanjeev Kumar. Sanjeev, The point of using CString over "char *" null terminated strings, is to free you from such concerns o...

ACDialog problems
Hi I have a routine that runs when my Menu loads that checks for any Orders due for Delivery today. Then it invites you to process those orders now. If yes is selected, it opens the new form in ACDialog, using a global variable to tell the order form to filter on deliveries due today. In the first place, when the Order form is loaded, the vertical scroll bar is missing. If I go to the next record, it appears. If I press any of the buttons which preview a report, they appear, but behind everything else, so the user won't think it has worked. Can I eliminate these two bugs? Stapes ...

email problems #5
I was told that in order for my email to function better, I should "delete cookies" and "delete files". How? What email program? To delete cookies and temporary Internet files: open Internet Explorer, Tools, Options, general tab and delete them there. "LB" wrote: > I was told that in order for my email to function better, I should "delete > cookies" and "delete files". How? LB <LB@discussions.microsoft.com> wrote: > I was told that in order for my email to function better, I should > "delete cookies" and &qu...

CComboBox
I am trying to add strings to a Combox Box and its not working. The AddString function return 0, but the string is not there. What am I doing wrong? Is there something you have to do before I can add strings to a combo box? I am using 7.1 by the way. Thanks for your help I can't increase the height, only the width. I started a new project and added a combo box and it worked fine. The AddString method returns the correct 0 based index. Thanks for the quick reply, any other ideas? >-----Original Message----- > Yes. You need to increase the height of the combo box by selecti...

Formula Problem #6
I am trying to develop a worksheet where my sum will vary depending on whether another cell is greater than one number, greater than or less than another number and less than another number. A second multiplier depends on this criteria. An example would be if cell L20was <30 then C20 would be multiplied by cell L20. If it was <36> It would be multiplied by I20and if it was >36 it would be multiplied by cell F20. I am trying to enter the formula into cell M20. Hope this makes sense. Thanks in advance. On Jul 3, 10:25 pm, "JoeH" <jbh8...@yahoo.com> wrot...

Exchange newbie problem
Hi all; A user on our domain was deleted when he should not have been. His mail box was not deleted. When his account was recreated, we tried to reconnect the old mailbox. But when selecting a user in the "Select a new user for this mailbox" dialog a message comes back saying that the user cannot be found. We tried several different users a none can be found even though they can get there mail just fine. We need to get the messages from this mailbox. Any ideas would be great -- Craig in the High Desert. craig@craignet.com But it's a dry heat. you should be able to reconnec...

Microsoft Outlook problem #3
I have a problem with Microsoft outlook. I've reinstalled office and Outlook Express but nothing works. All the other office programs are fine but Outlook always comes up with a message: "Cannot start Microsoft Outlook. Outlook requires Microsoft outlook Express 4.01 or greater. You can install Outlook Express by running IE5Setup.exe from the IE5 folder located on your CD or through the Windows Updated website." I tried running IE5Setup.exe. That comes up with a message saying that the current version of Internet Explorer is more updated and the installation will end. I have ...

Problem with the ethernet
Hi, i'm building a WinCE6 image. I added the wired lan connection, the lan driver, the ip protocol, .. I update the image via ethernet cable, then the hardware is good. When i land into the wince i see the network icon with a red cross and the ip set as dhcp and address 0.0.0.0. Pressing 'Renew' nothing change. If i type ipconfg i see on the serial console the output that says ip address and mask = 0.0.0.0 Any idea? -- SteM Is the KITL Ethernet driver still in the OS? That's the most-common cause. You can't both be talking directly to the adapter for...

date problem in excel
I have a problem that when I open a file, like text or csv file, the cell with number dash number, ex. 10-5, will be automatically changed to date format. But this really affect my data analysis. I know we could add ' before typing or change cell format before typing, but how to cancel this autoformat when opening another file?? Thanks is not number (dash) number is not a number only a text. in that case type '(single apostrophe)10-5 Wozniak <Wozniak@discussions.microsoft.com> wrote in message news:0F94D89E-29B4-4FDC-8C12-C8D3EF76700A@microsoft.com... > I have a probl...

Stored procedures not copied while installation #2
Dear All GP - tech people Please have a look and suggest - having Great Plains 8.0 service pack 3 -Sql 2000 created first live company DB - everything goes fine - setup every modules - start using Sales Order processing Invoice - nothing wrong anywhere , but when i go to Invoice Distribution button --> default -> delete / cancle , then recieved this error- Unhandled script exception: [Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'TSTGT.dbo.SVC_Delete_SOP_Inv_Dist'. EXCEPTION_CLASS_SCRIPT_MISSING SCRIPT_CMD_CALLSERVER I have checkd...

Exchange and/or GFI problem
Hello, I am currently having a problem with emails which have attachments (usually but not always PDFs) getting stuck in users outboxes in outlook 2003. When the user tried to send the email it just sits in the outbox until the user goes into the outbox, opens the message and clicks on send. The message will then sucessfully send. Not all attachments get stuck, just some! I think the problem may be with GFI MailSecurity which is installed on the exchange 2003 server. However, I have been in contact with GFI support who haven't given any help to fix the problem. We are getting the follow...

Problem with exported text
The code below works all the way up to the point where it exports the data to a text file. When I look within the text file I find that it includes bland rows as well as the rows with the data. I did add a formula to column 1 so that when they enter a specific value it always makes it a 1. Otherwise it leaves the cell blank. =IF(N8<>"",1,"") is the formula in column A starting on row 8. Text file has the following as the results... which goes on for one hundred rows which is how far down I copied the above formula. 1;;test;;;test;;;;;;;;s;;;;;;;;;...

MS Excel Career Training COurse Must see #2
Learn how to create database, spreadsheets, formulas and much much more. As our present to you included on this CD you get for FREE following: - set of Financial formulas - set spreadsheets examples Ok let's talk now about this training course. Two great ways to learn 1: Content rich Training CDs. Learn the easy way - all you need on one CD High quality Training at an affordable price. Affordable Training that is easy to understand and follow. No boring books to read, no expensive time consuming classroom training It's so easy Learn step by step right from your own desk, anytime ...

SMTP Logging? -- Spam Problem
I have a mail server that's being used as a relay by some spammer that knows one of my user's login and password. I've checked and tested the server and it is not a relay. I'm thinking this guy has a virus or trojan installed on one of my thousands of users computers and somehow getting their login info and then using our server to send out spam. I need to figure out what username he's using so I can take a look at the computer and make sure there isn't something on there secretly relaying him information. So my question is, how can I turn on logging or where do I ...

Address List Problem
Dear All, We have created two address lists on our Exchange Server 2003. But the problem is that the members of one Address list can only see the other Address List members. This happens only when the Outlook 2003 is configured in cache mode on the client side. If its not cache mode it is working fine. We have single AD domain and single forest. Please Help -- Haroon Malik ...

adding problem
Dear all, I have a problem with adding up rows of numbers. I have "dragged" the mouse across the row of figures, then click the Autosum icon but the row does not add up correctly. It shows as a format :- =SUM(B1:AI1). Is there something I am doing wrong? Many thanks for any help. -- Barry Angus Novice This e-mail is intended for the recipient(s) only. All e-mails are scanned for viruses etc prior to sending. It is possible that the numbers are text. Format them to General then copy an an empty cell. Select the numbers. Edit>Paste Special>Add>OK>Esc. This step...